From patchwork Fri Nov 11 18:35:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristen Carlson Accardi X-Patchwork-Id: 18961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp905911wru; Fri, 11 Nov 2022 10:39:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jNJG+0Bc24irTZZDvuM5XhloEa3+oIchlkIpIXPqe+xAdRegziuHiAiNjWKqWSQ/7M5oK X-Received: by 2002:a17:90a:a882:b0:214:1802:29f4 with SMTP id h2-20020a17090aa88200b00214180229f4mr3411119pjq.24.1668191969203; Fri, 11 Nov 2022 10:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668191969; cv=none; d=google.com; s=arc-20160816; b=Lk5xfB8O/7MbII4GPQ4YSshEarj1o8OGhGzdOUfER1pT9pPJbUq82iRWvtqegK2vqZ p64XniIXHsunPKYtOx72HBS6ARgbe2mQg/idNZmDTeGmQE13cMsIdDCQrW4R7hWvfUnz B0ToEIwsLv7VYSGrQNpbyDcUIKKiPJbWAQ4ZpDpQcsIZQg40BE3x73BuCreVMGCHH23z 97TOQIG1x4NsazP0M3fPv7p30ZA1LqLRv+X2gO8+z5E5Qgdw+jhZ61+vF8JUcWYAFUbK oIs5EAD3UgUCBnnpKB4gIsV+rwnzaRu3dHEgmaw4mz3C65FqISQGeM/sUpP/WBq9goaO uoDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7TuPSYymvk8MntW4ttgZXt7RocyaTUEvWlakwsL0ERg=; b=X335B9SQ9Zuoz4pFhzjGhobIaf5qEbsdM7WBcDb+vCGnypWz9VJKOlp5ydskMYVEy4 CurLq9MmjV//6kHX2dAZbKG8tfUOBsYhJSdGuebn+G+BWDE2Q/yt5bnqfSh+TlpmKThG MgS5wesxxWcZ7Eqrpj5iXd90JMAxv/eaQzpOiV9q+7PLFJ0BjJLEGuJebAyTIA8Njy7H jnBeDn2Gk0A7g2DH5HM1f73RXUSIazhEwMy1Spa3lUwDXvOnCBeCxPQmeyjoapALW90f Vc23fbFZH9oo/aHwbh1YAVZKQ81W9HM5TzaflJLaTH+CwqAkcIY+LFX70Jb07mlGrsGi 61RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aNX7gCXN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l4-20020a17090270c400b0017f77922b11si2978196plt.84.2022.11.11.10.39.14; Fri, 11 Nov 2022 10:39:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aNX7gCXN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234606AbiKKShu (ORCPT + 99 others); Fri, 11 Nov 2022 13:37:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbiKKSg2 (ORCPT ); Fri, 11 Nov 2022 13:36:28 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52FB283691; Fri, 11 Nov 2022 10:36:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668191781; x=1699727781; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eSkn/vztgv3b1H9AuqHP1f8+st1SIUnPEpjHioF/AGg=; b=aNX7gCXNB77Zoq0LIpI74k/wVWVCbS7k02cNdzM8lHUCMjrk3M49xxs4 9Hy6XxA3OtiyyF4pwFMjhyeXj5D2geooZ18TZm3ALUbxGWrIfr8//X5j9 F3+RLD9n7WUAQ1Dn3HZCjko1MdEVCUpsdwvLz25WGV2r/St+bukPRShkZ 1Dl7NEzvT8yy/3s3FykGwa/9mIdUhLSOC+LtQ1TbQ4MxCEW9G+3wLr6Pk eMQIR1DbKSmsxgSEPg+vCLdXZeYT3nc9Egx7QElFfUAl8qdVNzoOsGZUo QAwr/154NpdKnULBX+np9F1mmJRsiEdUdbFLONgT5VaBexGUVtkQIthhB w==; X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="313447732" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="313447732" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 10:36:20 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10528"; a="640089434" X-IronPort-AV: E=Sophos;i="5.96,157,1665471600"; d="scan'208";a="640089434" Received: from hermesli-mobl.amr.corp.intel.com (HELO kcaccard-desk.amr.corp.intel.com) ([10.212.218.5]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 10:36:19 -0800 From: Kristen Carlson Accardi To: jarkko@kernel.org, dave.hansen@linux.kernel.org, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org Cc: zhiquan1.li@intel.com, Kristen Carlson Accardi Subject: [PATCH 23/26] cgroup/misc: Add tryget functionality for misc controller Date: Fri, 11 Nov 2022 10:35:28 -0800 Message-Id: <20221111183532.3676646-24-kristen@linux.intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221111183532.3676646-1-kristen@linux.intel.com> References: <20221111183532.3676646-1-kristen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749226061849674103?= X-GMAIL-MSGID: =?utf-8?q?1749226061849674103?= Allows caller to do a css_tryget() on a specific misc cgroup. Signed-off-by: Kristen Carlson Accardi --- include/linux/misc_cgroup.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/misc_cgroup.h b/include/linux/misc_cgroup.h index 7fbf3efb0f62..cee848205715 100644 --- a/include/linux/misc_cgroup.h +++ b/include/linux/misc_cgroup.h @@ -112,6 +112,16 @@ static inline void put_misc_cg(struct misc_cg *cg) css_put(&cg->css); } +/* + * misc_cg_tryget() - Try to increment this misc cgroup ref count. + * @cg - cgroup to get. + */ +static inline bool misc_cg_tryget(struct misc_cg *cg) +{ + if (cg) + return css_tryget(&cg->css); + return false; +} #else /* !CONFIG_CGROUP_MISC */ static inline struct misc_cg *root_misc(void) { @@ -175,6 +185,11 @@ static inline void put_misc_cg(struct misc_cg *cg) { } +static inline bool misc_cg_tryget(struct misc_cg *cg) +{ + return true; +} + static inline int register_misc_cg_notifier(struct notifier_block *nb) { return 0;