From: Brian Gerst <brgerst@gmail.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Ard Biesheuvel <ardb@kernel.org>,
Uros Bizjak <ubizjak@gmail.com>,
Linus Torvalds <torvalds@linuxfoundation.org>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Brian Gerst <brgerst@gmail.com>
Subject: [PATCH v3 07/11] x86/irq: Move irq stacks to percpu hot section
Date: Mon, 3 Mar 2025 11:52:42 -0500 [thread overview]
Message-ID: <20250303165246.2175811-8-brgerst@gmail.com> (raw)
In-Reply-To: <20250303165246.2175811-1-brgerst@gmail.com>
No functional change.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/include/asm/current.h | 6 ------
arch/x86/include/asm/irq_stack.h | 12 ++++++------
arch/x86/include/asm/processor.h | 7 +++++++
arch/x86/kernel/dumpstack_32.c | 4 ++--
arch/x86/kernel/dumpstack_64.c | 2 +-
arch/x86/kernel/irq.c | 2 ++
arch/x86/kernel/irq_32.c | 12 +++++++-----
arch/x86/kernel/irq_64.c | 7 ++++---
arch/x86/kernel/process_64.c | 2 +-
9 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/arch/x86/include/asm/current.h b/arch/x86/include/asm/current.h
index f153c77853de..6fad5a4c21d7 100644
--- a/arch/x86/include/asm/current.h
+++ b/arch/x86/include/asm/current.h
@@ -15,12 +15,6 @@ struct task_struct;
struct pcpu_hot {
struct task_struct *current_task;
unsigned long top_of_stack;
- void *hardirq_stack_ptr;
-#ifdef CONFIG_X86_64
- bool hardirq_stack_inuse;
-#else
- void *softirq_stack_ptr;
-#endif
};
DECLARE_PER_CPU_CACHE_HOT(struct pcpu_hot, pcpu_hot);
diff --git a/arch/x86/include/asm/irq_stack.h b/arch/x86/include/asm/irq_stack.h
index 8e56a07aef70..3ce0314eaf7c 100644
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -117,7 +117,7 @@
ASM_CALL_ARG2
#define call_on_irqstack(func, asm_call, argconstr...) \
- call_on_stack(__this_cpu_read(pcpu_hot.hardirq_stack_ptr), \
+ call_on_stack(__this_cpu_read(hardirq_stack_ptr), \
func, asm_call, argconstr)
/* Macros to assert type correctness for run_*_on_irqstack macros */
@@ -136,7 +136,7 @@
* User mode entry and interrupt on the irq stack do not \
* switch stacks. If from user mode the task stack is empty. \
*/ \
- if (user_mode(regs) || __this_cpu_read(pcpu_hot.hardirq_stack_inuse)) { \
+ if (user_mode(regs) || __this_cpu_read(hardirq_stack_inuse)) { \
irq_enter_rcu(); \
func(c_args); \
irq_exit_rcu(); \
@@ -147,9 +147,9 @@
* places. Invoke the stack switch macro with the call \
* sequence which matches the above direct invocation. \
*/ \
- __this_cpu_write(pcpu_hot.hardirq_stack_inuse, true); \
+ __this_cpu_write(hardirq_stack_inuse, true); \
call_on_irqstack(func, asm_call, constr); \
- __this_cpu_write(pcpu_hot.hardirq_stack_inuse, false); \
+ __this_cpu_write(hardirq_stack_inuse, false); \
} \
}
@@ -213,9 +213,9 @@
*/
#define do_softirq_own_stack() \
{ \
- __this_cpu_write(pcpu_hot.hardirq_stack_inuse, true); \
+ __this_cpu_write(hardirq_stack_inuse, true); \
call_on_irqstack(__do_softirq, ASM_CALL_ARG0); \
- __this_cpu_write(pcpu_hot.hardirq_stack_inuse, false); \
+ __this_cpu_write(hardirq_stack_inuse, false); \
}
#endif
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index a969bea1ed07..9203cecb7695 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -420,6 +420,13 @@ struct irq_stack {
char stack[IRQ_STACK_SIZE];
} __aligned(IRQ_STACK_SIZE);
+DECLARE_PER_CPU_CACHE_HOT(struct irq_stack *, hardirq_stack_ptr);
+#ifdef CONFIG_X86_64
+DECLARE_PER_CPU_CACHE_HOT(bool, hardirq_stack_inuse);
+#else
+DECLARE_PER_CPU_CACHE_HOT(struct irq_stack *, softirq_stack_ptr);
+#endif
+
#ifdef CONFIG_X86_64
static inline unsigned long cpu_kernelmode_gs_base(int cpu)
{
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index b4905d5173fd..722fd712e1cf 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -37,7 +37,7 @@ const char *stack_type_name(enum stack_type type)
static bool in_hardirq_stack(unsigned long *stack, struct stack_info *info)
{
- unsigned long *begin = (unsigned long *)this_cpu_read(pcpu_hot.hardirq_stack_ptr);
+ unsigned long *begin = (unsigned long *)this_cpu_read(hardirq_stack_ptr);
unsigned long *end = begin + (THREAD_SIZE / sizeof(long));
/*
@@ -62,7 +62,7 @@ static bool in_hardirq_stack(unsigned long *stack, struct stack_info *info)
static bool in_softirq_stack(unsigned long *stack, struct stack_info *info)
{
- unsigned long *begin = (unsigned long *)this_cpu_read(pcpu_hot.softirq_stack_ptr);
+ unsigned long *begin = (unsigned long *)this_cpu_read(softirq_stack_ptr);
unsigned long *end = begin + (THREAD_SIZE / sizeof(long));
/*
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index f05339fee778..6c5defd6569a 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -134,7 +134,7 @@ static __always_inline bool in_exception_stack(unsigned long *stack, struct stac
static __always_inline bool in_irq_stack(unsigned long *stack, struct stack_info *info)
{
- unsigned long *end = (unsigned long *)this_cpu_read(pcpu_hot.hardirq_stack_ptr);
+ unsigned long *end = (unsigned long *)this_cpu_read(hardirq_stack_ptr);
unsigned long *begin;
/*
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 83a5252a473c..81f9b78e0f7b 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -36,6 +36,8 @@ EXPORT_PER_CPU_SYMBOL(irq_stat);
DEFINE_PER_CPU_CACHE_HOT(u16, __softirq_pending);
EXPORT_PER_CPU_SYMBOL(__softirq_pending);
+DEFINE_PER_CPU_CACHE_HOT(struct irq_stack *, hardirq_stack_ptr);
+
atomic_t irq_err_count;
/*
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index dc1049c01f9b..48a27cde9635 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -52,6 +52,8 @@ static inline int check_stack_overflow(void) { return 0; }
static inline void print_stack_overflow(void) { }
#endif
+DEFINE_PER_CPU_CACHE_HOT(struct irq_stack *, softirq_stack_ptr);
+
static void call_on_stack(void *func, void *stack)
{
asm volatile("xchgl %%ebx,%%esp \n"
@@ -74,7 +76,7 @@ static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
u32 *isp, *prev_esp, arg1;
curstk = (struct irq_stack *) current_stack();
- irqstk = __this_cpu_read(pcpu_hot.hardirq_stack_ptr);
+ irqstk = __this_cpu_read(hardirq_stack_ptr);
/*
* this is where we switch to the IRQ stack. However, if we are
@@ -112,7 +114,7 @@ int irq_init_percpu_irqstack(unsigned int cpu)
int node = cpu_to_node(cpu);
struct page *ph, *ps;
- if (per_cpu(pcpu_hot.hardirq_stack_ptr, cpu))
+ if (per_cpu(hardirq_stack_ptr, cpu))
return 0;
ph = alloc_pages_node(node, THREADINFO_GFP, THREAD_SIZE_ORDER);
@@ -124,8 +126,8 @@ int irq_init_percpu_irqstack(unsigned int cpu)
return -ENOMEM;
}
- per_cpu(pcpu_hot.hardirq_stack_ptr, cpu) = page_address(ph);
- per_cpu(pcpu_hot.softirq_stack_ptr, cpu) = page_address(ps);
+ per_cpu(hardirq_stack_ptr, cpu) = page_address(ph);
+ per_cpu(softirq_stack_ptr, cpu) = page_address(ps);
return 0;
}
@@ -135,7 +137,7 @@ void do_softirq_own_stack(void)
struct irq_stack *irqstk;
u32 *isp, *prev_esp;
- irqstk = __this_cpu_read(pcpu_hot.softirq_stack_ptr);
+ irqstk = __this_cpu_read(softirq_stack_ptr);
/* build the stack frame on the softirq stack */
isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index 56bdeecd8ee0..ca78dce39361 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -26,6 +26,7 @@
#include <asm/io_apic.h>
#include <asm/apic.h>
+DEFINE_PER_CPU_CACHE_HOT(bool, hardirq_stack_inuse);
DEFINE_PER_CPU_PAGE_ALIGNED(struct irq_stack, irq_stack_backing_store) __visible;
#ifdef CONFIG_VMAP_STACK
@@ -50,7 +51,7 @@ static int map_irq_stack(unsigned int cpu)
return -ENOMEM;
/* Store actual TOS to avoid adjustment in the hotpath */
- per_cpu(pcpu_hot.hardirq_stack_ptr, cpu) = va + IRQ_STACK_SIZE - 8;
+ per_cpu(hardirq_stack_ptr, cpu) = va + IRQ_STACK_SIZE - 8;
return 0;
}
#else
@@ -63,14 +64,14 @@ static int map_irq_stack(unsigned int cpu)
void *va = per_cpu_ptr(&irq_stack_backing_store, cpu);
/* Store actual TOS to avoid adjustment in the hotpath */
- per_cpu(pcpu_hot.hardirq_stack_ptr, cpu) = va + IRQ_STACK_SIZE - 8;
+ per_cpu(hardirq_stack_ptr, cpu) = va + IRQ_STACK_SIZE - 8;
return 0;
}
#endif
int irq_init_percpu_irqstack(unsigned int cpu)
{
- if (per_cpu(pcpu_hot.hardirq_stack_ptr, cpu))
+ if (per_cpu(hardirq_stack_ptr, cpu))
return 0;
return map_irq_stack(cpu);
}
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 4ca73ddfb30b..3a8f967a0c79 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -614,7 +614,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
int cpu = smp_processor_id();
WARN_ON_ONCE(IS_ENABLED(CONFIG_DEBUG_ENTRY) &&
- this_cpu_read(pcpu_hot.hardirq_stack_inuse));
+ this_cpu_read(hardirq_stack_inuse));
if (!test_tsk_thread_flag(prev_p, TIF_NEED_FPU_LOAD))
switch_fpu_prepare(prev_p, cpu);
--
2.48.1
next prev parent reply other threads:[~2025-03-03 16:53 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 16:52 [PATCH v3 00/11] Add a percpu subsection for cache hot data Brian Gerst
2025-03-03 16:52 ` [PATCH v3 01/11] percpu: Introduce percpu hot section Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 02/11] x86/percpu: Move pcpu_hot to " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 03/11] x86/preempt: Move preempt count " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 04/11] x86/smp: Move cpu number " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 05/11] x86/retbleed: Move call depth " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 06/11] x86/softirq: Move softirq_pending " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` Brian Gerst [this message]
2025-03-04 8:27 ` [tip: x86/core] x86/irq: Move irq stacks " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:34 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 08/11] x86/percpu: Move top_of_stack " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:33 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 09/11] x86/percpu: Move current_task " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:33 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 10/11] x86/stackprotector: Move __stack_chk_guard " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:33 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 16:52 ` [PATCH v3 11/11] x86/smp: Move this_cpu_off " Brian Gerst
2025-03-04 8:27 ` [tip: x86/core] " tip-bot2 for Brian Gerst
2025-03-04 10:36 ` tip-bot2 for Brian Gerst
2025-03-04 19:33 ` tip-bot2 for Brian Gerst
2025-03-04 19:43 ` tip-bot2 for Brian Gerst
2025-03-03 19:53 ` [PATCH v3 00/11] Add a percpu subsection for cache hot data Uros Bizjak
2025-03-03 20:38 ` Ingo Molnar
2025-03-03 20:55 ` Brian Gerst
2025-03-04 8:47 ` Ingo Molnar
2025-03-04 9:26 ` Brian Gerst
2025-03-04 9:47 ` Ingo Molnar
2025-03-04 9:52 ` Uros Bizjak
2025-03-04 9:55 ` Ingo Molnar
2025-03-04 15:00 ` Brian Gerst
2025-03-04 16:01 ` Uros Bizjak
2025-03-04 16:42 ` Brian Gerst
2025-03-04 16:48 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250303165246.2175811-8-brgerst@gmail.com \
--to=brgerst@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linuxfoundation.org \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.