Re: [PATCH -next v2] include/linux/mm.h: move nr_free_buffer_pages from swap.h to mm.h

From: Matthew Wilcox
Date: Sun Aug 15 2021 - 11:31:41 EST


On Sun, Aug 15, 2021 at 07:50:57PM +0800, Mianhan Liu wrote:
> nr_free_buffer_pages could be exposed through mm.h instead of swap.h.
> The advantage of this change is that it can reduce the obsolete includes.
> For example, net/ipv4/tcp.c wouldn't need swap.h any more since it has
> already included mm.h.
> Moreover, after preprocessing all the files that use nr_free_buffer_pages,
> it turns out that those files have already included mm.h.
> Thus, we can move nr_free_buffer_pages from swap.h to mm.h safely. This change
> will not affect the compilation of other files.

In general, we're trying to move in the other direction; move things out
of mm.h and reduce the number of files which include mm.h. That said,
I don't see what nr_free_buffer_pages() has to do with the rest of
swap.h, so I'm OK with moving this over.

That said, there are a number of other files which should have swap.h
removed. eg:

drivers/mmc/core/mmc_test.c:#include <linux/swap.h> /* For nr_free_buffer_pages() */

and it would be good to check the other files which use
nr_free_buffer_pages() to see if they can have swap.h removed too.

> +++ b/include/linux/mm.h
> @@ -871,6 +871,7 @@ void put_pages_list(struct list_head *pages);
> void split_page(struct page *page, unsigned int order);
> void folio_copy(struct folio *dst, struct folio *src);
>
> +extern unsigned long nr_free_buffer_pages(void);

Please remove the 'extern' while you're moving this.

> +++ b/net/ipv4/tcp.c

If you're interested in cleaning up the headers, it'd be nice if less
of the networking code depended on pagemap.h ...