tree:
https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.15
head: b4852fbf90916fdc2f1e0e282e100f7e0e889d77
commit: 467d55003e7cac35a55032ae02df445c18566434 [989/2818] CHROMIUM: mm: move low memory
code
config:
arm-chromiumos-arm-customedconfig-chrome-os:chromeos-5.15:b4852fbf90916fdc2f1e0e282e100f7e0e889d77
(
https://download.01.org/0day-ci/archive/20211212/202112120914.wBfKM0Ox-lk...)
compiler: arm-linux-gnueabi-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
git remote add chrome-os
https://chromium.googlesource.com/chromiumos/third_party/kernel
git fetch --no-tags chrome-os chromeos-5.15
git checkout 467d55003e7cac35a55032ae02df445c18566434
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir
ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
> mm/low-mem-notify.c:53:6: error: no previous prototype for
'low_mem_notify' [-Werror=missing-prototypes]
53 | void
low_mem_notify(void)
| ^~~~~~~~~~~~~~
> mm/low-mem-notify.c:121:6: error: no previous prototype for
'low_mem_check' [-Werror=missing-prototypes]
121 | bool
low_mem_check(void)
| ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
vim +/low_mem_notify +53 mm/low-mem-notify.c
6f9d293215315a Luigi Semenzato 2014-04-03 52
6f9d293215315a Luigi Semenzato 2014-04-03 @53 void low_mem_notify(void)
6f9d293215315a Luigi Semenzato 2014-04-03 54 {
6f9d293215315a Luigi Semenzato 2014-04-03 55 atomic_set(&low_mem_state, true);
6f9d293215315a Luigi Semenzato 2014-04-03 56 wake_up(&low_mem_wait);
6f9d293215315a Luigi Semenzato 2014-04-03 57 }
6f9d293215315a Luigi Semenzato 2014-04-03 58
467d55003e7cac Yu Zhao 2019-11-10 59 /*
467d55003e7cac Yu Zhao 2019-11-10 60 * Compute available memory used by files
that can be reclaimed quickly.
467d55003e7cac Yu Zhao 2019-11-10 61 */
467d55003e7cac Yu Zhao 2019-11-10 62 static unsigned long
get_available_file_mem(void)
6f9d293215315a Luigi Semenzato 2014-04-03 63 {
467d55003e7cac Yu Zhao 2019-11-10 64 unsigned long file_mem =
467d55003e7cac Yu Zhao 2019-11-10 65 global_node_page_state(NR_ACTIVE_FILE)
+
467d55003e7cac Yu Zhao 2019-11-10 66
global_node_page_state(NR_INACTIVE_FILE);
467d55003e7cac Yu Zhao 2019-11-10 67 unsigned long dirty_mem =
global_node_page_state(NR_FILE_DIRTY);
467d55003e7cac Yu Zhao 2019-11-10 68 unsigned long min_file_mem =
min_filelist_kbytes >> (PAGE_SHIFT - 10);
467d55003e7cac Yu Zhao 2019-11-10 69 unsigned long clean_file_mem = file_mem
> dirty_mem ?
467d55003e7cac Yu Zhao 2019-11-10 70 file_mem - dirty_mem : 0;
467d55003e7cac Yu Zhao 2019-11-10 71 /* Conservatively estimate the amount of
available_file_mem */
467d55003e7cac Yu Zhao 2019-11-10 72 unsigned long available_file_mem =
clean_file_mem > min_file_mem ?
467d55003e7cac Yu Zhao 2019-11-10 73 clean_file_mem - min_file_mem : 0;
467d55003e7cac Yu Zhao 2019-11-10 74 return available_file_mem;
467d55003e7cac Yu Zhao 2019-11-10 75 }
6f9d293215315a Luigi Semenzato 2014-04-03 76
467d55003e7cac Yu Zhao 2019-11-10 77 /*
467d55003e7cac Yu Zhao 2019-11-10 78 * Available anonymous memory.
467d55003e7cac Yu Zhao 2019-11-10 79 */
467d55003e7cac Yu Zhao 2019-11-10 80 static unsigned long
get_available_anon_mem(void)
467d55003e7cac Yu Zhao 2019-11-10 81 {
467d55003e7cac Yu Zhao 2019-11-10 82 return
global_node_page_state(NR_ACTIVE_ANON) +
467d55003e7cac Yu Zhao 2019-11-10 83
global_node_page_state(NR_INACTIVE_ANON);
6f9d293215315a Luigi Semenzato 2014-04-03 84 }
6f9d293215315a Luigi Semenzato 2014-04-03 85
467d55003e7cac Yu Zhao 2019-11-10 86 /*
467d55003e7cac Yu Zhao 2019-11-10 87 * Compute "available" memory,
that is either free memory or memory that can be
467d55003e7cac Yu Zhao 2019-11-10 88 * reclaimed quickly, adjusted for the
presence of swap.
467d55003e7cac Yu Zhao 2019-11-10 89 */
467d55003e7cac Yu Zhao 2019-11-10 90 static unsigned long
get_available_mem_adj(void)
467d55003e7cac Yu Zhao 2019-11-10 91 {
467d55003e7cac Yu Zhao 2019-11-10 92 /* free_mem is completely unallocated;
clean file-backed memory
467d55003e7cac Yu Zhao 2019-11-10 93 * (file_mem - dirty_mem) is easy to
reclaim, except for the last
467d55003e7cac Yu Zhao 2019-11-10 94 * min_filelist_kbytes.
totalreserve_pages is the reserve of pages that
467d55003e7cac Yu Zhao 2019-11-10 95 * are not available to user space.
467d55003e7cac Yu Zhao 2019-11-10 96 */
467d55003e7cac Yu Zhao 2019-11-10 97 unsigned long raw_free_mem =
global_zone_page_state(NR_FREE_PAGES);
467d55003e7cac Yu Zhao 2019-11-10 98 unsigned long free_mem = raw_free_mem
> totalreserve_pages ?
467d55003e7cac Yu Zhao 2019-11-10 99 raw_free_mem - totalreserve_pages : 0;
467d55003e7cac Yu Zhao 2019-11-10 100 unsigned long available_mem = free_mem +
get_available_file_mem();
467d55003e7cac Yu Zhao 2019-11-10 101 unsigned long swappable_pages =
min_t(unsigned long,
467d55003e7cac Yu Zhao 2019-11-10 102 get_nr_swap_pages(),
get_available_anon_mem());
467d55003e7cac Yu Zhao 2019-11-10 103 /*
467d55003e7cac Yu Zhao 2019-11-10 104 * The contribution of swap is reduced by
a factor of
467d55003e7cac Yu Zhao 2019-11-10 105 * low_mem_ram_vs_swap_weight.
467d55003e7cac Yu Zhao 2019-11-10 106 */
467d55003e7cac Yu Zhao 2019-11-10 107 return available_mem + swappable_pages /
low_mem_ram_vs_swap_weight;
467d55003e7cac Yu Zhao 2019-11-10 108 }
467d55003e7cac Yu Zhao 2019-11-10 109
467d55003e7cac Yu Zhao 2019-11-10 110 #ifdef CONFIG_SYSFS
467d55003e7cac Yu Zhao 2019-11-10 111 static void
low_mem_threshold_notify(void);
467d55003e7cac Yu Zhao 2019-11-10 112 #else
467d55003e7cac Yu Zhao 2019-11-10 113 static void
low_mem_threshold_notify(void)
467d55003e7cac Yu Zhao 2019-11-10 114 {
467d55003e7cac Yu Zhao 2019-11-10 115 }
467d55003e7cac Yu Zhao 2019-11-10 116 #endif
467d55003e7cac Yu Zhao 2019-11-10 117
467d55003e7cac Yu Zhao 2019-11-10 118 /*
467d55003e7cac Yu Zhao 2019-11-10 119 * Returns TRUE if we are in a low memory
state.
467d55003e7cac Yu Zhao 2019-11-10 120 */
467d55003e7cac Yu Zhao 2019-11-10 @121 bool low_mem_check(void)
467d55003e7cac Yu Zhao 2019-11-10 122 {
467d55003e7cac Yu Zhao 2019-11-10 123 static bool was_low_mem; /* = false, as
per style guide */
467d55003e7cac Yu Zhao 2019-11-10 124 static atomic_t in_low_mem_check =
ATOMIC_INIT(0);
467d55003e7cac Yu Zhao 2019-11-10 125 /* last observed threshold */
467d55003e7cac Yu Zhao 2019-11-10 126 static unsigned int
low_mem_threshold_last = UINT_MAX;
467d55003e7cac Yu Zhao 2019-11-10 127 /* Limit logging low memory to once per
second. */
467d55003e7cac Yu Zhao 2019-11-10 128 static
DEFINE_RATELIMIT_STATE(low_mem_logging_ratelimit, 1 * HZ, 1);
467d55003e7cac Yu Zhao 2019-11-10 129
467d55003e7cac Yu Zhao 2019-11-10 130 /* We declare a low-memory condition when
a combination of RAM and swap
467d55003e7cac Yu Zhao 2019-11-10 131 * space is low.
467d55003e7cac Yu Zhao 2019-11-10 132 */
467d55003e7cac Yu Zhao 2019-11-10 133 unsigned long available_mem =
get_available_mem_adj();
467d55003e7cac Yu Zhao 2019-11-10 134 /*
467d55003e7cac Yu Zhao 2019-11-10 135 * For backwards compatibility with the
older margin interface, we will
467d55003e7cac Yu Zhao 2019-11-10 136 * trigger the /dev/chromeos-low_mem
device when we are below the
467d55003e7cac Yu Zhao 2019-11-10 137 * lowest threshold
467d55003e7cac Yu Zhao 2019-11-10 138 */
467d55003e7cac Yu Zhao 2019-11-10 139 bool is_low_mem = available_mem <
low_mem_thresholds[0];
467d55003e7cac Yu Zhao 2019-11-10 140 unsigned int threshold_lowest =
UINT_MAX;
467d55003e7cac Yu Zhao 2019-11-10 141 int i;
467d55003e7cac Yu Zhao 2019-11-10 142
467d55003e7cac Yu Zhao 2019-11-10 143 if (!low_mem_margin_enabled)
467d55003e7cac Yu Zhao 2019-11-10 144 return false;
467d55003e7cac Yu Zhao 2019-11-10 145
467d55003e7cac Yu Zhao 2019-11-10 146 if (atomic_read(&in_low_mem_check) ||
atomic_xchg(&in_low_mem_check, 1))
467d55003e7cac Yu Zhao 2019-11-10 147 return was_low_mem;
467d55003e7cac Yu Zhao 2019-11-10 148
467d55003e7cac Yu Zhao 2019-11-10 149 if (unlikely(is_low_mem &&
!was_low_mem) &&
467d55003e7cac Yu Zhao 2019-11-10 150
__ratelimit(&low_mem_logging_ratelimit)) {
467d55003e7cac Yu Zhao 2019-11-10 151 pr_info("entering low_mem (avail
RAM = %lu kB, avail swap %lu kB, avail file %lu kB, anon mem: %lu kB)\n",
467d55003e7cac Yu Zhao 2019-11-10 152 available_mem * PAGE_SIZE / 1024,
467d55003e7cac Yu Zhao 2019-11-10 153 get_nr_swap_pages() * PAGE_SIZE /
1024,
467d55003e7cac Yu Zhao 2019-11-10 154 get_available_file_mem() * PAGE_SIZE /
1024,
467d55003e7cac Yu Zhao 2019-11-10 155 get_available_anon_mem() * PAGE_SIZE /
1024);
467d55003e7cac Yu Zhao 2019-11-10 156 }
467d55003e7cac Yu Zhao 2019-11-10 157 was_low_mem = is_low_mem;
467d55003e7cac Yu Zhao 2019-11-10 158
467d55003e7cac Yu Zhao 2019-11-10 159 if (is_low_mem)
467d55003e7cac Yu Zhao 2019-11-10 160 low_mem_notify();
467d55003e7cac Yu Zhao 2019-11-10 161
467d55003e7cac Yu Zhao 2019-11-10 162 for (i = 0; i <
low_mem_threshold_count; i++) {
467d55003e7cac Yu Zhao 2019-11-10 163 if (available_mem <
low_mem_thresholds[i]) {
467d55003e7cac Yu Zhao 2019-11-10 164 threshold_lowest = i;
467d55003e7cac Yu Zhao 2019-11-10 165 break;
467d55003e7cac Yu Zhao 2019-11-10 166 }
467d55003e7cac Yu Zhao 2019-11-10 167 }
467d55003e7cac Yu Zhao 2019-11-10 168
467d55003e7cac Yu Zhao 2019-11-10 169 /* we crossed one or more thresholds */
467d55003e7cac Yu Zhao 2019-11-10 170 if (unlikely(threshold_lowest <
low_mem_threshold_last))
467d55003e7cac Yu Zhao 2019-11-10 171 low_mem_threshold_notify();
467d55003e7cac Yu Zhao 2019-11-10 172
467d55003e7cac Yu Zhao 2019-11-10 173 low_mem_threshold_last =
threshold_lowest;
467d55003e7cac Yu Zhao 2019-11-10 174
467d55003e7cac Yu Zhao 2019-11-10 175 atomic_set(&in_low_mem_check, 0);
467d55003e7cac Yu Zhao 2019-11-10 176
467d55003e7cac Yu Zhao 2019-11-10 177 return is_low_mem;
467d55003e7cac Yu Zhao 2019-11-10 178 }
467d55003e7cac Yu Zhao 2019-11-10 179
:::::: The code at line 53 was first introduced by commit
:::::: 6f9d293215315aefb091456a2eb8c2799ff1232a CHROMIUM: Add /dev/low-mem device for
low-memory notification.
:::::: TO: Luigi Semenzato <semenzato(a)chromium.org>
:::::: CC: Guenter Roeck <groeck(a)chromium.org>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org