From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>, Jonathan Corbet <corbet@lwn.net>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
David Hildenbrand <david@redhat.com>,
Barry Song <baohua@kernel.org>, Lance Yang <ioworker0@gmail.com>,
Gavin Shan <gshan@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v2 2/3] mm: Tidy up shmem mTHP controls and stats
Date: Mon, 22 Jul 2024 16:04:34 +0800 [thread overview]
Message-ID: <df5f4dc7-a014-4060-9c5d-1c6c0fd5b7a7@linux.alibaba.com> (raw)
In-Reply-To: <1732c37b-ab9d-47f7-8bfe-cc7992b632cf@arm.com>
On 2024/7/22 15:33, Ryan Roberts wrote:
> On 22/07/2024 07:14, Baolin Wang wrote:
>>
>>
>> On 2024/7/16 21:59, Ryan Roberts wrote:
>>> Previously we had a situation where shmem mTHP controls and stats were
>>> not exposed for some supported sizes and were exposed for some
>>> unsupported sizes. So let's clean that up.
>>>
>>> Anon mTHP can support all large orders (2, PMD_ORDER). But shmem can
>>> support all large orders (1, MAX_PAGECACHE_ORDER). However, per-size
>>> shmem controls and stats were previously being exposed for all the anon
>>> mTHP orders, meaning order-1 was not present, and for arm64 64K base
>>> pages, orders 12 and 13 were exposed but were not supported internally.
>>>
>>> Tidy this all up by defining ctrl and stats attribute groups for anon
>>> and file separately. Anon ctrl and stats groups are populated for all
>>> orders in THP_ORDERS_ALL_ANON and file ctrl and stats groups are
>>> populated for all orders in THP_ORDERS_ALL_FILE_DEFAULT.
>>
>> Make sense.
>>
>>>
>>> The side-effect of all this is that different hugepage-*kB directories
>>> contain different sets of controls and stats, depending on which memory
>>> types support that size. This approach is preferred over the
>>> alternative, which is to populate dummy controls and stats for memory
>>> types that do not support a given size.
>>
>> OK.
>>
>>>
>>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>>> ---
>>> mm/huge_memory.c | 110 ++++++++++++++++++++++++++++++++++-------------
>>> 1 file changed, 80 insertions(+), 30 deletions(-)
>>>
>>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>>> index f4be468e06a4..578ac212c172 100644
>>> --- a/mm/huge_memory.c
>>> +++ b/mm/huge_memory.c
>>> @@ -463,8 +463,8 @@ static void thpsize_release(struct kobject *kobj);
>>> static DEFINE_SPINLOCK(huge_anon_orders_lock);
>>> static LIST_HEAD(thpsize_list);
>>> -static ssize_t thpsize_enabled_show(struct kobject *kobj,
>>> - struct kobj_attribute *attr, char *buf)
>>> +static ssize_t anon_enabled_show(struct kobject *kobj,
>>> + struct kobj_attribute *attr, char *buf)
>>> {
>>> int order = to_thpsize(kobj)->order;
>>> const char *output;
>>> @@ -481,9 +481,9 @@ static ssize_t thpsize_enabled_show(struct kobject *kobj,
>>> return sysfs_emit(buf, "%s\n", output);
>>> }
>>> -static ssize_t thpsize_enabled_store(struct kobject *kobj,
>>> - struct kobj_attribute *attr,
>>> - const char *buf, size_t count)
>>> +static ssize_t anon_enabled_store(struct kobject *kobj,
>>> + struct kobj_attribute *attr,
>>> + const char *buf, size_t count)
>>> {
>>> int order = to_thpsize(kobj)->order;
>>> ssize_t ret = count;
>>> @@ -525,19 +525,27 @@ static ssize_t thpsize_enabled_store(struct kobject *kobj,
>>> return ret;
>>> }
>>> -static struct kobj_attribute thpsize_enabled_attr =
>>> - __ATTR(enabled, 0644, thpsize_enabled_show, thpsize_enabled_store);
>>> +static struct kobj_attribute anon_enabled_attr =
>>> + __ATTR(enabled, 0644, anon_enabled_show, anon_enabled_store);
>>> -static struct attribute *thpsize_attrs[] = {
>>> - &thpsize_enabled_attr.attr,
>>> +static struct attribute *anon_ctrl_attrs[] = {
>>> + &anon_enabled_attr.attr,
>>> + NULL,
>>> +};
>>> +
>>> +static const struct attribute_group anon_ctrl_attr_grp = {
>>> + .attrs = anon_ctrl_attrs,
>>> +};
>>> +
>>> +static struct attribute *file_ctrl_attrs[] = {
>>> #ifdef CONFIG_SHMEM
>>> &thpsize_shmem_enabled_attr.attr,
>>> #endif
>>> NULL,
>>> };
>>> -static const struct attribute_group thpsize_attr_group = {
>>> - .attrs = thpsize_attrs,
>>> +static const struct attribute_group file_ctrl_attr_grp = {
>>> + .attrs = file_ctrl_attrs,
>>> };
>>> static const struct kobj_type thpsize_ktype = {
>>> @@ -583,57 +591,99 @@ DEFINE_MTHP_STAT_ATTR(split, MTHP_STAT_SPLIT);
>>> DEFINE_MTHP_STAT_ATTR(split_failed, MTHP_STAT_SPLIT_FAILED);
>>> DEFINE_MTHP_STAT_ATTR(split_deferred, MTHP_STAT_SPLIT_DEFERRED);
>>> -static struct attribute *stats_attrs[] = {
>>> +static struct attribute *anon_stats_attrs[] = {
>>> &anon_fault_alloc_attr.attr,
>>> &anon_fault_fallback_attr.attr,
>>> &anon_fault_fallback_charge_attr.attr,
>>> &swpout_attr.attr,
>>> &swpout_fallback_attr.attr,
>>> - &shmem_alloc_attr.attr,
>>> - &shmem_fallback_attr.attr,
>>> - &shmem_fallback_charge_attr.attr,
>>> &split_attr.attr,
>>> &split_failed_attr.attr,
>>> &split_deferred_attr.attr,
>>> NULL,
>>> };
>>> -static struct attribute_group stats_attr_group = {
>>> +static struct attribute_group anon_stats_attr_grp = {
>>> + .name = "stats",
>>> + .attrs = anon_stats_attrs,
>>> +};
>>> +
>>> +static struct attribute *file_stats_attrs[] = {
>>> +#ifdef CONFIG_SHMEM
>>> + &shmem_alloc_attr.attr,
>>> + &shmem_fallback_attr.attr,
>>> + &shmem_fallback_charge_attr.attr,
>>
>> Shmem should also support swpout_* counters.
>
> OK, so to put it another way, swpout_* stats are required all orders in
> (THP_ORDERS_ALL_ANON | THP_ORDERS_ALL_FILE_DEFAULT) if CONFIG_SHMEM is defined,
> else all orders in THP_ORDERS_ALL_ANON. Have I understood correctly?
>
> If so, I'll fix that in the next version.
Yes, I think so.
next prev parent reply other threads:[~2024-07-22 8:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 13:59 [PATCH v2 0/3] mTHP allocation stats for file-backed memory Ryan Roberts
2024-07-16 13:59 ` [PATCH v2 1/3] mm: Cleanup count_mthp_stat() definition Ryan Roberts
2024-07-16 13:59 ` [PATCH v2 2/3] mm: Tidy up shmem mTHP controls and stats Ryan Roberts
2024-07-22 6:14 ` Baolin Wang
2024-07-22 7:33 ` Ryan Roberts
2024-07-22 8:04 ` Baolin Wang [this message]
2024-07-16 13:59 ` [PATCH v2 3/3] mm: mTHP stats for pagecache folio allocations Ryan Roberts
2024-07-19 0:12 ` Barry Song
2024-07-19 8:56 ` Ryan Roberts
2024-07-23 22:07 ` Barry Song
2024-07-24 8:12 ` Ryan Roberts
2024-07-24 10:23 ` Barry Song
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=df5f4dc7-a014-4060-9c5d-1c6c0fd5b7a7@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=gshan@redhat.com \
--cc=hughd@google.com \
--cc=ioworker0@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.com \
--cc=willy@infradead.org \
/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