From: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
To: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Cc: containers@lists.osdl.org, linux-mm@kvack.org,
Lee.Schermerhorn@hp.com, riel@redhat.com,
balbir@linux.vnet.ibm.com, kosaki.motohiro@jp.fujitsu.com,
hugh@veritas.com, xemul@openvz.org
Subject: Re: [PATCH 4/4] swapcgroup: modify vm_swap_full for cgroup
Date: Thu, 22 May 2008 21:34:50 +0900 [thread overview]
Message-ID: <4835686A.9000106@mxp.nes.nec.co.jp> (raw)
In-Reply-To: <20080522064507.AB6A35A0A@siro.lan>
Hi,
On 2008/05/22 15:45 +0900, YAMAMOTO Takashi wrote:
>> @@ -1892,3 +1892,36 @@ int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
>> *offset = ++toff;
>> return nr_pages? ++nr_pages: 0;
>> }
>> +
>> +#ifdef CONFIG_CGROUP_SWAP_RES_CTLR
>> +int swap_cgroup_vm_swap_full(struct page *page)
>> +{
>> + int ret;
>> + struct swap_info_struct *p;
>> + struct mem_cgroup *mem;
>> + u64 usage;
>> + u64 limit;
>> + swp_entry_t entry;
>> +
>> + VM_BUG_ON(!PageLocked(page));
>> + VM_BUG_ON(!PageSwapCache(page));
>> +
>> + ret = 0;
>> + entry.val = page_private(page);
>> + p = swap_info_get(entry);
>> + if (!p)
>> + goto out;
>> +
>> + mem = p->memcg[swp_offset(entry)];
>> + usage = swap_cgroup_read_usage(mem) / PAGE_SIZE;
>> + limit = swap_cgroup_read_limit(mem) / PAGE_SIZE;
>> + limit = (limit < total_swap_pages) ? limit : total_swap_pages;
>> +
>> + ret = usage * 2 > limit;
>> +
>> + spin_unlock(&swap_lock);
>> +
>> +out:
>> + return ret;
>> +}
>> +#endif
>
> shouldn't it check the global usage (nr_swap_pages) as well?
>
> YAMAMOTO Takashi
>
I didn't check global usage because I didn't want
some group to be influenced by other groups.
But in above code, there would be some cases that
vm_swap_full() returns false even when more than
half of swap is used in global.
Thanks you for pointing it out.
How about something like this?
:
usage = swap_cgroup_read_usage(mem); //no need to align to number of page
limit = swap_cgroup_read_limit(mem); //no need to align to number of page
ret = (usage * 2 > limit) || (nr_swap_pages * 2 < total_swap_pages)
:
Thanks,
Daisuke Nishimura.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-05-22 12:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-22 6:13 [PATCH 0/4] swapcgroup(v2) Daisuke Nishimura
2008-05-22 6:17 ` [PATCH 1/4] swapcgroup: add cgroup files Daisuke Nishimura
2008-05-22 6:18 ` [PATCH 2/4] swapcgroup: add member to swap_info_struct for cgroup Daisuke Nishimura
2008-05-22 7:23 ` KAMEZAWA Hiroyuki
2008-05-22 8:46 ` Daisuke Nishimura
2008-05-22 9:35 ` KAMEZAWA Hiroyuki
2008-05-22 6:20 ` [PATCH 3/4] swapcgroup: implement charge/uncharge Daisuke Nishimura
2008-05-22 7:37 ` KAMEZAWA Hiroyuki
2008-05-23 11:52 ` Daisuke Nishimura
2008-05-26 0:57 ` KAMEZAWA Hiroyuki
2008-05-27 13:42 ` KAMEZAWA Hiroyuki
2008-05-22 6:22 ` [PATCH 4/4] swapcgroup: modify vm_swap_full for cgroup Daisuke Nishimura
2008-05-22 6:45 ` YAMAMOTO Takashi
2008-05-22 12:34 ` Daisuke Nishimura [this message]
2008-05-25 23:35 ` YAMAMOTO Takashi
2008-05-22 7:39 ` KAMEZAWA Hiroyuki
2008-05-22 8:00 ` KOSAKI Motohiro
2008-05-22 12:22 ` Daisuke Nishimura
2008-05-22 12:32 ` KOSAKI Motohiro
2008-05-23 12:26 ` Daisuke Nishimura
2008-05-22 7:44 ` [PATCH 0/4] swapcgroup(v2) KAMEZAWA Hiroyuki
2008-05-23 2:10 ` Daisuke Nishimura
2008-05-23 2:42 ` Daisuke Nishimura
2008-05-22 21:27 ` Balbir Singh
2008-05-23 4:27 ` Daisuke Nishimura
2008-05-27 7:31 ` YAMAMOTO Takashi
2008-05-27 7:42 ` Balbir Singh
2008-05-27 8:30 ` Daisuke Nishimura
2008-05-27 13:18 ` Balbir Singh
2008-05-27 13:42 ` Daisuke Nishimura
2008-05-27 13:46 ` Balbir Singh
2008-05-27 14:00 ` Daisuke Nishimura
2008-05-23 2:26 ` Rik van Riel
2008-05-23 3:10 ` KAMEZAWA Hiroyuki
2008-05-23 3:32 ` Rik van Riel
2008-05-23 3:59 ` Balbir Singh
2008-05-23 4:30 ` KOSAKI Motohiro
2008-05-23 4:51 ` Balbir Singh
2008-05-23 5:23 ` KAMEZAWA Hiroyuki
2008-05-23 5:29 ` David Singleton
2008-05-23 6:00 ` KOSAKI Motohiro
2008-05-23 6:45 ` Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4835686A.9000106@mxp.nes.nec.co.jp \
--to=nishimura@mxp.nes.nec.co.jp \
--cc=Lee.Schermerhorn@hp.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=containers@lists.osdl.org \
--cc=hugh@veritas.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.com \
--cc=xemul@openvz.org \
--cc=yamamoto@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox