All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: use mapping_mapped to simplify the code
@ 2026-06-12  7:30 Huang Shijie
  2026-06-12  8:44 ` Muchun Song
  2026-06-12 10:16 ` Oscar Salvador (SUSE)
  0 siblings, 2 replies; 3+ messages in thread
From: Huang Shijie @ 2026-06-12  7:30 UTC (permalink / raw)
  To: muchun.song, osalvador, david, akpm
  Cc: zhongyuan, fangbaoshun, yingzhiwei, ljs, liam, vbabka, rppt,
	surenb, mhocko, linux-mm, linux-kernel, Huang Shijie,
	Pedro Falcato

Use mapping_mapped() to simplify the code, make
the code tidy and clean.

Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
Signed-off-by: Huang Shijie <huangsj@hygon.cn>
---
 fs/hugetlbfs/inode.c | 4 ++--
 mm/memory.c          | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 78d61bf2bd9b..216e1a0dd0b2 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -614,7 +614,7 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)
 
 	i_size_write(inode, offset);
 	i_mmap_lock_write(mapping);
-	if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
+	if (mapping_mapped(mapping))
 		hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0,
 				      ZAP_FLAG_DROP_MARKER);
 	i_mmap_unlock_write(mapping);
@@ -675,7 +675,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
 	/* Unmap users of full pages in the hole. */
 	if (hole_end > hole_start) {
-		if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
+		if (mapping_mapped(mapping))
 			hugetlb_vmdelete_list(&mapping->i_mmap,
 					      hole_start >> PAGE_SHIFT,
 					      hole_end >> PAGE_SHIFT, 0);
diff --git a/mm/memory.c b/mm/memory.c
index 86a973119bd4..5335077765e2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4386,7 +4386,7 @@ void unmap_mapping_folio(struct folio *folio)
 	details.zap_flags = ZAP_FLAG_DROP_MARKER;
 
 	i_mmap_lock_read(mapping);
-	if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
+	if (unlikely(mapping_mapped(mapping)))
 		unmap_mapping_range_tree(&mapping->i_mmap, first_index,
 					 last_index, &details);
 	i_mmap_unlock_read(mapping);
@@ -4416,7 +4416,7 @@ void unmap_mapping_pages(struct address_space *mapping, pgoff_t start,
 		last_index = ULONG_MAX;
 
 	i_mmap_lock_read(mapping);
-	if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
+	if (unlikely(mapping_mapped(mapping)))
 		unmap_mapping_range_tree(&mapping->i_mmap, first_index,
 					 last_index, &details);
 	i_mmap_unlock_read(mapping);
-- 
2.53.0




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

* Re: [PATCH] mm: use mapping_mapped to simplify the code
  2026-06-12  7:30 [PATCH] mm: use mapping_mapped to simplify the code Huang Shijie
@ 2026-06-12  8:44 ` Muchun Song
  2026-06-12 10:16 ` Oscar Salvador (SUSE)
  1 sibling, 0 replies; 3+ messages in thread
From: Muchun Song @ 2026-06-12  8:44 UTC (permalink / raw)
  To: Huang Shijie
  Cc: osalvador, david, akpm, zhongyuan, fangbaoshun, yingzhiwei, ljs,
	liam, vbabka, rppt, surenb, mhocko, linux-mm, linux-kernel,
	Pedro Falcato



> On Jun 12, 2026, at 15:30, Huang Shijie <huangsj@hygon.cn> wrote:
> 
> Use mapping_mapped() to simplify the code, make
> the code tidy and clean.
> 
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
> Signed-off-by: Huang Shijie <huangsj@hygon.cn>

Reviewed-by: Muchun Song <muchun.song@linux.dev>

Thanks.



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

* Re: [PATCH] mm: use mapping_mapped to simplify the code
  2026-06-12  7:30 [PATCH] mm: use mapping_mapped to simplify the code Huang Shijie
  2026-06-12  8:44 ` Muchun Song
@ 2026-06-12 10:16 ` Oscar Salvador (SUSE)
  1 sibling, 0 replies; 3+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-06-12 10:16 UTC (permalink / raw)
  To: Huang Shijie
  Cc: muchun.song, osalvador, david, akpm, zhongyuan, fangbaoshun,
	yingzhiwei, ljs, liam, vbabka, rppt, surenb, mhocko, linux-mm,
	linux-kernel, Pedro Falcato

On Fri, Jun 12, 2026 at 03:30:32PM +0800, Huang Shijie wrote:
> Use mapping_mapped() to simplify the code, make
> the code tidy and clean.
> 
> Reviewed-by: Pedro Falcato <pfalcato@suse.de>
> Reviewed-by: Lorenzo Stoakes <ljs@kernel.org>
> Signed-off-by: Huang Shijie <huangsj@hygon.cn>

Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>

> ---
>  fs/hugetlbfs/inode.c | 4 ++--
>  mm/memory.c          | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 78d61bf2bd9b..216e1a0dd0b2 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -614,7 +614,7 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)
>  
>  	i_size_write(inode, offset);
>  	i_mmap_lock_write(mapping);
> -	if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
> +	if (mapping_mapped(mapping))
>  		hugetlb_vmdelete_list(&mapping->i_mmap, pgoff, 0,
>  				      ZAP_FLAG_DROP_MARKER);
>  	i_mmap_unlock_write(mapping);
> @@ -675,7 +675,7 @@ static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
>  
>  	/* Unmap users of full pages in the hole. */
>  	if (hole_end > hole_start) {
> -		if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
> +		if (mapping_mapped(mapping))
>  			hugetlb_vmdelete_list(&mapping->i_mmap,
>  					      hole_start >> PAGE_SHIFT,
>  					      hole_end >> PAGE_SHIFT, 0);
> diff --git a/mm/memory.c b/mm/memory.c
> index 86a973119bd4..5335077765e2 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4386,7 +4386,7 @@ void unmap_mapping_folio(struct folio *folio)
>  	details.zap_flags = ZAP_FLAG_DROP_MARKER;
>  
>  	i_mmap_lock_read(mapping);
> -	if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
> +	if (unlikely(mapping_mapped(mapping)))
>  		unmap_mapping_range_tree(&mapping->i_mmap, first_index,
>  					 last_index, &details);
>  	i_mmap_unlock_read(mapping);
> @@ -4416,7 +4416,7 @@ void unmap_mapping_pages(struct address_space *mapping, pgoff_t start,
>  		last_index = ULONG_MAX;
>  
>  	i_mmap_lock_read(mapping);
> -	if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root)))
> +	if (unlikely(mapping_mapped(mapping)))
>  		unmap_mapping_range_tree(&mapping->i_mmap, first_index,
>  					 last_index, &details);
>  	i_mmap_unlock_read(mapping);
> -- 
> 2.53.0
> 
> 

-- 
Oscar Salvador
SUSE Labs


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

end of thread, other threads:[~2026-06-12 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-12  7:30 [PATCH] mm: use mapping_mapped to simplify the code Huang Shijie
2026-06-12  8:44 ` Muchun Song
2026-06-12 10:16 ` Oscar Salvador (SUSE)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.