History

mm: vmscan: simplify lruvec_lru_size()

Patch series "mm: vmscan: cgroup-related cleanups". Here are 8 patches that clean up the reclaim code's interaction with cgroups a bit. They're not supposed to change any behavior, just make the implementation easier to understand and work with. This patch (of 8): This function currently takes the node or lruvec size and subtracts the zones that are excluded by the classzone index of the allocation. It uses four different types of counters to do this. Just add up the eligible zones. [cai@lca.pw: fix an undefined behavior for zone id] Link: http://lkml.kernel.org/r/20191108204407.1435-1-cai@lca.pw [akpm@linux-foundation.org: deal with the MAX_NR_ZONES special case. per Qian Cai] Link: http://lkml.kernel.org/r/64E60F6F-7582-427B-8DD5-EF97B1656F5A@lca.pw Link: http://lkml.kernel.org/r/20191022144803.302233-2-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Roman Gushchin <guro@fb.com> Reviewed-by: Shakeel Butt <shakeelb@google.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Johannes Weiner committed 6 years ago

Commit de3b0151 parent cb165561 file · +5 −16Browse files

Unified · Split

mm/vmscan.c+5−16
@@ -351,32 +351,21 @@ unsigned long zone_reclaimable_pages(struct zone *zone) · 350 unmodified lines
351 */351 */
352unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx)352unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx)
353{353{
354 unsigned long lru_size = 0;354 unsigned long size = 0;
355 int zid;355 int zid;
356 356
357 if (!mem_cgroup_disabled()) {357 for (zid = 0; zid <= zone_idx && zid < MAX_NR_ZONES; zid++) {
358 for (zid = 0; zid < MAX_NR_ZONES; zid++)
359 lru_size += mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
360 } else
361 lru_size = node_page_state(lruvec_pgdat(lruvec), NR_LRU_BASE + lru);
362
363 for (zid = zone_idx + 1; zid < MAX_NR_ZONES; zid++) {
364 struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];358 struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid];
365 unsigned long size;
366 359
367 if (!managed_zone(zone))360 if (!managed_zone(zone))
368 continue;361 continue;
369 362
370 if (!mem_cgroup_disabled())363 if (!mem_cgroup_disabled())
371 size = mem_cgroup_get_zone_lru_size(lruvec, lru, zid);364 size += mem_cgroup_get_zone_lru_size(lruvec, lru, zid);
372 else365 else
373 size = zone_page_state(&lruvec_pgdat(lruvec)->node_zones[zid],366 size += zone_page_state(zone, NR_ZONE_LRU_BASE + lru);
374 NR_ZONE_LRU_BASE + lru);
375 lru_size -= min(size, lru_size);
376 }367 }
377 368 return size;
378 return lru_size;
379
380}369}
381 370
382/*371/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t