From: Lorenzo Stoakes <ljs@kernel.org>
To: ranxiaokai627@163.com
Cc: hughd@google.com, baolin.wang@linux.alibaba.com,
akpm@linux-foundation.org, leitao@debian.org, ziy@nvidia.com,
liam@infradead.org, npache@redhat.com, ryan.roberts@arm.com,
dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev,
david@kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, ran.xiaokai@zte.com.cn
Subject: Re: [PATCH v3 2/2] mm: shmem: refactor thpsize_shmem_enabled_show() with helper arrays
Date: Fri, 22 May 2026 11:54:38 +0100 [thread overview]
Message-ID: <ahA1zkl2U44GYVrz@lucifer> (raw)
In-Reply-To: <ahAwLxwW3ki9cOjw@lucifer>
On Fri, May 22, 2026 at 11:35:01AM +0100, Lorenzo Stoakes wrote:
> On Mon, May 18, 2026 at 12:32:38PM +0000, ranxiaokai627@163.com wrote:
> > From: Ran Xiaokai <ran.xiaokai@zte.com.cn>
> >
> > Replace the hardcoded if/else chain of test_bit() calls and string
> > literals in thpsize_shmem_enabled_show() with a loop over
> > huge_shmem_orders_by_mode[] and huge_shmem_enabled_mode_strings[] arrays.
> >
> > This makes thpsize_shmem_enabled_show() consistent with
> > thpsize_shmem_enabled_store() and eliminates duplicated mode name strings.
> >
> > Signed-off-by: Ran Xiaokai <ran.xiaokai@zte.com.cn>
>
> From: ranxiaokai627@163.com
>
> This does not match the From: field of the email.
>
> This is violating kernel process. See
> https://docs.kernel.org/process/submitting-patches.html
>
> Please either update this to your 163 email account or resend from your
> zte.com.cn address, otherwise we can't take this.
Apologies - I'm apparently blind :)
You provided this in-body, there's no issue, ignore this!
Thanks, Lorenzo
>
> Cheers, Lorenzo
>
> > Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Tested-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Reviewed-by: Breno Leitao <leitao@debian.org>
> > Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
> > ---
> > mm/shmem.c | 36 +++++++++++++++++++++++-------------
> > 1 file changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 46d2cfc30823..197c9cc314c5 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -5553,20 +5553,30 @@ static ssize_t thpsize_shmem_enabled_show(struct kobject *kobj,
> > struct kobj_attribute *attr, char *buf)
> > {
> > int order = to_thpsize(kobj)->order;
> > - const char *output;
> > -
> > - if (test_bit(order, &huge_shmem_orders_always))
> > - output = "[always] inherit within_size advise never";
> > - else if (test_bit(order, &huge_shmem_orders_inherit))
> > - output = "always [inherit] within_size advise never";
> > - else if (test_bit(order, &huge_shmem_orders_within_size))
> > - output = "always inherit [within_size] advise never";
> > - else if (test_bit(order, &huge_shmem_orders_madvise))
> > - output = "always inherit within_size [advise] never";
> > - else
> > - output = "always inherit within_size advise [never]";
> > + int active = HUGE_SHMEM_ENABLED_NEVER;
> > + int len = 0;
> > + int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(huge_shmem_orders_by_mode); i++) {
> > + if (test_bit(order, huge_shmem_orders_by_mode[i])) {
> > + active = i;
> > + break;
> > + }
> > + }
> > +
> > + for (i = 0; i < ARRAY_SIZE(huge_shmem_enabled_mode_strings); i++) {
> > + if (i == active)
> > + len += sysfs_emit_at(buf, len, "[%s] ",
> > + huge_shmem_enabled_mode_strings[i]);
> > + else
> > + len += sysfs_emit_at(buf, len, "%s ",
> > + huge_shmem_enabled_mode_strings[i]);
> > + }
> > +
> > + /* Replace trailing space with newline */
> > + buf[len - 1] = '\n';
> >
> > - return sysfs_emit(buf, "%s\n", output);
> > + return len;
> > }
> >
> > static bool set_shmem_enabled_mode(int order, enum huge_shmem_enabled_mode mode)
> > --
> > 2.25.1
> >
> >
next prev parent reply other threads:[~2026-05-22 10:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260518123238.56344-1-ranxiaokai627@163.com>
[not found] ` <20260518123238.56344-2-ranxiaokai627@163.com>
2026-05-19 2:22 ` [PATCH v3 1/2] mm: shmem: refactor thpsize_shmem_enabled_store() with sysfs_match_string() Baolin Wang
2026-05-21 13:17 ` Lance Yang
2026-05-22 8:07 ` Barry Song
2026-05-22 10:39 ` Lorenzo Stoakes
2026-05-22 10:55 ` Lorenzo Stoakes
2026-05-25 7:52 ` ranxiaokai627
[not found] ` <20260518123238.56344-3-ranxiaokai627@163.com>
2026-05-21 13:18 ` [PATCH v3 2/2] mm: shmem: refactor thpsize_shmem_enabled_show() with helper arrays Lance Yang
2026-05-22 10:34 ` Lorenzo Stoakes
2026-05-22 10:44 ` Barry Song
2026-05-22 10:56 ` Lorenzo Stoakes
2026-05-22 10:54 ` Lorenzo Stoakes [this message]
2026-05-22 11:36 ` 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=ahA1zkl2U44GYVrz@lucifer \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hughd@google.com \
--cc=lance.yang@linux.dev \
--cc=leitao@debian.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npache@redhat.com \
--cc=ran.xiaokai@zte.com.cn \
--cc=ranxiaokai627@163.com \
--cc=ryan.roberts@arm.com \
--cc=ziy@nvidia.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