linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: David Hildenbrand <david@redhat.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<akpm@linux-foundation.org>, <mike.kravetz@oracle.com>
Subject: Re: [PATCH] hugetlbfs: rework calculation code of Hugepage size in hugetlbfs_show_options()
Date: Mon, 1 Feb 2021 19:19:38 +0800	[thread overview]
Message-ID: <bf9d1db9-5f4e-4a1d-8389-c53ca63acfc1@huawei.com> (raw)
In-Reply-To: <2bb70cac-b8ef-cdbe-fa4e-db6229587e98@redhat.com>

Hi:
On 2021/2/1 18:56, David Hildenbrand wrote:
> On 01.02.21 09:23, Miaohe Lin wrote:
>> Rework calculation code of the Hugepage size to make it more readable and
>> straightforward.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>   fs/hugetlbfs/inode.c | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>> index 3a08fbae3b53..1be18de4b537 100644
>> --- a/fs/hugetlbfs/inode.c
>> +++ b/fs/hugetlbfs/inode.c
>> @@ -1014,11 +1014,12 @@ static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root)
>>       if (sbinfo->max_inodes != -1)
>>           seq_printf(m, ",nr_inodes=%lu", sbinfo->max_inodes);
>>   -    hpage_size /= 1024;
>> -    mod = 'K';
>> -    if (hpage_size >= 1024) {
>> -        hpage_size /= 1024;
>> +    if (hpage_size >= SZ_1M) {
>> +        hpage_size /= SZ_1M;
>>           mod = 'M';
>> +    } else {
>> +        hpage_size /= SZ_1K;
>> +        mod = 'K';
>>       }
>>       seq_printf(m, ",pagesize=%lu%c", hpage_size, mod);
>>       if (spool) {
>>
> 
> Looks correct but I am not convinced the old code was that complicated to understand.
> 

The old code is not complicated but I think it may be better to use macro instead of well-known "magic number".
Many thanks for review.:)


      reply	other threads:[~2021-02-01 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01  8:23 [PATCH] hugetlbfs: rework calculation code of Hugepage size in hugetlbfs_show_options() Miaohe Lin
2021-02-01 10:56 ` David Hildenbrand
2021-02-01 11:19   ` Miaohe Lin [this message]

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=bf9d1db9-5f4e-4a1d-8389-c53ca63acfc1@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.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;
as well as URLs for NNTP newsgroup(s).