Re: [PATCH v2 3/4] mm: convert totalram_pages and totalhigh_pages variables to atomic

From: kbuild test robot
Date: Wed Nov 07 2018 - 15:07:59 EST


Hi Arun,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc1 next-20181107]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Arun-KS/mm-Fix-multiple-evaluvations-of-totalram_pages-and-managed_pages/20181108-025657
config: x86_64-randconfig-x018-201844 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64

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

In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:47,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/gfp.h:5,
from mm/kasan/quarantine.c:20:
mm/kasan/quarantine.c: In function 'quarantine_reduce':
>> include/linux/compiler.h:246:20: error: lvalue required as unary '&' operand
__read_once_size(&(x), __u.__c, sizeof(x)); \
^
>> include/linux/compiler.h:252:22: note: in expansion of macro '__READ_ONCE'
#define READ_ONCE(x) __READ_ONCE(x, 1)
^~~~~~~~~~~
>> mm/kasan/quarantine.c:239:16: note: in expansion of macro 'READ_ONCE'
total_size = (READ_ONCE(totalram_pages()) << PAGE_SHIFT) /
^~~~~~~~~
include/linux/compiler.h:248:28: error: lvalue required as unary '&' operand
__read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
^
>> include/linux/compiler.h:252:22: note: in expansion of macro '__READ_ONCE'
#define READ_ONCE(x) __READ_ONCE(x, 1)
^~~~~~~~~~~
>> mm/kasan/quarantine.c:239:16: note: in expansion of macro 'READ_ONCE'
total_size = (READ_ONCE(totalram_pages()) << PAGE_SHIFT) /
^~~~~~~~~
--
In file included from include/asm-generic/bug.h:5:0,
from arch/x86/include/asm/bug.h:47,
from include/linux/bug.h:5,
from include/linux/mmdebug.h:5,
from include/linux/gfp.h:5,
from mm//kasan/quarantine.c:20:
mm//kasan/quarantine.c: In function 'quarantine_reduce':
>> include/linux/compiler.h:246:20: error: lvalue required as unary '&' operand
__read_once_size(&(x), __u.__c, sizeof(x)); \
^
>> include/linux/compiler.h:252:22: note: in expansion of macro '__READ_ONCE'
#define READ_ONCE(x) __READ_ONCE(x, 1)
^~~~~~~~~~~
mm//kasan/quarantine.c:239:16: note: in expansion of macro 'READ_ONCE'
total_size = (READ_ONCE(totalram_pages()) << PAGE_SHIFT) /
^~~~~~~~~
include/linux/compiler.h:248:28: error: lvalue required as unary '&' operand
__read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
^
>> include/linux/compiler.h:252:22: note: in expansion of macro '__READ_ONCE'
#define READ_ONCE(x) __READ_ONCE(x, 1)
^~~~~~~~~~~
mm//kasan/quarantine.c:239:16: note: in expansion of macro 'READ_ONCE'
total_size = (READ_ONCE(totalram_pages()) << PAGE_SHIFT) /
^~~~~~~~~

vim +/READ_ONCE +239 mm/kasan/quarantine.c

211
212 void quarantine_reduce(void)
213 {
214 size_t total_size, new_quarantine_size, percpu_quarantines;
215 unsigned long flags;
216 int srcu_idx;
217 struct qlist_head to_free = QLIST_INIT;
218
219 if (likely(READ_ONCE(quarantine_size) <=
220 READ_ONCE(quarantine_max_size)))
221 return;
222
223 /*
224 * srcu critical section ensures that quarantine_remove_cache()
225 * will not miss objects belonging to the cache while they are in our
226 * local to_free list. srcu is chosen because (1) it gives us private
227 * grace period domain that does not interfere with anything else,
228 * and (2) it allows synchronize_srcu() to return without waiting
229 * if there are no pending read critical sections (which is the
230 * expected case).
231 */
232 srcu_idx = srcu_read_lock(&remove_cache_srcu);
233 raw_spin_lock_irqsave(&quarantine_lock, flags);
234
235 /*
236 * Update quarantine size in case of hotplug. Allocate a fraction of
237 * the installed memory to quarantine minus per-cpu queue limits.
238 */
> 239 total_size = (READ_ONCE(totalram_pages()) << PAGE_SHIFT) /
240 QUARANTINE_FRACTION;
241 percpu_quarantines = QUARANTINE_PERCPU_SIZE * num_online_cpus();
242 new_quarantine_size = (total_size < percpu_quarantines) ?
243 0 : total_size - percpu_quarantines;
244 WRITE_ONCE(quarantine_max_size, new_quarantine_size);
245 /* Aim at consuming at most 1/2 of slots in quarantine. */
246 WRITE_ONCE(quarantine_batch_size, max((size_t)QUARANTINE_PERCPU_SIZE,
247 2 * total_size / QUARANTINE_BATCHES));
248
249 if (likely(quarantine_size > quarantine_max_size)) {
250 qlist_move_all(&global_quarantine[quarantine_head], &to_free);
251 WRITE_ONCE(quarantine_size, quarantine_size - to_free.bytes);
252 quarantine_head++;
253 if (quarantine_head == QUARANTINE_BATCHES)
254 quarantine_head = 0;
255 }
256
257 raw_spin_unlock_irqrestore(&quarantine_lock, flags);
258
259 qlist_free_all(&to_free, NULL);
260 srcu_read_unlock(&remove_cache_srcu, srcu_idx);
261 }
262

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip