All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steffen Klassert <steffen.klassert@secunet.com>
To: Dan Kruchinin <dkruchinin@acm.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Herbert Xu <herbert@gondor.hengli.com.au>
Subject: Re: [PATCH 1/3] padata: separate serial and parallel cpumasks
Date: Tue, 6 Jul 2010 15:28:25 +0200	[thread overview]
Message-ID: <20100706132825.GT10072@secunet.com> (raw)
In-Reply-To: <AANLkTimYK_4PcVrAniOE3pQjgYNwYNjI6q8p1FMZntEa@mail.gmail.com>

On Tue, Jul 06, 2010 at 12:31:21PM +0400, Dan Kruchinin wrote:
> 
> Would't it be the same as with a pointer to cpumask_var_t? I mean:

Using a pointer to cpumask_var_t is a bit problematic because
you don't know a priori about the type of cpumask_var_t.
The type depends whether the cpumasks are on/off stack.
So the easiest thing is to embed it to a struct, then you don't
need to care about the type. If you allocate a struct of type
pcrypt_cpumask you get what you want to have.

> struct pcrypt {
>   ...
>   struct pcrypt_cpumask *mask;
>   ...
> } pencrypt;
> 
> To assign a pointer via RCU:
> 
> int cpumask_change_nitify(...) {
>    ...
>   struct pcrypt_cpumask *new_mask = kmalloc(sizeof(*mask), GFP);
>   struct pcrypt_cpumask *old_mask = pencrypt.mask;
> 
>   if (!new_mask)
>      error();
>   if (!alloc_cpumask_var(&new_mask->smask, GFP_KERNEL))
>      error();
> 
>   get_serial_cpumask_from_padata(new_mask->mask);
>   rcu_assign_pointer(pencrypt.mask, new_mask);
>   synchronize_rcu_bh();
> 
>   free_cpumask_var(old_mask->smask);
>   kfree(old_mask);
>   ...
> }
> 
> It's a bit hard to read this code because at the first sight it
> appears unclear and odd why we allocate the structure with only one
> member.
> 

We can easily add a code comment if this appears to be unclear :)

  reply	other threads:[~2010-07-06 13:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTikeDE4hvZ3spyTBSHZsdQPc-2wlD5nTfb1aF-VD@mail.gmail.com>
2010-07-02  8:53 ` [PATCH 1/3] padata: separate serial and parallel cpumasks Steffen Klassert
     [not found]   ` <AANLkTinyPGjXjlvJxB8WYB3EYFBtANXMzpTdUixyBRHW@mail.gmail.com>
2010-07-02  9:17     ` Steffen Klassert
2010-07-02  9:32       ` Dan Kruchinin
2010-07-02  9:34         ` Dan Kruchinin
2010-07-02 11:11         ` Steffen Klassert
2010-07-02 13:01           ` Dan Kruchinin
2010-07-05 10:58             ` Steffen Klassert
     [not found]           ` <AANLkTimEgKGJ5pi7GzOnvP42ivJ4GCKX59LdKK0x4fnx@mail.gmail.com>
     [not found]             ` <20100706053612.GQ10072@secunet.com>
2010-07-06  5:44               ` Steffen Klassert
2010-07-06  7:40                 ` Dan Kruchinin
2010-07-06  7:46                   ` Steffen Klassert
2010-07-06  8:31                     ` Dan Kruchinin
2010-07-06 13:28                       ` Steffen Klassert [this message]
2010-07-06 16:30                         ` Dan Kruchinin
2010-07-07 13:16                           ` Steffen Klassert

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=20100706132825.GT10072@secunet.com \
    --to=steffen.klassert@secunet.com \
    --cc=dkruchinin@acm.org \
    --cc=herbert@gondor.hengli.com.au \
    --cc=linux-kernel@vger.kernel.org \
    /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.