Skip to contentSkip to conversation

cpumask: add cpumask_var_t documentation

PATCH Superseded KOSAKI Motohiro 2 participants 5 messages Apr 28, 2011 Bitmap API

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpumask: add cpumask_var_t documentation

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/cpumask.h +14 -0
index 1e40dd0..471c98a 100644
@@ -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 (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 bring memroy corruption.
+ * You have to use cpumask_copy() instead.
  */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 typedef struct cpumask *cpumask_var_t;
Signature · 1 line
1.7.3.1
#1 lore raw
Quoted 13 lines · KOSAKI Motohiro

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++

 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/cpumask.h +0 -0
index 1e40dd0..471c98a 100644

include/linux/cpumask.h static inline size_t cpumask_size(void) · line 623

Quoted 7 lines
include/linux/cpumask.h +4 -0
@@ -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" ?

Quoted 2 lines

(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/ ?

Quoted 8 lines

+ *
+ *     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?

Quoted 2 lines

+ * You have to use cpumask_copy() instead.
 */

I don't get this. :(

Quoted 13 lines

 #ifdef CONFIG_CPUMASK_OFFSTACK
 typedef struct cpumask *cpumask_var_t;
--
1.7.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

#2 lore raw

PATCH v3 1/1 cpumask: add cpumask_var_t documentation

Quoted 10 lines
Quoted 8 lines · KOSAKI Motohiro

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++

 1 files changed, 14 insertions(+), 0 deletions(-)
Quoted 14 lines

include/linux/cpumask.h static inline size_t cpumask_size(void) · line 623

Quoted 12 lines
include/linux/cpumask.h +4 -0
index 1e40dd0..471c98a 100644
@@ -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? :)

Quoted 5 lines
Quoted 2 lines

(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.

Quoted 9 lines
Quoted 8 lines

+ *
+ *     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.

Quoted 4 lines

/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.

Quoted 4 lines
Quoted 2 lines

+ * You have to use cpumask_copy() instead.
 */

I don't get this. :(

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

Quoted 1 line

From d2ea9d4846e46bcc8a82b9a641ede3a10aca346c Mon Sep 17 00:00:00 2001

From: KOSAKI Motohiro <[email protected]>
Date: Tue, 26 Apr 2011 19:58:39 +0900
Subject: [PATCH v3] cpumask: add cpumask_var_t documentation

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/cpumask.h +14 -0
index 1e40dd0..e2b9032 100644
@@ -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 bring memory corruption.
+ * cpumask_copy() privide safe copy functionality.
  */
 #ifdef CONFIG_CPUMASK_OFFSTACK
 typedef struct cpumask *cpumask_var_t;
Signature · 1 line
1.7.3.1
#3 lore raw
Quoted 25 lines · KOSAKI Motohiro
Quoted 10 lines
Quoted 8 lines · KOSAKI Motohiro

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++

 1 files changed, 14 insertions(+), 0 deletions(-)
Quoted 14 lines

include/linux/cpumask.h static inline size_t cpumask_size(void) · line 623

Quoted 12 lines
include/linux/cpumask.h +4 -0
index 1e40dd0..471c98a 100644
@@ -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" ?

Quoted 2 lines

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

Yup. Thx.

Quoted 27 lines
Quoted 6 lines
Quoted 3 lines

(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.

Quoted 9 lines
Quoted 8 lines

+ *
+ *     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.

Quoted 4 lines

/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.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

+ * You have to use cpumask_copy() instead.
 */

I don't get this. :(

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

Yes. ;)

Quoted 25 lines

From d2ea9d4846e46bcc8a82b9a641ede3a10aca346c Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <[email protected]>
Date: Tue, 26 Apr 2011 19:58:39 +0900
Subject: [PATCH v3] cpumask: add cpumask_var_t documentation

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++

 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/cpumask.h +3 -0
index 1e40dd0..e2b9032 100644
@@ -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

include/linux/cpumask.h static inline size_t cpumask_size(void) · line 632

Quoted 10 lines
include/linux/cpumask.h +10 -0
+ * 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 bring memory corruption.

Maybe:

s/bring memory/brings to a memory/

?

include/linux/cpumask.h static inline size_t cpumask_size(void) · line 633

Quoted 1 line
include/linux/cpumask.h +1 -0
+ * cpumask_copy() privide safe copy functionality.

s/privide/provides ?

Quoted 9 lines
include/linux/cpumask.h +0 -1
  */
  #ifdef CONFIG_CPUMASK_OFFSTACK
  typedef struct cpumask *cpumask_var_t;
--

1.7.3.1

#4 lore raw

PATCH v4 1/1 cpumask: add cpumask_var_t documentation

Quoted 10 lines
Quoted 1 line

+ * This code makes NR_CPUS length memcopy and bring memory corruption.

Maybe:

s/bring memory/brings to a memory/

?

Quoted 1 line

+ * cpumask_copy() privide safe copy functionality.

s/privide/provides ?

Thank you.

Quoted 1 line

From 28549f1a51072a58bd661a409e378e36a97072a3 Mon Sep 17 00:00:00 2001

From: KOSAKI Motohiro <[email protected]>
Date: Tue, 26 Apr 2011 19:58:39 +0900
Subject: [PATCH v4] cpumask: add cpumask_var_t documentation

cpumask_var_t has one nortable difference against cpumask_t. This patch adds the explanation.

---
 include/linux/cpumask.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
include/linux/cpumask.h +14 -0
index 1e40dd0..8fcd82c 100644
@@ -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;
Signature · 1 line
1.7.3.1