mm/page_alloc.c: clean code by merging two functions
Subsystems (2)
RFC PATCH 1/1 mm/page_alloc.c: clean code by merging two functions
From: Mateusz Nosek <[email protected]>
The 'finalise_ac' function is just 'epilogue' for 'prepare_alloc_pages'. Therefore there is no need to keep them both so 'finalise_ac' content can be merged into 'prepare_alloc_pages' code. It would make '__alloc_pages_nodemask' cleaner when it comes to readability.
--- mm/page_alloc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
mm/page_alloc.c +2 -8
@@ -4824,12 +4824,6 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, *alloc_flags =current_alloc_flags (gfp_mask, *alloc_flags); -return true; -} - -/* Determine whether to spread dirty pages and what the first usable zone */ -static inline void finalise_ac (gfp_t gfp_mask,struct alloc_context *ac) -{/* Dirty zone balancing only done in the fast path */ ac->spread_dirty_pages = (gfp_mask & __GFP_WRITE);
@@ -4840,6 +4834,8 @@ static inline void finalise_ac(gfp_t gfp_mask, struct alloc_context *ac)*/ ac->preferred_zoneref =first_zones_zonelist (ac->zonelist, ac->highest_zoneidx, ac->nodemask); + +return true; }/*
@@ -4868,8 +4864,6 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,if (!prepare_alloc_pages (gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))return NULL ; -finalise_ac (gfp_mask, &ac); -/* * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered.
Signature · 1 line
2.20.1
Hi,
(added Mel)
Quoted 6 lines · On Wed, Sep 16, 2020 at 01:01:18PM +0200, [email protected] wrote:
From: Mateusz Nosek <[email protected]>
The '
finalise_ac' function is just 'epilogue' for 'prepare_alloc_pages'. Therefore there is no need to keep them both so 'finalise_ac' content can be merged into 'prepare_alloc_pages' code. It would make '__alloc_pages_nodemask' cleaner when it comes to readability.
These functions were split from alloc_pages_nodemask() by commit 9cd7555875bb ("mm, page_alloc: split alloc_pages_nodemask()"), so at the very least I'd add Mel to 'cc.
Quoted 44 lines
Signed-off-by Mateusz Nosek <[email protected]>--- mm/page_alloc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)mm/page_alloc.c +2
-8@@ -4824,12 +4824,6 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order, *alloc_flags =current_alloc_flags (gfp_mask, *alloc_flags); -return true; -} - -/* Determine whether to spread dirty pages and what the first usable zone */ -static inline void finalise_ac (gfp_t gfp_mask,struct alloc_context *ac) -{/* Dirty zone balancing only done in the fast path */ ac->spread_dirty_pages = (gfp_mask & __GFP_WRITE);@@ -4840,6 +4834,8 @@ static inline void finalise_ac(gfp_t gfp_mask, struct alloc_context *ac)*/ ac->preferred_zoneref =first_zones_zonelist (ac->zonelist, ac->highest_zoneidx, ac->nodemask); + +return true; }/* @@ -4868,8 +4864,6 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid,if (!prepare_alloc_pages (gfp_mask, order, preferred_nid, nodemask, &ac, &alloc_mask, &alloc_flags))return NULL ; -finalise_ac (gfp_mask, &ac); -/* * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered. Signature · 1 line
2.20.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 7 lines · Mike Rapoport
Hi,
(added Mel)
Quoted 2 lines · On Wed, Sep 16, 2020 at 01:01:18PM +0200, [email protected] wrote:
From: Mateusz Nosek <[email protected]>
Quoted 9 lines
Quoted 4 lines
The '
finalise_ac' function is just 'epilogue' for 'prepare_alloc_pages'. Therefore there is no need to keep them both so 'finalise_ac' content can be merged into 'prepare_alloc_pages' code. It would make '__alloc_pages_nodemask' cleaner when it comes to readability.These functions were split from
alloc_pages_nodemask()by commit9cd7555875bb("mm,page_alloc: splitalloc_pages_nodemask()"), so at the very least I'd add Mel to 'cc.
The changelog explains the intent. At the time, there was demand for a bulk page allocator for networking support and one was prototyped
https://lore.kernel.org/lkml/[email protected]/
but the networking side to consume the interface was never finished.
Signature · 2 lines
Mel Gorman SUSE Labs