From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DCC6823DD for ; Fri, 22 May 2026 10:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779447287; cv=none; b=o+k2bZa9u4j0Pc7pNfFNxNdfJLDm6XIFfZp3z1Xk576W5de5EK9F6LmICTsRseIu+PcSP87SDb5HCN2ek0+guz/nvMUDY2kX9VfToJO7lteKIhu4ZANyGhDMWOoxQgd+s1S03dXKnJml58CnpCrP04TAEkd7gNx3bSEtgnzOdYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779447287; c=relaxed/simple; bh=mzDjrxpiKw1GA1OST+aqZ0tmqU43WQglGeOPelhBdGM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DSDpwbI2gbNIllRuezUCSLyyRgjwOrMq9DuqCgTzb4l+zvsneRCARh4g4v96lRXoI8nvWiBf7vu5/0OwaL3EiDrT3fF6G9p6xQE33hRep7f7aqtKE6vx/r2ZXcGEs6TkV/Bf7Hudy24A2h+Dl9RmgS9+k7X/madavEaKhIfoH0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BkutECvS; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BkutECvS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 492BD1F00A3D; Fri, 22 May 2026 10:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779447285; bh=5AIOvztfUjkiBTbuolahgtGC2mZLONjW3VWKNqcGZNE=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=BkutECvSwEHWNWqVb7d0yLZr9hcjO0kBXD3BN8rCDMNZcYi14emZxpIJoAaB+Wrek LCKFLn7rVFsnRp/x+5T4ztxayo8hBByKpGiXNCaDp2sJpVI43wxkIDnT571MtYfTlv uP+HsH5/UQlampmc6Lsjq35VRu55LN4YBOukjk0ptGsfeF0G28CFO/OmkIlZCex1mU 9GSsJuaiTvRojjt4nZ3WW7vIirKQF13bhAL2W84u71L6VUQxH+8RjOzzZKlhNLyJ/M 6EiZdConJLPZtB+mefGs10+MM7T8WlS1KFTsV+N+OZwm8QZJsv5/XmZQTlfWYgHAG0 coeyBZmCO+dJg== Date: Fri, 22 May 2026 11:54:38 +0100 From: Lorenzo Stoakes 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 Message-ID: References: <20260518123238.56344-1-ranxiaokai627@163.com> <20260518123238.56344-3-ranxiaokai627@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > > > > 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 > > 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 > > Tested-by: Baolin Wang > > Reviewed-by: Breno Leitao > > Reviewed-by: Lorenzo Stoakes > > --- > > 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 > > > >