From patchwork Mon Sep 19 18:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 12980905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A06DECAAA1 for ; Mon, 19 Sep 2022 18:06:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75F416B0071; Mon, 19 Sep 2022 14:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70F4380008; Mon, 19 Sep 2022 14:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B02B80007; Mon, 19 Sep 2022 14:06:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4AAC66B0071 for ; Mon, 19 Sep 2022 14:06:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 127D31403CD for ; Mon, 19 Sep 2022 18:06:54 +0000 (UTC) X-FDA: 79929615948.21.29F674D Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf24.hostedemail.com (Postfix) with ESMTP id 8E91718000C for ; Mon, 19 Sep 2022 18:06:53 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id c24so6950722plo.3 for ; Mon, 19 Sep 2022 11:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date; bh=C+GNb1CRkpsaWy3nNaUeEZwBpKEJtnfXNeVMo/vFMIU=; b=fJXZ9vt1XMtBtJhooHOuHVO6gpZg/2Uq4qGa9T5h11pcGRnzjkEqyCrZLqmAkJO3mt 6jZ6Kmcm5Xrl4n/4Ha9OVyvbf7KSeSHSaBIOVNkl/Y+DFmj3H/uy0xNC+pLhyrze7MCr dwJzSTDmkot2vsTjksuK2VD4SWXd5wJcjGqt1tPITOlZ7VGEfcr6qO3cRxkn0CYilHgB T55kdJjZVfwysg0KjtfHwmZN+5pQSnz3gMRiZsYhWXzRHLhezJGrkX5qv07Q/7gmikk6 B/FPhC5n0u2iEpfA1o6oGoGvCu3B2YW8UjFu0aCFVVNQytVv//tVdMVPcPIP8TNm7bdz I93w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date; bh=C+GNb1CRkpsaWy3nNaUeEZwBpKEJtnfXNeVMo/vFMIU=; b=XLgLL10sXwFjMsfQuj+cPj9A6FavX6FhgrQPVDcIqNmY7pwud3d+JX2SeIe7S3ZIm6 insgp5E7ukS0SnzlkTMyUlXx9hIgK9v2TC+DuZeHx2KHi/oE9cE1CAnPlC7esC5CrDKT mxrh7Rah0LZRH+Po3BSmmCaicZqXgJNt9og1XtLbPz2cqqmmGYkj/MYusg3wx0k6shbQ DvitrPohFuCwj/GUe9HNjZ392+hN1vcYHpqyiErMzJ5W9E2VrLiiWDrWF5Hc3F0Sz/ac 5zNtGH73KoZ9pd46Ys94v7LypthzutWEBxJyyrKpkfzqESinAJ+DFrqRXn1hZg27JacZ DKDg== X-Gm-Message-State: ACrzQf1eSO3zmYw/0F+gPLwwYZN3yJy0KszZvn5RHtk0+jHcCvop4ElZ gjp49f4asbkbgZCCV5djCZc= X-Google-Smtp-Source: AMsMyM779q0TTvhK4qsuqZ791YA4zyjY0m9M+JWLvcM1gMkroLtT/c+VgF5ZePOZ7fH3LVOzJk9gXw== X-Received: by 2002:a17:90a:be10:b0:202:cdf2:56a1 with SMTP id a16-20020a17090abe1000b00202cdf256a1mr31606922pjs.41.1663610812577; Mon, 19 Sep 2022 11:06:52 -0700 (PDT) Received: from KASONG-MB0.tencent.com ([115.171.41.135]) by smtp.gmail.com with ESMTPSA id u21-20020a632355000000b0041c30def5e8sm14176654pgm.33.2022.09.19.11.06.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Sep 2022 11:06:52 -0700 (PDT) From: Kairui Song To: cgroups@vger.kernel.org, linux-mm@kvack.org Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v2 1/2] mm: memcontrol: use memcg_kmem_enabled in count_objcg_event Date: Tue, 20 Sep 2022 02:06:33 +0800 Message-Id: <20220919180634.45958-2-ryncsn@gmail.com> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220919180634.45958-1-ryncsn@gmail.com> References: <20220919180634.45958-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663610813; a=rsa-sha256; cv=none; b=sDhL7StRjevh+6ThUU3mKRVZK6Dfljc5cNEhjFEI/I34v2jxVXYkchrQ/PO4Fk2qXWVUEF +O1eOhGL9Z6tsUD0qat3FH2XtWN+0+WYALaHoZeClQTv4wgQsloLOYP7RQGj5Qr1KhXwZD 4SHRBOs1bGtzolhEuEIxubcs4zeYTPI= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fJXZ9vt1; spf=pass (imf24.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663610813; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=C+GNb1CRkpsaWy3nNaUeEZwBpKEJtnfXNeVMo/vFMIU=; b=PfULqaZNf6MZ099xpgI4MBCjUNzdwEwBtic4PliRbhL+XSiLMJQOI9388iz/I0wGA31CSq ev6BbJ15WVRSmPuWIegxmsnWJniw4ZzTiK4raAgPjpU1huaYp/T+UtVzPFWGU9hHohWRng T8W4Q1j2OPHpKYXcdD+VwVgvsIQo+H4= X-Stat-Signature: 7cr4fajrt1wdhhcm6q9djft99ap7tjec X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fJXZ9vt1; spf=pass (imf24.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8E91718000C X-HE-Tag: 1663610813-904815 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Kairui Song There are currently two helpers for checking if cgroup kmem accounting is enabled: - mem_cgroup_kmem_disabled - memcg_kmem_enabled mem_cgroup_kmem_disabled is a simple helper that returns true if cgroup.memory=nokmem is specified, otherwise returns false. memcg_kmem_enabled is a bit different, it returns true if cgroup.memory=nokmem is not specified and there was at least one non-root memory control enabled cgroup ever created. This help improve performance when kmem accounting was not actually activated. And it's optimized with static branch. The usage of mem_cgroup_kmem_disabled is for sub-systems that need to preallocate data for kmem accounting since they could be initialized before kmem accounting is activated. But count_objcg_event doesn't need that, so using memcg_kmem_enabled is better here. Signed-off-by: Kairui Song Acked-by: Shakeel Butt Acked-by: Roman Gushchin Acked-by: Muchun Song --- include/linux/memcontrol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6257867fbf95..e6d3d5870d6f 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1779,7 +1779,7 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, { struct mem_cgroup *memcg; - if (mem_cgroup_kmem_disabled()) + if (!memcg_kmem_enabled()) return; rcu_read_lock();