From: Li Zefan <lizf@cn.fujitsu.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
containers@lists.linux-foundation.org,
Paul Menage <menage@google.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm 1/3] cgroup: use a hash table for css_set finding
Date: Thu, 03 Apr 2008 15:51:05 +0800 [thread overview]
Message-ID: <47F48C69.2080805@cn.fujitsu.com> (raw)
In-Reply-To: <20080403162459.4a90d574.kamezawa.hiroyu@jp.fujitsu.com>
KAMEZAWA Hiroyuki wrote:
> On Thu, 03 Apr 2008 13:52:43 +0800
> Li Zefan <lizf@cn.fujitsu.com> wrote:
>> +/* hash table for cgroup groups. This improves the performance to
>> + * find an existing css_set */
>> +#define CSS_SET_HASH_BITS 7
>> +#define CSS_SET_TABLE_SIZE (1 << CSS_SET_HASH_BITS)
>> +static struct hlist_head css_set_table[CSS_SET_TABLE_SIZE];
>
> How above number is selected ?
>
I suppose 100 will be suitable, so i would like to choose from 6 or 7 bits.
>> +static struct hlist_head *css_set_hash(struct cgroup_subsys_state *css[])
>> +{
>> + int i;
>> + int index;
>> + unsigned long tmp = 0UL;
>> +
>> + for (i = 0; i < CGROUP_SUBSYS_COUNT; i++)
>> + tmp += (unsigned long)css[i];
>> +
>
> maybe css[i]'s lower 2-3 bits will be ignored. because thery are always 0.
>
> And I don't like "+" for hash. how about
> ==
> for (i = 0; i < CGROUP_SUBSYS_COUNT; i++)
> unsigned long x;
> x = (unsigned long)css[i];
> tmp = (x >> 16) ^ (x & 0xffff)
> ==
> or some func, which uses full bits.
>
I'm using hash_long(), which has been proved to be a good one. And I've tested
css_set_hash(), I run the css_set benchmark with N == 1000, the for loop in
find_existing_css_set() will break out within 10 iterations for most cases,
which is the expected result.
>
>> + index = hash_long(tmp, CSS_SET_HASH_BITS);
>> +
>> + return &css_set_table[index];
>> +}
>> +
>> /* We don't maintain the lists running through each css_set to its
>> * task until after the first call to cgroup_iter_start(). This
>> * reduces the fork()/exit() overhead for people who have cgroups
>> @@ -219,6 +240,7 @@ static int use_task_css_set_links;
>> static void unlink_css_set(struct css_set *cg)
>> {
>> write_lock(&css_set_lock);
>> + hlist_del(&cg->hlist);
>> list_del(&cg->list);
>> css_set_count--;
>
> This css_set_lock is worth to be rwlock ?
> how about per hashline spinlock ? (but per-hashline seems overkill..)
>
I think it's an overkill. And the css_set_lock protects not only the hash
table.
Thanks for looking into this. :)
Regards,
Li Zefan
next prev parent reply other threads:[~2008-04-03 7:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-03 5:52 [PATCH -mm 1/3] cgroup: use a hash table for css_set finding Li Zefan
[not found] ` <47F470AB.2070904-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-04-03 7:24 ` KAMEZAWA Hiroyuki
2008-04-03 7:24 ` KAMEZAWA Hiroyuki
2008-04-03 7:51 ` Li Zefan [this message]
2008-04-03 10:13 ` Li Zefan
[not found] ` <47F48C69.2080805-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-04-03 10:13 ` Li Zefan
2008-04-03 10:17 ` Li Zefan
2008-04-03 10:17 ` Li Zefan
[not found] ` <20080403162459.4a90d574.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2008-04-03 7:51 ` Li Zefan
-- strict thread matches above, loose matches on Subject: below --
2008-04-03 5:52 Li Zefan
2008-04-02 2:16 Li Zefan
2008-04-02 10:23 ` Paul Menage
[not found] ` <47F2EC8D.30805-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-04-02 10:23 ` Paul Menage
2008-04-02 2:16 Li Zefan
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=47F48C69.2080805@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.