From patchwork Fri Jul 19 09:16:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13737039 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 61E3CC3DA5D for ; Fri, 19 Jul 2024 09:17:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC5DE6B0088; Fri, 19 Jul 2024 05:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E754C6B0089; Fri, 19 Jul 2024 05:17:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3D6E6B008C; Fri, 19 Jul 2024 05:17:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AC1736B0088 for ; Fri, 19 Jul 2024 05:17:27 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5FD951A04FD for ; Fri, 19 Jul 2024 09:17:27 +0000 (UTC) X-FDA: 82355948934.11.77C4273 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf01.hostedemail.com (Postfix) with ESMTP id 5398F40007 for ; Fri, 19 Jul 2024 09:17:25 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=NykYiRAA; dkim=pass header.d=suse.com header.s=susede1 header.b=NykYiRAA; spf=pass (imf01.hostedemail.com: domain of wqu@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=wqu@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721380604; h=from:from:sender: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=fmyu5jbhji4elkLqRwur2P37OFeRBcl+AErISbo0FHE=; b=Iq9g1BURBDONZH+3e4y1W/i3nRi7sfUb8qSgR1jQI06nBHY67t/0Mg/ro6tJ87wwbug4fc ut9U3VTW6LaV4LDRfujdJVsmmgk2VD9lnAzI3QBNyIh12uVeRwFKQQGn/TcRYms0onQK9e KFKkoPwYOpUV0+Tmqaj2sj8imWtF3sI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721380604; a=rsa-sha256; cv=none; b=ljaF+0PXNEzfBO1SZGnSqpxMMiJ5+QAqDEFVtg/2+wxWEckDvaNmlc7noZWlifqQ7mE4Tu xVnjjhzZfwj8uxRnzzM5r13fWQb70snfVZxW/tToRl/7/cPIoXrsGq86OXXjYMqedFMH/N s30RC+lUAJrcbr7NvkQjwf1UwF8fH/U= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=NykYiRAA; dkim=pass header.d=suse.com header.s=susede1 header.b=NykYiRAA; spf=pass (imf01.hostedemail.com: domain of wqu@suse.com designates 195.135.223.131 as permitted sender) smtp.mailfrom=wqu@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id ADDB01F79B; Fri, 19 Jul 2024 09:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721380643; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fmyu5jbhji4elkLqRwur2P37OFeRBcl+AErISbo0FHE=; b=NykYiRAAxu7CsxrlNeU2oyqWd3jlozTIsGR11G4SkfqRlbI0mqPsl3e6Wb1hTNnODc9YrV UgOwGz8b95Bc0JBCiUCqZU3qPFb6PdG+AQkB6mSRNthtOZkH6SUVQLQqHXjjLlolivIcUf WY6pLkbue+RduN6RYvcivFlX4Mm7cwc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721380643; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fmyu5jbhji4elkLqRwur2P37OFeRBcl+AErISbo0FHE=; b=NykYiRAAxu7CsxrlNeU2oyqWd3jlozTIsGR11G4SkfqRlbI0mqPsl3e6Wb1hTNnODc9YrV UgOwGz8b95Bc0JBCiUCqZU3qPFb6PdG+AQkB6mSRNthtOZkH6SUVQLQqHXjjLlolivIcUf WY6pLkbue+RduN6RYvcivFlX4Mm7cwc= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D4E30136F7; Fri, 19 Jul 2024 09:17:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id YLdvIyAvmmZPRAAAD6G6ig (envelope-from ); Fri, 19 Jul 2024 09:17:20 +0000 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v6 1/3] memcontrol: define root_mem_cgroup for CONFIG_MEMCG=n cases Date: Fri, 19 Jul 2024 18:46:57 +0930 Message-ID: <299298648bc5689b2f163c7876936179338301ba.1721380449.git.wqu@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 5398F40007 X-Stat-Signature: 34x4bti168uetfwjnwcy9fg9akio4b4t X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721380645-711291 X-HE-Meta: U2FsdGVkX18zI1QFDmEUy2Df0MZ0OcZWVmvEI33/ONDAAloE/QGfCTs0avzguBgu87X5k2x6FQyuOJohhI74G9ISLhWNo1t/n6RLPk/ZABkCMCqBaA2ml8G8VM2f/KAd2HyTvOyeF1OqFEgqBD3cDo1IVKkdeHEvmUcgC0T3TN77wFmVV4fZoVkGS2WkP53l+p3GgMTQ/8xvM+hZpbTDVMul9CwVyJsEKk8GFB0SJOSxW9LfJIgbRjtkaZxkbMHDzqWdYKWaa+0JS3ISMfrFJc38ryZy41TE9Ex09XYEt2rl3tAeLn9J5khQ6+wzOIHPGC+SPrtu7F0+dk4QnybZ4mhgRb+Uhlgptk/c3r09ak8C/W2pG7JQ9YUKBh97K5SSVs1ekxLiflE8FmQSjvqb2vEsJFCwYCbZHSkZgwOjMUljM7FbQmIiCQsefLkWLV4NsmRmaOGuWVfftFxvPP5S1umGpHStM5hI+Wm5iO9e0Tb4M0i8EwMj2RBLQ8OpnD6Xew483RZSl+dBBW1dSsS7Eb0OtMixQgRqwcWZVsuIO39t6veWiBpmGp0Rt9PDm8ORqiB66FYPb+C6L94gSHOsVDgLPwnHuoFdiS6JnOT37zhZXGwTVPHgNFIbfCuZPeQNIkZRntWnkSNaTyu3cAbAF8lA3y5a5qPEPBj3yXVAVlbBDwNdUWO/Z2IPgxkPcX3HnW+5YqBkgNNrQ20buphcW5qzAz5YM5VrM1AHbF8n+1bvLpgIL1uJ90JH++e3I7LXS6vQ+hzK1/OgcYkk14SAwss0wJWQvF5eXHUV906rkZagM77yy8Qp5Sw8/eORiiK97jC9UWmYegXYGGLmZt691rkBfsWhTnLNOZa1rzTXWE4+IitA55KiOqE8Fa5JTWCOMuBGVVuBB8r7TyulYJZOSyAUCHZA1G6EW8KL9x+6d3frDR5brVQVH03EiBVYEW4HsRvJHn1CBej9AuP9Yc4 TlzOHIfO CuxsBvSM/tOLZV8M/w+NHJy5KyTrrhKhzZoHDaOsnbAZNoK95i1gzNOe6du+6r5QQYTmFslkNup0IBmiDEK0f1I78gAGBIhUf3URzB2HAQSAt9uGTqYXsDV0cIuBDwdM4xjbNu2mKlTzlz/Zohn3R4PAAnxMykC5d4+vVAqAAnny4kc4OhQcW7/0uwd+/xLVnqcI0WQ/Wan2/GX5OygxC8BNxb96IGt5CHUd176CWkfyJ1tDv0K90BMceckdyUlibLxyC9d1coBF+Y7bViXAtnE/rJtQAzi4GXftIFGtO9OSfCPUU2qO0ypGoug== 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: List-Subscribe: List-Unsubscribe: There is an incoming btrfs patchset, which will use @root_mem_cgroup as the active cgroup to attach metadata folios to its internal btree inode, so that btrfs can skip the possibly costly charge for the internal inode which is only accessible by btrfs itself. However @root_mem_cgroup is not always defined (not defined for CONFIG_MEMCG=n case), thus all such callers need to do the extra handling for different CONFIG_MEMCG settings. So here we add a special macro definition of root_mem_cgroup, making it to always be NULL. The advantage of this, other than pulling the pointer definition out, is that we will avoid wasting global data section space for such pointer. Signed-off-by: Qu Wenruo --- include/linux/memcontrol.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 030d34e9d117..a268585babdc 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -329,8 +329,6 @@ struct mem_cgroup { */ #define MEMCG_CHARGE_BATCH 64U -extern struct mem_cgroup *root_mem_cgroup; - enum page_memcg_data_flags { /* page->memcg_data is a pointer to an slabobj_ext vector */ MEMCG_DATA_OBJEXTS = (1UL << 0), @@ -346,6 +344,12 @@ enum page_memcg_data_flags { #define __FIRST_OBJEXT_FLAG (1UL << 0) +/* + * For CONFIG_MEMCG=n case, still define a root_mem_cgroup, but that will + * always be NULL and not taking any global data section space. + */ +#define root_mem_cgroup (NULL) + #endif /* CONFIG_MEMCG */ enum objext_flags {