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 096F2C433B4 for ; Wed, 7 Apr 2021 05:59:57 +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 945F5613A3 for ; Wed, 7 Apr 2021 05:59:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 945F5613A3 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=1iD6/K7fJMKBDIfZUesljDlxrGU2yeB8KDNvK+Xuadc=; b=SeVYB6phLpgHnfoT8VksaueiT9 kGSZwi6KI2Qs8s6ZsXOCxXvFOEzaIzf+g4UUsvQNYIcpl1rK6zNDBcFznJodtpgD7Jf9STyS/7FlE +ZX7AR/iwqBqgT1iS0bxWfIepKWQ6n9e85MolwVy+klgohXbyYMmSMIv+5tdBUdzykypExf2Z/evm kvAoh2hxqDgUfqSPnj+Ks0ze9q/nnQcaeeRTCZ8Ii0O5CbUadZtZk/qVKBY11Kvn/D3UOEYTK2Zxg G67hUIx9am72wkMirjFfkgP9bvvJSDikpSJPg22sCmGvvjhq4Dkj1CDyKqVfUiWYFU1PioebFESuw hOegJBJw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lU1E5-0049qp-Fq; Wed, 07 Apr 2021 05:59:41 +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 1lU1E2-0049qJ-Kq for linux-nvme@desiato.infradead.org; Wed, 07 Apr 2021 05:59:38 +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=XQI9szHCs7RRnBVZij8h8Si4eJ/idPRoPNfNU41Gen4=; b=Resecpt+//Cur0+Q/fWXBnBX6r GOQyqPiBbCYULrdCS3tNJbp1Vd93aMCrJ1yqwaTBrHIKZUEghFNCGb3hy0TA7IrQS+GrRQrkeTev9 ibFHcW/xoeOqez78MkrJmL8gBj7lvVCdQu7iXb0V1gDNCYkS/UGH21+5LK6Hq/H26vQa+MBsq57A3 gmbXGtx88OTo6UnXLWLrALTPuCcHsd1F0lwgbdp4ezRlLGhrq1GV1NHzsYXAFM40gBijzCmJmLjgp WQplObaKx9hWPdm8+E5z5OKBF96y7HmgKRdyljIr2FX6/toWgCC2acZRiagg7zCC33zEc70/muN3G cqkvlTIQ==; Received: from relay.smtp-ext.broadcom.com ([192.19.232.172]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lU1Db-00DySm-EX for linux-nvme@lists.infradead.org; Wed, 07 Apr 2021 05:59:26 +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 0E88921829; Tue, 6 Apr 2021 22:58:57 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 0E88921829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1617775140; bh=2WueO+L+WPkxa8j6sNZVzXHUywAB54EZZgPo0i0AcgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIv2ZKSI5GEhLsEsO3diUV6RQ66HtAjoXLy5max1vkC/5AHnSg2Qju8mMN+67rp62 yIWZsQpEwVnivrcCQBgctgA9JhDxcVE3sO5U0hnT9BAHQEhtEZnWHiLaIP/2UYZeS0 lhnEwzl2BFBu6EFHMjCTqkbPPoXTWfF6tRqwCrXY= 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 01/13] cgroup: Added cgroup_get_from_id Date: Wed, 7 Apr 2021 04:36:25 +0530 Message-Id: <1617750397-26466-2-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_065924_254557_849A8DF0 X-CRM114-Status: GOOD ( 15.48 ) 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 Added a new function cgroup_get_from_id to retrieve the cgroup associated with cgroup id. Exported the same as this can be used by blk-cgorup.c Added function declaration of cgroup_get_from_id in cgorup.h This patch also exported the function cgroup_get_e_css as this is getting used in blk-cgroup.h Reported-by: kernel test robot Signed-off-by: Muneendra --- v9: Addressed the issues reported by kernel test robot v8: No change v7: No change v6: No change v5: renamed the function cgroup_get_from_kernfs_id to cgroup_get_from_id v4: No change v3: Exported the cgroup_get_e_css v2: New patch --- include/linux/cgroup.h | 6 ++++++ kernel/cgroup/cgroup.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 4f2f79de083e..d2eace88d9d1 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -696,6 +696,7 @@ static inline void cgroup_kthread_ready(void) } void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen); +struct cgroup *cgroup_get_from_id(u64 id); #else /* !CONFIG_CGROUPS */ struct cgroup_subsys_state; @@ -743,6 +744,11 @@ static inline bool task_under_cgroup_hierarchy(struct task_struct *task, static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) {} + +static inline struct cgroup *cgroup_get_from_id(u64 id) +{ + return NULL; +} #endif /* !CONFIG_CGROUPS */ #ifdef CONFIG_CGROUPS diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 9153b20e5cc6..20e5424a8227 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -577,6 +577,7 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp, rcu_read_unlock(); return css; } +EXPORT_SYMBOL_GPL(cgroup_get_e_css); static void cgroup_get_live(struct cgroup *cgrp) { @@ -5768,6 +5769,31 @@ void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen) kernfs_put(kn); } +/* + * cgroup_get_from_id : get the cgroup associated with cgroup id + * @id: cgroup id + * On success it returns the cgrp on failure it returns NULL + */ +struct cgroup *cgroup_get_from_id(u64 id) +{ + struct kernfs_node *kn; + struct cgroup *cgrp = NULL; + + mutex_lock(&cgroup_mutex); + kn = kernfs_find_and_get_node_by_id(cgrp_dfl_root.kf_root, id); + if (!kn) + goto out_unlock; + + cgrp = kn->priv; + if (cgroup_is_dead(cgrp) || !cgroup_tryget(cgrp)) + cgrp = NULL; + kernfs_put(kn); +out_unlock: + mutex_unlock(&cgroup_mutex); + return cgrp; +} +EXPORT_SYMBOL_GPL(cgroup_get_from_id); + /* * proc_cgroup_show() * - Print task's cgroup paths into seq_file, one line for each hierarchy -- 2.26.2 _______________________________________________ Linux-nvme mailing list Linux-nvme@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-nvme