[PATCH v3] cpumask: add cpumask_var_t documentation

From: KOSAKI Motohiro
Date: Thu Apr 28 2011 - 11:43:36 EST


> On Thu, Apr 28, 2011 at 12:27 PM, KOSAKI Motohiro
> <kosaki.motohiro@xxxxxxxxxxxxxx> wrote:
> > cpumask_var_t has one nortable difference against cpumask_t.
> > This patch adds the explanation.
> >
> > Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
> > ---
> > Âinclude/linux/cpumask.h | Â 14 ++++++++++++++
> > Â1 files changed, 14 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> > index 1e40dd0..471c98a 100644
> > --- a/include/linux/cpumask.h
> > +++ b/include/linux/cpumask.h
> > @@ -617,6 +617,20 @@ static inline size_t cpumask_size(void)
> > Â* Â Â Â ... use 'tmpmask' like a normal struct cpumask * ...
> > Â*
> > Â* Â Â free_cpumask_var(tmpmask);
> > + *
> > + *
> > + * However, one notable exception is there. cpumask_var_t is allocated
> > + * only nr_cpu_ids bits
>
> Maybe, instead of "is allocated only", "allocates only" ?

Instead, "alloc_cpumask_var() allocates only nr_cpu_ids bits" is more clear? :)


> > (in the other hand, real cpumask_t always has
> > + * NR_CPUS bits). therefore You don't have to dereference cpumask_var_t.
>
> s/therefore You/Therefore you/ ?
>

Thx.


> > + *
> > + * Â Â cpumask_var_t tmpmask;
> > + * Â Â if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
> > + * Â Â Â Â Â Â return -ENOMEM;
> > + *
> > + * Â Â var = *tmpmask;
> > + *
> > + * This code makes NR_CPUS length memcopy and bring memroy corruption.
>
> /s/memroy/memory
>
> You are saying that I should not use this code? I'm confused, could
> you explain a little bit?

Yes. you aren't confused.


> > + * You have to use cpumask_copy() instead.
> > Â*/
>
> I don't get this. :(

"cpumask_copy() privide safe copy functionality." is clear?