From: Andrew Morton <akpm@linux-foundation.org>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
"nishimura@mxp.nes.nec.co.jp" <nishimura@mxp.nes.nec.co.jp>,
"balbir@linux.vnet.ibm.com" <balbir@linux.vnet.ibm.com>,
gthelen@google.com, m-ikeda@ds.jp.nec.com,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH 1/7][memcg] virtually indexed array library.
Date: Wed, 28 Jul 2010 12:45:13 -0700 [thread overview]
Message-ID: <20100728124513.85bfa047.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100727165303.7d7d18e9.kamezawa.hiroyu@jp.fujitsu.com>
On Tue, 27 Jul 2010 16:53:03 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> This virt-array allocates a virtally contiguous array via get_vm_area()
> and allows object allocation per an element of array.
> Physical pages are used only for used items in the array.
>
> - At first, the user has to create an array by create_virt_array().
> - At using an element, virt_array_alloc_index(index) should be called.
> - At freeing an element, virt_array_free_index(index) should be called.
> - At destroying, destroy_virt_array() should be called.
>
> Item used/unused status is controlled by bitmap and back-end physical
> pages are automatically allocated/freed. This is useful when you
> want to access objects by index in light weight. For example,
>
> create_virt_array(va);
> struct your_struct *objmap = va->address;
> Then, you can access your objects by objmap[i].
>
> In usual case, holding reference by index rather than pointer can save memory.
> But index -> object lookup cost cannot be negligible. In such case,
> this virt-array may be helpful. Ah yes, if lookup performance is not important,
> using radix-tree will be better (from TLB point of view). This virty-array
> may consume VMALLOC area too much. and alloc/free routine is very slow.
>
> Changelog:
> - fixed bugs in bitmap ops.
> - add offset for find_free_index.
>
My gut reaction to this sort of thing is "run away in terror". It
encourages kernel developers to operate like lackadaisical userspace
developers and to assume that underlying code can perform heroic and
immortal feats. But it can't. This is the kernel and the kernel is a
tough and hostile place and callers should be careful and defensive and
take great efforts to minimise the strain they put upon other systems.
IOW, can we avoid doing this?
>
> ...
>
> +void free_varray_item(struct virt_array *v, int idx)
> +{
> + mutex_lock(&v->mutex);
> + __free_unmap_entry(v, idx);
> + mutex_unlock(&v->mutex);
> +}
It's generally a bad idea for library code to perform its own locking.
In this case we've just made this whole facility inaccessible to code
which runs from interrupt or atomic contexts.
> + pg[0] = alloc_page(GFP_KERNEL);
And hard-wiring GFP_KERNEL makes this facility inaccessible to GFP_NOIO
and GFP_NOFS contexts as well.
--
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:[~2010-07-28 19:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-27 7:51 [RFC][PATCH 0/7][memcg] towards I/O aware memory cgroup KAMEZAWA Hiroyuki
2010-07-27 7:53 ` [RFC][PATCH 1/7][memcg] virtually indexed array library KAMEZAWA Hiroyuki
2010-07-27 18:29 ` Jonathan Corbet
2010-07-28 0:08 ` KAMEZAWA Hiroyuki
2010-07-28 19:45 ` Andrew Morton [this message]
2010-07-29 0:32 ` KAMEZAWA Hiroyuki
2010-07-29 4:27 ` KAMEZAWA Hiroyuki
2010-08-02 18:00 ` Balbir Singh
2010-08-02 23:45 ` KAMEZAWA Hiroyuki
2010-07-27 7:54 ` [RFC][PATCH 2/7][memcg] cgroup arbitarary ID allocation KAMEZAWA Hiroyuki
2010-07-28 2:30 ` Vivek Goyal
2010-07-28 2:35 ` KAMEZAWA Hiroyuki
2010-07-28 3:10 ` Vivek Goyal
2010-08-02 18:04 ` Balbir Singh
2010-08-02 23:45 ` KAMEZAWA Hiroyuki
2010-07-27 7:55 ` [RFC][PATCH 3/7][memcg] memcg on virt array for quick access via ID KAMEZAWA Hiroyuki
2010-07-27 7:56 ` [RFC][PATCH 4/7][memcg] memcg use ID in page_cgroup KAMEZAWA Hiroyuki
2010-07-28 2:39 ` Vivek Goyal
2010-07-28 2:44 ` KAMEZAWA Hiroyuki
2010-07-28 3:13 ` Vivek Goyal
2010-07-28 3:18 ` KAMEZAWA Hiroyuki
2010-07-28 3:21 ` KAMEZAWA Hiroyuki
2010-07-28 14:17 ` Vivek Goyal
2010-07-28 15:43 ` Munehiro Ikeda
2010-07-27 7:59 ` [RFC][PATCH 5/7][memcg] memcg lockless update of file mapped KAMEZAWA Hiroyuki
2010-07-28 7:09 ` Greg Thelen
2010-07-28 7:13 ` KAMEZAWA Hiroyuki
2010-07-27 8:00 ` [RFC][PATCH 6/7][memcg] generic file status update KAMEZAWA Hiroyuki
2010-07-28 7:12 ` Greg Thelen
2010-07-28 7:14 ` KAMEZAWA Hiroyuki
2010-07-27 8:02 ` [RFC][PATCH 7/7][memcg] use spin lock instead of bit_spin_lock in page_cgroup KAMEZAWA Hiroyuki
2010-07-28 6:16 ` Greg Thelen
2010-07-28 6:20 ` KAMEZAWA Hiroyuki
2010-08-02 18:09 ` Balbir Singh
2010-08-02 23:46 ` KAMEZAWA Hiroyuki
2010-07-28 0:13 ` [RFC][PATCH 0/7][memcg] towards I/O aware memory cgroup KAMEZAWA Hiroyuki
2010-07-28 14:42 ` 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=20100728124513.85bfa047.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=gthelen@google.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=m-ikeda@ds.jp.nec.com \
--cc=nishimura@mxp.nes.nec.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;
as well as URLs for NNTP newsgroup(s).