From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1741C433B4 for ; Wed, 7 Apr 2021 06:00:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EAA56128D for ; Wed, 7 Apr 2021 06:00:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EAA56128D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2yHyTKRDnnAeLF2q59XOIWh4wrCdwhiUvxwj4YUUFpQ=; b=M0wHF7exZF8/LLnUkv33ANkIAj APKk7qrv/sFkIYKiUYRP1OnHs1mpukSQcfilQona6PMfpOl8n8gf6zi6m5h+oAjjeyFu12lcx906L 83F1M1XewniKaIuyH95zKKYNXOqsYGMsd6BxmtqocdXQUg1HrWGtaJ/PBAHTbf8NaU8scfjepHqZn y6XBYTxs2KbRaeoY1+xhSCAauDYIfTyLW9YAF+8V6T1FLpyGsH6qziJiPA2hnkzbu/YRHDTMuoDee G8X5TRfJ31lr2wrPsDbD6U+owiWplVWlgTAhrPVBYsT86D77qOguYuBwdxM4B/cDQl0nes/rEjvNu S5VRzwiw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lU1Eq-0049yY-HR; Wed, 07 Apr 2021 06:00:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lU1EU-0049v4-T7 for linux-nvme@desiato.infradead.org; Wed, 07 Apr 2021 06:00:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5tYdNJks365C+0+KmAKQ2JiYWKVcKZ5Ur6tq3ePkAek=; b=j4wNVTjd8Np+eius2AHtBCZExP fJK99u2ioJwbqi7QvgFTadCN6L/AWFyIag5i9br3hFH0DUem2WFaEmJkgtepzGCn8LyYtcWZpeRWy z11Xd5otxT/PgclAgLxPr4UFjOEfRKE0yXfPVDryqIA99EqCPDqZ4DQjzLI9Ahhq3hvbgUO984KGN Cd/dVPoxMYsFxHkjU549ScdwRIsXXhF79pESgrVkQv6tQ/HtJ6Srs8JBCQCo0KLCcz5g7tSkRtAUb 9pKNfOphqsO2tW29pMR+wsyswmspZLRxyOXuo4PxUoy3lK/VgZWCNAWWaoKRTIr64IfKFWLb//wOR xp9IFzhg==; Received: from saphodev.broadcom.com ([192.19.232.172] helo=relay.smtp-ext.broadcom.com) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lU1Dg-00DyT1-8N for linux-nvme@lists.infradead.org; Wed, 07 Apr 2021 05:59:46 +0000 Received: from localhost.localdomain (unknown [10.157.2.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 940A022566; Tue, 6 Apr 2021 22:59:00 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 940A022566 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1617775142; bh=d6tS35YGWCW9agJ3M8LpakfG7RdM5DC13s3mwlFQonQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JA7tAYrlnP5/K3Bv50V0K04JudJZAAqVfvNbJSc6MpjGfZqqVs0OcRy+1VrvLg/yR PZzCtUP4kX2E5NLoSe3K+fnEcs/CrJLWt2I7gYLx/YJuljZfLedZ/CgGSvzZZDgfZ9 44X/2hkhcUu00FIIv6lcv/4I+3DenMMfa7gqucJ0= From: Muneendra To: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, tj@kernel.org, linux-nvme@lists.infradead.org, hare@suse.de Cc: jsmart2021@gmail.com, emilne@redhat.com, mkumar@redhat.com, Muneendra Subject: [PATCH v9 02/13] blkcg: Added a app identifier support for blkcg Date: Wed, 7 Apr 2021 04:36:26 +0530 Message-Id: <1617750397-26466-3-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1617750397-26466-1-git-send-email-muneendra.kumar@broadcom.com> References: <1617750397-26466-1-git-send-email-muneendra.kumar@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210407_065930_023051_380F6087 X-CRM114-Status: GOOD ( 19.53 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org This Patch added a unique application identifier i.e fc_app_id member in blkcg which allows identification of traffic sources at an individual cgroup based Applications (ex:virtual machine (VM))level in both host and fabric infrastructure. Added a new function blkcg_get_fc_appid to grab the app identifier associated with a bio. Added a new function blkcg_set_fc_appid to set the app identifier in a blkcgrp associated with cgroup id Added a new config BLK_CGROUP_FC_APPID and moved the changes under this config Merged the patch 16 of previous version in which we added a new config FC_APPID to select BLK_CGROUP_FC_APPID which Enable support to track FC io Traffic. Signed-off-by: Muneendra --- v9: Merged patch16 of previosu version to this patch where we are using Kconfig settings v8: No change v7: Modified the Kconfig file v6: Modified the Kconfig file as per standard specified in Documentation/process/coding-style.rst v5: Renamed the arguments appropriatley Renamed APPID_LEN to FC_APPID_LEN Moved the input validation at the begining of the function Modified the comments v4: No change v3: Renamed the functions and app_id to more specific Addressed the reference leaks in blkcg_set_app_identifier Added a new config BLK_CGROUP_FC_APPID and moved the changes under this config Added blkcg_get_fc_appid,blkcg_set_fc_appid as inline functions v2: renamed app_identifier to app_id removed the sysfs interface blkio.app_identifie under --- block/Kconfig | 9 ++++++ drivers/scsi/Kconfig | 13 +++++++++ include/linux/blk-cgroup.h | 56 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/block/Kconfig b/block/Kconfig index a2297edfdde8..03886d105301 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -144,6 +144,15 @@ config BLK_CGROUP_IOLATENCY Note, this is an experimental interface and could be changed someday. +config BLK_CGROUP_FC_APPID + bool "Enable support to track FC I/O Traffic across cgroup applications" + depends on BLK_CGROUP=y + help + Enabling this option enables the support to track FC I/O traffic across + cgroup applications. It enables the Fabric and the storage targets to + identify, monitor, and handle FC traffic based on VM tags by inserting + application specific identification into the FC frame. + config BLK_CGROUP_IOCOST bool "Enable support for cost model based cgroup IO controller" depends on BLK_CGROUP=y diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 06b87c7f6bab..20aa1536a3ba 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -235,6 +235,19 @@ config SCSI_FC_ATTRS each attached FiberChannel device to sysfs, say Y. Otherwise, say N. +config FC_APPID + bool "Enable support to track FC I/O Traffic" + depends on BLOCK && BLK_CGROUP + depends on SCSI + select BLK_CGROUP_FC_APPID + default y + help + If you say Y here, it enables the support to track + FC I/O traffic over fabric. It enables the Fabric and the + storage targets to identify, monitor, and handle FC traffic + based on VM tags by inserting application specific + identification into the FC frame. + config SCSI_ISCSI_ATTRS tristate "iSCSI Transport Attributes" depends on SCSI && NET diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index b9f3c246c3c9..9204f8f8a932 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 FC_APPID_LEN 129 + #ifdef CONFIG_BLK_CGROUP @@ -55,6 +57,9 @@ struct blkcg { struct blkcg_policy_data *cpd[BLKCG_MAX_POLS]; struct list_head all_blkcgs_node; +#ifdef CONFIG_BLK_CGROUP_FC_APPID + char fc_app_id[FC_APPID_LEN]; +#endif #ifdef CONFIG_CGROUP_WRITEBACK struct list_head cgwb_list; #endif @@ -660,4 +665,55 @@ static inline void blk_cgroup_bio_start(struct bio *bio) { } #endif /* CONFIG_BLOCK */ #endif /* CONFIG_BLK_CGROUP */ + +#ifdef CONFIG_BLK_CGROUP_FC_APPID +/* + * Sets the fc_app_id field associted to blkcg + * @app_id: application identifier + * @cgrp_id: cgroup id + * @app_id_len: size of application identifier + */ +static inline int blkcg_set_fc_appid(char *app_id, u64 cgrp_id, size_t app_id_len) +{ + struct cgroup *cgrp; + struct cgroup_subsys_state *css; + struct blkcg *blkcg; + int ret = 0; + + if (app_id_len > FC_APPID_LEN) + return -EINVAL; + + cgrp = cgroup_get_from_id(cgrp_id); + if (!cgrp) + return -ENOENT; + css = cgroup_get_e_css(cgrp, &io_cgrp_subsys); + if (!css) { + ret = -ENOENT; + goto out_cgrp_put; + } + blkcg = css_to_blkcg(css); + strlcpy(blkcg->fc_app_id, app_id, app_id_len); + css_put(css); +out_cgrp_put: + cgroup_put(cgrp); + return ret; +} + +/** + * blkcg_get_fc_appid - get the fc app identifier associated with a bio + * @bio: target bio + * + * On success it returns the fc_app_id on failure it returns NULL + */ +static inline char *blkcg_get_fc_appid(struct bio *bio) +{ + if (bio && bio->bi_blkg && + (bio->bi_blkg->blkcg->fc_app_id[0] != '\0')) + return bio->bi_blkg->blkcg->fc_app_id; + return NULL; +} +#else +static inline int blkcg_set_fc_appid(char *buf, u64 id, size_t len) { return -EINVAL; } +static inline char *blkcg_get_fc_appid(struct bio *bio) { return NULL; } +#endif /*CONFIG_BLK_CGROUP_FC_APPID*/ #endif /* _BLK_CGROUP_H */ -- 2.26.2 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme