linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Usama Arif <usamaarif642@gmail.com>
To: Suren Baghdasaryan <surenb@google.com>,
	Shakeel Butt <shakeel.butt@linux.dev>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, hannes@cmpxchg.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH] alloc_tag: introduce Kconfig option for default compressed profiling
Date: Thu, 17 Apr 2025 19:35:40 +0100	[thread overview]
Message-ID: <33632210-6de3-445b-8f9c-d0fbcf3deab2@gmail.com> (raw)
In-Reply-To: <25ac1d9c-c7e4-4dcf-b297-254fa51c6f2a@gmail.com>



On 17/04/2025 18:50, Usama Arif wrote:
> 
> 
> On 17/04/2025 17:00, Suren Baghdasaryan wrote:
>> On Thu, Apr 17, 2025 at 8:47 AM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>>>
>>> On Wed, Apr 16, 2025 at 05:11:11PM -0700, Suren Baghdasaryan wrote:
>>>> On Wed, Apr 16, 2025 at 2:41 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>>>>>
>>>>> On Wed, Apr 16, 2025 at 02:08:31PM -0700, Suren Baghdasaryan wrote:
>>>>>> On Wed, Apr 16, 2025 at 11:06 AM Usama Arif <usamaarif642@gmail.com> wrote:
>>>>>>>
>>>>>>> With this Kconfig option enabled, the kernel stores allocation tag references
>>>>>>> in the page flags by default.
>>>>>>>
>>>>>>> There are 2 reasons to introduce this:
>>>>>>> - As mentioned in [1], compressed tags dont have system memory overhead
>>>>>>> and much lower performance overhead. It would be preferrable to have this as
>>>>>>> the default option, and to be able to switch it at compile time. Another
>>>>>>> option is to just declare the static key as true by default?
>>>>>>> - As compressed option is the best one, it doesn't make sense to have to
>>>>>>> change both defconfig and command line options to enable memory
>>>>>>> allocation profiling. Changing commandline across a large number of services
>>>>>>> can result in signifcant work, which shouldn't be needed if the kernel
>>>>>>> defconfig needs to be changed anyways.
>>>>>>
>>>>>> The reason tag compression is not the default option is because it
>>>>>> works only if there are enough free bits in the page flags to store a
>>>>>> tag index. If you configure it to use page flags and your build does
>>>>>> not have enough free bits, the profiling will be disabled (see
>>>>>> alloc_tag_sec_init()).
>>>>>
>>>>> Is it possible to fail the build in that case i.e. check the page flags
>>>>> availability at build time?
>>>>
>>>> The difficulty is finding out the number of allocation tags in the
>>>> kernel before it gets built. Maybe there is a way to add an additional
>>>> post-build stage to run that check.
>>>
>>> Yeah that would be good to have.
>>>
>>>> But even then making this option
>>>> default and causing build failures does not seem like a good idea to
>>>> me but maybe I'm being too cautious?
>>>
>>> Oh my question was orthogonal to the patch. Basically some users may
>>> want build time guarantee for this and they can enable such
>>> build-failing opt-in config/check.
>>
>> Yes, that would require the post-build step to check the number of
>> tags vs the number of available page flag bits. I'll add it to my TODO
>> list but it won't be at the top, sorry :) Volunteers to help with that
>> would be highly appreciated.
> 
> Hi Suren,
> 
> A question orthogonal to the patch, the defconfig entry is defined as below:
> 
> config MEM_ALLOC_PROFILING
> 	bool "Enable memory allocation profiling"
> 	default n
> 	depends on MMU
> 	depends on PROC_FS
> 	depends on !DEBUG_FORCE_WEAK_PER_CPU
> 	select CODE_TAGGING
> 	select PAGE_EXTENSION
> 	select SLAB_OBJ_EXT
> 
> i.e. we select PAGE_EXTENSION even if we use compressed profiling and use page flags
> instead of page extension. Which means the 0.2% (8 bytes per struct page) memory overhead
> will still exist even when we dont need it?
> 
> Should we have some defconfig option (happy with any other way) that only allows compressed
> profiling (otherwise nothing), so that we don't have the dependency on page extension
> and thus not have the overhead if we only plan to use compressed profiling?
> 
> Thanks


Johannes pointed out the .need function of page_alloc_tagging_ops, i.e. need_page_alloc_tagging,
so page extensions wouldn't be enabled and hopefully there is no memory overhead when
mem_profiling_compressed is true. Let me know if my understanding is wrong.
And sorry for the noise!


  reply	other threads:[~2025-04-17 18:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 18:06 Usama Arif
2025-04-16 21:08 ` Suren Baghdasaryan
2025-04-16 21:41   ` Shakeel Butt
2025-04-17  0:11     ` Suren Baghdasaryan
2025-04-17 15:47       ` Shakeel Butt
2025-04-17 16:00         ` Suren Baghdasaryan
2025-04-17 17:50           ` Usama Arif
2025-04-17 18:35             ` Usama Arif [this message]
2025-04-17 18:38               ` Suren Baghdasaryan
2025-04-16 21:52   ` Usama Arif
2025-04-17  0:15     ` Suren Baghdasaryan
2025-04-17 14:33       ` Usama Arif

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=33632210-6de3-445b-8f9c-d0fbcf3deab2@gmail.com \
    --to=usamaarif642@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.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