linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Paul Menage" <menage@google.com>
To: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Linux Containers <containers@lists.osdl.org>,
	YAMAMOTO Takashi <yamamoto@valinux.co.jp>,
	Eric W Biederman <ebiederm@xmission.com>,
	Linux MM Mailing List <linux-mm@kvack.org>,
	Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
	Pavel Emelianov <xemul@openvz.org>,
	Dave Hansen <haveblue@us.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][-mm PATCH 4/8] Memory controller memory accounting (v3)
Date: Fri, 20 Jul 2007 14:03:36 -0700	[thread overview]
Message-ID: <6599ad830707201403n6a364514y601996145fa3714c@mail.gmail.com> (raw)
In-Reply-To: <20070720082440.20752.67223.sendpatchset@balbir-laptop>

On 7/20/07, Balbir Singh <balbir@linux.vnet.ibm.com> wrote:

> +void __always_inline unlock_meta_page(struct page *page)
> +{
> +       bit_spin_unlock(PG_metapage, &page->flags);
> +}

Maybe add a BUG_ON(!test_bit(PG_metapage, &page->flags)) at least for
development?

> +       mem = rcu_dereference(mm->mem_container);
> +       /*
> +        * For every charge from the container, increment reference
> +        * count
> +        */
> +       css_get(&mem->css);
> +       rcu_read_unlock();

It's not clear to me that this is safe.

If

> +
> +       /*
> +        * If we created the meta_page, we should free it on exceeding
> +        * the container limit.
> +        */
> +       if (res_counter_charge(&mem->res, 1)) {
> +               css_put(&mem->css);
> +               goto free_mp;
> +       }
> +
> +       lock_meta_page(page);
> +       /*
> +        * Check if somebody else beat us to allocating the meta_page
> +        */
> +       if (page_get_meta_page(page)) {

I think you need to add something like

  kfree(mp);
  mp = page_get_meta_page(page);

otherwise you're going to leak the new but unneeded metapage.

> +               atomic_inc(&mp->ref_cnt);
> +               res_counter_uncharge(&mem->res, 1);
> +               goto done;
> +       }
> +
> +       atomic_set(&mp->ref_cnt, 1);
> +       mp->mem_container = mem;
> +       mp->page = page;
> +       page_assign_meta_page(page, mp);

Would it make sense to have the "mp->page = page" be part of
page_assign_meta_page() for consistency?

> +err:
> +       unlock_meta_page(page);
> +       return -ENOMEM;

The only jump to err: is from a location where the metapage is already
unlocked. Maybe scrap err: and just do a return -ENOMEM when the
allocation fails?

> +out_uncharge:
> +       mem_container_uncharge(page_get_meta_page(page));

Wanting to call mem_container_uncharge() on a page and hence having to
call page_get_meta_page() seems to be more common than wanting to call
it on a meta page that you already have available. Maybe make
mem_container_uncharge() be a wrapper that take a struct page and does
something like mem_container_uncharge_mp(page_get_meta_page(page))
where mem_container_uncharge_mp() is the raw meta-page version?

Paul

--
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>

  reply	other threads:[~2007-07-20 21:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-20  8:23 [RFC][-mm PATCH 0/8] Memory controller introduction (v3) Balbir Singh
2007-07-20  8:24 ` [RFC][-mm PATCH 1/8] Memory controller resource counters (v3) Balbir Singh
2007-07-20 20:20   ` Paul Menage
2007-07-21 17:00     ` Balbir Singh
2007-07-20  8:24 ` [RFC][-mm PATCH 2/8] Memory controller containers setup (v3) Balbir Singh
2007-07-20 20:30   ` Paul Menage
2007-07-21 17:04     ` Balbir Singh
2007-07-20  8:24 ` [RFC][-mm PATCH 3/8] Memory controller accounting " Balbir Singh
2007-07-20 20:33   ` Paul Menage
2007-07-20 20:39     ` Paul Menage
2007-07-20  8:24 ` [RFC][-mm PATCH 4/8] Memory controller memory accounting (v3) Balbir Singh
2007-07-20 21:03   ` Paul Menage [this message]
2007-07-20 21:09     ` Paul Menage
2007-07-21 17:11     ` Balbir Singh
2007-07-20  8:24 ` [RFC][-mm PATCH 5/8] Memory controller task migration (v3) Balbir Singh
2007-07-20  8:25 ` [RFC][-mm PATCH 6/8] Memory controller add per container LRU and reclaim (v3) Balbir Singh
2007-07-24 11:51   ` YAMAMOTO Takashi
2007-07-24 12:14     ` Balbir Singh
2007-07-20  8:25 ` [RFC][-mm PATCH 7/8] Memory controller OOM handling (v3) Balbir Singh
2007-07-20  8:25 ` [RFC][-mm PATCH 8/8] Add switch to control what type of pages to limit (v3) Balbir Singh
2007-07-20 21:41   ` Paul Menage

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=6599ad830707201403n6a364514y601996145fa3714c@mail.gmail.com \
    --to=menage@google.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=haveblue@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=svaidy@linux.vnet.ibm.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