Re: [PATCH v9 74/96] mm/workingset: Convert workingset_refault to take a folio

From: kernel test robot
Date: Wed May 05 2021 - 16:23:55 EST


Hi "Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20210505]
[cannot apply to hnaz-linux-mm/master xfs-linux/for-next tip/perf/core shaggy/jfs-next block/for-next linus/master asm-generic/master v5.12 v5.12-rc8 v5.12-rc7 v5.12]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/Memory-folios/20210506-014108
base: 29955e0289b3255c5f609a7564a0f0bb4ae35c7a
config: nds32-defconfig (attached as .config)
compiler: nds32le-linux-gcc (GCC) 9.3.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/b1883a3797e1623bf783141c25482fee16e1031c
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Matthew-Wilcox-Oracle/Memory-folios/20210506-014108
git checkout b1883a3797e1623bf783141c25482fee16e1031c
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross W=1 ARCH=nds32

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

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

In file included from mm/workingset.c:8:
include/linux/memcontrol.h: In function 'folio_uncharge_cgroup':
include/linux/memcontrol.h:1213:42: error: parameter name omitted
1213 | static inline void folio_uncharge_cgroup(struct folio *)
| ^~~~~~~~~~~~~~
mm/workingset.c: In function 'unpack_shadow':
mm/workingset.c:201:15: warning: variable 'nid' set but not used [-Wunused-but-set-variable]
201 | int memcgid, nid;
| ^~~
mm/workingset.c: In function 'workingset_refault':
>> mm/workingset.c:348:10: error: implicit declaration of function 'folio_memcg' [-Werror=implicit-function-declaration]
348 | memcg = folio_memcg(folio);
| ^~~~~~~~~~~
>> mm/workingset.c:348:8: warning: assignment to 'struct mem_cgroup *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
348 | memcg = folio_memcg(folio);
| ^
cc1: some warnings being treated as errors


vim +/folio_memcg +348 mm/workingset.c

272
273 /**
274 * workingset_refault - evaluate the refault of a previously evicted folio
275 * @page: the freshly allocated replacement folio
276 * @shadow: shadow entry of the evicted folio
277 *
278 * Calculates and evaluates the refault distance of the previously
279 * evicted folio in the context of the node and the memcg whose memory
280 * pressure caused the eviction.
281 */
282 void workingset_refault(struct folio *folio, void *shadow)
283 {
284 bool file = folio_is_file_lru(folio);
285 struct mem_cgroup *eviction_memcg;
286 struct lruvec *eviction_lruvec;
287 unsigned long refault_distance;
288 unsigned long workingset_size;
289 struct pglist_data *pgdat;
290 struct mem_cgroup *memcg;
291 unsigned long eviction;
292 struct lruvec *lruvec;
293 unsigned long refault;
294 bool workingset;
295 int memcgid;
296
297 unpack_shadow(shadow, &memcgid, &pgdat, &eviction, &workingset);
298
299 rcu_read_lock();
300 /*
301 * Look up the memcg associated with the stored ID. It might
302 * have been deleted since the folio's eviction.
303 *
304 * Note that in rare events the ID could have been recycled
305 * for a new cgroup that refaults a shared folio. This is
306 * impossible to tell from the available data. However, this
307 * should be a rare and limited disturbance, and activations
308 * are always speculative anyway. Ultimately, it's the aging
309 * algorithm's job to shake out the minimum access frequency
310 * for the active cache.
311 *
312 * XXX: On !CONFIG_MEMCG, this will always return NULL; it
313 * would be better if the root_mem_cgroup existed in all
314 * configurations instead.
315 */
316 eviction_memcg = mem_cgroup_from_id(memcgid);
317 if (!mem_cgroup_disabled() && !eviction_memcg)
318 goto out;
319 eviction_lruvec = mem_cgroup_lruvec(eviction_memcg, pgdat);
320 refault = atomic_long_read(&eviction_lruvec->nonresident_age);
321
322 /*
323 * Calculate the refault distance
324 *
325 * The unsigned subtraction here gives an accurate distance
326 * across nonresident_age overflows in most cases. There is a
327 * special case: usually, shadow entries have a short lifetime
328 * and are either refaulted or reclaimed along with the inode
329 * before they get too old. But it is not impossible for the
330 * nonresident_age to lap a shadow entry in the field, which
331 * can then result in a false small refault distance, leading
332 * to a false activation should this old entry actually
333 * refault again. However, earlier kernels used to deactivate
334 * unconditionally with *every* reclaim invocation for the
335 * longest time, so the occasional inappropriate activation
336 * leading to pressure on the active list is not a problem.
337 */
338 refault_distance = (refault - eviction) & EVICTION_MASK;
339
340 /*
341 * The activation decision for this folio is made at the level
342 * where the eviction occurred, as that is where the LRU order
343 * during folio reclaim is being determined.
344 *
345 * However, the cgroup that will own the folio is the one that
346 * is actually experiencing the refault event.
347 */
> 348 memcg = folio_memcg(folio);
349 lruvec = mem_cgroup_lruvec(memcg, pgdat);
350
351 inc_lruvec_state(lruvec, WORKINGSET_REFAULT_BASE + file);
352
353 /*
354 * Compare the distance to the existing workingset size. We
355 * don't activate pages that couldn't stay resident even if
356 * all the memory was available to the workingset. Whether
357 * workingset competition needs to consider anon or not depends
358 * on having swap.
359 */
360 workingset_size = lruvec_page_state(eviction_lruvec, NR_ACTIVE_FILE);
361 if (!file) {
362 workingset_size += lruvec_page_state(eviction_lruvec,
363 NR_INACTIVE_FILE);
364 }
365 if (mem_cgroup_get_nr_swap_pages(memcg) > 0) {
366 workingset_size += lruvec_page_state(eviction_lruvec,
367 NR_ACTIVE_ANON);
368 if (file) {
369 workingset_size += lruvec_page_state(eviction_lruvec,
370 NR_INACTIVE_ANON);
371 }
372 }
373 if (refault_distance > workingset_size)
374 goto out;
375
376 folio_set_active_flag(folio);
377 workingset_age_nonresident(lruvec, folio_nr_pages(folio));
378 inc_lruvec_state(lruvec, WORKINGSET_ACTIVATE_BASE + file);
379
380 /* Folio was active prior to eviction */
381 if (workingset) {
382 folio_set_workingset_flag(folio);
383 /* XXX: Move to lru_cache_add() when it supports new vs putback */
384 lru_note_cost_folio(folio);
385 inc_lruvec_state(lruvec, WORKINGSET_RESTORE_BASE + file);
386 }
387 out:
388 rcu_read_unlock();
389 }
390

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

Attachment: .config.gz
Description: application/gzip