Commit 1d44f2e6 authored by Kefeng Wang's avatar Kefeng Wang Committed by Andrew Morton

mm_types: add virtual and _last_cpupid into struct folio

Patch series "mm: convert page cpupid functions to folios", v3.

The cpupid(or access time) used by numa balancing is stored in flags or
_last_cpupid(if LAST_CPUPID_NOT_IN_PAGE_FLAGS) of page, this is to convert
page cpupid to folio cpupid, a new _last_cpupid is added into folio, which
make us to use folio->_last_cpupid directly, and the page cpupid functions
are converted to folio ones.

  page_cpupid_last()		-> folio_last_cpupid()
  xchg_page_access_time()	-> folio_xchg_access_time()
  page_cpupid_xchg_last()	-> folio_xchg_last_cpupid()


This patch (of 19):

If WANT_PAGE_VIRTUAL and LAST_CPUPID_NOT_IN_PAGE_FLAGS defined, the
'virtual' and '_last_cpupid' are in struct page, and since _last_cpupid is
used by numa balancing feature, it is better to move it before KMSAN
metadata from struct page, also add them into struct folio to make us to
access them from folio directly.

Link: https://lkml.kernel.org/r/20231018140806.2783514-1-wangkefeng.wang@huawei.com
Link: https://lkml.kernel.org/r/20231018140806.2783514-2-wangkefeng.wang@huawei.comSigned-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Huang Ying <ying.huang@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent e5b306a0
...@@ -199,6 +199,10 @@ struct page { ...@@ -199,6 +199,10 @@ struct page {
not kmapped, ie. highmem) */ not kmapped, ie. highmem) */
#endif /* WANT_PAGE_VIRTUAL */ #endif /* WANT_PAGE_VIRTUAL */
#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
int _last_cpupid;
#endif
#ifdef CONFIG_KMSAN #ifdef CONFIG_KMSAN
/* /*
* KMSAN metadata for this page: * KMSAN metadata for this page:
...@@ -210,10 +214,6 @@ struct page { ...@@ -210,10 +214,6 @@ struct page {
struct page *kmsan_shadow; struct page *kmsan_shadow;
struct page *kmsan_origin; struct page *kmsan_origin;
#endif #endif
#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
int _last_cpupid;
#endif
} _struct_page_alignment; } _struct_page_alignment;
/* /*
...@@ -272,6 +272,8 @@ typedef struct { ...@@ -272,6 +272,8 @@ typedef struct {
* @_refcount: Do not access this member directly. Use folio_ref_count() * @_refcount: Do not access this member directly. Use folio_ref_count()
* to find how many references there are to this folio. * to find how many references there are to this folio.
* @memcg_data: Memory Control Group data. * @memcg_data: Memory Control Group data.
* @virtual: Virtual address in the kernel direct map.
* @_last_cpupid: IDs of last CPU and last process that accessed the folio.
* @_entire_mapcount: Do not use directly, call folio_entire_mapcount(). * @_entire_mapcount: Do not use directly, call folio_entire_mapcount().
* @_nr_pages_mapped: Do not use directly, call folio_mapcount(). * @_nr_pages_mapped: Do not use directly, call folio_mapcount().
* @_pincount: Do not use directly, call folio_maybe_dma_pinned(). * @_pincount: Do not use directly, call folio_maybe_dma_pinned().
...@@ -317,6 +319,12 @@ struct folio { ...@@ -317,6 +319,12 @@ struct folio {
atomic_t _refcount; atomic_t _refcount;
#ifdef CONFIG_MEMCG #ifdef CONFIG_MEMCG
unsigned long memcg_data; unsigned long memcg_data;
#endif
#if defined(WANT_PAGE_VIRTUAL)
void *virtual;
#endif
#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
int _last_cpupid;
#endif #endif
/* private: the union with struct page is transitional */ /* private: the union with struct page is transitional */
}; };
...@@ -373,6 +381,12 @@ FOLIO_MATCH(_refcount, _refcount); ...@@ -373,6 +381,12 @@ FOLIO_MATCH(_refcount, _refcount);
#ifdef CONFIG_MEMCG #ifdef CONFIG_MEMCG
FOLIO_MATCH(memcg_data, memcg_data); FOLIO_MATCH(memcg_data, memcg_data);
#endif #endif
#if defined(WANT_PAGE_VIRTUAL)
FOLIO_MATCH(virtual, virtual);
#endif
#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
FOLIO_MATCH(_last_cpupid, _last_cpupid);
#endif
#undef FOLIO_MATCH #undef FOLIO_MATCH
#define FOLIO_MATCH(pg, fl) \ #define FOLIO_MATCH(pg, fl) \
static_assert(offsetof(struct folio, fl) == \ static_assert(offsetof(struct folio, fl) == \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment