Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262697
b: refs/heads/master
c: 9f50fad
h: refs/heads/master
i:
  262695: c51ab59
v: v3
  • Loading branch information
Michal Hocko authored and Linus Torvalds committed Aug 10, 2011
1 parent 6638539 commit 4d96669
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 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: 47e180d6523081605c970f806572beab8a205537
refs/heads/master: 9f50fad65b87a8776ae989ca059ad6c17925dfc3
12 changes: 10 additions & 2 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,7 @@ struct memcg_stock_pcp {
#define FLUSHING_CACHED_CHARGE (0)
};
static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock);
static DEFINE_MUTEX(percpu_charge_mutex);

/*
* Try to consume stocked charge on this cpu. If success, one page is consumed
Expand Down Expand Up @@ -2197,8 +2198,7 @@ static void drain_all_stock(struct mem_cgroup *root_mem, bool sync)

for_each_online_cpu(cpu) {
struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
if (mem_cgroup_same_or_subtree(root_mem, stock->cached) &&
test_bit(FLUSHING_CACHED_CHARGE, &stock->flags))
if (test_bit(FLUSHING_CACHED_CHARGE, &stock->flags))
flush_work(&stock->work);
}
out:
Expand All @@ -2213,14 +2213,22 @@ static void drain_all_stock(struct mem_cgroup *root_mem, bool sync)
*/
static void drain_all_stock_async(struct mem_cgroup *root_mem)
{
/*
* If someone calls draining, avoid adding more kworker runs.
*/
if (!mutex_trylock(&percpu_charge_mutex))
return;
drain_all_stock(root_mem, false);
mutex_unlock(&percpu_charge_mutex);
}

/* This is a synchronous drain interface. */
static void drain_all_stock_sync(struct mem_cgroup *root_mem)
{
/* called when force_empty is called */
mutex_lock(&percpu_charge_mutex);
drain_all_stock(root_mem, true);
mutex_unlock(&percpu_charge_mutex);
}

/*
Expand Down

0 comments on commit 4d96669

Please sign in to comment.