From: Oleg Nesterov <oleg@tv-sign.ru>
To: Kirill Korotaev <dev@sw.ru>
Cc: Pavel Emelianov <xemul@sw.ru>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH 2/7] UBC: core (structures, API)
Date: Thu, 17 Aug 2006 22:35:51 +0400 [thread overview]
Message-ID: <20060817183551.GA588@oleg> (raw)
Kirill Korotaev wrote:
>
> +struct user_beancounter *beancounter_findcreate(uid_t uid,
> + struct user_beancounter *p, int mask)
> +{
> + struct user_beancounter *new_ub, *ub, *tmpl_ub;
> + unsigned long flags;
> + struct hlist_head *slot;
> + struct hlist_node *pos;
> +
> + if (mask & UB_LOOKUP_SUB) {
> + WARN_ON(p == NULL);
> + tmpl_ub = &default_subbeancounter;
> + slot = &ub_hash[ub_subhash_fun(p, uid)];
> + } else {
> + WARN_ON(p != NULL);
> + tmpl_ub = &default_beancounter;
> + slot = &ub_hash[ub_hash_fun(uid)];
> + }
> + new_ub = NULL;
> +
> +retry:
> + spin_lock_irqsave(&ub_hash_lock, flags);
> + hlist_for_each_entry (ub, pos, slot, hash)
> + if (ub->ub_uid == uid && ub->parent == p)
> + break;
> +
> + if (pos != NULL) {
> + get_beancounter(ub);
> + spin_unlock_irqrestore(&ub_hash_lock, flags);
> +
> + if (new_ub != NULL) {
> + put_beancounter(new_ub->parent);
^^^^^^^^^^^^^^
Stupid question: why ->parent can't be NULL ? (without UB_LOOKUP_SUB).
> + if (mask & UB_ALLOC_ATOMIC) {
> + new_ub = kmem_cache_alloc(ub_cachep, GFP_ATOMIC);
> + if (new_ub == NULL)
> + goto out_unlock;
> +
> + memcpy(new_ub, tmpl_ub, sizeof(*new_ub));
> + init_beancounter_struct(new_ub, uid);
> + if (p)
> + new_ub->parent = get_beancounter(p);
> + goto out_install;
> + }
> +
> + spin_unlock_irqrestore(&ub_hash_lock, flags);
> +
> + new_ub = kmem_cache_alloc(ub_cachep, GFP_KERNEL);
beancounter_findcreate() is not time critical, yes? Isn't it better
to kill 'if (mask & UB_ALLOC_ATOMIC) { ... }' and just do
new_ub = kmem_cache_alloc(ub_cachep,
UB_ALLOC_ATOMIC ? GFP_ATOMIC : GFP_KERNEL);
after spin_unlock(&ub_hash_lock) ?
Oleg.
next reply other threads:[~2006-08-17 14:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-17 18:35 Oleg Nesterov [this message]
2006-08-17 14:29 ` [RFC][PATCH 2/7] UBC: core (structures, API) Kirill Korotaev
-- strict thread matches above, loose matches on Subject: below --
2006-08-16 15:24 [RFC][PATCH] UBC: user resource beancounters Kirill Korotaev
2006-08-16 15:37 ` [RFC][PATCH 2/7] UBC: core (structures, API) Kirill Korotaev
2006-08-16 16:58 ` Alan Cox
2006-08-17 11:42 ` Kirill Korotaev
2006-08-16 17:15 ` Greg KH
2006-08-17 11:45 ` Kirill Korotaev
2006-08-17 12:14 ` Greg KH
2006-08-16 18:11 ` Rohit Seth
2006-08-16 18:18 ` Andrew Morton
2006-08-17 11:54 ` Kirill Korotaev
2006-08-17 11:53 ` Kirill Korotaev
2006-08-17 16:55 ` Rohit Seth
2006-08-18 11:14 ` Kirill Korotaev
2006-08-18 17:51 ` Rohit Seth
2006-08-18 5:31 ` Andrew Morton
2006-08-18 15:59 ` Alan Cox
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=20060817183551.GA588@oleg \
--to=oleg@tv-sign.ru \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dev@sw.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=xemul@sw.ru \
/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.