Skip to contentSkip to conversation

hyper-v: use GFP_KERNEL for hv_context.hv_numa_map

PATCH In review Jia-Ju Bai 2 participants 3 messages Dec 18, 2017 – Dec 19, 2017 Hyper-V/Azure core and drivers

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH v2 1/1 hyper-v: use GFP_KERNEL for hv_context.hv_numa_map

The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context, namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

---
 drivers/hv/hv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv.c +1 -1
index 8267439..b0d025a 100644
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
 	int cpu;
 
 	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-					 GFP_ATOMIC);
+					 GFP_KERNEL);
 	if (hv_context.hv_numa_map == NULL) {
 		pr_err("Unable to allocate NUMA map\n");
 		goto err;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 16 lines · On Mon, 18 Dec 2017 17:02:52 +0800 Jia-Ju Bai <[email protected]> wrote:

The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context, namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

---
 drivers/hv/hv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv.c +0 -0
index 8267439..b0d025a 100644

drivers/hv/hv.c int hv_synic_alloc(void) · line 156

Quoted 8 lines
drivers/hv/hv.c +1 -1
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
 	int cpu;
 
 	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-					 GFP_ATOMIC);
+					 GFP_KERNEL);
 	if (hv_context.hv_numa_map == NULL) {
 		pr_err("Unable to allocate NUMA map\n");
 		goto err;

Thanks, for fixing this.
While you are at it; wouldn't it make sense to use kcalloc here?

author
#2 lore raw
Quoted 21 lines · Stephen Hemminger
Quoted 18 lines · On Mon, 18 Dec 2017 17:02:52 +0800 Jia-Ju Bai <[email protected]> wrote:

The kzalloc function is called with GFP_ATOMIC.
But according to driver call graph, it is not in atomic context, namely no spinlock is held nor in an interrupt handler.

This GFP_ATOMIC is unnecessary, and replace with GFP_KERNEL.

---
  drivers/hv/hv.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hv/hv.c +0 -0
index 8267439..b0d025a 100644
@@ -150,7 +150,7 @@ int hv_synic_alloc(void)
  	int cpu;
 
Quoted 8 lines

drivers/hv/hv.c int hv_synic_alloc(void) · line 156

Quoted 6 lines
drivers/hv/hv.c +1 -1
  	hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
-					 GFP_ATOMIC);
+					 GFP_KERNEL);
  	if (hv_context.hv_numa_map == NULL) {
  		pr_err("Unable to allocate NUMA map\n");
  		goto err;

Thanks, for fixing this.
While you are at it; wouldn't it make sense to use kcalloc here?

I think kcalloc can be used here.

Thanks,
Jia-Ju Bai