On 8/14/24 00:03, Mirsad Todorovac wrote: > Hi, all, > > Now, the "randconfig" seed KCONFIG_SEED=0x44AB31A6 revealed another bug: > > mm/vmstat.c:34:12: error: ‘vmstat_late_init_done’ defined but not used [-Werror=unused-variable] > 34 | static int vmstat_late_init_done; > | ^~~~~~~~~~~~~~~~~~~~~ > > Apparently, it is obviously wrong because it is used below: > > Fixes: ef534a0d51984 ("mm/vmstat: defer the refresh_zone_stat_thresholds after all CPUs bringu") > > #ifdef .. #endif forest might be better documented, but this small fix makes it running > again: > > -----------------------------------------------------><---------------------------------- > diff --git a/mm/vmstat.c b/mm/vmstat.c > index e361c2b3a8bc..85b3fc0084a8 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -31,7 +31,10 @@ > > #include "internal.h" > > +#ifdef CONFIG_SMP > static int vmstat_late_init_done; > +#endif /* CONFIG_SMP */ > + > #ifdef CONFIG_NUMA > int sysctl_vm_numa_stat = ENABLE_NUMA_STAT; > > -- > > It eliminates -Werror=unused-variable and compile passes at least: > > CC kernel/sys.o > CC mm/vmstat.o > AR init/built-in.a > > Hope thi s helps. > > Best regards, > Mirsad Todorovac Hi, all, After this unobvious error that appeared only under certain configs, I thought of a little housekeeping, according to the instructions here: https://www.kernel.org/doc/html/v4.15/process/coding-style.html#conditional-compilation A little homework might make the #ifdef ... #else ... #endif forest more readable: 1932:#ifdef CONFIG_SMP 1936:# ifdef CONFIG_PROC_FS 1999:# endif /* CONFIG_PROC_FS */ 2137: if (vmstat_late_init_done) 2173: vmstat_late_init_done = 1; 2178:#endif /* CONFIG_SMP */ 2188:#ifdef CONFIG_SMP 2205:#endif /* CONFIG_SMP */ or the entire mm/vmstat.c: 34:#ifdef CONFIG_SMP 35:static int vmstat_late_init_done; 36:#endif /* CONFIG_SMP */ 38:#ifdef CONFIG_NUMA 108:#endif /* CONFIG_NUMA */ 110:#ifdef CONFIG_VM_EVENT_COUNTERS 159:#endif /* CONFIG_VM_EVENT_COUNTERS */ 172:#ifdef CONFIG_NUMA 198:#endif /* CONFIG_NUMA */ 200:#ifdef CONFIG_SMP 548:# ifdef CONFIG_HAVE_CMPXCHG_LOCAL 692:# else 771:# endif /* CONFIG_HAVE_CMPXCHG_LOCAL */ 833:#ifdef CONFIG_NUMA 836:#endif /* CONFIG_NUMA */ 844:#ifdef CONFIG_NUMA 873:#endif /* CONFIG_NUMA */ 923:#ifdef CONFIG_NUMA 933:#endif /* CONFIG_NUMA */ 972:#ifdef CONFIG_NUMA 980:#endif /* CONFIG_NUMA */ 982:#endif /* CONFIG_SMP */ 984:#ifdef CONFIG_NUMA 1024:# ifdef CONFIG_SMP 1027:# endif /* CONFIG_SMP */ 1038:#endif /* CONFIG_NUMA */ 1058:#ifdef CONFIG_COMPACTION 1162:#endif /* CONFIG_COMPACTION */ 1164:#if defined(CONFIG_PROC_FS) || defined(CONFIG_SYSFS) || \ 1166:# ifdef CONFIG_ZONE_DMA 1167:# define TEXT_FOR_DMA(xx) xx "_dma", 1168:# else 1169:# define TEXT_FOR_DMA(xx) 1170:# endif 1172:# ifdef CONFIG_ZONE_DMA32 1173:# define TEXT_FOR_DMA32(xx) xx "_dma32", 1174:# else 1175:# define TEXT_FOR_DMA32(xx) 1176:# endif 1178:# ifdef CONFIG_HIGHMEM 1179:# define TEXT_FOR_HIGHMEM(xx) xx "_high", 1180:# else 1181:# define TEXT_FOR_HIGHMEM(xx) 1182:# endif 1184:# ifdef CONFIG_ZONE_DEVICE 1185:# define TEXT_FOR_DEVICE(xx) xx "_device", 1186:# else 1187:# define TEXT_FOR_DEVICE(xx) 1188:# endif 1190:# define TEXTS_FOR_ZONES(xx) TEXT_FOR_DMA(xx) TEXT_FOR_DMA32(xx) xx "_normal", \ 1205:# if IS_ENABLED(CONFIG_ZSMALLOC) 1207:# endif 1209:# ifdef CONFIG_UNACCEPTED_MEMORY 1211:# endif 1214:# ifdef CONFIG_NUMA 1221:# endif 1262:# if IS_ENABLED(CONFIG_SHADOW_CALL_STACK) 1264:# endif 1267:# ifdef CONFIG_IOMMU_SUPPORT 1269:# endif 1270:# ifdef CONFIG_SWAP 1272:# endif 1273:# ifdef CONFIG_NUMA_BALANCING 1276:# endif 1286:# if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG) 1320:# ifdef CONFIG_NUMA 1323:# endif 1337:# ifdef CONFIG_NUMA_BALANCING 1343:# endif 1344:# ifdef CONFIG_MIGRATION 1350:# endif 1351:# ifdef CONFIG_COMPACTION 1361:# endif 1363:# ifdef CONFIG_HUGETLB_PAGE 1366:# endif 1367:# ifdef CONFIG_CMA 1370:# endif 1379:# ifdef CONFIG_TRANSPARENT_HUGEPAGE 1396:# ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD 1398:# endif 1403:# endif /*CONFIG_TRANSPARENT_HUGEPAGE */ 1404:# ifdef CONFIG_MEMORY_BALLOON 1407:# ifdef CONFIG_BALLOON_COMPACTION 1409:# endif 1410:# endif /* CONFIG_MEMORY_BALLOON */ 1411:# ifdef CONFIG_DEBUG_TLBFLUSH 1416:# endif /* CONFIG_DEBUG_TLBFLUSH */ 1418:# ifdef CONFIG_SWAP 1421:# ifdef CONFIG_KSM 1423:# endif /* CONFIG_KSM */ 1424:# endif /* CONFIG_SWAP */ 1425:# ifdef CONFIG_KSM 1427:# endif 1428:# ifdef CONFIG_ZSWAP 1432:# endif 1433:# ifdef CONFIG_X86 1436:# endif 1437:# ifdef CONFIG_PER_VMA_LOCK_STATS 1442:# endif 1443:# ifdef CONFIG_DEBUG_STACK_USAGE 1445:# if THREAD_SIZE > 1024 1447:# endif 1448:# if THREAD_SIZE > 2048 1450:# endif 1451:# if THREAD_SIZE > 4096 1453:# endif 1454:# if THREAD_SIZE > 8192 1456:# endif 1457:# if THREAD_SIZE > 16384 1459:# endif 1460:# if THREAD_SIZE > 32768 1462:# endif 1463:# if THREAD_SIZE > 65536 1465:# endif 1466:# endif /* CONFIG_DEBUG_STACK_USAGE */ 1467:# endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */ 1469:#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */ 1471:#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION)) || \ 1521:#endif /* CONFIG_DEBUG_FS && CONFIG_COMPACTION || CONFIG_PROC_FS */ 1523:#ifdef CONFIG_PROC_FS 1660:# ifdef CONFIG_PAGE_OWNER 1675:# endif /* CONFIG_PAGE_OWNER */ 1783:# ifdef CONFIG_NUMA 1787:# endif 1804:# ifdef CONFIG_SMP 1808:# endif 1839:#define NR_VMSTAT_ITEMS (NR_VM_ZONE_STAT_ITEMS + \ 1864:# ifdef CONFIG_NUMA 1868:# endif 1883:# ifdef CONFIG_VM_EVENT_COUNTERS 1887:# endif 1930:#endif /* CONFIG_PROC_FS */ 1932:#ifdef CONFIG_SMP 1936:# ifdef CONFIG_PROC_FS 1999:# endif /* CONFIG_PROC_FS */ 2137: if (vmstat_late_init_done) 2173: vmstat_late_init_done = 1; 2178:#endif /* CONFIG_SMP */ 2188:#ifdef CONFIG_SMP 2205:#endif /* CONFIG_SMP */ 2206:#ifdef CONFIG_PROC_FS 2211:#endif /* CONFIG_PROC_FS */ 2214:#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_COMPACTION) 2347:#endif /* CONFIG_DEBUG_FS && CONFIG_COMPACTION */ Indentation is optional, but preprocessors traditionally allowed it since the early 1990s I think :-/ Please find attached patch with and without #ifdef indentation. (Both compile w GCC 13.2.0.) Thank you. Best regards, Mirsad Todorovac