Message ID | 20240607001116.1061485-1-stephen.s.brennan@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v3] mm: convert page type macros to enum | expand |
On 6/7/24 2:11 AM, Stephen Brennan wrote: > Changing PG_slab from a page flag to a page type in commit 46df8e73a4a3 > ("mm: free up PG_slab") in has the unintended consequence of removing > the PG_slab constant from kernel debuginfo. The commit does add the > value to the vmcoreinfo note, which allows debuggers to find the value > without hardcoding it. However it's most flexible to continue > representing the constant with an enum. To that end, convert the page > type fields into an enum. Debuggers will now be able to detect that > PG_slab's type has changed from enum pageflags to enum page_type. > > Fixes: 46df8e73a4a3 ("mm: free up PG_slab") > > Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> > --- > v2 -> v3: rebase on mm-unstable > v1 -> v2: include PAGE_TYPE_BASE and PAGE_MAPCOUNT_RESERVE > > include/linux/page-flags.h | 31 +++++++++++++++++-------------- > 1 file changed, 17 insertions(+), 14 deletions(-) > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index f04fea86324d9..7c0a8fd2c8c17 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -945,20 +945,23 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) > * mistaken for a page type value. > */ > > -#define PAGE_TYPE_BASE 0x80000000 > -/* > - * Reserve 0xffff0000 - 0xfffffffe to catch _mapcount underflows and > - * allow owners that set a type to reuse the lower 16 bit for their own > - * purposes. > - */ > -#define PG_buddy 0x40000000 > -#define PG_offline 0x20000000 > -#define PG_table 0x10000000 > -#define PG_guard 0x08000000 > -#define PG_hugetlb 0x04000000 > -#define PG_slab 0x02000000 > -#define PG_zsmalloc 0x01000000 > -#define PAGE_MAPCOUNT_RESERVE (~0x0000ffff) > +enum page_type { > + /* > + * Reserve 0xffff0000 - 0xfffffffe to catch _mapcount underflows and > + * allow owners that set a type to reuse the lower 16 bit for their own > + * purposes. > + */ > + PG_buddy = 0x40000000, > + PG_offline = 0x20000000, > + PG_table = 0x10000000, > + PG_guard = 0x08000000, > + PG_hugetlb = 0x04000000, > + PG_slab = 0x02000000, > + PG_zsmalloc = 0x01000000, > + > + PAGE_TYPE_BASE = 0x80000000, > + PAGE_MAPCOUNT_RESERVE = ~0x0000ffff, > +}; > > #define PageType(page, flag) \ > ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
Hi Stephen,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
url: https://github.com/intel-lab-lkp/linux/commits/Stephen-Brennan/mm-convert-page-type-macros-to-enum/20240607-081253
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240607001116.1061485-1-stephen.s.brennan%40oracle.com
patch subject: [PATCH v3] mm: convert page type macros to enum
config: i386-randconfig-001-20240607 (https://download.01.org/0day-ci/archive/20240607/202406072138.EUCgPNSP-lkp@intel.com/config)
compiler: gcc-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240607/202406072138.EUCgPNSP-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406072138.EUCgPNSP-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from fs/f2fs/recovery.c:12:
>> fs/f2fs/f2fs.h:1118:6: error: nested redefinition of 'enum page_type'
enum page_type {
^~~~~~~~~
fs/f2fs/f2fs.h:1118:6: error: redeclaration of 'enum page_type'
In file included from include/linux/mmzone.h:23,
from include/linux/gfp.h:7,
from include/linux/xarray.h:16,
from include/linux/list_lru.h:14,
from include/linux/fs.h:13,
from fs/f2fs/recovery.c:9:
include/linux/page-flags.h:948:6: note: originally defined here
enum page_type {
^~~~~~~~~
vim +1118 fs/f2fs/f2fs.h
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1104
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1105 /*
e1c42045203071 arter97 2014-08-06 1106 * The below are the page types of bios used in submit_bio().
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1107 * The available types are:
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1108 * DATA User data pages. It operates as async mode.
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1109 * NODE Node pages. It operates as async mode.
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1110 * META FS metadata pages such as SIT, NAT, CP.
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1111 * NR_PAGE_TYPE The number of page types.
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1112 * META_FLUSH Make sure the previous pages are written
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1113 * with waiting the bio's completion
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1114 * ... Only can be used with META.
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1115 */
7d5e510944ce60 Jaegeuk Kim 2013-11-18 1116 #define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type))
87161a2b0aed9e Jaegeuk Kim 2024-02-06 1117 #define PAGE_TYPE_ON_MAIN(type) ((type) == DATA || (type) == NODE)
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 @1118 enum page_type {
6b8beca0edd320 Chao Yu 2022-05-06 1119 DATA = 0,
6b8beca0edd320 Chao Yu 2022-05-06 1120 NODE = 1, /* should not change this */
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1121 META,
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1122 NR_PAGE_TYPE,
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1123 META_FLUSH,
3db1de0e582c35 Daeho Jeong 2022-04-28 1124 IPU, /* the below types are used by tracepoints only. */
8ce67cb07dbf6b Jaegeuk Kim 2015-03-17 1125 OPU,
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1126 };
39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1127
Hi Stephen, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] url: https://github.com/intel-lab-lkp/linux/commits/Stephen-Brennan/mm-convert-page-type-macros-to-enum/20240607-081253 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20240607001116.1061485-1-stephen.s.brennan%40oracle.com patch subject: [PATCH v3] mm: convert page type macros to enum config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20240607/202406072244.8rZnMpsR-lkp@intel.com/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240607/202406072244.8rZnMpsR-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202406072244.8rZnMpsR-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from fs/f2fs/dir.c:13: >> fs/f2fs/f2fs.h:1118:6: error: redefinition of 'page_type' 1118 | enum page_type { | ^ include/linux/page-flags.h:948:6: note: previous definition is here 948 | enum page_type { | ^ 1 error generated. -- In file included from fs/f2fs/data.c:25: >> fs/f2fs/f2fs.h:1118:6: error: redefinition of 'page_type' 1118 | enum page_type { | ^ include/linux/page-flags.h:948:6: note: previous definition is here 948 | enum page_type { | ^ fs/f2fs/data.c:2373:10: warning: variable 'index' set but not used [-Wunused-but-set-variable] 2373 | pgoff_t index; | ^ 1 warning and 1 error generated. -- In file included from fs/f2fs/segment.c:21: >> fs/f2fs/f2fs.h:1118:6: error: redefinition of 'page_type' 1118 | enum page_type { | ^ include/linux/page-flags.h:948:6: note: previous definition is here 948 | enum page_type { | ^ >> fs/f2fs/segment.c:3403:7: warning: case value not in enumerated type 'enum page_type' [-Wswitch] 3403 | case DATA: | ^ fs/f2fs/segment.c:3414:7: warning: case value not in enumerated type 'enum page_type' [-Wswitch] 3414 | case NODE: | ^ fs/f2fs/segment.c:3425:7: warning: case value not in enumerated type 'enum page_type' [-Wswitch] 3425 | case META: | ^ 3 warnings and 1 error generated. vim +/page_type +1118 fs/f2fs/f2fs.h 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1104 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1105 /* e1c42045203071 arter97 2014-08-06 1106 * The below are the page types of bios used in submit_bio(). 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1107 * The available types are: 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1108 * DATA User data pages. It operates as async mode. 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1109 * NODE Node pages. It operates as async mode. 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1110 * META FS metadata pages such as SIT, NAT, CP. 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1111 * NR_PAGE_TYPE The number of page types. 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1112 * META_FLUSH Make sure the previous pages are written 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1113 * with waiting the bio's completion 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1114 * ... Only can be used with META. 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1115 */ 7d5e510944ce60 Jaegeuk Kim 2013-11-18 1116 #define PAGE_TYPE_OF_BIO(type) ((type) > META ? META : (type)) 87161a2b0aed9e Jaegeuk Kim 2024-02-06 1117 #define PAGE_TYPE_ON_MAIN(type) ((type) == DATA || (type) == NODE) 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 @1118 enum page_type { 6b8beca0edd320 Chao Yu 2022-05-06 1119 DATA = 0, 6b8beca0edd320 Chao Yu 2022-05-06 1120 NODE = 1, /* should not change this */ 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1121 META, 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1122 NR_PAGE_TYPE, 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1123 META_FLUSH, 3db1de0e582c35 Daeho Jeong 2022-04-28 1124 IPU, /* the below types are used by tracepoints only. */ 8ce67cb07dbf6b Jaegeuk Kim 2015-03-17 1125 OPU, 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1126 }; 39a53e0ce0df01 Jaegeuk Kim 2012-11-28 1127
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index f04fea86324d9..7c0a8fd2c8c17 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -945,20 +945,23 @@ PAGEFLAG_FALSE(HasHWPoisoned, has_hwpoisoned) * mistaken for a page type value. */ -#define PAGE_TYPE_BASE 0x80000000 -/* - * Reserve 0xffff0000 - 0xfffffffe to catch _mapcount underflows and - * allow owners that set a type to reuse the lower 16 bit for their own - * purposes. - */ -#define PG_buddy 0x40000000 -#define PG_offline 0x20000000 -#define PG_table 0x10000000 -#define PG_guard 0x08000000 -#define PG_hugetlb 0x04000000 -#define PG_slab 0x02000000 -#define PG_zsmalloc 0x01000000 -#define PAGE_MAPCOUNT_RESERVE (~0x0000ffff) +enum page_type { + /* + * Reserve 0xffff0000 - 0xfffffffe to catch _mapcount underflows and + * allow owners that set a type to reuse the lower 16 bit for their own + * purposes. + */ + PG_buddy = 0x40000000, + PG_offline = 0x20000000, + PG_table = 0x10000000, + PG_guard = 0x08000000, + PG_hugetlb = 0x04000000, + PG_slab = 0x02000000, + PG_zsmalloc = 0x01000000, + + PAGE_TYPE_BASE = 0x80000000, + PAGE_MAPCOUNT_RESERVE = ~0x0000ffff, +}; #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
Changing PG_slab from a page flag to a page type in commit 46df8e73a4a3 ("mm: free up PG_slab") in has the unintended consequence of removing the PG_slab constant from kernel debuginfo. The commit does add the value to the vmcoreinfo note, which allows debuggers to find the value without hardcoding it. However it's most flexible to continue representing the constant with an enum. To that end, convert the page type fields into an enum. Debuggers will now be able to detect that PG_slab's type has changed from enum pageflags to enum page_type. Fixes: 46df8e73a4a3 ("mm: free up PG_slab") Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com> --- v2 -> v3: rebase on mm-unstable v1 -> v2: include PAGE_TYPE_BASE and PAGE_MAPCOUNT_RESERVE include/linux/page-flags.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)