[RFC v2 02/18] blkcg: Added a app identifier support for blkcg
Tejun Heo
tj at kernel.org
Mon Oct 19 10:46:19 EDT 2020
On Mon, Oct 19, 2020 at 01:12:57PM +0530, Muneendra wrote:
> This Patch added a unique application identifier i.e
> app_id knob to blkcg which allows identification of traffic
> sources at an individual cgroup based Applications
> (ex:virtual machine (VM))level in both host and
> fabric infrastructure.
>
> Provided the interface blkcg_get_app_identifier to
> grab the app identifier associated with a bio.
>
> Provided the interface blkcg_set_app_identifier to
> set the app identifier in a blkcgrp associated with cgroup id
>
> Signed-off-by: Muneendra <muneendra.kumar at broadcom.com>
>
> ---
> v2:
> renamed app_identifier to app_id
> removed the sysfs interface blkio.app_identifie under
> /sys/fs/cgroup/blkio
> Added a new interface blkcg_set_app_identifier
> ---
> block/blk-cgroup.c | 31 +++++++++++++++++++++++++++++++
> include/linux/blk-cgroup.h | 22 ++++++++++++++++++++++
> 2 files changed, 53 insertions(+)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 619a79b51068..672971521010 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -546,6 +546,37 @@ static struct blkcg_gq *blkg_lookup_check(struct blkcg *blkcg,
> return __blkg_lookup(blkcg, q, true /* update_hint */);
> }
>
> +/*
> + * Sets the app_identifier field associted to blkcg
> + * @buf: application identifier
> + * @id: cgrp id
> + * @len: size of appid
> + */
> +int blkcg_set_app_identifier(char *buf, u64 id, size_t len)
Can you please use a name which is more specific?
> +{
> + struct cgroup *cgrp = NULL;
> + struct cgroup_subsys_state *css = NULL;
> + struct blkcg *blkcg = NULL;
> +
> + cgrp = cgroup_get_from_kernfs_id(id);
> + if (!cgrp)
> + return -ENOENT;
> +
> + css = cgroup_get_e_css(cgrp, &io_cgrp_subsys);
> + if (!css)
> + return -ENOENT;
> +
> + blkcg = css_to_blkcg(css);
> + if (!blkcg)
> + return -ENOENT;
> +
> + if (len > APPID_LEN)
> + return -EINVAL;
> + strlcpy(blkcg->app_id, buf, len);
Shouldn't the cgrp and css be put before exit?
> + return 0;
> +}
> +EXPORT_SYMBOL(blkcg_set_app_identifier);
> +
> /**
> * blkg_conf_prep - parse and prepare for per-blkg config update
> * @inputp: input string pointer
> diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
> index c8fc9792ac77..5bd3f9f397ac 100644
> --- a/include/linux/blk-cgroup.h
> +++ b/include/linux/blk-cgroup.h
> @@ -30,6 +30,8 @@
>
> /* Max limits for throttle policy */
> #define THROTL_IOPS_MAX UINT_MAX
> +#define APPID_LEN 128
> +
>
> #ifdef CONFIG_BLK_CGROUP
>
> @@ -55,6 +57,8 @@ struct blkcg {
> struct blkcg_policy_data *cpd[BLKCG_MAX_POLS];
>
> struct list_head all_blkcgs_node;
> + char app_id[APPID_LEN];
Please use a more specific name and gate them behind a CONFIG.
Thanks.
--
tejun
More information about the Linux-nvme
mailing list