From: Andrew Morton <akpm@linux-foundation.org>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] genalloc: add support of named pool
Date: Fri, 16 Dec 2011 16:42:43 -0800 [thread overview]
Message-ID: <20111216164243.01c41930.akpm@linux-foundation.org> (raw)
In-Reply-To: <1323359408-24407-1-git-send-email-plagnioj@jcrosoft.com>
On Thu, 8 Dec 2011 16:50:08 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> so we can get the pool in the driver by name instead of passing it via
> parameter
I'm not seeing any code whcih actually uses this interface, so there's
no reason to apply the patch?
The changelog should tell us why you believe this patch is needed: use
case, end-user value, etc.
> --- a/include/linux/genalloc.h
> +++ b/include/linux/genalloc.h
> @@ -33,9 +33,12 @@
> * General purpose special memory pool descriptor.
> */
> struct gen_pool {
> + char *name; /* pool name */
> spinlock_t lock;
> struct list_head chunks; /* list of chunks in this pool */
> int min_alloc_order; /* minimum allocation order */
> +
> + struct list_head list;
The other fields have nice descriptive comments - why shouldn't this one?
> +static LIST_HEAD(pools);
Except for certain special circumstances (which I don't think apply
here), a global list needs a global lock to protect it.
> +
> static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set)
> {
> unsigned long val, nval;
> @@ -136,23 +138,50 @@ static int bitmap_clear_ll(unsigned long *map, int start, int nr)
> }
>
> /**
> + * gen_pool_byname - get pool by name
> + * @name: pool name
> + *
Remove that empty comment line.
> + */
> +struct gen_pool* gen_pool_byname(char *name)
The patch has several minor coding-style errors which can be detected
by scripts/checkpatch.pl.
> +{
> + struct gen_pool *pool;
> +
> + if (!name)
> + return NULL;
> +
> + list_for_each_entry(pool, &pools, list) {
> + if(pool->name && strcmp(pool->name, name) == 0)
> + return pool;
> + }
> +
> + return NULL;
> +}
> +EXPORT_SYMBOL(gen_pool_byname);
This function is racy and cannot be fixed. If some other process comes
along and deletes *pool immediately after this function has completed,
the caller of this function is left holding a dead pointer.
next prev parent reply other threads:[~2011-12-17 0:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-08 15:50 [PATCH] genalloc: add support of named pool Jean-Christophe PLAGNIOL-VILLARD
2011-12-17 0:42 ` Andrew Morton [this message]
2011-12-17 1:05 ` Stephen Rothwell
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=20111216164243.01c41930.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=plagnioj@jcrosoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox