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 8595938E13F for ; Fri, 22 May 2026 10:35:02 +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=1779446103; cv=none; b=k6EVISGEl4ZPvay9lqYs/4C6TFEqIueXl1sA+VVwsQ+gYY0OXlL/m6afgEcXUvizOL2dR5hg5PmrBdE7fBBXUODS1G7B5eLlAA0RhRWs4hSIXwairBo2PdwhqfuTeWyNFTnZ+77M7RWDC1Awqj76XqUPpiy2XvoCq+Gqym5PwnM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779446103; c=relaxed/simple; bh=Ev9TAvVBeSKNqg3AmZ4F7oEO5gAyvH4HUL+kXgFBXkc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rzBxziJNi1b8tST3u3hAseGRfAPJpi12SonlzdEOf92Ie4AFFuP6BfPEU37Qqqu3CwBQSjIsAI8vAjFt+MUXr4GVdNMg9Mxdod88Y0XVwC3Zb3aIMS6/QSUha28aKxPbBaV15BfvVuFC3kYXWrO8BnfpxwJL2CEodflLfUlw6Zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FVkO1+71; 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="FVkO1+71" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D1481F000E9; Fri, 22 May 2026 10:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779446102; bh=5oSznGJd9kahjuR5wlJHn+DNoeoTiNjPUdlEP8QnSbI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FVkO1+71t89AwW42m+uw3Pxh9/wk2R1blObwE8ChYsBS5oG2UIG3SOUBR7k9Lss3z zIvjNT6mt9zPjyFgvUhRaZtmyJWskdQUiS3bO5h9H8FL5JI3cYSSyQotWnwAIu2dCp YZJkbBRWlfu2D+zJKXv7Ou3S/Y1Ixdle1cwWn72qd66o1LeJfsweCZh9lNc2IYY3R3 TJITEkJb7G7c7cXVWw9zfgALXwy76xJmS261k7aixm4DVSdEMtWeYlm878LkYiBSPM pXiAkR9JmIw25zrmVnL7FbO2TWLNGY0Wd/TcwPKlNR+5HGo4P5XksA4Gib/15b9IEI K44bRJYUwClZw== Date: Fri, 22 May 2026 11:34:54 +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: <20260518123238.56344-3-ranxiaokai627@163.com> 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. 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 > >