linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs
@ 2022-07-26 14:29 Miaohe Lin
  2022-07-26 14:29 ` [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

Hi everyone,
This series contains a few cleaup patches to remove unneeded forward
declaration, use helper macro and so on. More details can be found in
the respective changelogs.
Thanks!
---
v2:
  collect Reviewed-by tag per Mike.
  reshape the comment of 4/5 per Mike.
  drop code change in 5/5 and change to correct the comment per Mike.
  Many thanks Mike for review.
---
Miaohe Lin (5):
  hugetlbfs: use helper macro SZ_1{K,M}
  hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
  hugetlbfs: remove unneeded header file
  hugetlbfs: cleanup some comments in inode.c
  hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()

 fs/hugetlbfs/inode.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

-- 
2.23.0


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

* [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M}
  2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
@ 2022-07-26 14:29 ` Miaohe Lin
  2022-07-27  6:43   ` Muchun Song
  2022-07-26 14:29 ` [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration Miaohe Lin
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

Use helper macro SZ_1K and SZ_1M to do the size conversion. Minor
readability improvement.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 20336cb3c040..e998c416b85f 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1309,7 +1309,7 @@ static int hugetlbfs_parse_param(struct fs_context *fc, struct fs_parameter *par
 		ps = memparse(param->string, &rest);
 		ctx->hstate = size_to_hstate(ps);
 		if (!ctx->hstate) {
-			pr_err("Unsupported page size %lu MB\n", ps >> 20);
+			pr_err("Unsupported page size %lu MB\n", ps / SZ_1M);
 			return -EINVAL;
 		}
 		return 0;
@@ -1555,7 +1555,7 @@ static struct vfsmount *__init mount_one_hugetlbfs(struct hstate *h)
 	}
 	if (IS_ERR(mnt))
 		pr_err("Cannot mount internal hugetlbfs for page size %luK",
-		       huge_page_size(h) >> 10);
+		       huge_page_size(h) / SZ_1K);
 	return mnt;
 }
 
-- 
2.23.0


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

* [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
  2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
  2022-07-26 14:29 ` [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
@ 2022-07-26 14:29 ` Miaohe Lin
  2022-07-27  6:44   ` Muchun Song
  2022-07-26 14:29 ` [PATCH v2 3/5] hugetlbfs: remove unneeded header file Miaohe Lin
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

The forward declaration for hugetlbfs_ops is unnecessary. Remove it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e998c416b85f..a10156df5726 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -40,7 +40,6 @@
 #include <linux/uaccess.h>
 #include <linux/sched/mm.h>
 
-static const struct super_operations hugetlbfs_ops;
 static const struct address_space_operations hugetlbfs_aops;
 const struct file_operations hugetlbfs_file_operations;
 static const struct inode_operations hugetlbfs_dir_inode_operations;
-- 
2.23.0


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

* [PATCH v2 3/5] hugetlbfs: remove unneeded header file
  2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
  2022-07-26 14:29 ` [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
  2022-07-26 14:29 ` [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration Miaohe Lin
@ 2022-07-26 14:29 ` Miaohe Lin
  2022-07-27  6:44   ` Muchun Song
  2022-07-26 14:29 ` [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c Miaohe Lin
  2022-07-26 14:29 ` [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs() Miaohe Lin
  4 siblings, 1 reply; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

The header file signal.h is unneeded now. Remove it.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a10156df5726..aa7a5b8fc724 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -11,7 +11,6 @@
 
 #include <linux/thread_info.h>
 #include <asm/current.h>
-#include <linux/sched/signal.h>		/* remove ASAP */
 #include <linux/falloc.h>
 #include <linux/fs.h>
 #include <linux/mount.h>
-- 
2.23.0


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

* [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c
  2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
                   ` (2 preceding siblings ...)
  2022-07-26 14:29 ` [PATCH v2 3/5] hugetlbfs: remove unneeded header file Miaohe Lin
@ 2022-07-26 14:29 ` Miaohe Lin
  2022-07-27  6:45   ` Muchun Song
  2022-07-26 14:29 ` [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs() Miaohe Lin
  4 siblings, 1 reply; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

The function generic_file_buffered_read has been renamed to filemap_read
since commit 87fa0f3eb267 ("mm/filemap: rename generic_file_buffered_read
to filemap_read"). Update the corresponding comment. And duplicated taken
in hugetlbfs_fill_super is removed.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 fs/hugetlbfs/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index aa7a5b8fc724..96c60aa3ab47 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -313,8 +313,7 @@ hugetlbfs_read_actor(struct page *page, unsigned long offset,
 
 /*
  * Support for read() - Find the page attached to f_mapping and copy out the
- * data. Its *very* similar to generic_file_buffered_read(), we can't use that
- * since it has PAGE_SIZE assumptions.
+ * data. This provides functionality similar to filemap_read().
  */
 static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
@@ -1383,7 +1382,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	/*
 	 * Allocate and initialize subpool if maximum or minimum size is
 	 * specified.  Any needed reservations (for minimum size) are taken
-	 * taken when the subpool is created.
+	 * when the subpool is created.
 	 */
 	if (ctx->max_hpages != -1 || ctx->min_hpages != -1) {
 		sbinfo->spool = hugepage_new_subpool(ctx->hstate,
-- 
2.23.0


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

* [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
  2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
                   ` (3 preceding siblings ...)
  2022-07-26 14:29 ` [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c Miaohe Lin
@ 2022-07-26 14:29 ` Miaohe Lin
  2022-07-26 21:20   ` Mike Kravetz
  2022-07-27  6:46   ` Muchun Song
  4 siblings, 2 replies; 12+ messages in thread
From: Miaohe Lin @ 2022-07-26 14:29 UTC (permalink / raw)
  To: akpm, mike.kravetz, songmuchun; +Cc: linux-mm, linux-kernel, linmiaohe

In some cases, e.g. when size option is not specified, f_blocks, f_bavail
and f_bfree will be set to -1 instead of 0. Likewise, when nr_inodes isn't
specified, f_files and f_ffree will be set to -1 too. Update the comment
to make this clear.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 fs/hugetlbfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 96c60aa3ab47..fe0e374b02a3 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1079,7 +1079,7 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_bsize = huge_page_size(h);
 	if (sbinfo) {
 		spin_lock(&sbinfo->stat_lock);
-		/* If no limits set, just report 0 for max/free/used
+		/* If no limits set, just report 0 or -1 for max/free/used
 		 * blocks, like simple_statfs() */
 		if (sbinfo->spool) {
 			long free_pages;
-- 
2.23.0


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

* Re: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
  2022-07-26 14:29 ` [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs() Miaohe Lin
@ 2022-07-26 21:20   ` Mike Kravetz
  2022-07-27  6:46   ` Muchun Song
  1 sibling, 0 replies; 12+ messages in thread
From: Mike Kravetz @ 2022-07-26 21:20 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, songmuchun, linux-mm, linux-kernel

On 07/26/22 22:29, Miaohe Lin wrote:
> In some cases, e.g. when size option is not specified, f_blocks, f_bavail
> and f_bfree will be set to -1 instead of 0. Likewise, when nr_inodes isn't
> specified, f_files and f_ffree will be set to -1 too. Update the comment
> to make this clear.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  fs/hugetlbfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks,

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 96c60aa3ab47..fe0e374b02a3 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -1079,7 +1079,7 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
>  	buf->f_bsize = huge_page_size(h);
>  	if (sbinfo) {
>  		spin_lock(&sbinfo->stat_lock);
> -		/* If no limits set, just report 0 for max/free/used
> +		/* If no limits set, just report 0 or -1 for max/free/used
>  		 * blocks, like simple_statfs() */
>  		if (sbinfo->spool) {
>  			long free_pages;
> -- 
> 2.23.0
> 

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

* Re: [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M}
  2022-07-26 14:29 ` [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
@ 2022-07-27  6:43   ` Muchun Song
  0 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2022-07-27  6:43 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Tue, Jul 26, 2022 at 10:29:14PM +0800, Miaohe Lin wrote:
> Use helper macro SZ_1K and SZ_1M to do the size conversion. Minor
> readability improvement.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.


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

* Re: [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration
  2022-07-26 14:29 ` [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration Miaohe Lin
@ 2022-07-27  6:44   ` Muchun Song
  0 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2022-07-27  6:44 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Tue, Jul 26, 2022 at 10:29:15PM +0800, Miaohe Lin wrote:
> The forward declaration for hugetlbfs_ops is unnecessary. Remove it.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.

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

* Re: [PATCH v2 3/5] hugetlbfs: remove unneeded header file
  2022-07-26 14:29 ` [PATCH v2 3/5] hugetlbfs: remove unneeded header file Miaohe Lin
@ 2022-07-27  6:44   ` Muchun Song
  0 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2022-07-27  6:44 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Tue, Jul 26, 2022 at 10:29:16PM +0800, Miaohe Lin wrote:
> The header file signal.h is unneeded now. Remove it.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.

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

* Re: [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c
  2022-07-26 14:29 ` [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c Miaohe Lin
@ 2022-07-27  6:45   ` Muchun Song
  0 siblings, 0 replies; 12+ messages in thread
From: Muchun Song @ 2022-07-27  6:45 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Tue, Jul 26, 2022 at 10:29:17PM +0800, Miaohe Lin wrote:
> The function generic_file_buffered_read has been renamed to filemap_read
> since commit 87fa0f3eb267 ("mm/filemap: rename generic_file_buffered_read
> to filemap_read"). Update the corresponding comment. And duplicated taken
> in hugetlbfs_fill_super is removed.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.

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

* Re: [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs()
  2022-07-26 14:29 ` [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs() Miaohe Lin
  2022-07-26 21:20   ` Mike Kravetz
@ 2022-07-27  6:46   ` Muchun Song
  1 sibling, 0 replies; 12+ messages in thread
From: Muchun Song @ 2022-07-27  6:46 UTC (permalink / raw)
  To: Miaohe Lin; +Cc: akpm, mike.kravetz, linux-mm, linux-kernel

On Tue, Jul 26, 2022 at 10:29:18PM +0800, Miaohe Lin wrote:
> In some cases, e.g. when size option is not specified, f_blocks, f_bavail
> and f_bfree will be set to -1 instead of 0. Likewise, when nr_inodes isn't
> specified, f_files and f_ffree will be set to -1 too. Update the comment
> to make this clear.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.

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

end of thread, other threads:[~2022-07-27  6:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 14:29 [PATCH v2 0/5] A few cleanup and fixup patches for hugetlbfs Miaohe Lin
2022-07-26 14:29 ` [PATCH v2 1/5] hugetlbfs: use helper macro SZ_1{K,M} Miaohe Lin
2022-07-27  6:43   ` Muchun Song
2022-07-26 14:29 ` [PATCH v2 2/5] hugetlbfs: remove unneeded hugetlbfs_ops forward declaration Miaohe Lin
2022-07-27  6:44   ` Muchun Song
2022-07-26 14:29 ` [PATCH v2 3/5] hugetlbfs: remove unneeded header file Miaohe Lin
2022-07-27  6:44   ` Muchun Song
2022-07-26 14:29 ` [PATCH v2 4/5] hugetlbfs: cleanup some comments in inode.c Miaohe Lin
2022-07-27  6:45   ` Muchun Song
2022-07-26 14:29 ` [PATCH v2 5/5] hugetlbfs: fix inaccurate comment in hugetlbfs_statfs() Miaohe Lin
2022-07-26 21:20   ` Mike Kravetz
2022-07-27  6:46   ` Muchun Song

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