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=ham 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 BF351C433E0 for ; Thu, 4 Mar 2021 12:21:27 +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 5D50164F11 for ; Thu, 4 Mar 2021 12:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D50164F11 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=mLlaB8EclHw7J5GLoTx/H3eiWYGAhtIjHOb6CnxoF+Q=; b=qlmWBsiCr557faHm6uOfmu4Lsd HFu66qT6sX8T0OF/vWDPpcte3OyjS0sSwXArs4UBEW/CxaoV6SHEPUKY2QcLskP4cF2SGSHygLXbk 43obfBXTUMMeyYyvU/NTsC5ClFJUiOiz3F78oKCPpzF7EfGG+ATDdyrCHb8VZtdaKqbQenz4ySQEr JT9hFwpElKb5Z4maddwMbwySVcMJzWlM+3bPDNGI3JrOWoUsA7upLRo1r4cblGOAFmYXQNqJUgG81 xGrmYHwxjhOzEdVvze3dWpsnbuyXVr5+oH0AeuKiry1Nf/3N6qszXVgW+OwaZig5v4SQPGWRuebv9 7Hc3YS5w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHmyV-008aNq-M2; Thu, 04 Mar 2021 12:21:03 +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 1lHmyS-008aNd-SR for linux-nvme@desiato.infradead.org; Thu, 04 Mar 2021 12:21:01 +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=bXwr43rIbbsBM6Q+1gYlNDJ2krh2dsPw+sVBskUfoso=; b=SkbP7PyhzREAekl6oWjxg1T14Y ZB3paSaUdKYYxSyI3KoV7k515hxxf76nIdfpaJUloaYjQKCsFmOZ3l1FeHxJQU3csI7K/OPAr/5H9 BzdPnBLi4N2M9m0f7De0prItCcG1p2zOo2fsQkh7qBH9Yxpqh0zn4h3EI5HkDoPj9KUNEvNVyXi93 8VAjmOXLagZBu0X4eOPWLNW4R7jWzbvgJkLbttLTvOQxojtBKgLSQ8ZmBXd6WKNMzVIF96hQ6RP8y ZdbeCzMHvjN9pNcIhGN7lb1faZrZF/TXAPsic6ANq9gSz4V4sXOoby5onJVRN5PBmZJXc8EGl5RTb QzvxHtjA==; Received: from relay.smtp-ext.broadcom.com ([192.19.221.30]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHmxj-006yvo-6a for linux-nvme@lists.infradead.org; Thu, 04 Mar 2021 12:20:40 +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 353992256B; Thu, 4 Mar 2021 04:19:55 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 353992256B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1614860395; bh=ho6NN7/oHCG8UGfKOYuFljorTKWw2Yt20bXrDOyHrzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A+Jwn6DtxpH90+SKybxl9ILuBBQ25lWA8P6RvXHepr3Jeiz7wtFXjW/rh736MxvQL j/tQbLmrpF2YcZHf5Fi4GzUc9pPltdjbJoCEEjOsOKFfzvShEnV8NuZ65GkR+kuV6E 2wVbGhzGXWmDGB8RIcM8SikhCXf42D2lNuvIHAL4= 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 v8 01/16] cgroup: Added cgroup_get_from_id Date: Thu, 4 Mar 2021 10:57:11 +0530 Message-Id: <1614835646-16217-2-git-send-email-muneendra.kumar@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1614835646-16217-1-git-send-email-muneendra.kumar@broadcom.com> References: <1614835646-16217-1-git-send-email-muneendra.kumar@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_122025_170504_F631221E X-CRM114-Status: GOOD ( 15.01 ) 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 Signed-off-by: Muneendra --- 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 451c2d26a5db..9573d45de065 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 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 613845769103..e5e37b2f6a10 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) { @@ -5793,6 +5794,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