linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlbfs: show pagesize in unit of GB if possible
@ 2021-01-30  9:03 Miaohe Lin
  2021-01-30 22:07 ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2021-01-30  9:03 UTC (permalink / raw)
  To: akpm, mike.kravetz; +Cc: linux-mm, linux-kernel, linmiaohe

Hugepage size in unit of GB is supported. We could show pagesize in unit of
GB to make it more friendly to read. Also rework the calculation code of
page size unit to make it more readable.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 fs/hugetlbfs/inode.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 3a08fbae3b53..40a9795f250a 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1014,11 +1014,15 @@ 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_1G) {
+		hpage_size /= SZ_1G;
+		mod = 'G';
+	} else 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) {
-- 
2.19.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible
  2021-01-30  9:03 [PATCH] hugetlbfs: show pagesize in unit of GB if possible Miaohe Lin
@ 2021-01-30 22:07 ` David Rientjes
  2021-02-01  1:22   ` Miaohe Lin
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2021-01-30 22:07 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Sat, 30 Jan 2021, Miaohe Lin wrote:

> Hugepage size in unit of GB is supported. We could show pagesize in unit of
> GB to make it more friendly to read. Also rework the calculation code of
> page size unit to make it more readable.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  fs/hugetlbfs/inode.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 3a08fbae3b53..40a9795f250a 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1014,11 +1014,15 @@ 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_1G) {
> +		hpage_size /= SZ_1G;
> +		mod = 'G';
> +	} else 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) {

NACK, this can break existing userspace parsing.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible
  2021-01-30 22:07 ` David Rientjes
@ 2021-02-01  1:22   ` Miaohe Lin
  2021-02-01 21:31     ` David Rientjes
  0 siblings, 1 reply; 5+ messages in thread
From: Miaohe Lin @ 2021-02-01  1:22 UTC (permalink / raw)
  To: David Rientjes; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

Hi:
On 2021/1/31 6:07, David Rientjes wrote:
> On Sat, 30 Jan 2021, Miaohe Lin wrote:
> 
>> Hugepage size in unit of GB is supported. We could show pagesize in unit of
>> GB to make it more friendly to read. Also rework the calculation code of
>> page size unit to make it more readable.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  fs/hugetlbfs/inode.c | 12 ++++++++----
>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>> index 3a08fbae3b53..40a9795f250a 100644
>> --- a/fs/hugetlbfs/inode.c
>> +++ b/fs/hugetlbfs/inode.c
>> @@ -1014,11 +1014,15 @@ 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_1G) {
>> +		hpage_size /= SZ_1G;
>> +		mod = 'G';
>> +	} else 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) {
> 
> NACK, this can break existing userspace parsing.
> .
> 

I see. I should take care of this. Many thanks.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible
  2021-02-01  1:22   ` Miaohe Lin
@ 2021-02-01 21:31     ` David Rientjes
  2021-02-02  1:26       ` Miaohe Lin
  0 siblings, 1 reply; 5+ messages in thread
From: David Rientjes @ 2021-02-01 21:31 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Mon, 1 Feb 2021, Miaohe Lin wrote:

> >> Hugepage size in unit of GB is supported. We could show pagesize in unit of
> >> GB to make it more friendly to read. Also rework the calculation code of
> >> page size unit to make it more readable.
> >>
> >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> >> ---
> >>  fs/hugetlbfs/inode.c | 12 ++++++++----
> >>  1 file changed, 8 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> >> index 3a08fbae3b53..40a9795f250a 100644
> >> --- a/fs/hugetlbfs/inode.c
> >> +++ b/fs/hugetlbfs/inode.c
> >> @@ -1014,11 +1014,15 @@ 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_1G) {
> >> +		hpage_size /= SZ_1G;
> >> +		mod = 'G';
> >> +	} else 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) {
> > 
> > NACK, this can break existing userspace parsing.
> > .
> > 
> 
> I see. I should take care of this. Many thanks.
> 

Thanks.  It's an important point to emphasize because it shows how 
important user-facing interfaces are.  Once the hugetlbfs mount options 
are printed in the way they are, it becomes very difficult to change them 
because there can be userspace in the wild that would break as a result.  
This is why it's crucial to be very careful when specifying user-facing 
interfaces the first time so they are extensible.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] hugetlbfs: show pagesize in unit of GB if possible
  2021-02-01 21:31     ` David Rientjes
@ 2021-02-02  1:26       ` Miaohe Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Miaohe Lin @ 2021-02-02  1:26 UTC (permalink / raw)
  To: David Rientjes; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

Hi:
On 2021/2/2 5:31, David Rientjes wrote:
> On Mon, 1 Feb 2021, Miaohe Lin wrote:
> 
>>>> Hugepage size in unit of GB is supported. We could show pagesize in unit of
>>>> GB to make it more friendly to read. Also rework the calculation code of
>>>> page size unit to make it more readable.
>>>>
>>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>>> ---
>>>>  fs/hugetlbfs/inode.c | 12 ++++++++----
>>>>  1 file changed, 8 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>>>> index 3a08fbae3b53..40a9795f250a 100644
>>>> --- a/fs/hugetlbfs/inode.c
>>>> +++ b/fs/hugetlbfs/inode.c
>>>> @@ -1014,11 +1014,15 @@ 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_1G) {
>>>> +		hpage_size /= SZ_1G;
>>>> +		mod = 'G';
>>>> +	} else 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) {
>>>
>>> NACK, this can break existing userspace parsing.
>>> .
>>>
>>
>> I see. I should take care of this. Many thanks.
>>
> 
> Thanks.  It's an important point to emphasize because it shows how 
> important user-facing interfaces are.  Once the hugetlbfs mount options 
> are printed in the way they are, it becomes very difficult to change them 
> because there can be userspace in the wild that would break as a result.  
> This is why it's crucial to be very careful when specifying user-facing 
> interfaces the first time so they are extensible.
> .
> 

Many thanks for detailed explanation! I will keep this in mind! Thanks again.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-02  1:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-30  9:03 [PATCH] hugetlbfs: show pagesize in unit of GB if possible Miaohe Lin
2021-01-30 22:07 ` David Rientjes
2021-02-01  1:22   ` Miaohe Lin
2021-02-01 21:31     ` David Rientjes
2021-02-02  1:26       ` Miaohe Lin

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).