diff mbox series

mm/page_alloc: use free_area_empty() instead of open-coding

Message ID 1583668905-6569-1-git-send-email-qiwuchen55@gmail.com (mailing list archive)
State New, archived
Headers show
Series mm/page_alloc: use free_area_empty() instead of open-coding | expand

Commit Message

chenqiwu March 8, 2020, 12:01 p.m. UTC
From: chenqiwu <chenqiwu@xiaomi.com>

Use free_area_empty() API to replace list_empty() for better
code readability.

Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
 mm/page_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthew Wilcox March 8, 2020, 12:29 p.m. UTC | #1
On Sun, Mar 08, 2020 at 08:01:45PM +0800, qiwuchen55@gmail.com wrote:
>  		if (alloc_harder &&
> -			!list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))
> +		    !free_area_empty(area, MIGRATE_HIGHATOMIC))

I think these can now be one line?

Also, I think free_area_empty() and a number of related functions can move
from mmzone.h to mm/internal.h.  This will benefit all of us since mmzone.h
is included from mm.h and so is widely seen throughout the kernel.
chenqiwu March 8, 2020, 1:27 p.m. UTC | #2
On Sun, Mar 08, 2020 at 05:29:55AM -0700, Matthew Wilcox wrote:
> On Sun, Mar 08, 2020 at 08:01:45PM +0800, qiwuchen55@gmail.com wrote:
> >  		if (alloc_harder &&
> > -			!list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))
> > +		    !free_area_empty(area, MIGRATE_HIGHATOMIC))
> 
> I think these can now be one line?
> 
> Also, I think free_area_empty() and a number of related functions can move
> from mmzone.h to mm/internal.h.  This will benefit all of us since mmzone.h
> is included from mm.h and so is widely seen throughout the kernel.

I agree.
Qiwu
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 79e950d..6ae7142 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3534,7 +3534,7 @@  bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
 		}
 #endif
 		if (alloc_harder &&
-			!list_empty(&area->free_list[MIGRATE_HIGHATOMIC]))
+		    !free_area_empty(area, MIGRATE_HIGHATOMIC))
 			return true;
 	}
 	return false;