* [RFC PATCH] mm/page_alloc.c: clean code by merging two functions
@ 2020-09-16 11:01 mateusznosek0
2020-09-21 12:36 ` Mike Rapoport
0 siblings, 1 reply; 3+ messages in thread
From: mateusznosek0 @ 2020-09-16 11:01 UTC (permalink / raw)
To: linux-mm, linux-kernel; +Cc: Mateusz Nosek, akpm
From: Mateusz Nosek <mateusznosek0@gmail.com>
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.
Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
---
mm/page_alloc.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b9bd75cacf02..a094e297c88f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -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.
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] mm/page_alloc.c: clean code by merging two functions
2020-09-16 11:01 [RFC PATCH] mm/page_alloc.c: clean code by merging two functions mateusznosek0
@ 2020-09-21 12:36 ` Mike Rapoport
2020-09-21 15:58 ` Mel Gorman
0 siblings, 1 reply; 3+ messages in thread
From: Mike Rapoport @ 2020-09-21 12:36 UTC (permalink / raw)
To: mateusznosek0; +Cc: linux-mm, linux-kernel, akpm, Mel Gorman
Hi,
(added Mel)
On Wed, Sep 16, 2020 at 01:01:18PM +0200, mateusznosek0@gmail.com wrote:
> From: Mateusz Nosek <mateusznosek0@gmail.com>
>
> 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.
> Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
> ---
> mm/page_alloc.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b9bd75cacf02..a094e297c88f 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -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.
> --
> 2.20.1
>
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] mm/page_alloc.c: clean code by merging two functions
2020-09-21 12:36 ` Mike Rapoport
@ 2020-09-21 15:58 ` Mel Gorman
0 siblings, 0 replies; 3+ messages in thread
From: Mel Gorman @ 2020-09-21 15:58 UTC (permalink / raw)
To: Mike Rapoport; +Cc: mateusznosek0, linux-mm, linux-kernel, akpm
On Mon, Sep 21, 2020 at 03:36:07PM +0300, Mike Rapoport wrote:
> Hi,
>
> (added Mel)
>
> On Wed, Sep 16, 2020 at 01:01:18PM +0200, mateusznosek0@gmail.com wrote:
> > From: Mateusz Nosek <mateusznosek0@gmail.com>
> >
> > 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.
>
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/20170109163518.6001-5-mgorman@techsingularity.net/
but the networking side to consume the interface was never finished.
--
Mel Gorman
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-21 16:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 11:01 [RFC PATCH] mm/page_alloc.c: clean code by merging two functions mateusznosek0
2020-09-21 12:36 ` Mike Rapoport
2020-09-21 15:58 ` Mel Gorman
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).