Commit a64a26e822ddb739de464540dfd2cbb6abce47d5

Authored by KOSAKI Motohiro
Committed by Linus Torvalds
1 parent 37e7b5f153

cpumask: add cpumask_var_t documentation

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>

Showing 1 changed file with 14 additions and 0 deletions Side-by-side Diff

include/linux/cpumask.h
... ... @@ -617,6 +617,20 @@
617 617 * ... use 'tmpmask' like a normal struct cpumask * ...
618 618 *
619 619 * free_cpumask_var(tmpmask);
  620 + *
  621 + *
  622 + * However, one notable exception is there. alloc_cpumask_var() allocates
  623 + * only nr_cpumask_bits bits (in the other hand, real cpumask_t always has
  624 + * NR_CPUS bits). Therefore you don't have to dereference cpumask_var_t.
  625 + *
  626 + * cpumask_var_t tmpmask;
  627 + * if (!alloc_cpumask_var(&tmpmask, GFP_KERNEL))
  628 + * return -ENOMEM;
  629 + *
  630 + * var = *tmpmask;
  631 + *
  632 + * This code makes NR_CPUS length memcopy and brings to a memory corruption.
  633 + * cpumask_copy() provide safe copy functionality.
620 634 */
621 635 #ifdef CONFIG_CPUMASK_OFFSTACK
622 636 typedef struct cpumask *cpumask_var_t;