linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmscan: define macros for refaults in struct lruvec
@ 2022-08-02  7:10 cgel.zte
  2022-08-07 10:02 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2022-08-02  7:10 UTC (permalink / raw)
  To: akpm, hannes; +Cc: linux-mm, linux-kernel, Yang Yang, CGEL ZTE

From: Yang Yang <yang.yang29@zte.com.cn>

The magic number 0 and 1 are used in several places in vmscan.c.
Define macros for them to improve code readability.

Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Signed-off-by: CGEL ZTE <cgel.zte@gmail.com>
---
 include/linux/mmzone.h | 2 ++
 mm/vmscan.c            | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e24b40c52468..795076c33163 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -306,6 +306,8 @@ static inline bool is_active_lru(enum lru_list lru)
 	return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
 }
 
+#define ANON 0
+#define FILE 1
 #define ANON_AND_FILE 2
 
 enum lruvec_flags {
diff --git a/mm/vmscan.c b/mm/vmscan.c
index b2b1431352dc..f6a54c25ac7d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3230,7 +3230,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 
 		refaults = lruvec_page_state(target_lruvec,
 				WORKINGSET_ACTIVATE_ANON);
-		if (refaults != target_lruvec->refaults[0] ||
+		if (refaults != target_lruvec->refaults[ANON] ||
 			inactive_is_low(target_lruvec, LRU_INACTIVE_ANON))
 			sc->may_deactivate |= DEACTIVATE_ANON;
 		else
@@ -3243,7 +3243,7 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
 		 */
 		refaults = lruvec_page_state(target_lruvec,
 				WORKINGSET_ACTIVATE_FILE);
-		if (refaults != target_lruvec->refaults[1] ||
+		if (refaults != target_lruvec->refaults[FILE] ||
 		    inactive_is_low(target_lruvec, LRU_INACTIVE_FILE))
 			sc->may_deactivate |= DEACTIVATE_FILE;
 		else
@@ -3559,9 +3559,9 @@ static void snapshot_refaults(struct mem_cgroup *target_memcg, pg_data_t *pgdat)
 
 	target_lruvec = mem_cgroup_lruvec(target_memcg, pgdat);
 	refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_ANON);
-	target_lruvec->refaults[0] = refaults;
+	target_lruvec->refaults[ANON] = refaults;
 	refaults = lruvec_page_state(target_lruvec, WORKINGSET_ACTIVATE_FILE);
-	target_lruvec->refaults[1] = refaults;
+	target_lruvec->refaults[FILE] = refaults;
 }
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/vmscan: define macros for refaults in struct lruvec
  2022-08-02  7:10 [PATCH] mm/vmscan: define macros for refaults in struct lruvec cgel.zte
@ 2022-08-07 10:02 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2022-08-07 10:02 UTC (permalink / raw)
  To: cgel.zte, akpm, hannes
  Cc: kbuild-all, linux-mm, linux-kernel, Yang Yang, CGEL ZTE

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/cgel-zte-gmail-com/mm-vmscan-define-macros-for-refaults-in-struct-lruvec/20220802-151054
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220807/202208071759.nIRUnjYn-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/cb852a4d1456d03ec22ce56b90e321d14c853bb7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review cgel-zte-gmail-com/mm-vmscan-define-macros-for-refaults-in-struct-lruvec/20220802-151054
        git checkout cb852a4d1456d03ec22ce56b90e321d14c853bb7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

   In file included from include/linux/build_bug.h:5,
                    from include/linux/container_of.h:5,
                    from include/linux/list.h:5,
                    from include/linux/swait.h:5,
                    from include/linux/completion.h:12,
                    from fs/nfs/delegation.c:10:
   fs/nfs/delegation.c: In function 'nfs_inode_set_delegation':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/delegation.c:476:17: note: in expansion of macro 'dfprintk'
     476 |                 dfprintk(FILE, "%s: server %s handed out "
         |                 ^~~~~~~~
   include/linux/nfs_fs.h:623:58: note: each undeclared identifier is reported only once for each function it appears in
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/delegation.c:476:17: note: in expansion of macro 'dfprintk'
     476 |                 dfprintk(FILE, "%s: server %s handed out "
         |                 ^~~~~~~~
--
   In file included from include/linux/export.h:33,
                    from include/linux/linkage.h:7,
                    from arch/x86/include/asm/cache.h:5,
                    from include/linux/cache.h:6,
                    from include/linux/time.h:5,
                    from include/linux/compat.h:10,
                    from fs/nfs/dir.c:21:
   fs/nfs/dir.c: In function 'nfs_opendir':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/dir.c:116:9: note: in expansion of macro 'dfprintk'
     116 |         dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
         |         ^~~~~~~~
   include/linux/nfs_fs.h:623:58: note: each undeclared identifier is reported only once for each function it appears in
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/dir.c:116:9: note: in expansion of macro 'dfprintk'
     116 |         dfprintk(FILE, "NFS: open dir(%pD2)\n", filp);
         |         ^~~~~~~~
   fs/nfs/dir.c: In function 'nfs_readdir':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/dir.c:1220:9: note: in expansion of macro 'dfprintk'
    1220 |         dfprintk(FILE, "NFS: readdir(%pD2) starting at cookie %llu\n",
         |         ^~~~~~~~
   fs/nfs/dir.c: In function 'nfs_llseek_dir':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/dir.c:1316:9: note: in expansion of macro 'dfprintk'
    1316 |         dfprintk(FILE, "NFS: llseek dir(%pD2, %lld, %d)\n",
         |         ^~~~~~~~
   fs/nfs/dir.c: In function 'nfs_fsync_dir':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/dir.c:1360:9: note: in expansion of macro 'dfprintk'
    1360 |         dfprintk(FILE, "NFS: fsync dir(%pD2) datasync %d\n", filp, datasync);
         |         ^~~~~~~~
--
   In file included from arch/x86/include/asm/current.h:5,
                    from include/linux/sched.h:12,
                    from fs/nfs/direct.c:43:
   fs/nfs/direct.c: In function 'nfs_file_direct_read':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/direct.c:453:9: note: in expansion of macro 'dfprintk'
     453 |         dfprintk(FILE, "NFS: direct read(%pD2, %zd@%Ld)\n",
         |         ^~~~~~~~
   include/linux/nfs_fs.h:623:58: note: each undeclared identifier is reported only once for each function it appears in
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/direct.c:453:9: note: in expansion of macro 'dfprintk'
     453 |         dfprintk(FILE, "NFS: direct read(%pD2, %zd@%Ld)\n",
         |         ^~~~~~~~
   fs/nfs/direct.c: In function 'nfs_file_direct_write':
>> include/linux/nfs_fs.h:623:58: error: 'NFSDBG_1' undeclared (first use in this function); did you mean 'NFSDBG_ALL'?
     623 | #  define ifdebug(fac)          if (unlikely(nfs_debug & NFSDBG_##fac))
         |                                                          ^~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/sunrpc/debug.h:39:9: note: in expansion of macro 'ifdebug'
      39 |         ifdebug(fac)                                                    \
         |         ^~~~~~~
   fs/nfs/direct.c:909:9: note: in expansion of macro 'dfprintk'
     909 |         dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
         |         ^~~~~~~~


vim +623 include/linux/nfs_fs.h

^1da177e4c3f41 Linus Torvalds 2005-04-16  619  
4dc2eaecd4cf06 Benny Halevy   2006-12-20  620  
^1da177e4c3f41 Linus Torvalds 2005-04-16  621  # undef ifdebug
^1da177e4c3f41 Linus Torvalds 2005-04-16  622  # ifdef NFS_DEBUG
^1da177e4c3f41 Linus Torvalds 2005-04-16 @623  #  define ifdebug(fac)		if (unlikely(nfs_debug & NFSDBG_##fac))

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-07 10:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02  7:10 [PATCH] mm/vmscan: define macros for refaults in struct lruvec cgel.zte
2022-08-07 10:02 ` kernel test robot

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).