Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

KOSAKI Motohiro and committed by
Linus Torvalds
a64a26e8 37e7b5f1

+14
+14
include/linux/cpumask.h
··· 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;