* [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c
@ 2023-03-19 11:42 Mike Rapoport
2023-03-19 12:07 ` Lorenzo Stoakes
2023-03-19 14:16 ` Kirill A. Shutemov
0 siblings, 2 replies; 5+ messages in thread
From: Mike Rapoport @ 2023-03-19 11:42 UTC (permalink / raw)
To: Andrew Morton; +Cc: Mike Rapoport, linux-mm, linux-kernel
From: "Mike Rapoport (IBM)" <rppt@kernel.org>
The get_page_from_free_area() helper is only used in mm/page_alloc.c so
move it there to reduce noise in include/linux/mmzone.h
Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
---
include/linux/mmzone.h | 7 -------
mm/page_alloc.c | 7 +++++++
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 96599cb9eb62..8f5a9e2c722a 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -108,13 +108,6 @@ struct free_area {
unsigned long nr_free;
};
-static inline struct page *get_page_from_free_area(struct free_area *area,
- int migratetype)
-{
- return list_first_entry_or_null(&area->free_list[migratetype],
- struct page, lru);
-}
-
static inline bool free_area_empty(struct free_area *area, int migratetype)
{
return list_empty(&area->free_list[migratetype]);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 87d760236dba..2e72fdbdd8db 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1048,6 +1048,13 @@ static inline void del_page_from_free_list(struct page *page, struct zone *zone,
zone->free_area[order].nr_free--;
}
+static inline struct page *get_page_from_free_area(struct free_area *area,
+ int migratetype)
+{
+ return list_first_entry_or_null(&area->free_list[migratetype],
+ struct page, lru);
+}
+
/*
* If this is not the largest possible page, check if the buddy
* of the next-highest order is free. If it is, it's possible
base-commit: 4018ab1f7cec061b8425737328edefebdc0ab832
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c
2023-03-19 11:42 [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c Mike Rapoport
@ 2023-03-19 12:07 ` Lorenzo Stoakes
2023-03-19 20:22 ` Matthew Wilcox
2023-03-19 14:16 ` Kirill A. Shutemov
1 sibling, 1 reply; 5+ messages in thread
From: Lorenzo Stoakes @ 2023-03-19 12:07 UTC (permalink / raw)
To: Mike Rapoport; +Cc: Andrew Morton, linux-mm, linux-kernel
On Sun, Mar 19, 2023 at 01:42:14PM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (IBM)" <rppt@kernel.org>
>
> The get_page_from_free_area() helper is only used in mm/page_alloc.c so
> move it there to reduce noise in include/linux/mmzone.h
>
> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
> ---
> include/linux/mmzone.h | 7 -------
> mm/page_alloc.c | 7 +++++++
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 96599cb9eb62..8f5a9e2c722a 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -108,13 +108,6 @@ struct free_area {
> unsigned long nr_free;
> };
>
> -static inline struct page *get_page_from_free_area(struct free_area *area,
> - int migratetype)
> -{
> - return list_first_entry_or_null(&area->free_list[migratetype],
> - struct page, lru);
> -}
> -
> static inline bool free_area_empty(struct free_area *area, int migratetype)
> {
> return list_empty(&area->free_list[migratetype]);
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 87d760236dba..2e72fdbdd8db 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1048,6 +1048,13 @@ static inline void del_page_from_free_list(struct page *page, struct zone *zone,
> zone->free_area[order].nr_free--;
> }
>
> +static inline struct page *get_page_from_free_area(struct free_area *area,
> + int migratetype)
> +{
> + return list_first_entry_or_null(&area->free_list[migratetype],
> + struct page, lru);
> +}
> +
> /*
> * If this is not the largest possible page, check if the buddy
> * of the next-highest order is free. If it is, it's possible
>
> base-commit: 4018ab1f7cec061b8425737328edefebdc0ab832
> --
> 2.35.1
>
Good catch, I wonder if there are more functions like this that can be dropped
from headers?
Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c
2023-03-19 11:42 [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c Mike Rapoport
2023-03-19 12:07 ` Lorenzo Stoakes
@ 2023-03-19 14:16 ` Kirill A. Shutemov
1 sibling, 0 replies; 5+ messages in thread
From: Kirill A. Shutemov @ 2023-03-19 14:16 UTC (permalink / raw)
To: Mike Rapoport; +Cc: Andrew Morton, linux-mm, linux-kernel
On Sun, Mar 19, 2023 at 01:42:14PM +0200, Mike Rapoport wrote:
> From: "Mike Rapoport (IBM)" <rppt@kernel.org>
>
> The get_page_from_free_area() helper is only used in mm/page_alloc.c so
> move it there to reduce noise in include/linux/mmzone.h
>
> Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c
2023-03-19 12:07 ` Lorenzo Stoakes
@ 2023-03-19 20:22 ` Matthew Wilcox
2023-03-19 20:52 ` Mike Rapoport
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2023-03-19 20:22 UTC (permalink / raw)
To: Lorenzo Stoakes; +Cc: Mike Rapoport, Andrew Morton, linux-mm, linux-kernel
On Sun, Mar 19, 2023 at 12:07:43PM +0000, Lorenzo Stoakes wrote:
> On Sun, Mar 19, 2023 at 01:42:14PM +0200, Mike Rapoport wrote:
> > From: "Mike Rapoport (IBM)" <rppt@kernel.org>
> >
> > The get_page_from_free_area() helper is only used in mm/page_alloc.c so
> > move it there to reduce noise in include/linux/mmzone.h
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Good catch, I wonder if there are more functions like this that can be dropped
> from headers?
I don't think anything outside mm/ has any reason to see 'struct
free_area'. Unfortunately, it's a field in struct zone, so moving
it out of mmzone.h will be hard (unless we can move struct zone out of
mmzone.h?)
free_area_empty() can move to mm/internal.h though
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c
2023-03-19 20:22 ` Matthew Wilcox
@ 2023-03-19 20:52 ` Mike Rapoport
0 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2023-03-19 20:52 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Lorenzo Stoakes, Andrew Morton, linux-mm, linux-kernel
On Sun, Mar 19, 2023 at 08:22:14PM +0000, Matthew Wilcox wrote:
> On Sun, Mar 19, 2023 at 12:07:43PM +0000, Lorenzo Stoakes wrote:
> > On Sun, Mar 19, 2023 at 01:42:14PM +0200, Mike Rapoport wrote:
> > > From: "Mike Rapoport (IBM)" <rppt@kernel.org>
> > >
> > > The get_page_from_free_area() helper is only used in mm/page_alloc.c so
> > > move it there to reduce noise in include/linux/mmzone.h
>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> > Good catch, I wonder if there are more functions like this that can be dropped
> > from headers?
>
> I don't think anything outside mm/ has any reason to see 'struct
> free_area'. Unfortunately, it's a field in struct zone, so moving
> it out of mmzone.h will be hard (unless we can move struct zone out of
> mmzone.h?)
Seems possible but not trivial.
> free_area_empty() can move to mm/internal.h though
Yes.
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-19 20:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-19 11:42 [PATCH] mm: move get_page_from_free_area() to mm/page_alloc.c Mike Rapoport
2023-03-19 12:07 ` Lorenzo Stoakes
2023-03-19 20:22 ` Matthew Wilcox
2023-03-19 20:52 ` Mike Rapoport
2023-03-19 14:16 ` Kirill A. Shutemov
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).