Skip to contentSkip to conversation

kernel: x86: apic: Replace GFP_ATOMIC with GFP_KERNEL in __add_pin_to_irq_node

PATCH NAK Jia-Ju Bai 3 participants 5 messages Jan 24, 2018 – Feb 13, 2018 x86

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 kernel: x86: apic: Replace GFP_ATOMIC with GFP_KERNEL in __add_pin_to_irq_node

The function __add_pin_to_irq_node is not called in atomic context. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

---
 arch/x86/kernel/apic/io_apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +1 -1
index 201579d..665c013 100644
@@ -379,7 +379,7 @@ static int __add_pin_to_irq_node(struct mp_chip_data *data,
 		if (entry->apic == apic && entry->pin == pin)
 			return 0;
 
-	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_ATOMIC, node);
+	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 	if (!entry) {
 		pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
 		       node, apic, pin);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 13 lines · Jia-Ju Bai

The function __add_pin_to_irq_node is not called in atomic context. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

---
 arch/x86/kernel/apic/io_apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +0 -0
index 201579d..665c013 100644

arch/x86/kernel/apic/io_apic.c static int __add_pin_to_irq_node(struct mp_chip_data *data, · line 385

Quoted 8 lines
arch/x86/kernel/apic/io_apic.c +1 -1
@@ -379,7 +379,7 @@ static int __add_pin_to_irq_node(struct mp_chip_data *data,
 		if (entry->apic == apic && entry->pin == pin)
 			return 0;
 
-	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_ATOMIC, node);
+	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 	if (!entry) {
 		pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
 		       node, apic, pin);

NAK: this is called in an atomic section: with IRQs disabled ...

Thanks,

Ingo

#2 lore raw
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Jia-Ju Bai

The function __add_pin_to_irq_node is not called in atomic context. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

---
 arch/x86/kernel/apic/io_apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +0 -0
index 201579d..665c013 100644
@@ -379,7 +379,7 @@ static int __add_pin_to_irq_node(struct mp_chip_data *data,
 		if (entry->apic == apic && entry->pin == pin)
 			return 0;
 
Quoted 7 lines

arch/x86/kernel/apic/io_apic.c static int __add_pin_to_irq_node(struct mp_chip_data *data, · line 385

Quoted 5 lines
arch/x86/kernel/apic/io_apic.c +1 -1
-	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_ATOMIC, node);
+	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 	if (!entry) {
 		pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
 		       node, apic, pin);

NAK: this is called in an atomic section: with IRQs disabled ...

The only invocation where this happens with IRQs disabled is the early check_timer() code which runs _before_ the scheduler is working. GFP_KERNEL is valid during that phase. All other call sites have interrupts enabled.

Thanks,

tglx

#3 lore raw
Quoted 27 lines · Thomas Gleixner
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Jia-Ju Bai

The function __add_pin_to_irq_node is not called in atomic context. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

---
 arch/x86/kernel/apic/io_apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +0 -0
index 201579d..665c013 100644
@@ -379,7 +379,7 @@ static int __add_pin_to_irq_node(struct mp_chip_data *data,
 		if (entry->apic == apic && entry->pin == pin)
 			return 0;
 
Quoted 7 lines

arch/x86/kernel/apic/io_apic.c static int __add_pin_to_irq_node(struct mp_chip_data *data, · line 385

Quoted 5 lines
arch/x86/kernel/apic/io_apic.c +1 -1
-	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_ATOMIC, node);
+	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 	if (!entry) {
 		pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
 		       node, apic, pin);

NAK: this is called in an atomic section: with IRQs disabled ...

Quoted 3 lines

The only invocation where this happens with IRQs disabled is the early check_timer() code which runs _before_ the scheduler is working. GFP_KERNEL is valid during that phase. All other call sites have interrupts enabled.

Yeah, so at minimum there's a mismatch between the changelog:

Quoted 1 line
Quoted 1 line
Quoted 1 line

The function __add_pin_to_irq_node is not called in atomic context.

... and actual behavior. What you wrote should be part of the changelog I suspect.

Thanks,

Ingo

#4 lore raw
Quoted 32 lines · Ingo Molnar
Quoted 27 lines · Thomas Gleixner
Quoted 18 lines · Ingo Molnar
Quoted 16 lines · Jia-Ju Bai

The function __add_pin_to_irq_node is not called in atomic context. Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

---
 arch/x86/kernel/apic/io_apic.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/io_apic.c +0 -0
index 201579d..665c013 100644
@@ -379,7 +379,7 @@ static int __add_pin_to_irq_node(struct mp_chip_data *data,
 		if (entry->apic == apic && entry->pin == pin)
 			return 0;
 
Quoted 7 lines

arch/x86/kernel/apic/io_apic.c static int __add_pin_to_irq_node(struct mp_chip_data *data, · line 385

Quoted 5 lines
arch/x86/kernel/apic/io_apic.c +1 -1
-	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_ATOMIC, node);
+	entry = kzalloc_node(sizeof(struct irq_pin_list), GFP_KERNEL, node);
 	if (!entry) {
 		pr_err("can not alloc irq_pin_list (%d,%d,%d)\n",
 		       node, apic, pin);

NAK: this is called in an atomic section: with IRQs disabled ...

Quoted 3 lines

The only invocation where this happens with IRQs disabled is the early check_timer() code which runs _before_ the scheduler is working. GFP_KERNEL is valid during that phase. All other call sites have interrupts enabled.

Quoted 5 lines

Yeah, so at minimum there's a mismatch between the changelog:

Quoted 1 line
Quoted 1 line
Quoted 1 line

The function __add_pin_to_irq_node is not called in atomic context.

... and actual behavior. What you wrote should be part of the changelog I suspect.

Fair enough.