Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105911
b: refs/heads/master
c: 628f423
h: refs/heads/master
i:
  105909: 51078ab
  105907: 076a587
  105903: e42919d
v: v3
  • Loading branch information
KAMEZAWA Hiroyuki authored and Linus Torvalds committed Jul 25, 2008
1 parent 7216f23 commit 84594ab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 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: 12b9804419cfb1c1bdac413f6c373af3b88d154b
refs/heads/master: 628f42355389cfb596ca3a5a5f64fb9054a2a06a
3 changes: 1 addition & 2 deletions trunk/Documentation/controllers/memory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ rmdir() if there are no tasks.
1. Add support for accounting huge pages (as a separate controller)
2. Make per-cgroup scanner reclaim not-shared pages first
3. Teach controller to account for shared-pages
4. Start reclamation when the limit is lowered
5. Start reclamation in the background when the limit is
4. Start reclamation in the background when the limit is
not yet hit but the usage is getting closer

Summary
Expand Down
48 changes: 44 additions & 4 deletions trunk/mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,30 @@ int mem_cgroup_shrink_usage(struct mm_struct *mm, gfp_t gfp_mask)
return 0;
}

int mem_cgroup_resize_limit(struct mem_cgroup *memcg, unsigned long long val)
{

int retry_count = MEM_CGROUP_RECLAIM_RETRIES;
int progress;
int ret = 0;

while (res_counter_set_limit(&memcg->res, val)) {
if (signal_pending(current)) {
ret = -EINTR;
break;
}
if (!retry_count) {
ret = -EBUSY;
break;
}
progress = try_to_free_mem_cgroup_pages(memcg, GFP_KERNEL);
if (!progress)
retry_count--;
}
return ret;
}


/*
* This routine traverse page_cgroup in given list and drop them all.
* *And* this routine doesn't reclaim page itself, just removes page_cgroup.
Expand Down Expand Up @@ -896,13 +920,29 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
return res_counter_read_u64(&mem_cgroup_from_cont(cont)->res,
cft->private);
}

/*
* The user of this function is...
* RES_LIMIT.
*/
static int mem_cgroup_write(struct cgroup *cont, struct cftype *cft,
const char *buffer)
{
return res_counter_write(&mem_cgroup_from_cont(cont)->res,
cft->private, buffer,
res_counter_memparse_write_strategy);
struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
unsigned long long val;
int ret;

switch (cft->private) {
case RES_LIMIT:
/* This function does all necessary parse...reuse it */
ret = res_counter_memparse_write_strategy(buffer, &val);
if (!ret)
ret = mem_cgroup_resize_limit(memcg, val);
break;
default:
ret = -EINVAL; /* should be BUG() ? */
break;
}
return ret;
}

static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
Expand Down

0 comments on commit 84594ab

Please sign in to comment.