diff mbox series

[v13,15/18] mm/memcg: Add folio_lruvec()

Message ID 20210712194551.91920-16-willy@infradead.org (mailing list archive)
State New
Headers show
Series Convert memcg to folios | expand

Commit Message

Matthew Wilcox July 12, 2021, 7:45 p.m. UTC
This replaces mem_cgroup_page_lruvec().  All callers converted.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/memcontrol.h | 20 +++++++++-----------
 mm/compaction.c            |  2 +-
 mm/memcontrol.c            |  9 ++++++---
 mm/swap.c                  |  3 ++-
 mm/workingset.c            |  3 ++-
 5 files changed, 20 insertions(+), 17 deletions(-)

Comments

kernel test robot July 12, 2021, 10:41 p.m. UTC | #1
Hi "Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.14-rc1 next-20210712]
[cannot apply to hnaz-linux-mm/master tip/perf/core linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/Convert-memcg-to-folios/20210713-035650
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git e73f0f0ee7541171d89f2e2491130c7771ba58d3
config: i386-randconfig-p002-20210712 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/01c63778e430697015122448ac6344d1dc2f10e4
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Matthew-Wilcox-Oracle/Convert-memcg-to-folios/20210713-035650
        git checkout 01c63778e430697015122448ac6344d1dc2f10e4
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

         |                  ^~~~~~~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:420:55: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                       ^~~~~
   include/linux/memcontrol.h: In function '__folio_objcg':
   include/linux/memcontrol.h:422:34: error: dereferencing pointer to incomplete type 'struct folio'
     422 |  unsigned long memcg_data = folio->memcg_data;
         |                                  ^~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:451:53: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                                     ^~~~~
   include/linux/memcontrol.h: In function 'folio_memcg':
   include/linux/memcontrol.h:453:23: error: passing argument 1 of 'folio_memcg_kmem' from incompatible pointer type [-Werror=incompatible-pointer-types]
     453 |  if (folio_memcg_kmem(folio))
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:375:51: note: expected 'struct folio *' but argument is of type 'struct folio *'
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:454:41: error: passing argument 1 of '__folio_objcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     454 |   return obj_cgroup_memcg(__folio_objcg(folio));
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:420:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:455:23: error: passing argument 1 of '__folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     455 |  return __folio_memcg(folio);
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:399:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     399 | static inline struct mem_cgroup *__folio_memcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: In function 'page_memcg':
   include/linux/memcontrol.h:460:21: error: implicit declaration of function 'page_folio' [-Werror=implicit-function-declaration]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~
   include/linux/memcontrol.h:460:21: warning: passing argument 1 of 'folio_memcg' makes pointer from integer without a cast [-Wint-conversion]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~~~~~~~
         |                     |
         |                     int
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'int'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:540:44: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                            ^~~~~
   include/linux/memcontrol.h:540:20: error: conflicting types for 'folio_memcg_kmem'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                    ^~~~~~~~~~~~~~~~
   include/linux/memcontrol.h:375:20: note: previous declaration of 'folio_memcg_kmem' was here
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   In file included from include/asm-generic/atomic-instrumented.h:20,
                    from include/linux/atomic.h:81,
                    from include/linux/crypto.h:15,
                    from arch/x86/kernel/asm-offsets.c:9:
   include/linux/memcontrol.h: In function 'folio_memcg_kmem':
   include/linux/memcontrol.h:542:35: error: dereferencing pointer to incomplete type 'struct folio'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |                                   ^~
   include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
      30 | #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
         |                                                               ^
   include/linux/memcontrol.h:542:2: note: in expansion of macro 'VM_BUG_ON_PGFLAGS'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |  ^~~~~~~~~~~~~~~~~
   In file included from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/x86/kernel/asm-offsets.c:13:
   include/linux/memcontrol.h: In function 'PageMemcgKmem':
   include/linux/memcontrol.h:606:26: warning: passing argument 1 of 'folio_memcg_kmem' makes pointer from integer without a cast [-Wint-conversion]
     606 |  return folio_memcg_kmem(page_folio(page));
         |                          ^~~~~~~~~~~~~~~~
         |                          |
         |                          int
   include/linux/memcontrol.h:540:51: note: expected 'struct folio *' but argument is of type 'int'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:707:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     707 | int mem_cgroup_charge(struct folio *, struct mm_struct *, gfp_t);
         |                              ^~~~~
   include/linux/memcontrol.h:712:33: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     712 | void mem_cgroup_uncharge(struct folio *folio);
         |                                 ^~~~~
   include/linux/memcontrol.h:715:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     715 | void mem_cgroup_migrate(struct folio *old, struct folio *new);
         |                                ^~~~~
   include/linux/memcontrol.h:759:50: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     759 | static inline struct lruvec *folio_lruvec(struct folio *folio)
         |                                                  ^~~~~
   include/linux/memcontrol.h: In function 'folio_lruvec':
>> include/linux/memcontrol.h:761:41: error: passing argument 1 of 'folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     761 |  struct mem_cgroup *memcg = folio_memcg(folio);
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'struct folio *'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
>> include/linux/memcontrol.h:763:2: error: implicit declaration of function 'VM_WARN_ON_ONCE_FOLIO'; did you mean 'VM_WARN_ON_ONCE_PAGE'? [-Werror=implicit-function-declaration]
     763 |  VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled(), folio);
         |  ^~~~~~~~~~~~~~~~~~~~~
         |  VM_WARN_ON_ONCE_PAGE
>> include/linux/memcontrol.h:764:34: error: implicit declaration of function 'folio_pgdat'; did you mean 'folio_nid'? [-Werror=implicit-function-declaration]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~
         |                                  folio_nid
   include/linux/memcontrol.h:764:34: warning: passing argument 2 of 'mem_cgroup_lruvec' makes pointer from integer without a cast [-Wint-conversion]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~~~~~~~~
         |                                  |
         |                                  int
   include/linux/memcontrol.h:727:33: note: expected 'struct pglist_data *' but argument is of type 'int'
     727 |             struct pglist_data *pgdat)
         |             ~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:952:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     952 | void folio_memcg_lock(struct folio *folio);
         |                              ^~~~~
   include/linux/memcontrol.h:953:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     953 | void folio_memcg_unlock(struct folio *folio);
         |                                ^~~~~
   include/linux/memcontrol.h:375:20: warning: 'folio_memcg_kmem' used but never defined
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
--
         |                  ^~~~~~~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:420:55: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                       ^~~~~
   include/linux/memcontrol.h: In function '__folio_objcg':
   include/linux/memcontrol.h:422:34: error: dereferencing pointer to incomplete type 'struct folio'
     422 |  unsigned long memcg_data = folio->memcg_data;
         |                                  ^~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:451:53: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                                     ^~~~~
   include/linux/memcontrol.h: In function 'folio_memcg':
   include/linux/memcontrol.h:453:23: error: passing argument 1 of 'folio_memcg_kmem' from incompatible pointer type [-Werror=incompatible-pointer-types]
     453 |  if (folio_memcg_kmem(folio))
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:375:51: note: expected 'struct folio *' but argument is of type 'struct folio *'
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:454:41: error: passing argument 1 of '__folio_objcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     454 |   return obj_cgroup_memcg(__folio_objcg(folio));
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:420:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:455:23: error: passing argument 1 of '__folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     455 |  return __folio_memcg(folio);
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:399:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     399 | static inline struct mem_cgroup *__folio_memcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: In function 'page_memcg':
   include/linux/memcontrol.h:460:21: error: implicit declaration of function 'page_folio' [-Werror=implicit-function-declaration]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~
   include/linux/memcontrol.h:460:21: warning: passing argument 1 of 'folio_memcg' makes pointer from integer without a cast [-Wint-conversion]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~~~~~~~
         |                     |
         |                     int
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'int'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:540:44: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                            ^~~~~
   include/linux/memcontrol.h:540:20: error: conflicting types for 'folio_memcg_kmem'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                    ^~~~~~~~~~~~~~~~
   include/linux/memcontrol.h:375:20: note: previous declaration of 'folio_memcg_kmem' was here
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   In file included from include/asm-generic/atomic-instrumented.h:20,
                    from include/linux/atomic.h:81,
                    from include/linux/crypto.h:15,
                    from arch/x86/kernel/asm-offsets.c:9:
   include/linux/memcontrol.h: In function 'folio_memcg_kmem':
   include/linux/memcontrol.h:542:35: error: dereferencing pointer to incomplete type 'struct folio'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |                                   ^~
   include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
      30 | #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
         |                                                               ^
   include/linux/memcontrol.h:542:2: note: in expansion of macro 'VM_BUG_ON_PGFLAGS'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |  ^~~~~~~~~~~~~~~~~
   In file included from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/x86/kernel/asm-offsets.c:13:
   include/linux/memcontrol.h: In function 'PageMemcgKmem':
   include/linux/memcontrol.h:606:26: warning: passing argument 1 of 'folio_memcg_kmem' makes pointer from integer without a cast [-Wint-conversion]
     606 |  return folio_memcg_kmem(page_folio(page));
         |                          ^~~~~~~~~~~~~~~~
         |                          |
         |                          int
   include/linux/memcontrol.h:540:51: note: expected 'struct folio *' but argument is of type 'int'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:707:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     707 | int mem_cgroup_charge(struct folio *, struct mm_struct *, gfp_t);
         |                              ^~~~~
   include/linux/memcontrol.h:712:33: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     712 | void mem_cgroup_uncharge(struct folio *folio);
         |                                 ^~~~~
   include/linux/memcontrol.h:715:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     715 | void mem_cgroup_migrate(struct folio *old, struct folio *new);
         |                                ^~~~~
   include/linux/memcontrol.h:759:50: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     759 | static inline struct lruvec *folio_lruvec(struct folio *folio)
         |                                                  ^~~~~
   include/linux/memcontrol.h: In function 'folio_lruvec':
>> include/linux/memcontrol.h:761:41: error: passing argument 1 of 'folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     761 |  struct mem_cgroup *memcg = folio_memcg(folio);
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'struct folio *'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
>> include/linux/memcontrol.h:763:2: error: implicit declaration of function 'VM_WARN_ON_ONCE_FOLIO'; did you mean 'VM_WARN_ON_ONCE_PAGE'? [-Werror=implicit-function-declaration]
     763 |  VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled(), folio);
         |  ^~~~~~~~~~~~~~~~~~~~~
         |  VM_WARN_ON_ONCE_PAGE
>> include/linux/memcontrol.h:764:34: error: implicit declaration of function 'folio_pgdat'; did you mean 'folio_nid'? [-Werror=implicit-function-declaration]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~
         |                                  folio_nid
   include/linux/memcontrol.h:764:34: warning: passing argument 2 of 'mem_cgroup_lruvec' makes pointer from integer without a cast [-Wint-conversion]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~~~~~~~~
         |                                  |
         |                                  int
   include/linux/memcontrol.h:727:33: note: expected 'struct pglist_data *' but argument is of type 'int'
     727 |             struct pglist_data *pgdat)
         |             ~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:952:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     952 | void folio_memcg_lock(struct folio *folio);
         |                              ^~~~~
   include/linux/memcontrol.h:953:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     953 | void folio_memcg_unlock(struct folio *folio);
         |                                ^~~~~
   include/linux/memcontrol.h:375:20: warning: 'folio_memcg_kmem' used but never defined
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1212: prepare0] Error 2
   make[1]: Target 'modules_prepare' not remade because of errors.
   make: *** [Makefile:220: __sub-make] Error 2
   make: Target 'modules_prepare' not remade because of errors.
--
         |                  ^~~~~~~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:420:55: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                       ^~~~~
   include/linux/memcontrol.h: In function '__folio_objcg':
   include/linux/memcontrol.h:422:34: error: dereferencing pointer to incomplete type 'struct folio'
     422 |  unsigned long memcg_data = folio->memcg_data;
         |                                  ^~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:451:53: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                                     ^~~~~
   include/linux/memcontrol.h: In function 'folio_memcg':
   include/linux/memcontrol.h:453:23: error: passing argument 1 of 'folio_memcg_kmem' from incompatible pointer type [-Werror=incompatible-pointer-types]
     453 |  if (folio_memcg_kmem(folio))
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:375:51: note: expected 'struct folio *' but argument is of type 'struct folio *'
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:454:41: error: passing argument 1 of '__folio_objcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     454 |   return obj_cgroup_memcg(__folio_objcg(folio));
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:420:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     420 | static inline struct obj_cgroup *__folio_objcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h:455:23: error: passing argument 1 of '__folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     455 |  return __folio_memcg(folio);
         |                       ^~~~~
         |                       |
         |                       struct folio *
   include/linux/memcontrol.h:399:62: note: expected 'struct folio *' but argument is of type 'struct folio *'
     399 | static inline struct mem_cgroup *__folio_memcg(struct folio *folio)
         |                                                ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: In function 'page_memcg':
   include/linux/memcontrol.h:460:21: error: implicit declaration of function 'page_folio' [-Werror=implicit-function-declaration]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~
   include/linux/memcontrol.h:460:21: warning: passing argument 1 of 'folio_memcg' makes pointer from integer without a cast [-Wint-conversion]
     460 |  return folio_memcg(page_folio(page));
         |                     ^~~~~~~~~~~~~~~~
         |                     |
         |                     int
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'int'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:540:44: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                            ^~~~~
   include/linux/memcontrol.h:540:20: error: conflicting types for 'folio_memcg_kmem'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                    ^~~~~~~~~~~~~~~~
   include/linux/memcontrol.h:375:20: note: previous declaration of 'folio_memcg_kmem' was here
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   In file included from include/asm-generic/atomic-instrumented.h:20,
                    from include/linux/atomic.h:81,
                    from include/linux/crypto.h:15,
                    from arch/x86/kernel/asm-offsets.c:9:
   include/linux/memcontrol.h: In function 'folio_memcg_kmem':
   include/linux/memcontrol.h:542:35: error: dereferencing pointer to incomplete type 'struct folio'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |                                   ^~
   include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
      30 | #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
         |                                                               ^
   include/linux/memcontrol.h:542:2: note: in expansion of macro 'VM_BUG_ON_PGFLAGS'
     542 |  VM_BUG_ON_PGFLAGS(PageTail(&folio->page), &folio->page);
         |  ^~~~~~~~~~~~~~~~~
   In file included from include/linux/swap.h:9,
                    from include/linux/suspend.h:5,
                    from arch/x86/kernel/asm-offsets.c:13:
   include/linux/memcontrol.h: In function 'PageMemcgKmem':
   include/linux/memcontrol.h:606:26: warning: passing argument 1 of 'folio_memcg_kmem' makes pointer from integer without a cast [-Wint-conversion]
     606 |  return folio_memcg_kmem(page_folio(page));
         |                          ^~~~~~~~~~~~~~~~
         |                          |
         |                          int
   include/linux/memcontrol.h:540:51: note: expected 'struct folio *' but argument is of type 'int'
     540 | static inline bool folio_memcg_kmem(struct folio *folio)
         |                                     ~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:707:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     707 | int mem_cgroup_charge(struct folio *, struct mm_struct *, gfp_t);
         |                              ^~~~~
   include/linux/memcontrol.h:712:33: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     712 | void mem_cgroup_uncharge(struct folio *folio);
         |                                 ^~~~~
   include/linux/memcontrol.h:715:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     715 | void mem_cgroup_migrate(struct folio *old, struct folio *new);
         |                                ^~~~~
   include/linux/memcontrol.h:759:50: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     759 | static inline struct lruvec *folio_lruvec(struct folio *folio)
         |                                                  ^~~~~
   include/linux/memcontrol.h: In function 'folio_lruvec':
>> include/linux/memcontrol.h:761:41: error: passing argument 1 of 'folio_memcg' from incompatible pointer type [-Werror=incompatible-pointer-types]
     761 |  struct mem_cgroup *memcg = folio_memcg(folio);
         |                                         ^~~~~
         |                                         |
         |                                         struct folio *
   include/linux/memcontrol.h:451:60: note: expected 'struct folio *' but argument is of type 'struct folio *'
     451 | static inline struct mem_cgroup *folio_memcg(struct folio *folio)
         |                                              ~~~~~~~~~~~~~~^~~~~
>> include/linux/memcontrol.h:763:2: error: implicit declaration of function 'VM_WARN_ON_ONCE_FOLIO'; did you mean 'VM_WARN_ON_ONCE_PAGE'? [-Werror=implicit-function-declaration]
     763 |  VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled(), folio);
         |  ^~~~~~~~~~~~~~~~~~~~~
         |  VM_WARN_ON_ONCE_PAGE
>> include/linux/memcontrol.h:764:34: error: implicit declaration of function 'folio_pgdat'; did you mean 'folio_nid'? [-Werror=implicit-function-declaration]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~
         |                                  folio_nid
   include/linux/memcontrol.h:764:34: warning: passing argument 2 of 'mem_cgroup_lruvec' makes pointer from integer without a cast [-Wint-conversion]
     764 |  return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
         |                                  ^~~~~~~~~~~~~~~~~~
         |                                  |
         |                                  int
   include/linux/memcontrol.h:727:33: note: expected 'struct pglist_data *' but argument is of type 'int'
     727 |             struct pglist_data *pgdat)
         |             ~~~~~~~~~~~~~~~~~~~~^~~~~
   include/linux/memcontrol.h: At top level:
   include/linux/memcontrol.h:952:30: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     952 | void folio_memcg_lock(struct folio *folio);
         |                              ^~~~~
   include/linux/memcontrol.h:953:32: warning: 'struct folio' declared inside parameter list will not be visible outside of this definition or declaration
     953 | void folio_memcg_unlock(struct folio *folio);
         |                                ^~~~~
   include/linux/memcontrol.h:375:20: warning: 'folio_memcg_kmem' used but never defined
     375 | static inline bool folio_memcg_kmem(struct folio *folio);
         |                    ^~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors
   make[2]: *** [scripts/Makefile.build:117: arch/x86/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [Makefile:1212: prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [Makefile:220: __sub-make] Error 2
   make: Target 'prepare' not remade because of errors.


vim +/folio_memcg +761 include/linux/memcontrol.h

   752	
   753	/**
   754	 * folio_lruvec - return lruvec for isolating/putting an LRU folio
   755	 * @folio: Pointer to the folio.
   756	 *
   757	 * This function relies on folio->mem_cgroup being stable.
   758	 */
   759	static inline struct lruvec *folio_lruvec(struct folio *folio)
   760	{
 > 761		struct mem_cgroup *memcg = folio_memcg(folio);
   762	
 > 763		VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled(), folio);
 > 764		return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
   765	}
   766	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Christoph Hellwig July 13, 2021, 1:02 p.m. UTC | #2
On Mon, Jul 12, 2021 at 08:45:48PM +0100, Matthew Wilcox (Oracle) wrote:
> This replaces mem_cgroup_page_lruvec().  All callers converted.

Looks good, especially as it doesn't have much to do with
cgroups except as an implementation detail.  Shouldn't this
function also move out of memcontrol.h eventually?

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index be8664e027d5..d4af898a1294 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -751,18 +751,17 @@  static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 }
 
 /**
- * mem_cgroup_page_lruvec - return lruvec for isolating/putting an LRU page
- * @page: the page
+ * folio_lruvec - return lruvec for isolating/putting an LRU folio
+ * @folio: Pointer to the folio.
  *
- * This function relies on page->mem_cgroup being stable.
+ * This function relies on folio->mem_cgroup being stable.
  */
-static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page)
+static inline struct lruvec *folio_lruvec(struct folio *folio)
 {
-	pg_data_t *pgdat = page_pgdat(page);
-	struct mem_cgroup *memcg = page_memcg(page);
+	struct mem_cgroup *memcg = folio_memcg(folio);
 
-	VM_WARN_ON_ONCE_PAGE(!memcg && !mem_cgroup_disabled(), page);
-	return mem_cgroup_lruvec(memcg, pgdat);
+	VM_WARN_ON_ONCE_FOLIO(!memcg && !mem_cgroup_disabled(), folio);
+	return mem_cgroup_lruvec(memcg, folio_pgdat(folio));
 }
 
 struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
@@ -1226,10 +1225,9 @@  static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 	return &pgdat->__lruvec;
 }
 
-static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page)
+static inline struct lruvec *folio_lruvec(struct folio *folio)
 {
-	pg_data_t *pgdat = page_pgdat(page);
-
+	struct pglist_data *pgdat = folio_pgdat(folio);
 	return &pgdat->__lruvec;
 }
 
diff --git a/mm/compaction.c b/mm/compaction.c
index 621508e0ecd5..a88f7b893f80 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1028,7 +1028,7 @@  isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 		if (!TestClearPageLRU(page))
 			goto isolate_fail_put;
 
-		lruvec = mem_cgroup_page_lruvec(page);
+		lruvec = folio_lruvec(page_folio(page));
 
 		/* If we already hold the lock, we can skip some rechecking */
 		if (lruvec != locked) {
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 63cebdd48c27..3152a0e1ba6f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1186,9 +1186,10 @@  void lruvec_memcg_debug(struct lruvec *lruvec, struct page *page)
  */
 struct lruvec *lock_page_lruvec(struct page *page)
 {
+	struct folio *folio = page_folio(page);
 	struct lruvec *lruvec;
 
-	lruvec = mem_cgroup_page_lruvec(page);
+	lruvec = folio_lruvec(folio);
 	spin_lock(&lruvec->lru_lock);
 
 	lruvec_memcg_debug(lruvec, page);
@@ -1198,9 +1199,10 @@  struct lruvec *lock_page_lruvec(struct page *page)
 
 struct lruvec *lock_page_lruvec_irq(struct page *page)
 {
+	struct folio *folio = page_folio(page);
 	struct lruvec *lruvec;
 
-	lruvec = mem_cgroup_page_lruvec(page);
+	lruvec = folio_lruvec(folio);
 	spin_lock_irq(&lruvec->lru_lock);
 
 	lruvec_memcg_debug(lruvec, page);
@@ -1210,9 +1212,10 @@  struct lruvec *lock_page_lruvec_irq(struct page *page)
 
 struct lruvec *lock_page_lruvec_irqsave(struct page *page, unsigned long *flags)
 {
+	struct folio *folio = page_folio(page);
 	struct lruvec *lruvec;
 
-	lruvec = mem_cgroup_page_lruvec(page);
+	lruvec = folio_lruvec(folio);
 	spin_lock_irqsave(&lruvec->lru_lock, *flags);
 
 	lruvec_memcg_debug(lruvec, page);
diff --git a/mm/swap.c b/mm/swap.c
index b28c76a2e955..d5136cac4267 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -315,7 +315,8 @@  void lru_note_cost(struct lruvec *lruvec, bool file, unsigned int nr_pages)
 
 void lru_note_cost_page(struct page *page)
 {
-	lru_note_cost(mem_cgroup_page_lruvec(page),
+	struct folio *folio = page_folio(page);
+	lru_note_cost(folio_lruvec(folio),
 		      page_is_file_lru(page), thp_nr_pages(page));
 }
 
diff --git a/mm/workingset.c b/mm/workingset.c
index 5ba3e42446fa..e62c0f2084a2 100644
--- a/mm/workingset.c
+++ b/mm/workingset.c
@@ -396,6 +396,7 @@  void workingset_refault(struct page *page, void *shadow)
  */
 void workingset_activation(struct page *page)
 {
+	struct folio *folio = page_folio(page);
 	struct mem_cgroup *memcg;
 	struct lruvec *lruvec;
 
@@ -410,7 +411,7 @@  void workingset_activation(struct page *page)
 	memcg = page_memcg_rcu(page);
 	if (!mem_cgroup_disabled() && !memcg)
 		goto out;
-	lruvec = mem_cgroup_page_lruvec(page);
+	lruvec = folio_lruvec(folio);
 	workingset_age_nonresident(lruvec, thp_nr_pages(page));
 out:
 	rcu_read_unlock();