Linux Container Development
 help / color / mirror / Atom feed
From: yamamoto-jCdQPDEk3idL9jVzuh4AOg@public.gmane.org (YAMAMOTO Takashi)
To: kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
	balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org,
	xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org
Subject: Re: [RFC] memory controller : backgorund reclaim and avoid excessive locking [4/5] borrow resource
Date: Mon, 18 Feb 2008 09:53:35 +0900 (JST)	[thread overview]
Message-ID: <20080218005335.D93F51E3C5A@siro.lan> (raw)
In-Reply-To: Your message of "Thu, 14 Feb 2008 17:35:04 +0900" <20080214173504.cc1aa42e.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>

> +		/* try to charge */
> +		ret = res_counter_charge(&mem->res, mem->borrow_unit);
> +		if (!ret) { /* success */
> +			*bwp += (mem->borrow_unit - size);
> +			goto out;
> +		}
> +	}
> +	spin_lock(&mem->res.lock);
> +	ret = res_counter_charge_locked(&mem->res, size);
> +	spin_unlock(&mem->res.lock);

although i don't know if it matters, this retrying of charge affects failcnt.

> +static void mem_cgroup_return_and_uncharge(struct mem_cgroup *mem, int size)
> +{
> +	unsigned long flags;
> +	int uncharge_size = 0;
> +
> +	local_irq_save(flags);
> +	if (mem->borrow_unit) {
> +		int limit = mem->borrow_unit * 2;
> +		int cpu;
> +		s64 *bwp;
> +		cpu = smp_processor_id();
> +		bwp = &mem->stat.cpustat[cpu].count[MEM_CGROUP_STAT_BORROW];
> +		*bwp += size;
> +		if (*bwp > limit) {
> +			uncharge_size = *bwp - mem->borrow_unit;
> +			*bwp = mem->borrow_unit;
> +		}
> +	} else
> +		uncharge_size = size;
> +
> +	if (uncharge_size) {
> +		spin_lock(&mem->res.lock);
> +		res_counter_uncharge_locked(&mem->res, size);

s/size/uncharge_size/

> @@ -1109,12 +1202,29 @@ static u64 mem_throttle_read(struct cgro
>  	return (u64)mem->throttle.limit;
>  }
>  
> +static int mem_bulkratio_write(struct cgroup *cont, struct cftype *cft, u64 val)
> +{
> +	struct mem_cgroup *mem = mem_cgroup_from_cont(cont);
> +	int unit = val * PAGE_SIZE;
> +	if (unit > (PAGE_SIZE << (MAX_ORDER/2)))
> +		return -EINVAL;
> +	mem->borrow_unit = unit;
> +	return 0;
> +}

it seems unsafe with concurrent mem_cgroup_borrow_and_charge or
mem_cgroup_return_and_uncharge.

YAMAMOTO Takashi

  parent reply	other threads:[~2008-02-18  0:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-14  8:21 [RFC] memory controller : backgorund reclaim and avoid excessive locking [0/5] KAMEZAWA Hiroyuki
     [not found] ` <20080214172148.bfd564d5.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-14  8:28   ` [RFC] memory controller : backgorund reclaim and avoid excessive locking [1/5] high-low watermark KAMEZAWA Hiroyuki
     [not found]     ` <20080214172801.b1c35067.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-14  8:48       ` Balbir Singh
     [not found]         ` <47B40061.20200-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-02-14  9:12           ` KAMEZAWA Hiroyuki
2008-02-14  8:29   ` [RFC] memory controller : backgorund reclaim and avoid excessive locking [2/5] background reclaim KAMEZAWA Hiroyuki
     [not found]     ` <20080214172910.017cc755.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-14  8:32       ` Balbir Singh
     [not found]         ` <47B3FCAC.6010109-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-02-14  8:57           ` KAMEZAWA Hiroyuki
2008-02-14  8:30   ` [RFC] memory controller : backgorund reclaim and avoid excessive locking [3/5] throttling KAMEZAWA Hiroyuki
     [not found]     ` <20080214173043.d57b3619.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-14  9:14       ` Balbir Singh
     [not found]         ` <47B4068A.2050104-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-02-14  9:38           ` KAMEZAWA Hiroyuki
2008-02-14  8:35   ` [RFC] memory controller : backgorund reclaim and avoid excessive locking [4/5] borrow resource KAMEZAWA Hiroyuki
     [not found]     ` <20080214173504.cc1aa42e.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-18  0:53       ` YAMAMOTO Takashi [this message]
     [not found]         ` <20080218005335.D93F51E3C5A-Pcsii4f/SVk@public.gmane.org>
2008-02-18  2:06           ` KAMEZAWA Hiroyuki
2008-02-14  8:36   ` [RFC] memory controller : backgorund reclaim and avoid excessive locking [5/5] lazy page_cgroup freeing KAMEZAWA Hiroyuki
     [not found]     ` <20080214173624.d29b26d9.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-02-18  1:58       ` YAMAMOTO Takashi
     [not found]         ` <20080218015840.CE6FF1E3C58-Pcsii4f/SVk@public.gmane.org>
2008-02-18  2:11           ` KAMEZAWA Hiroyuki
2008-02-18  4:35       ` Balbir Singh
     [not found]         ` <47B90B04.3090001-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2008-02-18  4:55           ` KAMEZAWA Hiroyuki

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=20080218005335.D93F51E3C5A@siro.lan \
    --to=yamamoto-jcdqpdek3idl9jvzuh4aog@public.gmane.org \
    --cc=balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org \
    --cc=xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    /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