From patchwork Fri Jul 19 10:28:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 13737164 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 AA5BAC3DA59 for ; Fri, 19 Jul 2024 10:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 451A36B0089; Fri, 19 Jul 2024 06:29:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 400186B008C; Fri, 19 Jul 2024 06:29:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251FF6B0092; Fri, 19 Jul 2024 06:29:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 03EA16B0089 for ; Fri, 19 Jul 2024 06:29:10 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 76DA616057F for ; Fri, 19 Jul 2024 10:29:10 +0000 (UTC) X-FDA: 82356129660.16.577FDAE Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf28.hostedemail.com (Postfix) with ESMTP id 478C3C0020 for ; Fri, 19 Jul 2024 10:29:08 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=V+IUSZEQ; dkim=pass header.d=suse.com header.s=susede1 header.b=ZbQJrqhV; spf=pass (imf28.hostedemail.com: domain of wqu@suse.com designates 195.135.223.130 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=1721384906; 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=rCb4hBwueKHgs5zAbBKeIF4mFjfNu0oH5bRUKJriLuE=; b=ZSmVLjjK7kRORBlJYo/SS/kFeppuPgoRjwh5r2fWQlCDxUJ38vBitWBsXiGNS/RU0WqgoI Z39m2Nc+Yju4LSev4TTPKONT8pTgMneTKz7AjWcHW7I+BgWvPbIV+ZRBESs1JD7wXZ5HLx uIQvlQzjzOLBGf4qr2d1clCWrWhJdQA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721384906; a=rsa-sha256; cv=none; b=DRvTxhhBCEVq9uDbAXwbcI8TyhWbOKrhuXltIbGV18f2l+rpTYJS4tcpUpzDC0HTQkH6Zp RQykSfFFeB1WsHt2IP6f9vbTe+9uZAWVd5O3lPzSp3wvaPcYdW0/h43MecJjMih6hceRA7 gU24cAxUplGtC0/BD0FUhphfEGR1u08= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=V+IUSZEQ; dkim=pass header.d=suse.com header.s=susede1 header.b=ZbQJrqhV; spf=pass (imf28.hostedemail.com: domain of wqu@suse.com designates 195.135.223.130 as permitted sender) smtp.mailfrom=wqu@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out1.suse.de (Postfix) with ESMTPS id D57D721B36; Fri, 19 Jul 2024 10:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721384946; 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=rCb4hBwueKHgs5zAbBKeIF4mFjfNu0oH5bRUKJriLuE=; b=V+IUSZEQJ4MYRrnLifgbdIUzRgc8y/KMZSPNFbNUaBGyy/8meNC8E8Lz7mJZriO3NJFkBk iI6514FDCkKcStGKgBfADAtqriRv4uRsNkhIoNWt+A+78LlXp3YVOgXk20cfHiPZ+OBHgG vJ8uTncoAINjZ6wulsM0dbp+qo97ev8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1721384945; 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=rCb4hBwueKHgs5zAbBKeIF4mFjfNu0oH5bRUKJriLuE=; b=ZbQJrqhVESIcngQJArxsc/or77qC05ONkiZYpqs22KgoEuCGMkyXRsG7fMhX/VyPtaZhrA 4Hbe4PpROZiCogNRiVSzShQ1Q6BWKxEzP4JPoRj9XUc2Ni+Y0uLZjWukpv4am7X2ntY2uc dljKXwJ7mHRv++c+ar7UkBXOG1C9cHo= 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 0AD0213808; Fri, 19 Jul 2024 10:29:02 +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 iPirLe4/mmb5WAAAD6G6ig (envelope-from ); Fri, 19 Jul 2024 10:29:02 +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 v7 1/3] memcontrol: define root_mem_cgroup for CONFIG_MEMCG=n cases Date: Fri, 19 Jul 2024 19:58:39 +0930 Message-ID: <2050f8a1bc181a9aaf01e0866e230e23216000f4.1721384771.git.wqu@suse.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Action: no action X-Spamd-Bar: / X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 478C3C0020 X-Stat-Signature: zhgkgdt9379jcxyapq4ar3sfbsxy86tg X-HE-Tag: 1721384948-784623 X-HE-Meta: U2FsdGVkX1/sZ+mADxfEVmkAKGb8JM9rKVmVM9p+6noZR8AWBb3pZnKce1hYdhN/MvcltU6CxZ/eKiGVxy68/KM8XarnwQVXbTrTqf/kOWWF27HUIiqCvi/mph643UmMjzZzSVWmKrVT39hsNLuR1oZdx3jdMHJHhIc2WoY2EHNl7iEocCVHZ6B+np/+7qH2WYFCc/L7svH2eUn+vUKEz6IeEFstfFxpoQtjzeGRAFxrw8MsA/0AAmUL971Mqo4h7E+37yJy5u+6n+afTQNFw0HBz301nQ+Xpjx5e3GdHBDfpBUOLALGbYmZo5+Ot00JSNtCsJLhQqxqtvOXlxXooFhDA0EOr+WEtQZ+tLlsnbIthOLk80pEOxs0qszYlnN2EKlU8tJdHa+URx/xtU/bBY/bQGmKWXJfJaXuaNfpPiwM6BY8jCj0uyk5KJ1ilhVJ9YBdYme1Fu9LB8/mkC33wasHNVdg/kfn3jipf7pysuf+ib/ym1+uTqpNTFHMnymzqGaZpJFM+8c4Q4/D8nAEddLCoZghMQ3MVzGT6qEHO/RtQAn410kbPJGvjfXJD1QckJM5qTAndfYCbKRQP9/Mu9hXmhER98FvIbJwNZUbfogFnJiDjEZN90cDknIG6bYbCNV+jsslJow47fD117IvWHNrMi0KgLh9Z2eVv+CkEZ2rNn1n97TX7c1AN3IZUgIUjLBa4uwexnHlR9XacEzxWn7WLrsgDkuOU9ANXaW00SRcQR+dnx2MqgzQjPmyMKoVmFPqEIbPxKjGFkig9e+rpw4yU7O06DQniTep4oxY3py0R4JC1GvlOBtL3AW59bRfWOO4W+7LMWrjBsXVZNP8NLCpSbB9bUexeWdxDgSXX2Psp1laAwqBPSe3rBFFSptmS0WsIN87A40SpeTdwG/66TSA9w7/p68fpnhAtgtWEV8YRRArfLwwfAhc7x6nmzstn7kHiUu6oDms+nQSQZU 9NADDNEz UTISErZuxojf/9zRdSWFGgwhmJELENAFdQed8scPTs+T/fDacSJQA6O2vdFWDQSffCk/me9Bx96pMIFedbv/Bg3WarcMdKawafOt52TY/VTiXucoXxIxh8WAc1rAewl8RvcgObx2R0WGkb8Z1Ajy6bOpXzxcF9m9hdZizD63wKGXJ87h256UsNZsltelHW0pi0gyN37Zr/JlnPndr4osLvfrooGpvW6uPx5Lpw0g4XL2hbOASMlRcgBtPaubUTE6ERTt4yA6pZ1MNIk1Nmzf/lu3G0galdk60ajO5BZ/aj7n/wAVrpM9bhCII5w== 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 030d34e9d117..ae5c78719454 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -346,6 +346,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 {