From: Vlastimil Babka <vbabka@suse.cz>
To: Qu Wenruo <wqu@suse.com>, 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: Re: [PATCH v6 1/3] memcontrol: define root_mem_cgroup for CONFIG_MEMCG=n cases
Date: Fri, 19 Jul 2024 12:19:46 +0200 [thread overview]
Message-ID: <5c9f852f-f00b-4543-830b-7dd71d5042e0@suse.cz> (raw)
In-Reply-To: <299298648bc5689b2f163c7876936179338301ba.1721380449.git.wqu@suse.com>
On 7/19/24 11:16 AM, Qu Wenruo wrote:
> 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 <wqu@suse.com>
> ---
> 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;
> -
This breaks the CONFIG_MEMCG=y case?
> 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 {
next prev parent reply other threads:[~2024-07-19 10:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 9:16 [PATCH v6 0/3] btrfs: try to allocate larger folios for metadata Qu Wenruo
2024-07-19 9:16 ` [PATCH v6 1/3] memcontrol: define root_mem_cgroup for CONFIG_MEMCG=n cases Qu Wenruo
2024-07-19 10:19 ` Vlastimil Babka [this message]
2024-07-19 9:16 ` [PATCH v6 2/3] btrfs: always uses root memcgroup for filemap_add_folio() Qu Wenruo
2024-07-19 9:16 ` [PATCH v6 3/3] btrfs: prefer to allocate larger folio for metadata Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c9f852f-f00b-4543-830b-7dd71d5042e0@suse.cz \
--to=vbabka@suse.cz \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox