cpumask: add cpumask_var_t documentation
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Tue, 26 Jul 2011 23:08:45 +0000 (16:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Jul 2011 23:49:44 +0000 (16:49 -0700)
cpumask_var_t has one notable difference from cpumask_t.  Add the
explanation.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Thiago Farina <tfransosi@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/cpumask.h

index b24ac56477b46bea69e7e748c04896cc564eda43..4f7a632374713c73fe096bb81f0f9daf122571c9 100644 (file)
@@ -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. alloc_cpumask_var() allocates
+ * only nr_cpumask_bits bits (in the other hand, real cpumask_t always has
+ * NR_CPUS bits). Therefore you don't have to dereference cpumask_var_t.
+ *
+ *     cpumask_var_t tmpmask;
+ *     if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
+ *             return -ENOMEM;
+ *
+ *     var = *tmpmask;
+ *
+ * This code makes NR_CPUS length memcopy and brings to a memory corruption.
+ * cpumask_copy() provide safe copy functionality.
  */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 typedef struct cpumask *cpumask_var_t;