Skip to contentSkip to conversation

mm: common PAGE_SIZE shift macros

RFC PATCH In review Oleksandr Natalenko 4 participants 8 messages Sep 19, 2021

Subsystems (37)
DRM drivers Memory management x86 VFS +33 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 cover mm: common PAGE_SIZE shift macros

There are various places where the K(x) macro (or its alternative and/or counterpart) is defined. This submission gets rid of multiple definitions and provides common ones.

Based on discussion with Miaohe Lin [1].

The patch is based on top of next-20210910 and is compile-tested using allyesconfig.

RFC v1: [2].

Changes since RFC v1:

* change name from K(x) to PG2KB(x)
* also provide KB2PG(x)
* replace open-coded variants
* do not use separate header file for macro definitions

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

Oleksandr Natalenko (3):
mm: add PG2KB/KB2PG helper macros
mm: replace custom PG2KB/KB2PG macros with common ones
mm: replace open-coded PG2KB/KB2PG variants with macros

 arch/alpha/kernel/setup.c                     |  3 +-
 arch/arc/include/asm/arcregs.h                |  4 +-
 arch/mips/mm/init.c                           |  2 +-
 arch/powerpc/platforms/pseries/cmm.c          | 17 ++--
 arch/s390/appldata/appldata_mem.c             | 19 ++--
 arch/x86/kernel/cpu/mtrr/cleanup.c            | 17 ++--
 block/blk-sysfs.c                             |  9 +-
 drivers/base/node.c                           | 69 ++++++++-------
 drivers/gpu/drm/v3d/v3d_debugfs.c             |  3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  5 +-
 drivers/md/md-bitmap.c                        |  4 +-
 drivers/scsi/mpt3sas/mpt3sas_base.c           |  5 +-
 drivers/xen/xen-balloon.c                     | 11 ++-
 fs/ceph/addr.c                                |  2 +-
 fs/ceph/super.h                               |  3 +-
 fs/fs-writeback.c                             |  2 +-
 fs/nfs/write.c                                |  4 +-
 fs/nfsd/nfscache.c                            |  3 +-
 fs/proc/meminfo.c                             |  4 +-
 fs/proc/task_mmu.c                            |  3 +-
 include/linux/mm.h                            |  3 +
 include/trace/events/writeback.h              | 19 ++--
 kernel/debug/kdb/kdb_main.c                   |  3 +-
 kernel/events/core.c                          |  2 +-
 kernel/fork.c                                 |  2 +-
 mm/backing-dev.c                              | 22 +++--
 mm/hugetlb.c                                  |  2 +-
 mm/memcontrol.c                               | 18 ++--
 mm/mmap.c                                     |  6 +-
 mm/nommu.c                                    |  4 +-
 mm/oom_kill.c                                 | 16 ++--
 mm/page-writeback.c                           |  4 +-
 mm/page_alloc.c                               | 86 +++++++++----------
 mm/shmem.c                                    |  3 +-
 mm/swap_state.c                               |  5 +-
 mm/swapfile.c                                 | 11 ++-
 mm/util.c                                     |  6 +-
 37 files changed, 197 insertions(+), 204 deletions(-)
Signature · 1 line
2.33.0
#1 lore raw

RFC PATCH v2 1/3 mm: add PG2KB/KB2PG helper macros

---
 include/linux/mm.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/mm.h +3 -0
index 00bb2d938df4..0a7e950ac8aa 100644
@@ -98,6 +98,9 @@ extern int mmap_rnd_compat_bits __read_mostly;
 #include <asm/page.h>
 #include <asm/processor.h>
 
+#define PG2KB(x)	((x) << (PAGE_SHIFT - 10))
+#define KB2PG(x)	((x) >> (PAGE_SHIFT - 10))
+
 /*
  * Architectures that support memory tagging (assigning tags to memory regions,
  * embedding these tags into addresses that point to these memory regions, and
Signature · 1 line
2.33.0
maintainer
#3 lore raw

Re: [RFC v2 PATCH 1/3] mm: add PG2KB/KB2PG helper macros

In reply to Oleksandr Natalenko

include/linux/mm.h extern int mmap_rnd_compat_bits __read_mostly; · line 102

Quoted 2 lines · Oleksandr Natalenko
include/linux/mm.h +2 -0
+#define PG2KB(x)	((x) << (PAGE_SHIFT - 10))
+#define KB2PG(x)	((x) >> (PAGE_SHIFT - 10))

This is not an improvement.

#4 lore raw

RFC PATCH v2 2/3 mm: replace custom PG2KB/KB2PG macros with common ones

In reply to Oleksandr Natalenko
---
 arch/arc/include/asm/arcregs.h       |  4 +-
 arch/powerpc/platforms/pseries/cmm.c | 17 +++---
 arch/s390/appldata/appldata_mem.c    | 19 +++----
 drivers/base/node.c                  | 69 +++++++++++------------
 drivers/scsi/mpt3sas/mpt3sas_base.c  |  5 +-
 drivers/xen/xen-balloon.c            | 11 ++--
 include/trace/events/writeback.h     | 19 +++----
 kernel/debug/kdb/kdb_main.c          |  3 +-
 mm/backing-dev.c                     | 20 +++----
 mm/memcontrol.c                      | 18 +++---
 mm/oom_kill.c                        | 16 +++---
 mm/page_alloc.c                      | 84 ++++++++++++++--------------
 12 files changed, 136 insertions(+), 149 deletions(-)
arch/arc/include/asm/arcregs.h +2 -2
index 2162023195c5..87becc380d6a 100644
@@ -146,13 +146,13 @@
 
 #ifndef __ASSEMBLY__
 
+#include <linux/mm.h>
 #include <soc/arc/aux.h>
 
 /* Helpers */
 #define TO_KB(bytes)		((bytes) >> 10)
 #define TO_MB(bytes)		(TO_KB(bytes) >> 10)
-#define PAGES_TO_KB(n_pages)	((n_pages) << (PAGE_SHIFT - 10))
-#define PAGES_TO_MB(n_pages)	(PAGES_TO_KB(n_pages) >> 10)
+#define PAGES_TO_MB(n_pages)	(PG2KB(n_pages) >> 10)
 
 
 /*
arch/powerpc/platforms/pseries/cmm.c +8 -9
index 45a3a3022a85..c22b9b66b930 100644
@@ -12,6 +12,7 @@
 #include <linux/fs.h>
 #include <linux/gfp.h>
 #include <linux/kthread.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/oom.h>
 #include <linux/reboot.h>
@@ -39,8 +40,6 @@
 #define CMM_DISABLE		0
 #define CMM_OOM_KB		1024
 #define CMM_MIN_MEM_MB		256
-#define KB2PAGES(_p)		((_p)>>(PAGE_SHIFT-10))
-#define PAGES2KB(_p)		((_p)<<(PAGE_SHIFT-10))
 
 #define CMM_MEM_HOTPLUG_PRI	1
 
@@ -215,13 +214,13 @@ static int cmm_oom_notify(struct notifier_block *self,
 			  unsigned long dummy, void *parm)
 {
 	unsigned long *freed = parm;
-	long nr = KB2PAGES(oom_kb);
+	long nr = KB2PG(oom_kb);
 
 	cmm_dbg("OOM processing started\n");
 	nr = cmm_free_pages(nr);
 	loaned_pages_target = atomic_long_read(&loaned_pages);
-	*freed += KB2PAGES(oom_kb) - nr;
-	oom_freed_pages += KB2PAGES(oom_kb) - nr;
+	*freed += KB2PG(oom_kb) - nr;
+	oom_freed_pages += KB2PG(oom_kb) - nr;
 	cmm_dbg("OOM processing complete\n");
 	return NOTIFY_OK;
 }
@@ -251,7 +250,7 @@ static void cmm_get_mpp(void)
 					    PAGE_SIZE);
 		target = page_loan_request + __loaned_pages;
 	} else {
-		target = KB2PAGES(simulate_loan_target_kb);
+		target = KB2PG(simulate_loan_target_kb);
 		page_loan_request = target - __loaned_pages;
 	}
 
@@ -342,13 +341,13 @@ static int cmm_thread(void *dummy)
 	}							\
 	static DEVICE_ATTR(name, 0444, show_##name, NULL)
 
-CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(atomic_long_read(&loaned_pages)));
-CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target));
+CMM_SHOW(loaned_kb, "%lu\n", PG2KB(atomic_long_read(&loaned_pages)));
+CMM_SHOW(loaned_target_kb, "%lu\n", PG2KB(loaned_pages_target));
 
 static ssize_t show_oom_pages(struct device *dev,
 			      struct device_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%lu\n", PAGES2KB(oom_freed_pages));
+	return sprintf(buf, "%lu\n", PG2KB(oom_freed_pages));
 }
 
 static ssize_t store_oom_pages(struct device *dev,
arch/s390/appldata/appldata_mem.c +9 -10
index 21c3147bd92a..35f02d18d88c 100644
@@ -8,6 +8,7 @@
  * Author: Gerald Schaefer <[email protected]>
  */
 
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/errno.h>
@@ -20,8 +21,6 @@
 #include "appldata.h"
 
 
-#define P2K(x) ((x) << (PAGE_SHIFT - 10))	/* Converts #Pages to KB */
-
 /*
  * Memory data
  *
@@ -94,17 +93,17 @@ static void appldata_get_mem_data(void *data)
 
 	si_meminfo(&val);
 	mem_data->sharedram = val.sharedram;
-	mem_data->totalram  = P2K(val.totalram);
-	mem_data->freeram   = P2K(val.freeram);
-	mem_data->totalhigh = P2K(val.totalhigh);
-	mem_data->freehigh  = P2K(val.freehigh);
-	mem_data->bufferram = P2K(val.bufferram);
-	mem_data->cached    = P2K(global_node_page_state(NR_FILE_PAGES)
+	mem_data->totalram  = PG2KB(val.totalram);
+	mem_data->freeram   = PG2KB(val.freeram);
+	mem_data->totalhigh = PG2KB(val.totalhigh);
+	mem_data->freehigh  = PG2KB(val.freehigh);
+	mem_data->bufferram = PG2KB(val.bufferram);
+	mem_data->cached    = PG2KB(global_node_page_state(NR_FILE_PAGES)
 				- val.bufferram);
 
 	si_swapinfo(&val);
-	mem_data->totalswap = P2K(val.totalswap);
-	mem_data->freeswap  = P2K(val.freeswap);
+	mem_data->totalswap = PG2KB(val.totalswap);
+	mem_data->freeswap  = PG2KB(val.freeswap);
 
 	mem_data->timestamp = get_tod_clock();
 	mem_data->sync_count_2++;
drivers/base/node.c +34 -35

103 lines not on this page · raw message

drivers/scsi/mpt3sas/mpt3sas_base.c +2 -3
index 27eb652b564f..bb11f31f8431 100644
@@ -44,6 +44,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -2988,8 +2989,6 @@ _base_build_sg_ieee(struct MPT3SAS_ADAPTER *ioc, void *psge,
 	}
 }
 
-#define convert_to_kb(x) ((x) << (PAGE_SHIFT - 10))
-
 /**
  * _base_config_dma_addressing - set dma addressing
  * @ioc: per adapter object
@@ -3026,7 +3025,7 @@ _base_config_dma_addressing(struct MPT3SAS_ADAPTER *ioc, struct pci_dev *pdev)
 
 	si_meminfo(&s);
 	ioc_info(ioc, "%d BIT PCI BUS DMA ADDRESSING SUPPORTED, total mem (%ld kB)\n",
-		ioc->dma_mask, convert_to_kb(s.totalram));
+		ioc->dma_mask, PG2KB(s.totalram));
 
 	return 0;
 }
drivers/xen/xen-balloon.c +5 -6
index 8cd583db20b1..fdd39e5e1a1e 100644
@@ -34,6 +34,7 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/mm.h>
 #include <linux/mm_types.h>
 #include <linux/init.h>
 #include <linux/capability.h>
@@ -47,8 +48,6 @@
 #include <xen/page.h>
 #include <xen/mem-reservation.h>
 
-#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
-
 #define BALLOON_CLASS_NAME "xen_memory"
 
 #ifdef CONFIG_MEMORY_HOTPLUG
@@ -142,9 +141,9 @@ EXPORT_SYMBOL_GPL(xen_balloon_init);
 	}								\
 	static DEVICE_ATTR_RO(name)
 
-BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
-BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
-BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
+BALLOON_SHOW(current_kb, "%lu\n", PG2KB(balloon_stats.current_pages));
+BALLOON_SHOW(low_kb, "%lu\n", PG2KB(balloon_stats.balloon_low));
+BALLOON_SHOW(high_kb, "%lu\n", PG2KB(balloon_stats.balloon_high));
 
 static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay);
 static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay);
@@ -155,7 +154,7 @@ static DEVICE_BOOL_ATTR(scrub_pages, 0644, xen_scrub_pages);
 static ssize_t target_kb_show(struct device *dev, struct device_attribute *attr,
 			      char *buf)
 {
-	return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages));
+	return sprintf(buf, "%lu\n", PG2KB(balloon_stats.target_pages));
 }
 
 static ssize_t target_kb_store(struct device *dev,
include/trace/events/writeback.h +9 -10
index 7dccb66474f7..3a30e0cb3bee 100644
@@ -5,6 +5,7 @@
 #if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
 #define _TRACE_WRITEBACK_H
 
+#include <linux/mm.h>
 #include <linux/tracepoint.h>
 #include <linux/backing-dev.h>
 #include <linux/writeback.h>
@@ -570,8 +571,6 @@ TRACE_EVENT(global_dirty_state,
 	)
 );
 
-#define KBps(x)			((x) << (PAGE_SHIFT - 10))
-
 TRACE_EVENT(bdi_dirty_ratelimit,
 
 	TP_PROTO(struct bdi_writeback *wb,
@@ -593,13 +592,13 @@ TRACE_EVENT(bdi_dirty_ratelimit,
 
 	TP_fast_assign(
 		strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32);
-		__entry->write_bw	= KBps(wb->write_bandwidth);
-		__entry->avg_write_bw	= KBps(wb->avg_write_bandwidth);
-		__entry->dirty_rate	= KBps(dirty_rate);
-		__entry->dirty_ratelimit = KBps(wb->dirty_ratelimit);
-		__entry->task_ratelimit	= KBps(task_ratelimit);
+		__entry->write_bw	= PG2KB(wb->write_bandwidth);
+		__entry->avg_write_bw	= PG2KB(wb->avg_write_bandwidth);
+		__entry->dirty_rate	= PG2KB(dirty_rate);
+		__entry->dirty_ratelimit = PG2KB(wb->dirty_ratelimit);
+		__entry->task_ratelimit	= PG2KB(task_ratelimit);
 		__entry->balanced_dirty_ratelimit =
-					KBps(wb->balanced_dirty_ratelimit);
+					PG2KB(wb->balanced_dirty_ratelimit);
 		__entry->cgroup_ino	= __trace_wb_assign_cgroup(wb);
 	),
 
@@ -666,8 +665,8 @@ TRACE_EVENT(balance_dirty_pages,
 		__entry->bdi_setpoint	= __entry->setpoint *
 						bdi_thresh / (thresh + 1);
 		__entry->bdi_dirty	= bdi_dirty;
-		__entry->dirty_ratelimit = KBps(dirty_ratelimit);
-		__entry->task_ratelimit	= KBps(task_ratelimit);
+		__entry->dirty_ratelimit = PG2KB(dirty_ratelimit);
+		__entry->task_ratelimit	= PG2KB(task_ratelimit);
 		__entry->dirtied	= dirtied;
 		__entry->dirtied_pause	= current->nr_dirtied_pause;
 		__entry->think		= current->dirty_paused_when == 0 ? 0 :
kernel/debug/kdb/kdb_main.c +1 -2
index fa6deda894a1..b1bbc8f39171 100644
@@ -2522,10 +2522,9 @@ static int kdb_summary(int argc, const char **argv)
 		LOAD_INT(val.loads[2]), LOAD_FRAC(val.loads[2]));
 
 	/* Display in kilobytes */
-#define K(x) ((x) << (PAGE_SHIFT - 10))
 	kdb_printf("\nMemTotal:       %8lu kB\nMemFree:        %8lu kB\n"
 		   "Buffers:        %8lu kB\n",
-		   K(val.totalram), K(val.freeram), K(val.bufferram));
+		   PG2KB(val.totalram), PG2KB(val.freeram), PG2KB(val.bufferram));
 	return 0;
 }
 
mm/backing-dev.c +9 -11
index 4a9d4e27d0d9..b1d9c7bb35b3 100644
@@ -33,8 +33,6 @@ LIST_HEAD(bdi_list);
 /* bdi_wq serves all asynchronous writeback tasks */
 struct workqueue_struct *bdi_wq;
 
-#define K(x) ((x) << (PAGE_SHIFT - 10))
-
 #ifdef CONFIG_DEBUG_FS
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
@@ -87,14 +85,14 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
 		   "b_dirty_time:       %10lu\n"
 		   "bdi_list:           %10u\n"
 		   "state:              %10lx\n",
-		   (unsigned long) K(wb_stat(wb, WB_WRITEBACK)),
-		   (unsigned long) K(wb_stat(wb, WB_RECLAIMABLE)),
-		   K(wb_thresh),
-		   K(dirty_thresh),
-		   K(background_thresh),
-		   (unsigned long) K(wb_stat(wb, WB_DIRTIED)),
-		   (unsigned long) K(wb_stat(wb, WB_WRITTEN)),
-		   (unsigned long) K(wb->write_bandwidth),
+		   (unsigned long) PG2KB(wb_stat(wb, WB_WRITEBACK)),
+		   (unsigned long) PG2KB(wb_stat(wb, WB_RECLAIMABLE)),
+		   PG2KB(wb_thresh),
+		   PG2KB(dirty_thresh),
+		   PG2KB(background_thresh),
+		   (unsigned long) PG2KB(wb_stat(wb, WB_DIRTIED)),
+		   (unsigned long) PG2KB(wb_stat(wb, WB_WRITTEN)),
+		   (unsigned long) PG2KB(wb->write_bandwidth),
 		   nr_dirty,
 		   nr_io,
 		   nr_more_io,
@@ -157,7 +155,7 @@ static ssize_t name##_show(struct device *dev,				\
 }									\
 static DEVICE_ATTR_RW(name);
 
-BDI_SHOW(read_ahead_kb, K(bdi->ra_pages))
+BDI_SHOW(read_ahead_kb, PG2KB(bdi->ra_pages))
 
 static ssize_t min_ratio_store(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count)
mm/memcontrol.c +9 -9
index 47dc4959ead8..5071380c77f0 100644
@@ -53,6 +53,7 @@
 #include <linux/fs.h>
 #include <linux/seq_file.h>
 #include <linux/vmpressure.h>
+#include <linux/mm.h>
 #include <linux/mm_inline.h>
 #include <linux/swap_cgroup.h>
 #include <linux/cpu.h>
@@ -1471,7 +1472,6 @@ static char *memory_stat_format(struct mem_cgroup *memcg)
 	return s.buffer;
 }
 
-#define K(x) ((x) << (PAGE_SHIFT-10))
 /**
  * mem_cgroup_print_oom_context: Print OOM information relevant to
  * memory controller.
@@ -1507,19 +1507,19 @@ void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg)
 	char *buf;
 
 	pr_info("memory: usage %llukB, limit %llukB, failcnt %lu\n",
-		K((u64)page_counter_read(&memcg->memory)),
-		K((u64)READ_ONCE(memcg->memory.max)), memcg->memory.failcnt);
+		PG2KB((u64)page_counter_read(&memcg->memory)),
+		PG2KB((u64)READ_ONCE(memcg->memory.max)), memcg->memory.failcnt);
 	if (cgroup_subsys_on_dfl(memory_cgrp_subsys))
 		pr_info("swap: usage %llukB, limit %llukB, failcnt %lu\n",
-			K((u64)page_counter_read(&memcg->swap)),
-			K((u64)READ_ONCE(memcg->swap.max)), memcg->swap.failcnt);
+			PG2KB((u64)page_counter_read(&memcg->swap)),
+			PG2KB((u64)READ_ONCE(memcg->swap.max)), memcg->swap.failcnt);
 	else {
 		pr_info("memory+swap: usage %llukB, limit %llukB, failcnt %lu\n",
-			K((u64)page_counter_read(&memcg->memsw)),
-			K((u64)memcg->memsw.max), memcg->memsw.failcnt);
+			PG2KB((u64)page_counter_read(&memcg->memsw)),
+			PG2KB((u64)memcg->memsw.max), memcg->memsw.failcnt);
 		pr_info("kmem: usage %llukB, limit %llukB, failcnt %lu\n",
-			K((u64)page_counter_read(&memcg->kmem)),
-			K((u64)memcg->kmem.max), memcg->kmem.failcnt);
+			PG2KB((u64)page_counter_read(&memcg->kmem)),
+			PG2KB((u64)memcg->kmem.max), memcg->kmem.failcnt);
 	}
 
 	pr_info("Memory cgroup stats for ");
mm/oom_kill.c +7 -9
index 431d38c3bba8..9c7a6ec4b298 100644
@@ -485,8 +485,6 @@ static DECLARE_WAIT_QUEUE_HEAD(oom_victims_wait);
 
 static bool oom_killer_disabled __read_mostly;
 
-#define K(x) ((x) << (PAGE_SHIFT-10))
-
 /*
  * task->mm can be NULL if the task is the exited group leader.  So to
  * determine whether the task is using a particular mm, we examine all the
@@ -599,9 +597,9 @@ static bool oom_reap_task_mm(struct task_struct *tsk, struct mm_struct *mm)
 
 	pr_info("oom_reaper: reaped process %d (%s), now anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
 			task_pid_nr(tsk), tsk->comm,
-			K(get_mm_counter(mm, MM_ANONPAGES)),
-			K(get_mm_counter(mm, MM_FILEPAGES)),
-			K(get_mm_counter(mm, MM_SHMEMPAGES)));
+			PG2KB(get_mm_counter(mm, MM_ANONPAGES)),
+			PG2KB(get_mm_counter(mm, MM_FILEPAGES)),
+			PG2KB(get_mm_counter(mm, MM_SHMEMPAGES)));
 out_finish:
 	trace_finish_task_reaping(tsk->pid);
 out_unlock:
@@ -894,10 +892,10 @@ static void __oom_kill_process(struct task_struct *victim, const char *message)
 	do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID);
 	mark_oom_victim(victim);
 	pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n",
-		message, task_pid_nr(victim), victim->comm, K(mm->total_vm),
-		K(get_mm_counter(mm, MM_ANONPAGES)),
-		K(get_mm_counter(mm, MM_FILEPAGES)),
-		K(get_mm_counter(mm, MM_SHMEMPAGES)),
+		message, task_pid_nr(victim), victim->comm, PG2KB(mm->total_vm),
+		PG2KB(get_mm_counter(mm, MM_ANONPAGES)),
+		PG2KB(get_mm_counter(mm, MM_FILEPAGES)),
+		PG2KB(get_mm_counter(mm, MM_SHMEMPAGES)),
 		from_kuid(&init_user_ns, task_uid(victim)),
 		mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
 	task_unlock(victim);
mm/page_alloc.c +41 -43

132 lines not on this page · raw message

Signature · 1 line
2.33.0
#5 lore raw

Re: [RFC v2 PATCH 2/3] mm: replace custom PG2KB/KB2PG macros with common ones

reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross #…

Hi Oleksandr,

[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on hnaz-mm/master]

url:    https://github.com/0day-ci/linux/commits/Oleksandr-Natalenko/mm-common-PAGE_SIZE-shift-macros/20210919-211421
base:   https://github.com/hnaz/linux-mm master
config: arc-randconfig-r043-20210919 (attached as .config)
compiler: arc-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c129ed106a8dd29030e8585cb39a779de91aaa6a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Oleksandr-Natalenko/mm-common-PAGE_SIZE-shift-macros/20210919-211421 git checkout c129ed106a8dd29030e8585cb39a779de91aaa6a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc prepare

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

arch/arc/Makefile:26: ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '' is unknown, fallback to ''
error: no override and no default toolchain set
init/Kconfig:70:warning: 'RUSTC_VERSION': number is invalid
In file included from ./arch/arc/include/generated/asm/div64.h:1,

                    from include/linux/math.h:5,
                    from include/linux/kernel.h:15,
                    from include/linux/list.h:9,
                    from include/linux/preempt.h:11,
                    from include/linux/percpu.h:6,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/math64.h: In function 'div_u64_rem':
>> include/asm-generic/div64.h:224:13: error: implicit declaration of function 'is_power_of_2' [-Werror=implicit-function-declaration]
     224 |             is_power_of_2(__base)) {                    \
         |             ^~~~~~~~~~~~~
   include/linux/math64.h:92:22: note: in expansion of macro 'do_div'
      92 |         *remainder = do_div(dividend, divisor);
         |                      ^~~~~~
>> include/asm-generic/div64.h:226:25: error: implicit declaration of function 'ilog2' [-Werror=implicit-function-declaration]
     226 |                 (n) >>= ilog2(__base);                  \
         |                         ^~~~~
   include/linux/math64.h:92:22: note: in expansion of macro 'do_div'
      92 |         *remainder = do_div(dividend, divisor);
         |                      ^~~~~~
   In file included from include/asm-generic/preempt.h:5,
                    from ./arch/arc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/percpu.h:6,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/thread_info.h: In function 'set_ti_thread_flag':
>> include/linux/thread_info.h:89:9: error: implicit declaration of function 'set_bit' [-Werror=implicit-function-declaration]
      89 |         set_bit(flag, (unsigned long *)&ti->flags);
         |         ^~~~~~~
   include/linux/thread_info.h: In function 'clear_ti_thread_flag':
>> include/linux/thread_info.h:94:9: error: implicit declaration of function 'clear_bit' [-Werror=implicit-function-declaration]
      94 |         clear_bit(flag, (unsigned long *)&ti->flags);
         |         ^~~~~~~~~
   include/linux/thread_info.h: In function 'test_and_set_ti_thread_flag':
>> include/linux/thread_info.h:108:16: error: implicit declaration of function 'test_and_set_bit' [-Werror=implicit-function-declaration]
     108 |         return test_and_set_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~~~~~~~~~
   include/linux/thread_info.h: In function 'test_and_clear_ti_thread_flag':
>> include/linux/thread_info.h:113:16: error: implicit declaration of function 'test_and_clear_bit' [-Werror=implicit-function-declaration]
     113 |         return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/thread_info.h: In function 'test_ti_thread_flag':
>> include/linux/thread_info.h:118:16: error: implicit declaration of function 'test_bit'; did you mean 'test_taint'? [-Werror=implicit-function-declaration]
     118 |         return test_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~
         |                test_taint
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/percpu.h:7,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/bitmap.h: In function 'bitmap_empty':
>> include/linux/bitmap.h:391:16: error: implicit declaration of function 'find_first_bit'; did you mean 'sched_find_first_bit'? [-Werror=implicit-function-declaration]
     391 |         return find_first_bit(src, nbits) == nbits;
         |                ^~~~~~~~~~~~~~
         |                sched_find_first_bit
   include/linux/bitmap.h: In function 'bitmap_full':
>> include/linux/bitmap.h:399:16: error: implicit declaration of function 'find_first_zero_bit' [-Werror=implicit-function-declaration]
     399 |         return find_first_zero_bit(src, nbits) == nbits;
         |                ^~~~~~~~~~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_weight':
>> include/linux/bitmap.h:405:24: error: implicit declaration of function 'hweight_long' [-Werror=implicit-function-declaration]
     405 |                 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
         |                        ^~~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_set':
>> include/linux/bitmap.h:413:17: error: implicit declaration of function '__set_bit' [-Werror=implicit-function-declaration]
     413 |                 __set_bit(start, map);
         |                 ^~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_clear':
>> include/linux/bitmap.h:427:17: error: implicit declaration of function '__clear_bit' [-Werror=implicit-function-declaration]
     427 |                 __clear_bit(start, map);
         |                 ^~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_next_clear_region':
>> include/linux/bitmap.h:471:15: error: implicit declaration of function 'find_next_zero_bit' [-Werror=implicit-function-declaration]
     471 |         *rs = find_next_zero_bit(bitmap, end, *rs);
         |               ^~~~~~~~~~~~~~~~~~
>> include/linux/bitmap.h:472:15: error: implicit declaration of function 'find_next_bit' [-Werror=implicit-function-declaration]
     472 |         *re = find_next_bit(bitmap, end, *rs + 1);
         |               ^~~~~~~~~~~~~
   In file included from include/linux/smp_types.h:5,
                    from include/linux/smp.h:15,
                    from include/linux/percpu.h:7,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/llist.h: In function 'llist_del_all':
>> include/linux/llist.h:237:16: error: implicit declaration of function 'xchg' [-Werror=implicit-function-declaration]
     237 |         return xchg(&head->first, NULL);
         |                ^~~~
>> include/linux/llist.h:237:16: warning: returning 'int' from a function with return type 'struct llist_node *' makes pointer from integer without a cast [-Wint-conversion]
     237 |         return xchg(&head->first, NULL);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from <command-line>:
   include/linux/gfp.h: In function 'gfp_migratetype':
>> include/linux/gfp.h:347:63: error: 'MIGRATE_MOVABLE' undeclared (first use in this function)
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |                                                               ^~~~~~~~~~~~~~~
   include/linux/compiler_types.h:302:23: note: in definition of macro '__compiletime_assert'
     302 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
     322 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   include/linux/gfp.h:347:9: note: in expansion of macro 'BUILD_BUG_ON'
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |         ^~~~~~~~~~~~
   include/linux/gfp.h:347:63: note: each undeclared identifier is reported only once for each function it appears in
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |                                                               ^~~~~~~~~~~~~~~
   include/linux/compiler_types.h:302:23: note: in definition of macro '__compiletime_assert'
     302 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
     322 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   include/linux/gfp.h:347:9: note: in expansion of macro 'BUILD_BUG_ON'
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |         ^~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:5,
                    from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
>> include/linux/gfp.h:349:22: error: 'page_group_by_mobility_disabled' undeclared (first use in this function)
     349 |         if (unlikely(page_group_by_mobility_disabled))
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   In file included from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
>> include/linux/gfp.h:350:24: error: 'MIGRATE_UNMOVABLE' undeclared (first use in this function)
     350 |                 return MIGRATE_UNMOVABLE;
         |                        ^~~~~~~~~~~~~~~~~
   include/linux/gfp.h: At top level:
>> include/linux/gfp.h:441:25: warning: "ZONES_SHIFT" is not defined, evaluates to 0 [-Wundef]
     441 | #define GFP_ZONES_SHIFT ZONES_SHIFT
         |                         ^~~~~~~~~~~
   include/linux/gfp.h:444:10: note: in expansion of macro 'GFP_ZONES_SHIFT'
     444 | #if 16 * GFP_ZONES_SHIFT > BITS_PER_LONG
         |          ^~~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'gfp_zone':
   include/linux/gfp.h:441:25: error: 'ZONES_SHIFT' undeclared (first use in this function); did you mean 'NMI_SHIFT'?
     441 | #define GFP_ZONES_SHIFT ZONES_SHIFT
         |                         ^~~~~~~~~~~
   include/linux/gfp.h:449:29: note: in expansion of macro 'GFP_ZONES_SHIFT'
     449 |         (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT)                                   \
         |                             ^~~~~~~~~~~~~~~
   include/linux/gfp.h:481:14: note: in expansion of macro 'GFP_ZONE_TABLE'
     481 |         z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) &
         |              ^~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'gfp_zonelist':
   include/linux/gfp.h:500:16: error: 'ZONELIST_FALLBACK' undeclared (first use in this function)
     500 |         return ZONELIST_FALLBACK;
         |                ^~~~~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'node_zonelist':
   include/linux/gfp.h:514:16: error: implicit declaration of function 'NODE_DATA' [-Werror=implicit-function-declaration]
     514 |         return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
         |                ^~~~~~~~~
   include/linux/gfp.h:514:30: error: invalid type argument of '->' (have 'int')
     514 |         return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
         |                              ^~
   include/linux/gfp.h: At top level:
   include/linux/gfp.h:525:17: error: unknown type name 'nodemask_t'
     525 |                 nodemask_t *nodemask);
         |                 ^~~~~~~~~~
   include/linux/gfp.h:527:17: error: unknown type name 'nodemask_t'
     527 |                 nodemask_t *nodemask);
         |                 ^~~~~~~~~~
   include/linux/gfp.h:530:33: error: unknown type name 'nodemask_t'
     530 |                                 nodemask_t *nodemask, int nr_pages,
         |                                 ^~~~~~~~~~
   include/linux/gfp.h: In function 'alloc_pages_bulk_list':
   include/linux/gfp.h:538:16: error: implicit declaration of function '__alloc_pages_bulk'; did you mean 'alloc_pages_bulk_list'? [-Werror=implicit-function-declaration]
     538 |         return __alloc_pages_bulk(gfp, numa_mem_id(), NULL, nr_pages, list, NULL);
         |                ^~~~~~~~~~~~~~~~~~
         |                alloc_pages_bulk_list
   include/linux/gfp.h: In function 'alloc_pages_bulk_array_node':
   include/linux/gfp.h:550:20: error: 'NUMA_NO_NODE' undeclared (first use in this function)
     550 |         if (nid == NUMA_NO_NODE)
         |                    ^~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:5,
                    from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/gfp.h: In function '__alloc_pages_node':
   include/linux/gfp.h:563:37: error: 'MAX_NUMNODES' undeclared (first use in this function)
     563 |         VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
         |                                     ^~~~~~~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/mmdebug.h:17:25: note: in expansion of macro 'BUG_ON'
      17 | #define VM_BUG_ON(cond) BUG_ON(cond)
         |                         ^~~~~~
   include/linux/gfp.h:563:9: note: in expansion of macro 'VM_BUG_ON'
     563 |         VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
         |         ^~~~~~~~~
   In file included from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/gfp.h:564:52: error: implicit declaration of function 'node_online'; did you mean 'node_zonelist'? [-Werror=implicit-function-declaration]
     564 |         VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
         |                                                    ^~~~~~~~~~~
   include/asm-generic/bug.h:121:32: note: in definition of macro 'WARN_ON'
     121 |         int __ret_warn_on = !!(condition);                              \
         |                                ^~~~~~~~~
   include/linux/gfp.h:564:9: note: in expansion of macro 'VM_WARN_ON'
     564 |         VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
         |         ^~~~~~~~~~
   In file included from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-arcv2.h:9,
                    from arch/arc/include/asm/irqflags.h:13,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/gfp.h:566:16: error: implicit declaration of function '__alloc_pages'; did you mean '__alloc_pages_node'? [-Werror=implicit-function-declaration]
     566 |         return __alloc_pages(gfp_mask, order, nid, NULL);
         |                ^~~~~~~~~~~~~
         |                __alloc_pages_node
   include/linux/gfp.h:566:16: warning: returning 'int' from a function with return type 'struct page *' makes pointer from integer without a cast [-Wint-conversion]
     566 |         return __alloc_pages(gfp_mask, order, nid, NULL);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:5,
                    from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,

vim +/MIGRATE_MOVABLE +347 include/linux/gfp.h

6cb062296f73e7 Christoph Lameter       2007-10-16  342  
01c0bfe061f309 Wei Yang                2020-06-03  343  static inline int gfp_migratetype(const gfp_t gfp_flags)
467c996c1e1910 Mel Gorman              2007-10-16  344  {
016c13daa5c9e4 Mel Gorman              2015-11-06  345  	VM_WARN_ON((gfp_flags & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
016c13daa5c9e4 Mel Gorman              2015-11-06  346  	BUILD_BUG_ON((1UL << GFP_MOVABLE_SHIFT) != ___GFP_MOVABLE);
016c13daa5c9e4 Mel Gorman              2015-11-06 @347  	BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
467c996c1e1910 Mel Gorman              2007-10-16  348  
467c996c1e1910 Mel Gorman              2007-10-16 @349  	if (unlikely(page_group_by_mobility_disabled))
467c996c1e1910 Mel Gorman              2007-10-16 @350  		return MIGRATE_UNMOVABLE;
467c996c1e1910 Mel Gorman              2007-10-16  351  
467c996c1e1910 Mel Gorman              2007-10-16  352  	/* Group based on mobility */
016c13daa5c9e4 Mel Gorman              2015-11-06  353  	return (gfp_flags & GFP_MOVABLE_MASK) >> GFP_MOVABLE_SHIFT;
467c996c1e1910 Mel Gorman              2007-10-16  354  }
dd56b046426760 Mel Gorman              2015-11-06  355  #undef GFP_MOVABLE_MASK
dd56b046426760 Mel Gorman              2015-11-06  356  #undef GFP_MOVABLE_SHIFT
a2f1b424900715 Andi Kleen              2005-11-05  357  
d0164adc89f6bb Mel Gorman              2015-11-06  358  static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
d0164adc89f6bb Mel Gorman              2015-11-06  359  {
543dfb2df8ebb3 Joshua Clayton          2016-01-14  360  	return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
d0164adc89f6bb Mel Gorman              2015-11-06  361  }
d0164adc89f6bb Mel Gorman              2015-11-06  362  
20eb4f29b60286 Tejun Heo               2019-10-24  363  /**
20eb4f29b60286 Tejun Heo               2019-10-24  364   * gfpflags_normal_context - is gfp_flags a normal sleepable context?
20eb4f29b60286 Tejun Heo               2019-10-24  365   * @gfp_flags: gfp_flags to test
20eb4f29b60286 Tejun Heo               2019-10-24  366   *
20eb4f29b60286 Tejun Heo               2019-10-24  367   * Test whether @gfp_flags indicates that the allocation is from the
20eb4f29b60286 Tejun Heo               2019-10-24  368   * %current context and allowed to sleep.
20eb4f29b60286 Tejun Heo               2019-10-24  369   *
20eb4f29b60286 Tejun Heo               2019-10-24  370   * An allocation being allowed to block doesn't mean it owns the %current
20eb4f29b60286 Tejun Heo               2019-10-24  371   * context.  When direct reclaim path tries to allocate memory, the
20eb4f29b60286 Tejun Heo               2019-10-24  372   * allocation context is nested inside whatever %current was doing at the
20eb4f29b60286 Tejun Heo               2019-10-24  373   * time of the original allocation.  The nested allocation may be allowed
20eb4f29b60286 Tejun Heo               2019-10-24  374   * to block but modifying anything %current owns can corrupt the outer
20eb4f29b60286 Tejun Heo               2019-10-24  375   * context's expectations.
20eb4f29b60286 Tejun Heo               2019-10-24  376   *
20eb4f29b60286 Tejun Heo               2019-10-24  377   * %true result from this function indicates that the allocation context
20eb4f29b60286 Tejun Heo               2019-10-24  378   * can sleep and use anything that's associated with %current.
20eb4f29b60286 Tejun Heo               2019-10-24  379   */
20eb4f29b60286 Tejun Heo               2019-10-24  380  static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
20eb4f29b60286 Tejun Heo               2019-10-24  381  {
20eb4f29b60286 Tejun Heo               2019-10-24  382  	return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
20eb4f29b60286 Tejun Heo               2019-10-24  383  		__GFP_DIRECT_RECLAIM;
20eb4f29b60286 Tejun Heo               2019-10-24  384  }
20eb4f29b60286 Tejun Heo               2019-10-24  385  
b70d94ee438b3f Christoph Lameter       2009-06-16  386  #ifdef CONFIG_HIGHMEM
b70d94ee438b3f Christoph Lameter       2009-06-16  387  #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
b70d94ee438b3f Christoph Lameter       2009-06-16  388  #else
b70d94ee438b3f Christoph Lameter       2009-06-16  389  #define OPT_ZONE_HIGHMEM ZONE_NORMAL
b70d94ee438b3f Christoph Lameter       2009-06-16  390  #endif
b70d94ee438b3f Christoph Lameter       2009-06-16  391  
4b51d66989218a Christoph Lameter       2007-02-10  392  #ifdef CONFIG_ZONE_DMA
b70d94ee438b3f Christoph Lameter       2009-06-16  393  #define OPT_ZONE_DMA ZONE_DMA
b70d94ee438b3f Christoph Lameter       2009-06-16  394  #else
b70d94ee438b3f Christoph Lameter       2009-06-16  395  #define OPT_ZONE_DMA ZONE_NORMAL
4b51d66989218a Christoph Lameter       2007-02-10  396  #endif
b70d94ee438b3f Christoph Lameter       2009-06-16  397  
4e4785bcf0c850 Christoph Lameter       2006-09-25  398  #ifdef CONFIG_ZONE_DMA32
b70d94ee438b3f Christoph Lameter       2009-06-16  399  #define OPT_ZONE_DMA32 ZONE_DMA32
b70d94ee438b3f Christoph Lameter       2009-06-16  400  #else
b70d94ee438b3f Christoph Lameter       2009-06-16  401  #define OPT_ZONE_DMA32 ZONE_NORMAL
4e4785bcf0c850 Christoph Lameter       2006-09-25  402  #endif
b70d94ee438b3f Christoph Lameter       2009-06-16  403  
b70d94ee438b3f Christoph Lameter       2009-06-16  404  /*
b70d94ee438b3f Christoph Lameter       2009-06-16  405   * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
ac2e8e40acf4c7 Hao Lee                 2017-05-03  406   * zone to use given the lowest 4 bits of gfp_t. Entries are GFP_ZONES_SHIFT
ac2e8e40acf4c7 Hao Lee                 2017-05-03  407   * bits long and there are 16 of them to cover all possible combinations of
263ff5d8e82e57 matt mooney             2010-05-24  408   * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
b70d94ee438b3f Christoph Lameter       2009-06-16  409   *
b70d94ee438b3f Christoph Lameter       2009-06-16  410   * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
b70d94ee438b3f Christoph Lameter       2009-06-16  411   * But GFP_MOVABLE is not only a zone specifier but also an allocation
b70d94ee438b3f Christoph Lameter       2009-06-16  412   * policy. Therefore __GFP_MOVABLE plus another zone selector is valid.
263ff5d8e82e57 matt mooney             2010-05-24  413   * Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1".
b70d94ee438b3f Christoph Lameter       2009-06-16  414   *
b70d94ee438b3f Christoph Lameter       2009-06-16  415   *       bit       result
b70d94ee438b3f Christoph Lameter       2009-06-16  416   *       =================
b70d94ee438b3f Christoph Lameter       2009-06-16  417   *       0x0    => NORMAL
b70d94ee438b3f Christoph Lameter       2009-06-16  418   *       0x1    => DMA or NORMAL
b70d94ee438b3f Christoph Lameter       2009-06-16  419   *       0x2    => HIGHMEM or NORMAL
b70d94ee438b3f Christoph Lameter       2009-06-16  420   *       0x3    => BAD (DMA+HIGHMEM)
4b33b6959581d5 Huaisheng Ye            2018-06-07  421   *       0x4    => DMA32 or NORMAL
b70d94ee438b3f Christoph Lameter       2009-06-16  422   *       0x5    => BAD (DMA+DMA32)
b70d94ee438b3f Christoph Lameter       2009-06-16  423   *       0x6    => BAD (HIGHMEM+DMA32)
b70d94ee438b3f Christoph Lameter       2009-06-16  424   *       0x7    => BAD (HIGHMEM+DMA32+DMA)
b70d94ee438b3f Christoph Lameter       2009-06-16  425   *       0x8    => NORMAL (MOVABLE+0)
b70d94ee438b3f Christoph Lameter       2009-06-16  426   *       0x9    => DMA or NORMAL (MOVABLE+DMA)
b70d94ee438b3f Christoph Lameter       2009-06-16  427   *       0xa    => MOVABLE (Movable is valid only if HIGHMEM is set too)
b70d94ee438b3f Christoph Lameter       2009-06-16  428   *       0xb    => BAD (MOVABLE+HIGHMEM+DMA)
4b33b6959581d5 Huaisheng Ye            2018-06-07  429   *       0xc    => DMA32 or NORMAL (MOVABLE+DMA32)
b70d94ee438b3f Christoph Lameter       2009-06-16  430   *       0xd    => BAD (MOVABLE+DMA32+DMA)
b70d94ee438b3f Christoph Lameter       2009-06-16  431   *       0xe    => BAD (MOVABLE+DMA32+HIGHMEM)
b70d94ee438b3f Christoph Lameter       2009-06-16  432   *       0xf    => BAD (MOVABLE+DMA32+HIGHMEM+DMA)
b70d94ee438b3f Christoph Lameter       2009-06-16  433   *
b11a7b94100cba Dan Williams            2016-03-17  434   * GFP_ZONES_SHIFT must be <= 2 on 32 bit platforms.
b70d94ee438b3f Christoph Lameter       2009-06-16  435   */
b70d94ee438b3f Christoph Lameter       2009-06-16  436  
b11a7b94100cba Dan Williams            2016-03-17  437  #if defined(CONFIG_ZONE_DEVICE) && (MAX_NR_ZONES-1) <= 4
b11a7b94100cba Dan Williams            2016-03-17  438  /* ZONE_DEVICE is not a valid GFP zone specifier */
b11a7b94100cba Dan Williams            2016-03-17  439  #define GFP_ZONES_SHIFT 2
b11a7b94100cba Dan Williams            2016-03-17  440  #else
b11a7b94100cba Dan Williams            2016-03-17 @441  #define GFP_ZONES_SHIFT ZONES_SHIFT
b11a7b94100cba Dan Williams            2016-03-17  442  #endif
b11a7b94100cba Dan Williams            2016-03-17  443  
b11a7b94100cba Dan Williams            2016-03-17  444  #if 16 * GFP_ZONES_SHIFT > BITS_PER_LONG
b11a7b94100cba Dan Williams            2016-03-17  445  #error GFP_ZONES_SHIFT too large to create GFP_ZONE_TABLE integer
b70d94ee438b3f Christoph Lameter       2009-06-16  446  #endif
b70d94ee438b3f Christoph Lameter       2009-06-16  447  
b70d94ee438b3f Christoph Lameter       2009-06-16  448  #define GFP_ZONE_TABLE ( \
b11a7b94100cba Dan Williams            2016-03-17  449  	(ZONE_NORMAL << 0 * GFP_ZONES_SHIFT)				       \
b11a7b94100cba Dan Williams            2016-03-17  450  	| (OPT_ZONE_DMA << ___GFP_DMA * GFP_ZONES_SHIFT)		       \
b11a7b94100cba Dan Williams            2016-03-17  451  	| (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * GFP_ZONES_SHIFT)	       \
b11a7b94100cba Dan Williams            2016-03-17  452  	| (OPT_ZONE_DMA32 << ___GFP_DMA32 * GFP_ZONES_SHIFT)		       \
b11a7b94100cba Dan Williams            2016-03-17  453  	| (ZONE_NORMAL << ___GFP_MOVABLE * GFP_ZONES_SHIFT)		       \
b11a7b94100cba Dan Williams            2016-03-17  454  	| (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT)    \
b11a7b94100cba Dan Williams            2016-03-17  455  	| (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT)\
b11a7b94100cba Dan Williams            2016-03-17  456  	| (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT)\
b70d94ee438b3f Christoph Lameter       2009-06-16  457  )
b70d94ee438b3f Christoph Lameter       2009-06-16  458  
b70d94ee438b3f Christoph Lameter       2009-06-16  459  /*
263ff5d8e82e57 matt mooney             2010-05-24  460   * GFP_ZONE_BAD is a bitmap for all combinations of __GFP_DMA, __GFP_DMA32
b70d94ee438b3f Christoph Lameter       2009-06-16  461   * __GFP_HIGHMEM and __GFP_MOVABLE that are not permitted. One flag per
b70d94ee438b3f Christoph Lameter       2009-06-16  462   * entry starting with bit 0. Bit is set if the combination is not
b70d94ee438b3f Christoph Lameter       2009-06-16  463   * allowed.
b70d94ee438b3f Christoph Lameter       2009-06-16  464   */
b70d94ee438b3f Christoph Lameter       2009-06-16  465  #define GFP_ZONE_BAD ( \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  466  	1 << (___GFP_DMA | ___GFP_HIGHMEM)				      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  467  	| 1 << (___GFP_DMA | ___GFP_DMA32)				      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  468  	| 1 << (___GFP_DMA32 | ___GFP_HIGHMEM)				      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  469  	| 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM)		      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  470  	| 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA)		      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  471  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA)		      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  472  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM)		      \
16b56cf4b8a0fa Namhyung Kim            2010-10-26  473  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM)  \
b70d94ee438b3f Christoph Lameter       2009-06-16  474  )
b70d94ee438b3f Christoph Lameter       2009-06-16  475  
b70d94ee438b3f Christoph Lameter       2009-06-16  476  static inline enum zone_type gfp_zone(gfp_t flags)
b70d94ee438b3f Christoph Lameter       2009-06-16  477  {
b70d94ee438b3f Christoph Lameter       2009-06-16  478  	enum zone_type z;
16b56cf4b8a0fa Namhyung Kim            2010-10-26  479  	int bit = (__force int) (flags & GFP_ZONEMASK);
b70d94ee438b3f Christoph Lameter       2009-06-16  480  
b11a7b94100cba Dan Williams            2016-03-17  481  	z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) &
b11a7b94100cba Dan Williams            2016-03-17  482  					 ((1 << GFP_ZONES_SHIFT) - 1);
82d4b5779a7588 Dave Hansen             2011-05-24  483  	VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
b70d94ee438b3f Christoph Lameter       2009-06-16  484  	return z;
4e4785bcf0c850 Christoph Lameter       2006-09-25  485  }
4e4785bcf0c850 Christoph Lameter       2006-09-25  486  
^1da177e4c3f41 Linus Torvalds          2005-04-16  487  /*
^1da177e4c3f41 Linus Torvalds          2005-04-16  488   * There is only one page-allocator function, and two main namespaces to
^1da177e4c3f41 Linus Torvalds          2005-04-16  489   * it. The alloc_page*() variants return 'struct page *' and as such
^1da177e4c3f41 Linus Torvalds          2005-04-16  490   * can allocate highmem pages, the *get*page*() variants return
^1da177e4c3f41 Linus Torvalds          2005-04-16  491   * virtual kernel addresses to the allocated page(s).
^1da177e4c3f41 Linus Torvalds          2005-04-16  492   */
^1da177e4c3f41 Linus Torvalds          2005-04-16  493  
54a6eb5c4765aa Mel Gorman              2008-04-28  494  static inline int gfp_zonelist(gfp_t flags)
54a6eb5c4765aa Mel Gorman              2008-04-28  495  {
c00eb15a8914b8 Yaowei Bai              2016-01-14  496  #ifdef CONFIG_NUMA
c00eb15a8914b8 Yaowei Bai              2016-01-14  497  	if (unlikely(flags & __GFP_THISNODE))
c00eb15a8914b8 Yaowei Bai              2016-01-14  498  		return ZONELIST_NOFALLBACK;
c00eb15a8914b8 Yaowei Bai              2016-01-14  499  #endif
c00eb15a8914b8 Yaowei Bai              2016-01-14 @500  	return ZONELIST_FALLBACK;
54a6eb5c4765aa Mel Gorman              2008-04-28  501  }
54a6eb5c4765aa Mel Gorman              2008-04-28  502  
^1da177e4c3f41 Linus Torvalds          2005-04-16  503  /*
^1da177e4c3f41 Linus Torvalds          2005-04-16  504   * We get the zone list from the current node and the gfp_mask.
cb152a1a95606a Shijie Luo              2021-05-06  505   * This zone list contains a maximum of MAX_NUMNODES*MAX_NR_ZONES zones.
54a6eb5c4765aa Mel Gorman              2008-04-28  506   * There are two zonelists per node, one for all zones with memory and
54a6eb5c4765aa Mel Gorman              2008-04-28  507   * one containing just zones from the node the zonelist belongs to.
^1da177e4c3f41 Linus Torvalds          2005-04-16  508   *
d3c251ab95b69f Mike Rapoport           2021-06-28  509   * For the case of non-NUMA systems the NODE_DATA() gets optimized to
d3c251ab95b69f Mike Rapoport           2021-06-28  510   * &contig_page_data at compile-time.
^1da177e4c3f41 Linus Torvalds          2005-04-16  511   */
0e88460da6ab7b Mel Gorman              2008-04-28  512  static inline struct zonelist *node_zonelist(int nid, gfp_t flags)
0e88460da6ab7b Mel Gorman              2008-04-28  513  {
54a6eb5c4765aa Mel Gorman              2008-04-28 @514  	return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
0e88460da6ab7b Mel Gorman              2008-04-28  515  }
^1da177e4c3f41 Linus Torvalds          2005-04-16  516  
^1da177e4c3f41 Linus Torvalds          2005-04-16  517  #ifndef HAVE_ARCH_FREE_PAGE
^1da177e4c3f41 Linus Torvalds          2005-04-16  518  static inline void arch_free_page(struct page *page, int order) { }
^1da177e4c3f41 Linus Torvalds          2005-04-16  519  #endif
cc102509074bba Nicholas Piggin         2006-12-06  520  #ifndef HAVE_ARCH_ALLOC_PAGE
cc102509074bba Nicholas Piggin         2006-12-06  521  static inline void arch_alloc_page(struct page *page, int order) { }
cc102509074bba Nicholas Piggin         2006-12-06  522  #endif
^1da177e4c3f41 Linus Torvalds          2005-04-16  523  
84172f4bb75242 Matthew Wilcox (Oracle  2021-04-29  524) struct page *__alloc_pages(gfp_t gfp, unsigned int order, int preferred_nid,
04ec6264f28793 Vlastimil Babka         2017-07-06 @525  		nodemask_t *nodemask);
da90006b76b648 Andrew Morton           2021-09-16  526  struct folio *__folio_alloc(gfp_t gfp, unsigned int order, int preferred_nid,
da90006b76b648 Andrew Morton           2021-09-16  527  		nodemask_t *nodemask);
e4048e5dc4aece KOSAKI Motohiro         2008-07-23  528  
387ba26fb1cb9b Mel Gorman              2021-04-29  529  unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,
387ba26fb1cb9b Mel Gorman              2021-04-29  530  				nodemask_t *nodemask, int nr_pages,
0f87d9d30f2139 Mel Gorman              2021-04-29  531  				struct list_head *page_list,
0f87d9d30f2139 Mel Gorman              2021-04-29  532  				struct page **page_array);
387ba26fb1cb9b Mel Gorman              2021-04-29  533  
387ba26fb1cb9b Mel Gorman              2021-04-29  534  /* Bulk allocate order-0 pages */
387ba26fb1cb9b Mel Gorman              2021-04-29  535  static inline unsigned long
0f87d9d30f2139 Mel Gorman              2021-04-29  536  alloc_pages_bulk_list(gfp_t gfp, unsigned long nr_pages, struct list_head *list)
387ba26fb1cb9b Mel Gorman              2021-04-29  537  {
0f87d9d30f2139 Mel Gorman              2021-04-29 @538  	return __alloc_pages_bulk(gfp, numa_mem_id(), NULL, nr_pages, list, NULL);
0f87d9d30f2139 Mel Gorman              2021-04-29  539  }
0f87d9d30f2139 Mel Gorman              2021-04-29  540  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#6 lore raw

Re: [RFC v2 PATCH 2/3] mm: replace custom PG2KB/KB2PG macros with common ones

In reply to Oleksandr Natalenko
reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross #…

Hi Oleksandr,

[FYI, it's a private test report for your RFC patch.] [auto build test ERROR on hnaz-mm/master]

url:    https://github.com/0day-ci/linux/commits/Oleksandr-Natalenko/mm-common-PAGE_SIZE-shift-macros/20210919-211421
base:   https://github.com/hnaz/linux-mm master
config: arc-randconfig-r014-20210919 (attached as .config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/c129ed106a8dd29030e8585cb39a779de91aaa6a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Oleksandr-Natalenko/mm-common-PAGE_SIZE-shift-macros/20210919-211421 git checkout c129ed106a8dd29030e8585cb39a779de91aaa6a
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc prepare

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

arch/arc/Makefile:26: ** WARNING ** CONFIG_ARC_TUNE_MCPU flag '' is unknown, fallback to ''
error: no override and no default toolchain set
init/Kconfig:70:warning: 'RUSTC_VERSION': number is invalid
In file included from ./arch/arc/include/generated/asm/div64.h:1,

                    from include/linux/math.h:5,
                    from include/linux/kernel.h:15,
                    from include/linux/list.h:9,
                    from include/linux/preempt.h:11,
                    from include/linux/percpu.h:6,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/math64.h: In function 'div_u64_rem':
>> include/asm-generic/div64.h:224:13: error: implicit declaration of function 'is_power_of_2' [-Werror=implicit-function-declaration]
     224 |             is_power_of_2(__base)) {                    \
         |             ^~~~~~~~~~~~~
   include/linux/math64.h:92:22: note: in expansion of macro 'do_div'
      92 |         *remainder = do_div(dividend, divisor);
         |                      ^~~~~~
>> include/asm-generic/div64.h:226:25: error: implicit declaration of function 'ilog2' [-Werror=implicit-function-declaration]
     226 |                 (n) >>= ilog2(__base);                  \
         |                         ^~~~~
   include/linux/math64.h:92:22: note: in expansion of macro 'do_div'
      92 |         *remainder = do_div(dividend, divisor);
         |                      ^~~~~~
   In file included from include/asm-generic/preempt.h:5,
                    from ./arch/arc/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/percpu.h:6,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/thread_info.h: In function 'set_ti_thread_flag':
>> include/linux/thread_info.h:89:9: error: implicit declaration of function 'set_bit' [-Werror=implicit-function-declaration]
      89 |         set_bit(flag, (unsigned long *)&ti->flags);
         |         ^~~~~~~
   include/linux/thread_info.h: In function 'clear_ti_thread_flag':
>> include/linux/thread_info.h:94:9: error: implicit declaration of function 'clear_bit' [-Werror=implicit-function-declaration]
      94 |         clear_bit(flag, (unsigned long *)&ti->flags);
         |         ^~~~~~~~~
   include/linux/thread_info.h: In function 'test_and_set_ti_thread_flag':
>> include/linux/thread_info.h:108:16: error: implicit declaration of function 'test_and_set_bit' [-Werror=implicit-function-declaration]
     108 |         return test_and_set_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~~~~~~~~~
   include/linux/thread_info.h: In function 'test_and_clear_ti_thread_flag':
>> include/linux/thread_info.h:113:16: error: implicit declaration of function 'test_and_clear_bit' [-Werror=implicit-function-declaration]
     113 |         return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~~~~~~~~~~~
   include/linux/thread_info.h: In function 'test_ti_thread_flag':
>> include/linux/thread_info.h:118:16: error: implicit declaration of function 'test_bit'; did you mean 'test_taint'? [-Werror=implicit-function-declaration]
     118 |         return test_bit(flag, (unsigned long *)&ti->flags);
         |                ^~~~~~~~
         |                test_taint
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/percpu.h:7,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/bitmap.h: In function 'bitmap_empty':
>> include/linux/bitmap.h:391:16: error: implicit declaration of function 'find_first_bit'; did you mean 'sched_find_first_bit'? [-Werror=implicit-function-declaration]
     391 |         return find_first_bit(src, nbits) == nbits;
         |                ^~~~~~~~~~~~~~
         |                sched_find_first_bit
   include/linux/bitmap.h: In function 'bitmap_full':
>> include/linux/bitmap.h:399:16: error: implicit declaration of function 'find_first_zero_bit' [-Werror=implicit-function-declaration]
     399 |         return find_first_zero_bit(src, nbits) == nbits;
         |                ^~~~~~~~~~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_weight':
>> include/linux/bitmap.h:405:24: error: implicit declaration of function 'hweight_long' [-Werror=implicit-function-declaration]
     405 |                 return hweight_long(*src & BITMAP_LAST_WORD_MASK(nbits));
         |                        ^~~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_set':
>> include/linux/bitmap.h:413:17: error: implicit declaration of function '__set_bit' [-Werror=implicit-function-declaration]
     413 |                 __set_bit(start, map);
         |                 ^~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_clear':
>> include/linux/bitmap.h:427:17: error: implicit declaration of function '__clear_bit' [-Werror=implicit-function-declaration]
     427 |                 __clear_bit(start, map);
         |                 ^~~~~~~~~~~
   include/linux/bitmap.h: In function 'bitmap_next_clear_region':
>> include/linux/bitmap.h:471:15: error: implicit declaration of function 'find_next_zero_bit' [-Werror=implicit-function-declaration]
     471 |         *rs = find_next_zero_bit(bitmap, end, *rs);
         |               ^~~~~~~~~~~~~~~~~~
>> include/linux/bitmap.h:472:15: error: implicit declaration of function 'find_next_bit' [-Werror=implicit-function-declaration]
     472 |         *re = find_next_bit(bitmap, end, *rs + 1);
         |               ^~~~~~~~~~~~~
   In file included from include/linux/smp.h:13,
                    from include/linux/percpu.h:7,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/cpumask.h: In function 'cpumask_last':
>> include/linux/cpumask.h:206:16: error: implicit declaration of function 'find_last_bit' [-Werror=implicit-function-declaration]
     206 |         return find_last_bit(cpumask_bits(srcp), nr_cpumask_bits);
         |                ^~~~~~~~~~~~~
   include/linux/cpumask.h: In function 'num_online_cpus':
>> include/linux/cpumask.h:887:16: error: implicit declaration of function 'atomic_read' [-Werror=implicit-function-declaration]
     887 |         return atomic_read(&__num_online_cpus);
         |                ^~~~~~~~~~~
   In file included from include/linux/smp_types.h:5,
                    from include/linux/smp.h:15,
                    from include/linux/percpu.h:7,
                    from include/linux/arch_topology.h:9,
                    from include/linux/topology.h:30,
                    from include/linux/gfp.h:9,
                    from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/llist.h: In function 'llist_del_all':
>> include/linux/llist.h:237:16: error: implicit declaration of function 'xchg' [-Werror=implicit-function-declaration]
     237 |         return xchg(&head->first, NULL);
         |                ^~~~
>> include/linux/llist.h:237:16: warning: returning 'int' from a function with return type 'struct llist_node *' makes pointer from integer without a cast [-Wint-conversion]
     237 |         return xchg(&head->first, NULL);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~
   In file included from <command-line>:
   include/linux/gfp.h: In function 'gfp_migratetype':
>> include/linux/gfp.h:347:63: error: 'MIGRATE_MOVABLE' undeclared (first use in this function)
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |                                                               ^~~~~~~~~~~~~~~
   include/linux/compiler_types.h:302:23: note: in definition of macro '__compiletime_assert'
     302 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
     322 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   include/linux/gfp.h:347:9: note: in expansion of macro 'BUILD_BUG_ON'
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |         ^~~~~~~~~~~~
   include/linux/gfp.h:347:63: note: each undeclared identifier is reported only once for each function it appears in
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |                                                               ^~~~~~~~~~~~~~~
   include/linux/compiler_types.h:302:23: note: in definition of macro '__compiletime_assert'
     302 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:322:9: note: in expansion of macro '_compiletime_assert'
     322 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   include/linux/gfp.h:347:9: note: in expansion of macro 'BUILD_BUG_ON'
     347 |         BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
         |         ^~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:5,
                    from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
>> include/linux/gfp.h:349:22: error: 'page_group_by_mobility_disabled' undeclared (first use in this function)
     349 |         if (unlikely(page_group_by_mobility_disabled))
         |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   In file included from include/linux/mm.h:10,
                    from arch/arc/include/asm/arcregs.h:149,
                    from arch/arc/include/asm/irqflags-compact.h:16,
                    from arch/arc/include/asm/irqflags.h:11,
                    from include/linux/irqflags.h:16,
                    from arch/arc/include/asm/smp.h:102,
                    from arch/arc/include/asm/cmpxchg.h:13,
                    from arch/arc/include/asm/atomic.h:13,
                    from include/linux/atomic.h:7,
                    from include/asm-generic/bitops/lock.h:5,
                    from arch/arc/include/asm/bitops.h:188,
                    from include/linux/bitops.h:33,
                    from include/linux/log2.h:12,
                    from kernel/bounds.c:13:
   include/linux/gfp.h:350:24: error: 'MIGRATE_UNMOVABLE' undeclared (first use in this function)
     350 |                 return MIGRATE_UNMOVABLE;
         |                        ^~~~~~~~~~~~~~~~~
   include/linux/gfp.h: At top level:
   include/linux/gfp.h:441:25: warning: "ZONES_SHIFT" is not defined, evaluates to 0 [-Wundef]
     441 | #define GFP_ZONES_SHIFT ZONES_SHIFT
         |                         ^~~~~~~~~~~
   include/linux/gfp.h:444:10: note: in expansion of macro 'GFP_ZONES_SHIFT'
     444 | #if 16 * GFP_ZONES_SHIFT > BITS_PER_LONG
         |          ^~~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'gfp_zone':
   include/linux/gfp.h:441:25: error: 'ZONES_SHIFT' undeclared (first use in this function); did you mean 'NMI_SHIFT'?
     441 | #define GFP_ZONES_SHIFT ZONES_SHIFT
         |                         ^~~~~~~~~~~
   include/linux/gfp.h:449:29: note: in expansion of macro 'GFP_ZONES_SHIFT'
     449 |         (ZONE_NORMAL << 0 * GFP_ZONES_SHIFT)                                   \
         |                             ^~~~~~~~~~~~~~~
   include/linux/gfp.h:481:14: note: in expansion of macro 'GFP_ZONE_TABLE'
     481 |         z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) &
         |              ^~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'gfp_zonelist':
   include/linux/gfp.h:500:16: error: 'ZONELIST_FALLBACK' undeclared (first use in this function)
     500 |         return ZONELIST_FALLBACK;
         |                ^~~~~~~~~~~~~~~~~
   include/linux/gfp.h: In function 'node_zonelist':
   include/linux/gfp.h:514:16: error: implicit declaration of function 'NODE_DATA' [-Werror=implicit-function-declaration]
     514 |         return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
         |                ^~~~~~~~~
   include/linux/gfp.h:514:30: error: invalid type argument of '->' (have 'int')
     514 |         return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
         |                              ^~
   include/linux/gfp.h: At top level:
   include/linux/gfp.h:525:17: error: unknown type name 'nodemask_t'
     525 |                 nodemask_t *nodemask);
         |                 ^~~~~~~~~~
   include/linux/gfp.h:527:17: error: unknown type name 'nodemask_t'
     527 |                 nodemask_t *nodemask);
         |                 ^~~~~~~~~~
   include/linux/gfp.h:530:33: error: unknown type name 'nodemask_t'
     530 |                                 nodemask_t *nodemask, int nr_pages,
         |                                 ^~~~~~~~~~
   include/linux/gfp.h: In function 'alloc_pages_bulk_list':
   include/linux/gfp.h:538:16: error: implicit declaration of function '__alloc_pages_bulk'; did you mean 'alloc_pages_bulk_list'? [-Werror=implicit-function-declaration]
     538 |         return __alloc_pages_bulk(gfp, numa_mem_id(), NULL, nr_pages, list, NULL);
         |                ^~~~~~~~~~~~~~~~~~
         |                alloc_pages_bulk_list
   include/linux/gfp.h: In function 'alloc_pages_bulk_array_node':
   include/linux/gfp.h:550:20: error: 'NUMA_NO_NODE' undeclared (first use in this function)
     550 |         if (nid == NUMA_NO_NODE)
         |                    ^~~~~~~~~~~~
   In file included from include/asm-generic/bug.h:5,
                    from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/gfp.h: In function '__alloc_pages_node':
   include/linux/gfp.h:563:37: error: 'MAX_NUMNODES' undeclared (first use in this function)
     563 |         VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
         |                                     ^~~~~~~~~~~~
   include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
      78 | # define unlikely(x)    __builtin_expect(!!(x), 0)
         |                                             ^
   include/linux/mmdebug.h:17:25: note: in expansion of macro 'BUG_ON'
      17 | #define VM_BUG_ON(cond) BUG_ON(cond)
         |                         ^~~~~~
   include/linux/gfp.h:563:9: note: in expansion of macro 'VM_BUG_ON'
     563 |         VM_BUG_ON(nid < 0 || nid >= MAX_NUMNODES);
         |         ^~~~~~~~~
   In file included from arch/arc/include/asm/bug.h:30,
                    from include/linux/bug.h:5,
                    from include/linux/page-flags.h:10,
                    from kernel/bounds.c:10:
   include/linux/gfp.h:564:52: error: implicit declaration of function 'node_online'; did you mean 'node_zonelist'? [-Werror=implicit-function-declaration]
     564 |         VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
         |                                                    ^~~~~~~~~~~
   include/asm-generic/bug.h:121:32: note: in definition of macro 'WARN_ON'
     121 |         int __ret_warn_on = !!(condition);                              \
         |                                ^~~~~~~~~
   include/linux/gfp.h:564:9: note: in expansion of macro 'VM_WARN_ON'
     564 |         VM_WARN_ON((gfp_mask & __GFP_THISNODE) && !node_online(nid));
         |         ^~~~~~~~~~

vim +/MIGRATE_MOVABLE +347 include/linux/gfp.h

6cb062296f73e747 Christoph Lameter       2007-10-16  342  
01c0bfe061f309b8 Wei Yang                2020-06-03  343  static inline int gfp_migratetype(const gfp_t gfp_flags)
467c996c1e191063 Mel Gorman              2007-10-16  344  {
016c13daa5c9e482 Mel Gorman              2015-11-06  345  	VM_WARN_ON((gfp_flags & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
016c13daa5c9e482 Mel Gorman              2015-11-06  346  	BUILD_BUG_ON((1UL << GFP_MOVABLE_SHIFT) != ___GFP_MOVABLE);
016c13daa5c9e482 Mel Gorman              2015-11-06 @347  	BUILD_BUG_ON((___GFP_MOVABLE >> GFP_MOVABLE_SHIFT) != MIGRATE_MOVABLE);
467c996c1e191063 Mel Gorman              2007-10-16  348  
467c996c1e191063 Mel Gorman              2007-10-16 @349  	if (unlikely(page_group_by_mobility_disabled))
467c996c1e191063 Mel Gorman              2007-10-16 @350  		return MIGRATE_UNMOVABLE;
467c996c1e191063 Mel Gorman              2007-10-16  351  
467c996c1e191063 Mel Gorman              2007-10-16  352  	/* Group based on mobility */
016c13daa5c9e482 Mel Gorman              2015-11-06  353  	return (gfp_flags & GFP_MOVABLE_MASK) >> GFP_MOVABLE_SHIFT;
467c996c1e191063 Mel Gorman              2007-10-16  354  }
dd56b046426760aa Mel Gorman              2015-11-06  355  #undef GFP_MOVABLE_MASK
dd56b046426760aa Mel Gorman              2015-11-06  356  #undef GFP_MOVABLE_SHIFT
a2f1b424900715ed Andi Kleen              2005-11-05  357  
d0164adc89f6bb37 Mel Gorman              2015-11-06  358  static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
d0164adc89f6bb37 Mel Gorman              2015-11-06  359  {
543dfb2df8ebb3eb Joshua Clayton          2016-01-14  360  	return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
d0164adc89f6bb37 Mel Gorman              2015-11-06  361  }
d0164adc89f6bb37 Mel Gorman              2015-11-06  362  
20eb4f29b60286e0 Tejun Heo               2019-10-24  363  /**
20eb4f29b60286e0 Tejun Heo               2019-10-24  364   * gfpflags_normal_context - is gfp_flags a normal sleepable context?
20eb4f29b60286e0 Tejun Heo               2019-10-24  365   * @gfp_flags: gfp_flags to test
20eb4f29b60286e0 Tejun Heo               2019-10-24  366   *
20eb4f29b60286e0 Tejun Heo               2019-10-24  367   * Test whether @gfp_flags indicates that the allocation is from the
20eb4f29b60286e0 Tejun Heo               2019-10-24  368   * %current context and allowed to sleep.
20eb4f29b60286e0 Tejun Heo               2019-10-24  369   *
20eb4f29b60286e0 Tejun Heo               2019-10-24  370   * An allocation being allowed to block doesn't mean it owns the %current
20eb4f29b60286e0 Tejun Heo               2019-10-24  371   * context.  When direct reclaim path tries to allocate memory, the
20eb4f29b60286e0 Tejun Heo               2019-10-24  372   * allocation context is nested inside whatever %current was doing at the
20eb4f29b60286e0 Tejun Heo               2019-10-24  373   * time of the original allocation.  The nested allocation may be allowed
20eb4f29b60286e0 Tejun Heo               2019-10-24  374   * to block but modifying anything %current owns can corrupt the outer
20eb4f29b60286e0 Tejun Heo               2019-10-24  375   * context's expectations.
20eb4f29b60286e0 Tejun Heo               2019-10-24  376   *
20eb4f29b60286e0 Tejun Heo               2019-10-24  377   * %true result from this function indicates that the allocation context
20eb4f29b60286e0 Tejun Heo               2019-10-24  378   * can sleep and use anything that's associated with %current.
20eb4f29b60286e0 Tejun Heo               2019-10-24  379   */
20eb4f29b60286e0 Tejun Heo               2019-10-24  380  static inline bool gfpflags_normal_context(const gfp_t gfp_flags)
20eb4f29b60286e0 Tejun Heo               2019-10-24  381  {
20eb4f29b60286e0 Tejun Heo               2019-10-24  382  	return (gfp_flags & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC)) ==
20eb4f29b60286e0 Tejun Heo               2019-10-24  383  		__GFP_DIRECT_RECLAIM;
20eb4f29b60286e0 Tejun Heo               2019-10-24  384  }
20eb4f29b60286e0 Tejun Heo               2019-10-24  385  
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  386  #ifdef CONFIG_HIGHMEM
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  387  #define OPT_ZONE_HIGHMEM ZONE_HIGHMEM
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  388  #else
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  389  #define OPT_ZONE_HIGHMEM ZONE_NORMAL
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  390  #endif
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  391  
4b51d66989218aad Christoph Lameter       2007-02-10  392  #ifdef CONFIG_ZONE_DMA
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  393  #define OPT_ZONE_DMA ZONE_DMA
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  394  #else
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  395  #define OPT_ZONE_DMA ZONE_NORMAL
4b51d66989218aad Christoph Lameter       2007-02-10  396  #endif
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  397  
4e4785bcf0c85032 Christoph Lameter       2006-09-25  398  #ifdef CONFIG_ZONE_DMA32
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  399  #define OPT_ZONE_DMA32 ZONE_DMA32
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  400  #else
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  401  #define OPT_ZONE_DMA32 ZONE_NORMAL
4e4785bcf0c85032 Christoph Lameter       2006-09-25  402  #endif
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  403  
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  404  /*
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  405   * GFP_ZONE_TABLE is a word size bitstring that is used for looking up the
ac2e8e40acf4c73e Hao Lee                 2017-05-03  406   * zone to use given the lowest 4 bits of gfp_t. Entries are GFP_ZONES_SHIFT
ac2e8e40acf4c73e Hao Lee                 2017-05-03  407   * bits long and there are 16 of them to cover all possible combinations of
263ff5d8e82e5772 matt mooney             2010-05-24  408   * __GFP_DMA, __GFP_DMA32, __GFP_MOVABLE and __GFP_HIGHMEM.
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  409   *
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  410   * The zone fallback order is MOVABLE=>HIGHMEM=>NORMAL=>DMA32=>DMA.
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  411   * But GFP_MOVABLE is not only a zone specifier but also an allocation
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  412   * policy. Therefore __GFP_MOVABLE plus another zone selector is valid.
263ff5d8e82e5772 matt mooney             2010-05-24  413   * Only 1 bit of the lowest 3 bits (DMA,DMA32,HIGHMEM) can be set to "1".
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  414   *
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  415   *       bit       result
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  416   *       =================
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  417   *       0x0    => NORMAL
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  418   *       0x1    => DMA or NORMAL
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  419   *       0x2    => HIGHMEM or NORMAL
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  420   *       0x3    => BAD (DMA+HIGHMEM)
4b33b6959581d509 Huaisheng Ye            2018-06-07  421   *       0x4    => DMA32 or NORMAL
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  422   *       0x5    => BAD (DMA+DMA32)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  423   *       0x6    => BAD (HIGHMEM+DMA32)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  424   *       0x7    => BAD (HIGHMEM+DMA32+DMA)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  425   *       0x8    => NORMAL (MOVABLE+0)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  426   *       0x9    => DMA or NORMAL (MOVABLE+DMA)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  427   *       0xa    => MOVABLE (Movable is valid only if HIGHMEM is set too)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  428   *       0xb    => BAD (MOVABLE+HIGHMEM+DMA)
4b33b6959581d509 Huaisheng Ye            2018-06-07  429   *       0xc    => DMA32 or NORMAL (MOVABLE+DMA32)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  430   *       0xd    => BAD (MOVABLE+DMA32+DMA)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  431   *       0xe    => BAD (MOVABLE+DMA32+HIGHMEM)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  432   *       0xf    => BAD (MOVABLE+DMA32+HIGHMEM+DMA)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  433   *
b11a7b94100cba5e Dan Williams            2016-03-17  434   * GFP_ZONES_SHIFT must be <= 2 on 32 bit platforms.
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  435   */
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  436  
b11a7b94100cba5e Dan Williams            2016-03-17  437  #if defined(CONFIG_ZONE_DEVICE) && (MAX_NR_ZONES-1) <= 4
b11a7b94100cba5e Dan Williams            2016-03-17  438  /* ZONE_DEVICE is not a valid GFP zone specifier */
b11a7b94100cba5e Dan Williams            2016-03-17  439  #define GFP_ZONES_SHIFT 2
b11a7b94100cba5e Dan Williams            2016-03-17  440  #else
b11a7b94100cba5e Dan Williams            2016-03-17 @441  #define GFP_ZONES_SHIFT ZONES_SHIFT
b11a7b94100cba5e Dan Williams            2016-03-17  442  #endif
b11a7b94100cba5e Dan Williams            2016-03-17  443  
b11a7b94100cba5e Dan Williams            2016-03-17  444  #if 16 * GFP_ZONES_SHIFT > BITS_PER_LONG
b11a7b94100cba5e Dan Williams            2016-03-17  445  #error GFP_ZONES_SHIFT too large to create GFP_ZONE_TABLE integer
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  446  #endif
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  447  
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  448  #define GFP_ZONE_TABLE ( \
b11a7b94100cba5e Dan Williams            2016-03-17  449  	(ZONE_NORMAL << 0 * GFP_ZONES_SHIFT)				       \
b11a7b94100cba5e Dan Williams            2016-03-17  450  	| (OPT_ZONE_DMA << ___GFP_DMA * GFP_ZONES_SHIFT)		       \
b11a7b94100cba5e Dan Williams            2016-03-17  451  	| (OPT_ZONE_HIGHMEM << ___GFP_HIGHMEM * GFP_ZONES_SHIFT)	       \
b11a7b94100cba5e Dan Williams            2016-03-17  452  	| (OPT_ZONE_DMA32 << ___GFP_DMA32 * GFP_ZONES_SHIFT)		       \
b11a7b94100cba5e Dan Williams            2016-03-17  453  	| (ZONE_NORMAL << ___GFP_MOVABLE * GFP_ZONES_SHIFT)		       \
b11a7b94100cba5e Dan Williams            2016-03-17  454  	| (OPT_ZONE_DMA << (___GFP_MOVABLE | ___GFP_DMA) * GFP_ZONES_SHIFT)    \
b11a7b94100cba5e Dan Williams            2016-03-17  455  	| (ZONE_MOVABLE << (___GFP_MOVABLE | ___GFP_HIGHMEM) * GFP_ZONES_SHIFT)\
b11a7b94100cba5e Dan Williams            2016-03-17  456  	| (OPT_ZONE_DMA32 << (___GFP_MOVABLE | ___GFP_DMA32) * GFP_ZONES_SHIFT)\
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  457  )
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  458  
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  459  /*
263ff5d8e82e5772 matt mooney             2010-05-24  460   * GFP_ZONE_BAD is a bitmap for all combinations of __GFP_DMA, __GFP_DMA32
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  461   * __GFP_HIGHMEM and __GFP_MOVABLE that are not permitted. One flag per
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  462   * entry starting with bit 0. Bit is set if the combination is not
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  463   * allowed.
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  464   */
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  465  #define GFP_ZONE_BAD ( \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  466  	1 << (___GFP_DMA | ___GFP_HIGHMEM)				      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  467  	| 1 << (___GFP_DMA | ___GFP_DMA32)				      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  468  	| 1 << (___GFP_DMA32 | ___GFP_HIGHMEM)				      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  469  	| 1 << (___GFP_DMA | ___GFP_DMA32 | ___GFP_HIGHMEM)		      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  470  	| 1 << (___GFP_MOVABLE | ___GFP_HIGHMEM | ___GFP_DMA)		      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  471  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA)		      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  472  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_HIGHMEM)		      \
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  473  	| 1 << (___GFP_MOVABLE | ___GFP_DMA32 | ___GFP_DMA | ___GFP_HIGHMEM)  \
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  474  )
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  475  
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  476  static inline enum zone_type gfp_zone(gfp_t flags)
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  477  {
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  478  	enum zone_type z;
16b56cf4b8a0fa9a Namhyung Kim            2010-10-26  479  	int bit = (__force int) (flags & GFP_ZONEMASK);
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  480  
b11a7b94100cba5e Dan Williams            2016-03-17  481  	z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) &
b11a7b94100cba5e Dan Williams            2016-03-17  482  					 ((1 << GFP_ZONES_SHIFT) - 1);
82d4b5779a758877 Dave Hansen             2011-05-24  483  	VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1);
b70d94ee438b3fd9 Christoph Lameter       2009-06-16  484  	return z;
4e4785bcf0c85032 Christoph Lameter       2006-09-25  485  }
4e4785bcf0c85032 Christoph Lameter       2006-09-25  486  
^1da177e4c3f4152 Linus Torvalds          2005-04-16  487  /*
^1da177e4c3f4152 Linus Torvalds          2005-04-16  488   * There is only one page-allocator function, and two main namespaces to
^1da177e4c3f4152 Linus Torvalds          2005-04-16  489   * it. The alloc_page*() variants return 'struct page *' and as such
^1da177e4c3f4152 Linus Torvalds          2005-04-16  490   * can allocate highmem pages, the *get*page*() variants return
^1da177e4c3f4152 Linus Torvalds          2005-04-16  491   * virtual kernel addresses to the allocated page(s).
^1da177e4c3f4152 Linus Torvalds          2005-04-16  492   */
^1da177e4c3f4152 Linus Torvalds          2005-04-16  493  
54a6eb5c4765aa57 Mel Gorman              2008-04-28  494  static inline int gfp_zonelist(gfp_t flags)
54a6eb5c4765aa57 Mel Gorman              2008-04-28  495  {
c00eb15a8914b8ba Yaowei Bai              2016-01-14  496  #ifdef CONFIG_NUMA
c00eb15a8914b8ba Yaowei Bai              2016-01-14  497  	if (unlikely(flags & __GFP_THISNODE))
c00eb15a8914b8ba Yaowei Bai              2016-01-14  498  		return ZONELIST_NOFALLBACK;
c00eb15a8914b8ba Yaowei Bai              2016-01-14  499  #endif
c00eb15a8914b8ba Yaowei Bai              2016-01-14 @500  	return ZONELIST_FALLBACK;
54a6eb5c4765aa57 Mel Gorman              2008-04-28  501  }
54a6eb5c4765aa57 Mel Gorman              2008-04-28  502  
^1da177e4c3f4152 Linus Torvalds          2005-04-16  503  /*
^1da177e4c3f4152 Linus Torvalds          2005-04-16  504   * We get the zone list from the current node and the gfp_mask.
cb152a1a95606aad Shijie Luo              2021-05-06  505   * This zone list contains a maximum of MAX_NUMNODES*MAX_NR_ZONES zones.
54a6eb5c4765aa57 Mel Gorman              2008-04-28  506   * There are two zonelists per node, one for all zones with memory and
54a6eb5c4765aa57 Mel Gorman              2008-04-28  507   * one containing just zones from the node the zonelist belongs to.
^1da177e4c3f4152 Linus Torvalds          2005-04-16  508   *
d3c251ab95b69f3d Mike Rapoport           2021-06-28  509   * For the case of non-NUMA systems the NODE_DATA() gets optimized to
d3c251ab95b69f3d Mike Rapoport           2021-06-28  510   * &contig_page_data at compile-time.
^1da177e4c3f4152 Linus Torvalds          2005-04-16  511   */
0e88460da6ab7bb6 Mel Gorman              2008-04-28  512  static inline struct zonelist *node_zonelist(int nid, gfp_t flags)
0e88460da6ab7bb6 Mel Gorman              2008-04-28  513  {
54a6eb5c4765aa57 Mel Gorman              2008-04-28 @514  	return NODE_DATA(nid)->node_zonelists + gfp_zonelist(flags);
0e88460da6ab7bb6 Mel Gorman              2008-04-28  515  }
^1da177e4c3f4152 Linus Torvalds          2005-04-16  516  
^1da177e4c3f4152 Linus Torvalds          2005-04-16  517  #ifndef HAVE_ARCH_FREE_PAGE
^1da177e4c3f4152 Linus Torvalds          2005-04-16  518  static inline void arch_free_page(struct page *page, int order) { }
^1da177e4c3f4152 Linus Torvalds          2005-04-16  519  #endif
cc102509074bba03 Nicholas Piggin         2006-12-06  520  #ifndef HAVE_ARCH_ALLOC_PAGE
cc102509074bba03 Nicholas Piggin         2006-12-06  521  static inline void arch_alloc_page(struct page *page, int order) { }
cc102509074bba03 Nicholas Piggin         2006-12-06  522  #endif
^1da177e4c3f4152 Linus Torvalds          2005-04-16  523  
84172f4bb7524244 Matthew Wilcox (Oracle  2021-04-29  524) struct page *__alloc_pages(gfp_t gfp, unsigned int order, int preferred_nid,
04ec6264f28793e5 Vlastimil Babka         2017-07-06 @525  		nodemask_t *nodemask);
da90006b76b64857 Andrew Morton           2021-09-16  526  struct folio *__folio_alloc(gfp_t gfp, unsigned int order, int preferred_nid,
da90006b76b64857 Andrew Morton           2021-09-16  527  		nodemask_t *nodemask);
e4048e5dc4aecec6 KOSAKI Motohiro         2008-07-23  528  
387ba26fb1cb9be9 Mel Gorman              2021-04-29  529  unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,
387ba26fb1cb9be9 Mel Gorman              2021-04-29  530  				nodemask_t *nodemask, int nr_pages,
0f87d9d30f21390d Mel Gorman              2021-04-29  531  				struct list_head *page_list,
0f87d9d30f21390d Mel Gorman              2021-04-29  532  				struct page **page_array);
387ba26fb1cb9be9 Mel Gorman              2021-04-29  533  
387ba26fb1cb9be9 Mel Gorman              2021-04-29  534  /* Bulk allocate order-0 pages */
387ba26fb1cb9be9 Mel Gorman              2021-04-29  535  static inline unsigned long
0f87d9d30f21390d Mel Gorman              2021-04-29  536  alloc_pages_bulk_list(gfp_t gfp, unsigned long nr_pages, struct list_head *list)
387ba26fb1cb9be9 Mel Gorman              2021-04-29  537  {
0f87d9d30f21390d Mel Gorman              2021-04-29 @538  	return __alloc_pages_bulk(gfp, numa_mem_id(), NULL, nr_pages, list, NULL);
0f87d9d30f21390d Mel Gorman              2021-04-29  539  }
0f87d9d30f21390d Mel Gorman              2021-04-29  540  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#7 lore raw

RFC PATCH v2 3/3 mm: replace open-coded PG2KB/KB2PG variants with macros

In reply to Oleksandr Natalenko
---
 arch/alpha/kernel/setup.c                     |  3 +--
 arch/mips/mm/init.c                           |  2 +-
 arch/x86/kernel/cpu/mtrr/cleanup.c            | 17 +++++++++--------
 block/blk-sysfs.c                             |  9 +++++----
 drivers/gpu/drm/v3d/v3d_debugfs.c             |  3 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  5 +++--
 drivers/md/md-bitmap.c                        |  4 ++--
 fs/ceph/addr.c                                |  2 +-
 fs/ceph/super.h                               |  3 ++-
 fs/fs-writeback.c                             |  2 +-
 fs/nfs/write.c                                |  4 ++--
 fs/nfsd/nfscache.c                            |  3 ++-
 fs/proc/meminfo.c                             |  4 ++--
 fs/proc/task_mmu.c                            |  3 ++-
 kernel/events/core.c                          |  2 +-
 kernel/fork.c                                 |  2 +-
 mm/backing-dev.c                              |  2 +-
 mm/hugetlb.c                                  |  2 +-
 mm/mmap.c                                     |  6 +++---
 mm/nommu.c                                    |  4 ++--
 mm/page-writeback.c                           |  4 ++--
 mm/page_alloc.c                               |  2 +-
 mm/shmem.c                                    |  3 +--
 mm/swap_state.c                               |  5 ++---
 mm/swapfile.c                                 | 11 +++++------
 mm/util.c                                     |  6 +++---
 26 files changed, 58 insertions(+), 55 deletions(-)
arch/alpha/kernel/setup.c +1 -2
index b4fbbba30aa2..c4282224c950 100644
@@ -355,8 +355,7 @@ setup_memory(void *kernel_end)
 	if (mem_size_limit && max_low_pfn >= mem_size_limit)
 	{
 		printk("setup: forcing memory size to %ldK (from %ldK).\n",
-		       mem_size_limit << (PAGE_SHIFT - 10),
-		       max_low_pfn    << (PAGE_SHIFT - 10));
+		       PG2KB(mem_size_limit), PG2KB(max_low_pfn));
 		max_low_pfn = mem_size_limit;
 	}
 
arch/mips/mm/init.c +1 -1
index 19347dc6bbf8..351a44437377 100644
@@ -414,7 +414,7 @@ void __init paging_init(void)
 	if (cpu_has_dc_aliases && max_low_pfn != highend_pfn) {
 		printk(KERN_WARNING "This processor doesn't support highmem."
 		       " %ldk highmem ignored\n",
-		       (highend_pfn - max_low_pfn) << (PAGE_SHIFT - 10));
+		       PG2KB(highend_pfn - max_low_pfn));
 		max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn;
 	}
 #endif
arch/x86/kernel/cpu/mtrr/cleanup.c +9 -8
index b5f43049fa5f..327aef0ff945 100644
@@ -18,6 +18,7 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 #include <linux/init.h>
+#include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/smp.h>
 #include <linux/cpu.h>
@@ -204,8 +205,8 @@ static void __init
 save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek,
 	      unsigned char type)
 {
-	range_state[reg].base_pfn = basek >> (PAGE_SHIFT - 10);
-	range_state[reg].size_pfn = sizek >> (PAGE_SHIFT - 10);
+	range_state[reg].base_pfn = KB2PG(basek);
+	range_state[reg].size_pfn = KB2PG(sizek);
 	range_state[reg].type = type;
 }
 
@@ -216,8 +217,8 @@ static void __init set_var_mtrr_all(unsigned int address_bits)
 	unsigned int reg;
 
 	for (reg = 0; reg < num_var_ranges; reg++) {
-		basek = range_state[reg].base_pfn << (PAGE_SHIFT - 10);
-		sizek = range_state[reg].size_pfn << (PAGE_SHIFT - 10);
+		basek = PG2KB(range_state[reg].base_pfn);
+		sizek = PG2KB(range_state[reg].size_pfn);
 		type = range_state[reg].type;
 
 		set_var_mtrr(reg, basek, sizek, type, address_bits);
@@ -415,8 +416,8 @@ set_var_mtrr_range(struct var_mtrr_state *state, unsigned long base_pfn,
 	if (state->reg >= num_var_ranges)
 		return;
 
-	basek = base_pfn << (PAGE_SHIFT - 10);
-	sizek = size_pfn << (PAGE_SHIFT - 10);
+	basek = PG2KB(base_pfn);
+	sizek = PG2KB(size_pfn);
 
 	/* See if I can merge with the last range: */
 	if ((basek <= 1024) ||
@@ -533,12 +534,12 @@ static void __init print_out_mtrr_range_state(void)
 
 	for (i = 0; i < num_var_ranges; i++) {
 
-		size_base = range_state[i].size_pfn << (PAGE_SHIFT - 10);
+		size_base = PG2KB(range_state[i].size_pfn);
 		if (!size_base)
 			continue;
 
 		size_base = to_size_factor(size_base, &size_factor);
-		start_base = range_state[i].base_pfn << (PAGE_SHIFT - 10);
+		start_base = PG2KB(range_state[i].base_pfn);
 		start_base = to_size_factor(start_base, &start_factor);
 		type = range_state[i].type;
 
block/blk-sysfs.c +5 -4
index 614d9d47de36..25e0bcc1208f 100644
@@ -4,6 +4,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/bio.h>
 #include <linux/blkdev.h>
@@ -92,7 +93,7 @@ static ssize_t queue_ra_show(struct request_queue *q, char *page)
 
 	if (!q->disk)
 		return -EINVAL;
-	ra_kb = q->disk->bdi->ra_pages << (PAGE_SHIFT - 10);
+	ra_kb = PG2KB(q->disk->bdi->ra_pages);
 	return queue_var_show(ra_kb, page);
 }
 
@@ -107,7 +108,7 @@ queue_ra_store(struct request_queue *q, const char *page, size_t count)
 	ret = queue_var_store(&ra_kb, page, count);
 	if (ret < 0)
 		return ret;
-	q->disk->bdi->ra_pages = ra_kb >> (PAGE_SHIFT - 10);
+	q->disk->bdi->ra_pages = KB2PG(ra_kb);
 	return ret;
 }
 
@@ -240,7 +241,7 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
 {
 	unsigned long max_sectors_kb,
 		max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1,
-			page_kb = 1 << (PAGE_SHIFT - 10);
+			page_kb = PG2KB(1);
 	ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
 
 	if (ret < 0)
@@ -255,7 +256,7 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
 	spin_lock_irq(&q->queue_lock);
 	q->limits.max_sectors = max_sectors_kb << 1;
 	if (q->disk)
-		q->disk->bdi->io_pages = max_sectors_kb >> (PAGE_SHIFT - 10);
+		q->disk->bdi->io_pages = KB2PG(max_sectors_kb);
 	spin_unlock_irq(&q->queue_lock);
 
 	return ret;
drivers/gpu/drm/v3d/v3d_debugfs.c +2 -1
index e76b24bb8828..29461f9056b3 100644
@@ -4,6 +4,7 @@
 #include <linux/circ_buf.h>
 #include <linux/ctype.h>
 #include <linux/debugfs.h>
+#include <linux/mm.h>
 #include <linux/pm_runtime.h>
 #include <linux/seq_file.h>
 
@@ -203,7 +204,7 @@ static int v3d_debugfs_bo_stats(struct seq_file *m, void *unused)
 	seq_printf(m, "allocated bos:          %d\n",
 		   v3d->bo_stats.num_allocated);
 	seq_printf(m, "allocated bo size (kb): %ld\n",
-		   (long)v3d->bo_stats.pages_allocated << (PAGE_SHIFT - 10));
+		   PG2KB((long)v3d->bo_stats.pages_allocated));
 	mutex_unlock(&v3d->bo_lock);
 
 	return 0;
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +3 -2
index b2c4af331c9d..1083a054d235 100644
@@ -32,6 +32,7 @@
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
 #include <linux/idr.h>
+#include <linux/mm.h>
 #include <linux/spinlock.h>
 #include <linux/kernel.h>
 
@@ -92,14 +93,14 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man,
 				new_max_pages = gman->max_gmr_pages * 2;
 			if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) {
 				DRM_WARN("vmwgfx: increasing guest mob limits to %u kB.\n",
-					 ((new_max_pages) << (PAGE_SHIFT - 10)));
+					 PG2KB(new_max_pages));
 
 				gman->max_gmr_pages = new_max_pages;
 			} else {
 				char buf[256];
 				snprintf(buf, sizeof(buf),
 					 "vmwgfx, error: guest graphics is out of memory (mob limit at: %ukB).\n",
-					 ((gman->max_gmr_pages) << (PAGE_SHIFT - 10)));
+					 PG2KB(gman->max_gmr_pages));
 				vmw_host_printf(buf);
 				DRM_WARN("%s", buf);
 				goto nospace;
drivers/md/md-bitmap.c +2 -2
index e29c6298ef5c..85277df1da5a 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/blkdev.h>
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
@@ -2038,8 +2039,7 @@ void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
 		   "%lu%s chunk",
 		   counts->pages - counts->missing_pages,
 		   counts->pages,
-		   (counts->pages - counts->missing_pages)
-		   << (PAGE_SHIFT - 10),
+		   PG2KB(counts->pages - counts->missing_pages),
 		   chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize,
 		   chunk_kb ? "KB" : "B");
 	if (bitmap->storage.file) {
fs/ceph/addr.c +1 -1
index 99b80b5c7a93..e9d296cffb83 100644
@@ -57,7 +57,7 @@
  * accounting is preserved.
  */
 
-#define CONGESTION_ON_THRESH(congestion_kb) (congestion_kb >> (PAGE_SHIFT-10))
+#define CONGESTION_ON_THRESH(congestion_kb) KB2PG(congestion_kb)
 #define CONGESTION_OFF_THRESH(congestion_kb)				\
 	(CONGESTION_ON_THRESH(congestion_kb) -				\
 	 (CONGESTION_ON_THRESH(congestion_kb) >> 2))
fs/ceph/super.h +2 -1
index a40eb14c282a..328d40843dbc 100644
@@ -9,6 +9,7 @@
 #include <linux/completion.h>
 #include <linux/exportfs.h>
 #include <linux/fs.h>
+#include <linux/mm.h>
 #include <linux/mempool.h>
 #include <linux/pagemap.h>
 #include <linux/wait.h>
@@ -908,7 +909,7 @@ static inline int default_congestion_kb(void)
 	 * This allows larger machines to have larger/more transfers.
 	 * Limit the default to 256M
 	 */
-	congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
+	congestion_kb = PG2KB(16*int_sqrt(totalram_pages()));
 	if (congestion_kb > 256*1024)
 		congestion_kb = 256*1024;
 
fs/fs-writeback.c +1 -1
index 81ec192ce067..1b694e6a27c0 100644
@@ -34,7 +34,7 @@
 /*
  * 4MB minimal write chunk size
  */
-#define MIN_WRITEBACK_PAGES	(4096UL >> (PAGE_SHIFT - 10))
+#define MIN_WRITEBACK_PAGES	KB2PG(4096UL)
 
 /*
  * Passed into wb_writeback(), essentially a subset of writeback_control
fs/nfs/write.c +2 -2
index eae9bf114041..9b565808c12f 100644
@@ -401,7 +401,7 @@ static int wb_priority(struct writeback_control *wbc)
 
 int nfs_congestion_kb;
 
-#define NFS_CONGESTION_ON_THRESH 	(nfs_congestion_kb >> (PAGE_SHIFT-10))
+#define NFS_CONGESTION_ON_THRESH 	KB2PG(nfs_congestion_kb)
 #define NFS_CONGESTION_OFF_THRESH	\
 	(NFS_CONGESTION_ON_THRESH - (NFS_CONGESTION_ON_THRESH >> 2))
 
@@ -2173,7 +2173,7 @@ int __init nfs_init_writepagecache(void)
 	 * This allows larger machines to have larger/more transfers.
 	 * Limit the default to 256M
 	 */
-	nfs_congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
+	nfs_congestion_kb = PG2KB(16*int_sqrt(totalram_pages()));
 	if (nfs_congestion_kb > 256*1024)
 		nfs_congestion_kb = 256*1024;
 
fs/nfsd/nfscache.c +2 -1
index 96cdf77925f3..aeb464f88fa7 100644
@@ -9,6 +9,7 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <[email protected]>
  */
 
+#include <linux/mm.h>
 #include <linux/sunrpc/svc_xprt.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
@@ -70,7 +71,7 @@ nfsd_cache_size_limit(void)
 	unsigned int limit;
 	unsigned long low_pages = totalram_pages() - totalhigh_pages();
 
-	limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10);
+	limit = PG2KB(16 * int_sqrt(low_pages));
 	return min_t(unsigned int, limit, 256*1024);
 }
 
fs/proc/meminfo.c +2 -2
index 6fa761c9cc78..5443be3060a8 100644
@@ -25,7 +25,7 @@ void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
 
 static void show_val_kb(struct seq_file *m, const char *s, unsigned long num)
 {
-	seq_put_decimal_ull_width(m, s, num << (PAGE_SHIFT - 10), 8);
+	seq_put_decimal_ull_width(m, s, PG2KB(num), 8);
 	seq_write(m, " kB\n", 4);
 }
 
@@ -124,7 +124,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
 
 #ifdef CONFIG_MEMORY_FAILURE
 	seq_printf(m, "HardwareCorrupted: %5lu kB\n",
-		   atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10));
+		   PG2KB(atomic_long_read(&num_poisoned_pages)));
 #endif
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
fs/proc/task_mmu.c +2 -1
index cf25be3e0321..11798f84292c 100644
@@ -3,6 +3,7 @@
 #include <linux/vmacache.h>
 #include <linux/hugetlb.h>
 #include <linux/huge_mm.h>
+#include <linux/mm.h>
 #include <linux/mount.h>
 #include <linux/seq_file.h>
 #include <linux/highmem.h>
@@ -26,7 +27,7 @@
 #include "internal.h"
 
 #define SEQ_PUT_DEC(str, val) \
-		seq_put_decimal_ull_width(m, str, (val) << (PAGE_SHIFT-10), 8)
+		seq_put_decimal_ull_width(m, str, PG2KB(val), 8)
 void task_mem(struct seq_file *m, struct mm_struct *mm)
 {
 	unsigned long text, lib, swap, anon, file, shmem;
kernel/events/core.c +1 -1
index 349f80aa9e7d..ee290e405d00 100644
@@ -6267,7 +6267,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	user_extra = nr_pages + 1;
 
 accounting:
-	user_lock_limit = sysctl_perf_event_mlock >> (PAGE_SHIFT - 10);
+	user_lock_limit = KB2PG(sysctl_perf_event_mlock);
 
 	/*
 	 * Increase the limit linearly with more CPUs:
kernel/fork.c +1 -1
index 723125f2cbed..04302967685f 100644
@@ -2325,7 +2325,7 @@ static __latent_entropy struct task_struct *copy_process(
 	}
 
 	p->nr_dirtied = 0;
-	p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10);
+	p->nr_dirtied_pause = KB2PG(128);
 	p->dirty_paused_when = 0;
 
 	p->pdeath_signal = 0;
mm/backing-dev.c +1 -1
index b1d9c7bb35b3..c0820114e1dd 100644
@@ -140,7 +140,7 @@ static ssize_t read_ahead_kb_store(struct device *dev,
 	if (ret < 0)
 		return ret;
 
-	bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10);
+	bdi->ra_pages = KB2PG(read_ahead_kb);
 
 	return count;
 }
mm/hugetlb.c +1 -1
index 6378c1066459..f496cef8abef 100644
@@ -4050,7 +4050,7 @@ void hugetlb_show_meminfo(void)
 void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
 {
 	seq_printf(m, "HugetlbPages:\t%8lu kB\n",
-		   atomic_long_read(&mm->hugetlb_usage) << (PAGE_SHIFT - 10));
+		   PG2KB(atomic_long_read(&mm->hugetlb_usage)));
 }
 
 /* Return the number pages of memory we physically have, in PAGE_SIZE units. */
mm/mmap.c +3 -3
index b22a07f5e761..95c4883d2a87 100644
@@ -3703,7 +3703,7 @@ static int init_user_reserve(void)
 {
 	unsigned long free_kbytes;
 
-	free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+	free_kbytes = PG2KB(global_zone_page_state(NR_FREE_PAGES));
 
 	sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
 	return 0;
@@ -3724,7 +3724,7 @@ static int init_admin_reserve(void)
 {
 	unsigned long free_kbytes;
 
-	free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+	free_kbytes = PG2KB(global_zone_page_state(NR_FREE_PAGES));
 
 	sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
 	return 0;
@@ -3768,7 +3768,7 @@ static int reserve_mem_notifier(struct notifier_block *nb,
 
 		break;
 	case MEM_OFFLINE:
-		free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+		free_kbytes = PG2KB(global_zone_page_state(NR_FREE_PAGES));
 
 		if (sysctl_user_reserve_kbytes > free_kbytes) {
 			init_user_reserve();
mm/nommu.c +2 -2
index 8943dc0e2132..783526838176 100644
@@ -1803,7 +1803,7 @@ static int __meminit init_user_reserve(void)
 {
 	unsigned long free_kbytes;
 
-	free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+	free_kbytes = PG2KB(global_zone_page_state(NR_FREE_PAGES));
 
 	sysctl_user_reserve_kbytes = min(free_kbytes / 32, 1UL << 17);
 	return 0;
@@ -1824,7 +1824,7 @@ static int __meminit init_admin_reserve(void)
 {
 	unsigned long free_kbytes;
 
-	free_kbytes = global_zone_page_state(NR_FREE_PAGES) << (PAGE_SHIFT - 10);
+	free_kbytes = PG2KB(global_zone_page_state(NR_FREE_PAGES));
 
 	sysctl_admin_reserve_kbytes = min(free_kbytes / 32, 1UL << 13);
 	return 0;
mm/page-writeback.c +2 -2
index 9c64490171e0..1e3ab56ded46 100644
@@ -50,7 +50,7 @@
  * Try to keep balance_dirty_pages() call intervals higher than this many pages
  * by raising pause time to max_pause when falls below it.
  */
-#define DIRTY_POLL_THRESH	(128 >> (PAGE_SHIFT - 10))
+#define DIRTY_POLL_THRESH	KB2PG(128)
 
 /*
  * Estimate write bandwidth at 200ms intervals.
@@ -1893,7 +1893,7 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping)
 
 	ratelimit = current->nr_dirtied_pause;
 	if (wb->dirty_exceeded)
-		ratelimit = min(ratelimit, 32 >> (PAGE_SHIFT - 10));
+		ratelimit = min(ratelimit, KB2PG(32));
 
 	preempt_disable();
 	/*
mm/page_alloc.c +1 -1
index 5fad2f6d7d5f..8617559ca211 100644
@@ -8350,7 +8350,7 @@ static void setup_per_zone_lowmem_reserve(void)
 
 static void __setup_per_zone_wmarks(void)
 {
-	unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10);
+	unsigned long pages_min = KB2PG(min_free_kbytes);
 	unsigned long lowmem_pages = 0;
 	struct zone *zone;
 	unsigned long flags;
mm/shmem.c +1 -2
index 6f975d4e08f4..95a9e0e81779 100644
@@ -3565,8 +3565,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
 	struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb);
 
 	if (sbinfo->max_blocks != shmem_default_max_blocks())
-		seq_printf(seq, ",size=%luk",
-			sbinfo->max_blocks << (PAGE_SHIFT - 10));
+		seq_printf(seq, ",size=%luk", PG2KB(sbinfo->max_blocks));
 	if (sbinfo->max_inodes != shmem_default_max_inodes())
 		seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
 	if (sbinfo->mode != (0777 | S_ISVTX))
mm/swap_state.c +2 -3
index 8d4104242100..0a11ca2aba50 100644
@@ -76,9 +76,8 @@ void show_swap_cache_info(void)
 	printk("Swap cache stats: add %lu, delete %lu, find %lu/%lu\n",
 		swap_cache_info.add_total, swap_cache_info.del_total,
 		swap_cache_info.find_success, swap_cache_info.find_total);
-	printk("Free swap  = %ldkB\n",
-		get_nr_swap_pages() << (PAGE_SHIFT - 10));
-	printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
+	printk("Free swap  = %ldkB\n", PG2KB(get_nr_swap_pages()));
+	printk("Total swap = %lukB\n", PG2KB(total_swap_pages));
 }
 
 void *get_shadow_from_swap_cache(swp_entry_t entry)
mm/swapfile.c +5 -6
index e3dcaeecc50f..1a8f95edd3c3 100644
@@ -2770,8 +2770,8 @@ static int swap_show(struct seq_file *swap, void *v)
 		return 0;
 	}
 
-	bytes = si->pages << (PAGE_SHIFT - 10);
-	inuse = si->inuse_pages << (PAGE_SHIFT - 10);
+	bytes = PG2KB(si->pages);
+	inuse = PG2KB(si->inuse_pages);
 
 	file = si->swap_file;
 	len = seq_file_path(swap, file, " \t\n\\");
@@ -2996,8 +2996,7 @@ static unsigned long read_swap_header(struct swap_info_struct *p,
 	}
 	if (last_page > maxpages) {
 		pr_warn("Truncating oversized swap area, only using %luk out of %luk\n",
-			maxpages << (PAGE_SHIFT - 10),
-			last_page << (PAGE_SHIFT - 10));
+			PG2KB(maxpages), PG2KB(last_page));
 	}
 	if (maxpages > last_page) {
 		maxpages = last_page + 1;
@@ -3338,8 +3337,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 	enable_swap_info(p, prio, swap_map, cluster_info, frontswap_map);
 
 	pr_info("Adding %uk swap on %s.  Priority:%d extents:%d across:%lluk %s%s%s%s%s\n",
-		p->pages<<(PAGE_SHIFT-10), name->name, p->prio,
-		nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10),
+		PG2KB(p->pages), name->name, p->prio,
+		nr_extents, PG2KB((unsigned long long)span),
 		(p->flags & SWP_SOLIDSTATE) ? "SS" : "",
 		(p->flags & SWP_DISCARDABLE) ? "D" : "",
 		(p->flags & SWP_AREA_DISCARD) ? "s" : "",
mm/util.c +3 -3
index 4ac87f1b30f1..6d301ddfc395 100644
@@ -848,7 +848,7 @@ unsigned long vm_commit_limit(void)
 	unsigned long allowed;
 
 	if (sysctl_overcommit_kbytes)
-		allowed = sysctl_overcommit_kbytes >> (PAGE_SHIFT - 10);
+		allowed = KB2PG(sysctl_overcommit_kbytes);
 	else
 		allowed = ((totalram_pages() - hugetlb_total_pages())
 			   * sysctl_overcommit_ratio / 100);
@@ -921,13 +921,13 @@ int __vm_enough_memory(struct mm_struct *mm, long pages, int cap_sys_admin)
 	 * Reserve some for root
 	 */
 	if (!cap_sys_admin)
-		allowed -= sysctl_admin_reserve_kbytes >> (PAGE_SHIFT - 10);
+		allowed -= KB2PG(sysctl_admin_reserve_kbytes);
 
 	/*
 	 * Don't let a single process grow so big a user can't recover
 	 */
 	if (mm) {
-		long reserve = sysctl_user_reserve_kbytes >> (PAGE_SHIFT - 10);
+		long reserve = KB2PG(sysctl_user_reserve_kbytes);
 
 		allowed -= min_t(long, mm->total_vm / 32, reserve);
 	}
Signature · 1 line
2.33.0