blkcg: move blkio_group_conf->iops and ->bps to blk-throttle
blkio_cgroup_conf->iops and ->bps are owned by blk-throttle and has no reason to be defined in blkcg core. Drop them and let conf setting functions directly manipulate throtl_grp->bps[] and ->iops[]. This makes blkio_group_conf empty. Drop it. Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
3381cb8d2e
commit
af133ceb26
|
@ -71,19 +71,11 @@ struct blkg_rwstat {
|
||||||
uint64_t cnt[BLKG_RWSTAT_NR];
|
uint64_t cnt[BLKG_RWSTAT_NR];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct blkio_group_conf {
|
|
||||||
u64 iops[2];
|
|
||||||
u64 bps[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
/* per-blkg per-policy data */
|
/* per-blkg per-policy data */
|
||||||
struct blkg_policy_data {
|
struct blkg_policy_data {
|
||||||
/* the blkg this per-policy data belongs to */
|
/* the blkg this per-policy data belongs to */
|
||||||
struct blkio_group *blkg;
|
struct blkio_group *blkg;
|
||||||
|
|
||||||
/* Configuration */
|
|
||||||
struct blkio_group_conf conf;
|
|
||||||
|
|
||||||
/* pol->pdata_size bytes of private data used by policy impl */
|
/* pol->pdata_size bytes of private data used by policy impl */
|
||||||
char pdata[] __aligned(__alignof__(unsigned long long));
|
char pdata[] __aligned(__alignof__(unsigned long long));
|
||||||
};
|
};
|
||||||
|
|
|
@ -924,20 +924,6 @@ throtl_schedule_delayed_work(struct throtl_data *td, unsigned long delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Can not take queue lock in update functions as queue lock under
|
|
||||||
* blkcg_lock is not allowed. Under other paths we take blkcg_lock under
|
|
||||||
* queue_lock.
|
|
||||||
*/
|
|
||||||
static void throtl_update_blkio_group_common(struct throtl_data *td,
|
|
||||||
struct throtl_grp *tg)
|
|
||||||
{
|
|
||||||
xchg(&tg->limits_changed, true);
|
|
||||||
xchg(&td->limits_changed, true);
|
|
||||||
/* Schedule a work now to process the limit change */
|
|
||||||
throtl_schedule_delayed_work(td, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,
|
static u64 tg_prfill_cpu_rwstat(struct seq_file *sf,
|
||||||
struct blkg_policy_data *pd, int off)
|
struct blkg_policy_data *pd, int off)
|
||||||
{
|
{
|
||||||
|
@ -968,68 +954,48 @@ static int tg_print_cpu_rwstat(struct cgroup *cgrp, struct cftype *cft,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 blkg_prfill_conf_u64(struct seq_file *sf,
|
static u64 tg_prfill_conf_u64(struct seq_file *sf, struct blkg_policy_data *pd,
|
||||||
struct blkg_policy_data *pd, int off)
|
int off)
|
||||||
{
|
{
|
||||||
u64 v = *(u64 *)((void *)&pd->conf + off);
|
u64 v = *(u64 *)((void *)pd->pdata + off);
|
||||||
|
|
||||||
if (!v)
|
if (v == -1)
|
||||||
return 0;
|
return 0;
|
||||||
return __blkg_prfill_u64(sf, pd, v);
|
return __blkg_prfill_u64(sf, pd, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkcg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
static u64 tg_prfill_conf_uint(struct seq_file *sf, struct blkg_policy_data *pd,
|
||||||
struct seq_file *sf)
|
int off)
|
||||||
{
|
{
|
||||||
blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp),
|
unsigned int v = *(unsigned int *)((void *)pd->pdata + off);
|
||||||
blkg_prfill_conf_u64, BLKIO_POLICY_THROTL,
|
|
||||||
cft->private, false);
|
if (v == -1)
|
||||||
|
return 0;
|
||||||
|
return __blkg_prfill_u64(sf, pd, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int tg_print_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
||||||
|
struct seq_file *sf)
|
||||||
|
{
|
||||||
|
blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), tg_prfill_conf_u64,
|
||||||
|
BLKIO_POLICY_THROTL, cft->private, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void throtl_update_blkio_group_read_bps(struct blkio_group *blkg,
|
static int tg_print_conf_uint(struct cgroup *cgrp, struct cftype *cft,
|
||||||
u64 read_bps)
|
struct seq_file *sf)
|
||||||
{
|
{
|
||||||
struct throtl_grp *tg = blkg_to_tg(blkg);
|
blkcg_print_blkgs(sf, cgroup_to_blkio_cgroup(cgrp), tg_prfill_conf_uint,
|
||||||
|
BLKIO_POLICY_THROTL, cft->private, false);
|
||||||
tg->bps[READ] = read_bps;
|
return 0;
|
||||||
throtl_update_blkio_group_common(blkg->q->td, tg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void throtl_update_blkio_group_write_bps(struct blkio_group *blkg,
|
static int tg_set_conf(struct cgroup *cgrp, struct cftype *cft, const char *buf,
|
||||||
u64 write_bps)
|
bool is_u64)
|
||||||
{
|
|
||||||
struct throtl_grp *tg = blkg_to_tg(blkg);
|
|
||||||
|
|
||||||
tg->bps[WRITE] = write_bps;
|
|
||||||
throtl_update_blkio_group_common(blkg->q->td, tg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void throtl_update_blkio_group_read_iops(struct blkio_group *blkg,
|
|
||||||
u64 read_iops)
|
|
||||||
{
|
|
||||||
struct throtl_grp *tg = blkg_to_tg(blkg);
|
|
||||||
|
|
||||||
tg->iops[READ] = read_iops;
|
|
||||||
throtl_update_blkio_group_common(blkg->q->td, tg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void throtl_update_blkio_group_write_iops(struct blkio_group *blkg,
|
|
||||||
u64 write_iops)
|
|
||||||
{
|
|
||||||
struct throtl_grp *tg = blkg_to_tg(blkg);
|
|
||||||
|
|
||||||
tg->iops[WRITE] = write_iops;
|
|
||||||
throtl_update_blkio_group_common(blkg->q->td, tg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blkcg_set_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
|
||||||
const char *buf,
|
|
||||||
void (*update)(struct blkio_group *, u64))
|
|
||||||
{
|
{
|
||||||
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
|
struct blkio_cgroup *blkcg = cgroup_to_blkio_cgroup(cgrp);
|
||||||
struct blkg_policy_data *pd;
|
|
||||||
struct blkg_conf_ctx ctx;
|
struct blkg_conf_ctx ctx;
|
||||||
|
struct throtl_grp *tg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = blkg_conf_prep(blkcg, buf, &ctx);
|
ret = blkg_conf_prep(blkcg, buf, &ctx);
|
||||||
|
@ -1037,10 +1003,23 @@ static int blkcg_set_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
pd = ctx.blkg->pd[BLKIO_POLICY_THROTL];
|
tg = blkg_to_tg(ctx.blkg);
|
||||||
if (pd) {
|
if (tg) {
|
||||||
*(u64 *)((void *)&pd->conf + cft->private) = ctx.v;
|
struct throtl_data *td = ctx.blkg->q->td;
|
||||||
update(ctx.blkg, ctx.v ?: -1);
|
|
||||||
|
if (!ctx.v)
|
||||||
|
ctx.v = -1;
|
||||||
|
|
||||||
|
if (is_u64)
|
||||||
|
*(u64 *)((void *)tg + cft->private) = ctx.v;
|
||||||
|
else
|
||||||
|
*(unsigned int *)((void *)tg + cft->private) = ctx.v;
|
||||||
|
|
||||||
|
/* XXX: we don't need the following deferred processing */
|
||||||
|
xchg(&tg->limits_changed, true);
|
||||||
|
xchg(&td->limits_changed, true);
|
||||||
|
throtl_schedule_delayed_work(td, 0);
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1048,61 +1027,45 @@ static int blkcg_set_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkcg_set_conf_bps_r(struct cgroup *cgrp, struct cftype *cft,
|
static int tg_set_conf_u64(struct cgroup *cgrp, struct cftype *cft,
|
||||||
const char *buf)
|
const char *buf)
|
||||||
{
|
{
|
||||||
return blkcg_set_conf_u64(cgrp, cft, buf,
|
return tg_set_conf(cgrp, cft, buf, true);
|
||||||
throtl_update_blkio_group_read_bps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkcg_set_conf_bps_w(struct cgroup *cgrp, struct cftype *cft,
|
static int tg_set_conf_uint(struct cgroup *cgrp, struct cftype *cft,
|
||||||
const char *buf)
|
const char *buf)
|
||||||
{
|
{
|
||||||
return blkcg_set_conf_u64(cgrp, cft, buf,
|
return tg_set_conf(cgrp, cft, buf, false);
|
||||||
throtl_update_blkio_group_write_bps);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blkcg_set_conf_iops_r(struct cgroup *cgrp, struct cftype *cft,
|
|
||||||
const char *buf)
|
|
||||||
{
|
|
||||||
return blkcg_set_conf_u64(cgrp, cft, buf,
|
|
||||||
throtl_update_blkio_group_read_iops);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blkcg_set_conf_iops_w(struct cgroup *cgrp, struct cftype *cft,
|
|
||||||
const char *buf)
|
|
||||||
{
|
|
||||||
return blkcg_set_conf_u64(cgrp, cft, buf,
|
|
||||||
throtl_update_blkio_group_write_iops);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct cftype throtl_files[] = {
|
static struct cftype throtl_files[] = {
|
||||||
{
|
{
|
||||||
.name = "throttle.read_bps_device",
|
.name = "throttle.read_bps_device",
|
||||||
.private = offsetof(struct blkio_group_conf, bps[READ]),
|
.private = offsetof(struct throtl_grp, bps[READ]),
|
||||||
.read_seq_string = blkcg_print_conf_u64,
|
.read_seq_string = tg_print_conf_u64,
|
||||||
.write_string = blkcg_set_conf_bps_r,
|
.write_string = tg_set_conf_u64,
|
||||||
.max_write_len = 256,
|
.max_write_len = 256,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "throttle.write_bps_device",
|
.name = "throttle.write_bps_device",
|
||||||
.private = offsetof(struct blkio_group_conf, bps[WRITE]),
|
.private = offsetof(struct throtl_grp, bps[WRITE]),
|
||||||
.read_seq_string = blkcg_print_conf_u64,
|
.read_seq_string = tg_print_conf_u64,
|
||||||
.write_string = blkcg_set_conf_bps_w,
|
.write_string = tg_set_conf_u64,
|
||||||
.max_write_len = 256,
|
.max_write_len = 256,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "throttle.read_iops_device",
|
.name = "throttle.read_iops_device",
|
||||||
.private = offsetof(struct blkio_group_conf, iops[READ]),
|
.private = offsetof(struct throtl_grp, iops[READ]),
|
||||||
.read_seq_string = blkcg_print_conf_u64,
|
.read_seq_string = tg_print_conf_uint,
|
||||||
.write_string = blkcg_set_conf_iops_r,
|
.write_string = tg_set_conf_uint,
|
||||||
.max_write_len = 256,
|
.max_write_len = 256,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "throttle.write_iops_device",
|
.name = "throttle.write_iops_device",
|
||||||
.private = offsetof(struct blkio_group_conf, iops[WRITE]),
|
.private = offsetof(struct throtl_grp, iops[WRITE]),
|
||||||
.read_seq_string = blkcg_print_conf_u64,
|
.read_seq_string = tg_print_conf_uint,
|
||||||
.write_string = blkcg_set_conf_iops_w,
|
.write_string = tg_set_conf_uint,
|
||||||
.max_write_len = 256,
|
.max_write_len = 256,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Reference in New Issue