Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 273244
b: refs/heads/master
c: 9b27297
h: refs/heads/master
v: v3
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed Nov 2, 2011
1 parent 671e651 commit 3209af8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0a619e58703b86d53d07e938eade9a91a4a863c6
refs/heads/master: 9b272977e3b99a8699361d214b51f98c8a9e0e7b
1 change: 0 additions & 1 deletion trunk/Documentation/cgroups/memory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ total_unevictable - sum of all children's "unevictable"

# The following additional stats are dependent on CONFIG_DEBUG_VM.

inactive_ratio - VM internal parameter. (see mm/page_alloc.c)
recent_rotated_anon - VM internal parameter. (see mm/vmscan.c)
recent_rotated_file - VM internal parameter. (see mm/vmscan.c)
recent_scanned_anon - VM internal parameter. (see mm/vmscan.c)
Expand Down
10 changes: 6 additions & 4 deletions trunk/include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ extern void mem_cgroup_end_migration(struct mem_cgroup *memcg,
/*
* For memory reclaim.
*/
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg);
int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg);
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg,
struct zone *zone);
int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg,
struct zone *zone);
int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
unsigned long mem_cgroup_zone_nr_lru_pages(struct mem_cgroup *memcg,
int nid, int zid, unsigned int lrumask);
Expand Down Expand Up @@ -295,13 +297,13 @@ static inline bool mem_cgroup_disabled(void)
}

static inline int
mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg)
mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone)
{
return 1;
}

static inline int
mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg)
mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg, struct zone *zone)
{
return 1;
}
Expand Down
51 changes: 17 additions & 34 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,55 +1104,40 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *memcg)
return ret;
}

static int calc_inactive_ratio(struct mem_cgroup *memcg, unsigned long *present_pages)
int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg, struct zone *zone)
{
unsigned long active;
unsigned long inactive_ratio;
int nid = zone_to_nid(zone);
int zid = zone_idx(zone);
unsigned long inactive;
unsigned long active;
unsigned long gb;
unsigned long inactive_ratio;

inactive = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_INACTIVE_ANON));
active = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_ACTIVE_ANON));
inactive = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid,
BIT(LRU_INACTIVE_ANON));
active = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid,
BIT(LRU_ACTIVE_ANON));

gb = (inactive + active) >> (30 - PAGE_SHIFT);
if (gb)
inactive_ratio = int_sqrt(10 * gb);
else
inactive_ratio = 1;

if (present_pages) {
present_pages[0] = inactive;
present_pages[1] = active;
}

return inactive_ratio;
return inactive * inactive_ratio < active;
}

int mem_cgroup_inactive_anon_is_low(struct mem_cgroup *memcg)
{
unsigned long active;
unsigned long inactive;
unsigned long present_pages[2];
unsigned long inactive_ratio;

inactive_ratio = calc_inactive_ratio(memcg, present_pages);

inactive = present_pages[0];
active = present_pages[1];

if (inactive * inactive_ratio < active)
return 1;

return 0;
}

int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg)
int mem_cgroup_inactive_file_is_low(struct mem_cgroup *memcg, struct zone *zone)
{
unsigned long active;
unsigned long inactive;
int zid = zone_idx(zone);
int nid = zone_to_nid(zone);

inactive = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_INACTIVE_FILE));
active = mem_cgroup_nr_lru_pages(memcg, BIT(LRU_ACTIVE_FILE));
inactive = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid,
BIT(LRU_INACTIVE_FILE));
active = mem_cgroup_zone_nr_lru_pages(memcg, nid, zid,
BIT(LRU_ACTIVE_FILE));

return (active > inactive);
}
Expand Down Expand Up @@ -4192,8 +4177,6 @@ static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
}

#ifdef CONFIG_DEBUG_VM
cb->fill(cb, "inactive_ratio", calc_inactive_ratio(mem_cont, NULL));

{
int nid, zid;
struct mem_cgroup_per_zone *mz;
Expand Down
4 changes: 2 additions & 2 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc)
if (scanning_global_lru(sc))
low = inactive_anon_is_low_global(zone);
else
low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup);
low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup, zone);
return low;
}
#else
Expand Down Expand Up @@ -1810,7 +1810,7 @@ static int inactive_file_is_low(struct zone *zone, struct scan_control *sc)
if (scanning_global_lru(sc))
low = inactive_file_is_low_global(zone);
else
low = mem_cgroup_inactive_file_is_low(sc->mem_cgroup);
low = mem_cgroup_inactive_file_is_low(sc->mem_cgroup, zone);
return low;
}

Expand Down

0 comments on commit 3209af8

Please sign in to comment.