... | ... | ||
---|---|---|---|
3 | also to round up CPUs in kdb/kgdb. The last post from Sumit that I | 3 | also to round up CPUs in kdb/kgdb. The last post from Sumit that I |
4 | could find was v7, so I started my series at v8. I haven't copied all | 4 | could find was v7, so I started my series at v8. I haven't copied all |
5 | of his old changelongs here, but you can find them from the link. | 5 | of his old changelongs here, but you can find them from the link. |
6 | 6 | ||
7 | This patch series targets v6.6. Specifically it can't land in v6.5 | 7 | This patch series targets v6.6. Specifically it can't land in v6.5 |
8 | since it depends on commit 36759e343ff9 ("nmi_backtrace: allow | 8 | since it depends on commit 8d539b84f1e3 ("nmi_backtrace: allow |
9 | excluding an arbitrary CPU"). | 9 | excluding an arbitrary CPU"). |
10 | 10 | ||
11 | It should be noted that Mark still feels there might be some corner | 11 | It should be noted that Mark still feels there might be some corner |
12 | cases where pseudo-NMI is not production ready [2] [3], but as far as | 12 | cases where pseudo-NMI is not production ready [2] [3], but as far as |
13 | I'm aware there are no concrete/documented issues. Regardless of | 13 | I'm aware there are no concrete/documented issues. Regardless of |
14 | whether this should be enabled for production, though, this series | 14 | whether this should be enabled for production, though, this series |
15 | will be invaluable to anyone trying to debug crashes on arm64 | 15 | will be invaluable to anyone trying to debug crashes on arm64 |
16 | machines. | 16 | machines. |
17 | 17 | ||
18 | v10 of this series attempts to address all of Mark's feedback on | 18 | v12 of this series collects tags, fixes a few small nits in comments |
19 | and commit messages from v11 and adds a new (and somewhat unrelated) | ||
20 | small patch to the end of the series. There are no code changes other | ||
21 | than the last patch, which is tiny. | ||
22 | |||
23 | v11 of this series addressed Stephen Boyd's feedback on v10 and added | ||
24 | a missing "static" that the patches robot found. | ||
25 | |||
26 | v10 of this series attempted to address all of Mark's feedback on | ||
19 | v9. As a quick summary: | 27 | v9. As a quick summary: |
20 | - It includes his patch to remove IPI_WAKEUP, freeing up an extra IPI. | 28 | - It includes his patch to remove IPI_WAKEUP, freeing up an extra IPI. |
21 | - It no longer combines the "kgdb" and "backtrace" IPIs. If we need | 29 | - It no longer combines the "kgdb" and "backtrace" IPIs. If we need |
22 | another IPI these could always be recombined later. | 30 | another IPI these could always be recombined later. |
23 | - It promotes IPI_CPU_STOP and IPI_CPU_CRASH_STOP to NMI. | 31 | - It promotes IPI_CPU_STOP and IPI_CPU_CRASH_STOP to NMI. |
... | ... | ||
46 | * Added an extra patch to gracefully fall back to regular IPIs if | 54 | * Added an extra patch to gracefully fall back to regular IPIs if |
47 | pseudo-NMIs aren't there. | 55 | pseudo-NMIs aren't there. |
48 | 56 | ||
49 | It can be noted that this patch series works very well with the recent | 57 | It can be noted that this patch series works very well with the recent |
50 | "hardlockup" patches that have landed through Andrew Morton's tree and | 58 | "hardlockup" patches that have landed through Andrew Morton's tree and |
51 | are currently in linuxnext. It works especially well with the "buddy" | 59 | are currently in mainline. It works especially well with the "buddy" |
52 | lockup detector. | 60 | lockup detector. |
53 | 61 | ||
54 | [1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/ | 62 | [1] https://lore.kernel.org/linux-arm-kernel/1604317487-14543-1-git-send-email-sumit.garg@linaro.org/ |
55 | [2] https://lore.kernel.org/lkml/ZFvGqD%2F%2Fpm%2FlZb+p@FVFF77S0Q05N.cambridge.arm.com/ | 63 | [2] https://lore.kernel.org/lkml/ZFvGqD%2F%2Fpm%2FlZb+p@FVFF77S0Q05N.cambridge.arm.com/ |
56 | [3] https://lore.kernel.org/lkml/ZNDKVP2m-iiZCz3v@FVFF77S0Q05N.cambridge.arm.com | 64 | [3] https://lore.kernel.org/lkml/ZNDKVP2m-iiZCz3v@FVFF77S0Q05N.cambridge.arm.com |
57 | [4] https://lore.kernel.org/r/20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid/ | 65 | [4] https://lore.kernel.org/r/20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid/ |
66 | |||
67 | Changes in v12: | ||
68 | - ("arm64: smp: Mark IPI globals as __ro_after_init") new for v12. | ||
69 | - Added a comment about why we account for 16 SGIs when Linux uses 8. | ||
70 | - Minor comment change to add "()" after nmi_trigger_cpumask_backtrace. | ||
71 | - Updated the commit hash of the commit this depends on. | ||
72 | |||
73 | Changes in v11: | ||
74 | - Adjust comment about NR_IPI/MAX_IPI. | ||
75 | - Don't use confusing "backed by" idiom in comment. | ||
76 | - Made arm64_backtrace_ipi() static. | ||
77 | - Updated commit message as per Stephen. | ||
78 | - arch_send_wakeup_ipi() now takes an unsigned int. | ||
58 | 79 | ||
59 | Changes in v10: | 80 | Changes in v10: |
60 | - ("IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI") new for v10. | 81 | - ("IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI") new for v10. |
61 | - ("arm64: smp: Remove dedicated wakeup IPI") new for v10. | 82 | - ("arm64: smp: Remove dedicated wakeup IPI") new for v10. |
62 | - Backtrace now directly supported in smp.c | 83 | - Backtrace now directly supported in smp.c |
... | ... | ||
79 | Changes in v8: | 100 | Changes in v8: |
80 | - "Tag the arm64 idle functions as __cpuidle" new for v8 | 101 | - "Tag the arm64 idle functions as __cpuidle" new for v8 |
81 | - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP | 102 | - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP |
82 | - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param | 103 | - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param |
83 | 104 | ||
84 | Douglas Anderson (5): | 105 | Douglas Anderson (6): |
85 | irqchip/gic-v3: Enable support for SGIs to act as NMIs | 106 | irqchip/gic-v3: Enable support for SGIs to act as NMIs |
86 | arm64: idle: Tag the arm64 idle functions as __cpuidle | 107 | arm64: idle: Tag the arm64 idle functions as __cpuidle |
87 | arm64: smp: Add arch support for backtrace using pseudo-NMI | 108 | arm64: smp: Add arch support for backtrace using pseudo-NMI |
88 | arm64: smp: IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI | 109 | arm64: smp: IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI |
89 | arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI | 110 | arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI |
90 | roundup | 111 | roundup |
112 | arm64: smp: Mark IPI globals as __ro_after_init | ||
91 | 113 | ||
92 | Mark Rutland (1): | 114 | Mark Rutland (1): |
93 | arm64: smp: Remove dedicated wakeup IPI | 115 | arm64: smp: Remove dedicated wakeup IPI |
94 | 116 | ||
95 | arch/arm64/include/asm/irq.h | 3 + | 117 | arch/arm64/include/asm/irq.h | 3 + |
96 | arch/arm64/include/asm/smp.h | 4 +- | 118 | arch/arm64/include/asm/smp.h | 4 +- |
97 | arch/arm64/kernel/acpi_parking_protocol.c | 2 +- | 119 | arch/arm64/kernel/acpi_parking_protocol.c | 2 +- |
98 | arch/arm64/kernel/idle.c | 4 +- | 120 | arch/arm64/kernel/idle.c | 4 +- |
99 | arch/arm64/kernel/smp.c | 135 +++++++++++++++++----- | 121 | arch/arm64/kernel/smp.c | 139 +++++++++++++++++----- |
100 | drivers/irqchip/irq-gic-v3.c | 54 ++++++--- | 122 | drivers/irqchip/irq-gic-v3.c | 59 ++++++--- |
101 | 6 files changed, 153 insertions(+), 49 deletions(-) | 123 | 6 files changed, 160 insertions(+), 51 deletions(-) |
102 | 124 | ||
103 | -- | 125 | -- |
104 | 2.42.0.rc1.204.g551eb34607-goog | 126 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
14 | 14 | ||
15 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> | 15 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> |
16 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> | 16 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> |
17 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 17 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
18 | --- | 18 | --- |
19 | In v10 I removed the previous Reviewed-by and Tested-by tags since the | 19 | I'll note that this change is a little more black magic to me than |
20 | patch contents changed pretty drastically. | 20 | others in this series. I don't have a massive amounts of familiarity |
21 | 21 | with all the moving parts of gic-v3, so I mostly just followed Mark | |
22 | I'll also note that this change is a little more black magic to me | 22 | Rutland's advice [1]. Please pay extra attention to make sure I didn't |
23 | than others in this series. I don't have a massive amounts of | 23 | do anything too terrible. |
24 | familiarity with all the moving parts of gic-v3, so I mostly just | ||
25 | followed Mark Rutland's advice [1]. Please pay extra attention to make | ||
26 | sure I didn't do anything too terrible. | ||
27 | 24 | ||
28 | Mark's advice wasn't a full patch and I ended up doing a bit of work | 25 | Mark's advice wasn't a full patch and I ended up doing a bit of work |
29 | to translate it to reality, so I did not add him as "Co-developed-by" | 26 | to translate it to reality, so I did not add him as "Co-developed-by" |
30 | here. Mark: if you would like this tag then please provide it and your | 27 | here. Mark: if you would like this tag then please provide it and your |
31 | Signed-off-by. I certainly won't object. | 28 | Signed-off-by. I certainly won't object. |
32 | 29 | ||
33 | [1] https://lore.kernel.org/r/ZNC-YRQopO0PaIIo@FVFF77S0Q05N.cambridge.arm.com | 30 | [1] https://lore.kernel.org/r/ZNC-YRQopO0PaIIo@FVFF77S0Q05N.cambridge.arm.com |
34 | 31 | ||
32 | Changes in v12: | ||
33 | - Added a comment about why we account for 16 SGIs when Linux uses 8. | ||
34 | |||
35 | Changes in v10: | 35 | Changes in v10: |
36 | - Rewrite as needed for 5.11+ as per Mark Rutland and Sumit. | 36 | - Rewrite as needed for 5.11+ as per Mark Rutland and Sumit. |
37 | 37 | ||
38 | drivers/irqchip/irq-gic-v3.c | 54 ++++++++++++++++++++++++------------ | 38 | drivers/irqchip/irq-gic-v3.c | 59 +++++++++++++++++++++++++----------- |
39 | 1 file changed, 36 insertions(+), 18 deletions(-) | 39 | 1 file changed, 41 insertions(+), 18 deletions(-) |
40 | 40 | ||
41 | diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c | 41 | diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c |
42 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/drivers/irqchip/irq-gic-v3.c | 43 | --- a/drivers/irqchip/irq-gic-v3.c |
44 | +++ b/drivers/irqchip/irq-gic-v3.c | 44 | +++ b/drivers/irqchip/irq-gic-v3.c |
45 | @@ -XXX,XX +XXX,XX @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key); | 45 | @@ -XXX,XX +XXX,XX @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key); |
46 | #define GIC_LINE_NR min(GICD_TYPER_SPIS(gic_data.rdists.gicd_typer), 1020U) | 46 | #define GIC_LINE_NR min(GICD_TYPER_SPIS(gic_data.rdists.gicd_typer), 1020U) |
47 | #define GIC_ESPI_NR GICD_TYPER_ESPIS(gic_data.rdists.gicd_typer) | 47 | #define GIC_ESPI_NR GICD_TYPER_ESPIS(gic_data.rdists.gicd_typer) |
48 | 48 | ||
49 | +/* | ||
50 | + * There are 16 SGIs, though we only actually use 8 in Linux. The other 8 SGIs | ||
51 | + * are potentially stolen by the secure side. Some code, especially code dealing | ||
52 | + * with hwirq IDs, is simplified by accounting for all 16. | ||
53 | + */ | ||
49 | +#define SGI_NR 16 | 54 | +#define SGI_NR 16 |
50 | + | 55 | + |
51 | /* | 56 | /* |
52 | * The behaviours of RPR and PMR registers differ depending on the value of | 57 | * The behaviours of RPR and PMR registers differ depending on the value of |
53 | * SCR_EL3.FIQ, and the behaviour of non-secure priority registers of the | 58 | * SCR_EL3.FIQ, and the behaviour of non-secure priority registers of the |
... | ... | ||
166 | - | 171 | - |
167 | return 0; | 172 | return 0; |
168 | 173 | ||
169 | out_free: | 174 | out_free: |
170 | -- | 175 | -- |
171 | 2.42.0.rc1.204.g551eb34607-goog | 176 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
1 | As per the (somewhat recent) comment before the definition of | 1 | As per the (somewhat recent) comment before the definition of |
---|---|---|---|
2 | `__cpuidle`, the tag is like `noinstr` but also marks a function so it | 2 | `__cpuidle`, the tag is like `noinstr` but also marks a function so it |
3 | can be identified by cpu_in_idle(). Let'a add this. | 3 | can be identified by cpu_in_idle(). Let's add these markings to arm64 |
4 | cpuidle functions | ||
4 | 5 | ||
5 | After doing this then when we dump stack traces of all processors | 6 | With this change we get useful backtraces like: |
6 | using nmi_cpu_backtrace() then instead of getting useless backtraces | ||
7 | we get things like: | ||
8 | 7 | ||
9 | NMI backtrace for cpu N skipped: idling at cpu_do_idle+0x94/0x98 | 8 | NMI backtrace for cpu N skipped: idling at cpu_do_idle+0x94/0x98 |
9 | |||
10 | instead of useless backtraces when dumping all processors using | ||
11 | nmi_cpu_backtrace(). | ||
10 | 12 | ||
11 | NOTE: this patch won't make cpu_in_idle() work perfectly for arm64, | 13 | NOTE: this patch won't make cpu_in_idle() work perfectly for arm64, |
12 | but it doesn't hurt and does catch some cases. Specifically an example | 14 | but it doesn't hurt and does catch some cases. Specifically an example |
13 | that wasn't caught in my testing looked like this: | 15 | that wasn't caught in my testing looked like this: |
14 | 16 | ||
... | ... | ||
21 | cpuidle_enter_state+0xb8/0x260 | 23 | cpuidle_enter_state+0xb8/0x260 |
22 | cpuidle_enter+0x44/0x5c | 24 | cpuidle_enter+0x44/0x5c |
23 | do_idle+0x188/0x30c | 25 | do_idle+0x188/0x30c |
24 | 26 | ||
25 | Acked-by: Mark Rutland <mark.rutland@arm.com> | 27 | Acked-by: Mark Rutland <mark.rutland@arm.com> |
28 | Reviewed-by: Stephen Boyd <swboyd@chromium.org> | ||
29 | Acked-by: Sumit Garg <sumit.garg@linaro.org> | ||
26 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 30 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
27 | --- | 31 | --- |
28 | 32 | ||
29 | (no changes since v9) | 33 | (no changes since v11) |
34 | |||
35 | Changes in v11: | ||
36 | - Updated commit message as per Stephen. | ||
30 | 37 | ||
31 | Changes in v9: | 38 | Changes in v9: |
32 | - Added to commit message that this doesn't catch all cases. | 39 | - Added to commit message that this doesn't catch all cases. |
33 | 40 | ||
34 | Changes in v8: | 41 | Changes in v8: |
... | ... | ||
58 | +void __cpuidle arch_cpu_idle(void) | 65 | +void __cpuidle arch_cpu_idle(void) |
59 | { | 66 | { |
60 | /* | 67 | /* |
61 | * This should do all the clock switching and wait for interrupt | 68 | * This should do all the clock switching and wait for interrupt |
62 | -- | 69 | -- |
63 | 2.42.0.rc1.204.g551eb34607-goog | 70 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
13 | cost of taking and handling the IPI in the first place. We can safely | 13 | cost of taking and handling the IPI in the first place. We can safely |
14 | handle redundant IPI_RESCHEDULE IPIs, so there should be no functional | 14 | handle redundant IPI_RESCHEDULE IPIs, so there should be no functional |
15 | impact as a result of this change. | 15 | impact as a result of this change. |
16 | 16 | ||
17 | Signed-off-by: Mark Rutland <mark.rutland@arm.com> | 17 | Signed-off-by: Mark Rutland <mark.rutland@arm.com> |
18 | Reviewed-by: Stephen Boyd <swboyd@chromium.org> | ||
19 | Reviewed-by: Sumit Garg <sumit.garg@linaro.org> | ||
18 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 20 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
19 | Cc: Catalin Marinas <catalin.marinas@arm.com> | 21 | Cc: Catalin Marinas <catalin.marinas@arm.com> |
20 | Cc: Marc Zyngier <maz@kernel.org> | 22 | Cc: Marc Zyngier <maz@kernel.org> |
21 | Cc: Sumit Garg <sumit.garg@linaro.org> | ||
22 | Cc: Will Deacon <will@kernel.org> | 23 | Cc: Will Deacon <will@kernel.org> |
23 | --- | 24 | --- |
24 | I have no idea how to test this. I just took Mark's patch and jammed | 25 | I have no idea how to test this. I just took Mark's patch and jammed |
25 | it into my series. Logicially the patch seems reasonable to me. | 26 | it into my series. Logicially the patch seems reasonable to me. |
27 | |||
28 | (no changes since v11) | ||
29 | |||
30 | Changes in v11: | ||
31 | - arch_send_wakeup_ipi() now takes an unsigned int. | ||
26 | 32 | ||
27 | Changes in v10: | 33 | Changes in v10: |
28 | - ("arm64: smp: Remove dedicated wakeup IPI") new for v10. | 34 | - ("arm64: smp: Remove dedicated wakeup IPI") new for v10. |
29 | 35 | ||
30 | arch/arm64/include/asm/smp.h | 4 ++-- | 36 | arch/arm64/include/asm/smp.h | 4 ++-- |
... | ... | ||
39 | @@ -XXX,XX +XXX,XX @@ extern void arch_send_call_function_single_ipi(int cpu); | 45 | @@ -XXX,XX +XXX,XX @@ extern void arch_send_call_function_single_ipi(int cpu); |
40 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); | 46 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); |
41 | 47 | ||
42 | #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL | 48 | #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL |
43 | -extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); | 49 | -extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); |
44 | +extern void arch_send_wakeup_ipi(int cpu); | 50 | +extern void arch_send_wakeup_ipi(unsigned int cpu); |
45 | #else | 51 | #else |
46 | -static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) | 52 | -static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) |
47 | +static inline void arch_send_wakeup_ipi(int cpu) | 53 | +static inline void arch_send_wakeup_ipi(unsigned int cpu) |
48 | { | 54 | { |
49 | BUILD_BUG(); | 55 | BUILD_BUG(); |
50 | } | 56 | } |
51 | diff --git a/arch/arm64/kernel/acpi_parking_protocol.c b/arch/arm64/kernel/acpi_parking_protocol.c | 57 | diff --git a/arch/arm64/kernel/acpi_parking_protocol.c b/arch/arm64/kernel/acpi_parking_protocol.c |
52 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
113 | @@ -XXX,XX +XXX,XX @@ void arch_smp_send_reschedule(int cpu) | 119 | @@ -XXX,XX +XXX,XX @@ void arch_smp_send_reschedule(int cpu) |
114 | smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); | 120 | smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); |
115 | } | 121 | } |
116 | 122 | ||
117 | +#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL | 123 | +#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL |
118 | +void arch_send_wakeup_ipi(int cpu) | 124 | +void arch_send_wakeup_ipi(unsigned int cpu) |
119 | +{ | 125 | +{ |
120 | + /* | 126 | + /* |
121 | + * We use a scheduler IPI to wake the CPU as this avoids the need for a | 127 | + * We use a scheduler IPI to wake the CPU as this avoids the need for a |
122 | + * dedicated IPI and we can safely handle spurious scheduler IPIs. | 128 | + * dedicated IPI and we can safely handle spurious scheduler IPIs. |
123 | + */ | 129 | + */ |
... | ... | ||
127 | + | 133 | + |
128 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST | 134 | #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST |
129 | void tick_broadcast(const struct cpumask *mask) | 135 | void tick_broadcast(const struct cpumask *mask) |
130 | { | 136 | { |
131 | -- | 137 | -- |
132 | 2.42.0.rc1.204.g551eb34607-goog | 138 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
7 | NOTE: this patch is a squash of the little bit of code adding the | 7 | NOTE: this patch is a squash of the little bit of code adding the |
8 | ability to mark an IPI to try to use pseudo-NMI plus the little bit of | 8 | ability to mark an IPI to try to use pseudo-NMI plus the little bit of |
9 | code to hook things up for kgdb. This approach was decided upon in the | 9 | code to hook things up for kgdb. This approach was decided upon in the |
10 | discussion of v9 [1]. | 10 | discussion of v9 [1]. |
11 | 11 | ||
12 | This patch depends on commit 36759e343ff9 ("nmi_backtrace: allow | 12 | This patch depends on commit 8d539b84f1e3 ("nmi_backtrace: allow |
13 | excluding an arbitrary CPU") since that commit changed the prototype | 13 | excluding an arbitrary CPU") since that commit changed the prototype |
14 | of arch_trigger_cpumask_backtrace(), which this patch implements. | 14 | of arch_trigger_cpumask_backtrace(), which this patch implements. |
15 | 15 | ||
16 | [1] https://lore.kernel.org/r/ZORY51mF4alI41G1@FVFF77S0Q05N | 16 | [1] https://lore.kernel.org/r/ZORY51mF4alI41G1@FVFF77S0Q05N |
17 | 17 | ||
18 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> | 18 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> |
19 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> | 19 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> |
20 | Co-developed-by: Mark Rutland <mark.rutland@arm.com> | 20 | Co-developed-by: Mark Rutland <mark.rutland@arm.com> |
21 | Signed-off-by: Mark Rutland <mark.rutland@arm.com> | 21 | Signed-off-by: Mark Rutland <mark.rutland@arm.com> |
22 | Reviewed-by: Stephen Boyd <swboyd@chromium.org> | ||
23 | Reviewed-by: Misono Tomohiro <misono.tomohiro@fujitsu.com> | ||
22 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 24 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
23 | --- | 25 | --- |
26 | |||
27 | Changes in v12: | ||
28 | - Minor comment change to add "()" after nmi_trigger_cpumask_backtrace. | ||
29 | - Updated the commit hash of the commit this depends on. | ||
30 | |||
31 | Changes in v11: | ||
32 | - Adjust comment about NR_IPI/MAX_IPI. | ||
33 | - Don't use confusing "backed by" idiom in comment. | ||
34 | - Made arm64_backtrace_ipi() static. | ||
24 | 35 | ||
25 | Changes in v10: | 36 | Changes in v10: |
26 | - Backtrace now directly supported in smp.c | 37 | - Backtrace now directly supported in smp.c |
27 | - Squash backtrace into patch adding support for pseudo-NMI IPIs. | 38 | - Squash backtrace into patch adding support for pseudo-NMI IPIs. |
28 | 39 | ||
... | ... | ||
73 | IPI_TIMER, | 84 | IPI_TIMER, |
74 | IPI_IRQ_WORK, | 85 | IPI_IRQ_WORK, |
75 | - NR_IPI | 86 | - NR_IPI |
76 | + NR_IPI, | 87 | + NR_IPI, |
77 | + /* | 88 | + /* |
78 | + * CPU_BACKTRACE is special and not included in NR_IPI | 89 | + * Any enum >= NR_IPI and < MAX_IPI is special and not tracable |
79 | + * or tracable with trace_ipi_* | 90 | + * with trace_ipi_* |
80 | + */ | 91 | + */ |
81 | + IPI_CPU_BACKTRACE = NR_IPI, | 92 | + IPI_CPU_BACKTRACE = NR_IPI, |
82 | + MAX_IPI | 93 | + MAX_IPI |
83 | }; | 94 | }; |
84 | 95 | ||
... | ... | ||
91 | 102 | ||
92 | @@ -XXX,XX +XXX,XX @@ static void __noreturn ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs | 103 | @@ -XXX,XX +XXX,XX @@ static void __noreturn ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs |
93 | #endif | 104 | #endif |
94 | } | 105 | } |
95 | 106 | ||
96 | +void arm64_backtrace_ipi(cpumask_t *mask) | 107 | +static void arm64_backtrace_ipi(cpumask_t *mask) |
97 | +{ | 108 | +{ |
98 | + __ipi_send_mask(ipi_desc[IPI_CPU_BACKTRACE], mask); | 109 | + __ipi_send_mask(ipi_desc[IPI_CPU_BACKTRACE], mask); |
99 | +} | 110 | +} |
100 | + | 111 | + |
101 | +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) | 112 | +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, int exclude_cpu) |
102 | +{ | 113 | +{ |
103 | + /* | 114 | + /* |
104 | + * NOTE: though nmi_trigger_cpumask_backtrace has "nmi_" in the name, | 115 | + * NOTE: though nmi_trigger_cpumask_backtrace() has "nmi_" in the name, |
105 | + * nothing about it truly needs to be backed by an NMI, it's just that | 116 | + * nothing about it truly needs to be implemented using an NMI, it's |
106 | + * it's _allowed_ to work with NMIs. If ipi_should_be_nmi() returned | 117 | + * just that it's _allowed_ to work with NMIs. If ipi_should_be_nmi() |
107 | + * false our backtrace attempt will just be backed by a regular IPI. | 118 | + * returned false our backtrace attempt will just use a regular IPI. |
108 | + */ | 119 | + */ |
109 | + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, arm64_backtrace_ipi); | 120 | + nmi_trigger_cpumask_backtrace(mask, exclude_cpu, arm64_backtrace_ipi); |
110 | +} | 121 | +} |
111 | + | 122 | + |
112 | /* | 123 | /* |
... | ... | ||
209 | + } | 220 | + } |
210 | 221 | ||
211 | ipi_desc[i] = irq_to_desc(ipi_base + i); | 222 | ipi_desc[i] = irq_to_desc(ipi_base + i); |
212 | irq_set_status_flags(ipi_base + i, IRQ_HIDDEN); | 223 | irq_set_status_flags(ipi_base + i, IRQ_HIDDEN); |
213 | -- | 224 | -- |
214 | 2.42.0.rc1.204.g551eb34607-goog | 225 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
1 | There's no reason why IPI_CPU_STOP and IPI_CPU_CRASH_STOP can't be | 1 | There's no reason why IPI_CPU_STOP and IPI_CPU_CRASH_STOP can't be |
---|---|---|---|
2 | handled as NMI. They are very simple and everything in them is | 2 | handled as NMI. They are very simple and everything in them is |
3 | NMI-safe. Mark them as things to use NMI for if NMI is available. | 3 | NMI-safe. Mark them as things to use NMI for if NMI is available. |
4 | 4 | ||
5 | Suggested-by: Mark Rutland <mark.rutland@arm.com> | 5 | Suggested-by: Mark Rutland <mark.rutland@arm.com> |
6 | Reviewed-by: Stephen Boyd <swboyd@chromium.org> | ||
7 | Reviewed-by: Misono Tomohiro <misono.tomohiro@fujitsu.com> | ||
8 | Reviewed-by: Sumit Garg <sumit.garg@linaro.org> | ||
6 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 9 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
7 | --- | 10 | --- |
8 | I don't actually have any good way to test/validate this patch. It's | 11 | I don't actually have any good way to test/validate this patch. It's |
9 | added to the series at Mark's request. | 12 | added to the series at Mark's request. |
13 | |||
14 | (no changes since v10) | ||
10 | 15 | ||
11 | Changes in v10: | 16 | Changes in v10: |
12 | - ("IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI") new for v10. | 17 | - ("IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI") new for v10. |
13 | 18 | ||
14 | arch/arm64/kernel/smp.c | 2 ++ | 19 | arch/arm64/kernel/smp.c | 2 ++ |
... | ... | ||
26 | + case IPI_CPU_CRASH_STOP: | 31 | + case IPI_CPU_CRASH_STOP: |
27 | case IPI_CPU_BACKTRACE: | 32 | case IPI_CPU_BACKTRACE: |
28 | return true; | 33 | return true; |
29 | default: | 34 | default: |
30 | -- | 35 | -- |
31 | 2.42.0.rc1.204.g551eb34607-goog | 36 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
8 | it avoids the potential situation described in the generic | 8 | it avoids the potential situation described in the generic |
9 | kgdb_call_nmi_hook(). | 9 | kgdb_call_nmi_hook(). |
10 | 10 | ||
11 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> | 11 | Co-developed-by: Sumit Garg <sumit.garg@linaro.org> |
12 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> | 12 | Signed-off-by: Sumit Garg <sumit.garg@linaro.org> |
13 | Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> | ||
14 | Reviewed-by: Stephen Boyd <swboyd@chromium.org> | ||
13 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | 15 | Signed-off-by: Douglas Anderson <dianders@chromium.org> |
14 | --- | 16 | --- |
15 | I debated whether this should be in "arch/arm64/kernel/smp.c" or if I | 17 | I debated whether this should be in "arch/arm64/kernel/smp.c" or if I |
16 | should try to find a way for it to go into "arch/arm64/kernel/kgdb.c". | 18 | should try to find a way for it to go into "arch/arm64/kernel/kgdb.c". |
17 | In the end this is so little code that it didn't seem worth it to find | 19 | In the end this is so little code that it didn't seem worth it to find |
... | ... | ||
22 | 24 | ||
23 | FWIW, it seems like ~half the other platforms put this in "smp.c" with | 25 | FWIW, it seems like ~half the other platforms put this in "smp.c" with |
24 | an ifdef for KGDB and the other half put it in "kgdb.c" with an ifdef | 26 | an ifdef for KGDB and the other half put it in "kgdb.c" with an ifdef |
25 | for SMP. :-P | 27 | for SMP. :-P |
26 | 28 | ||
29 | (no changes since v10) | ||
30 | |||
27 | Changes in v10: | 31 | Changes in v10: |
28 | - Don't allocate the cpumask on the stack; just iterate. | 32 | - Don't allocate the cpumask on the stack; just iterate. |
29 | - Moved kgdb calls to smp.c to avoid needing to export IPI info. | 33 | - Moved kgdb calls to smp.c to avoid needing to export IPI info. |
30 | - kgdb now has its own IPI. | 34 | - kgdb now has its own IPI. |
31 | 35 | ||
32 | Changes in v9: | 36 | Changes in v9: |
33 | - Remove fallback for when debug IPI isn't available. | 37 | - Remove fallback for when debug IPI isn't available. |
34 | - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. | 38 | - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. |
35 | 39 | ||
36 | arch/arm64/kernel/smp.c | 25 ++++++++++++++++++++++++- | 40 | arch/arm64/kernel/smp.c | 23 +++++++++++++++++++++++ |
37 | 1 file changed, 24 insertions(+), 1 deletion(-) | 41 | 1 file changed, 23 insertions(+) |
38 | 42 | ||
39 | diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c | 43 | diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c |
40 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/arch/arm64/kernel/smp.c | 45 | --- a/arch/arm64/kernel/smp.c |
42 | +++ b/arch/arm64/kernel/smp.c | 46 | +++ b/arch/arm64/kernel/smp.c |
... | ... | ||
47 | +#include <linux/kgdb.h> | 51 | +#include <linux/kgdb.h> |
48 | #include <linux/kvm_host.h> | 52 | #include <linux/kvm_host.h> |
49 | #include <linux/nmi.h> | 53 | #include <linux/nmi.h> |
50 | 54 | ||
51 | @@ -XXX,XX +XXX,XX @@ enum ipi_msg_type { | 55 | @@ -XXX,XX +XXX,XX @@ enum ipi_msg_type { |
52 | IPI_IRQ_WORK, | 56 | * with trace_ipi_* |
53 | NR_IPI, | ||
54 | /* | ||
55 | - * CPU_BACKTRACE is special and not included in NR_IPI | ||
56 | + * CPU_BACKTRACE and KGDB_ROUNDUP are special and not included in NR_IPI | ||
57 | * or tracable with trace_ipi_* | ||
58 | */ | 57 | */ |
59 | IPI_CPU_BACKTRACE = NR_IPI, | 58 | IPI_CPU_BACKTRACE = NR_IPI, |
60 | + IPI_KGDB_ROUNDUP, | 59 | + IPI_KGDB_ROUNDUP, |
61 | MAX_IPI | 60 | MAX_IPI |
62 | }; | 61 | }; |
... | ... | ||
102 | + case IPI_KGDB_ROUNDUP: | 101 | + case IPI_KGDB_ROUNDUP: |
103 | return true; | 102 | return true; |
104 | default: | 103 | default: |
105 | return false; | 104 | return false; |
106 | -- | 105 | -- |
107 | 2.42.0.rc1.204.g551eb34607-goog | 106 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Mark the three IPI-related globals in smp.c as "__ro_after_init" since | ||
2 | they are only ever set in set_smp_ipi_range(), which is marked | ||
3 | "__init". This is a better and more secure marking than the old | ||
4 | "__read_mostly". | ||
1 | 5 | ||
6 | Suggested-by: Stephen Boyd <swboyd@chromium.org> | ||
7 | Signed-off-by: Douglas Anderson <dianders@chromium.org> | ||
8 | --- | ||
9 | This patch is almost completely unrelated to the rest of the series | ||
10 | other than the fact that it would cause a merge conflict with the | ||
11 | series if sent separately. I tacked it on to this series in response | ||
12 | to Stephen's feedback on v11 of this series [1]. If someone hates it | ||
13 | (not sure why they would), it could be dropped. If someone loves it, | ||
14 | it could be promoted to the start of the series and/or land on its own | ||
15 | (resolving merge conflicts). | ||
16 | |||
17 | [1] https://lore.kernel.org/r/CAE-0n52iVDgZa8XT8KTMj12c_ESSJt7f7A0fuZ_oAMMqpGcSzA@mail.gmail.com | ||
18 | |||
19 | Changes in v12: | ||
20 | - ("arm64: smp: Mark IPI globals as __ro_after_init") new for v12. | ||
21 | |||
22 | arch/arm64/kernel/smp.c | 6 +++--- | ||
23 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
24 | |||
25 | diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/arch/arm64/kernel/smp.c | ||
28 | +++ b/arch/arm64/kernel/smp.c | ||
29 | @@ -XXX,XX +XXX,XX @@ enum ipi_msg_type { | ||
30 | MAX_IPI | ||
31 | }; | ||
32 | |||
33 | -static int ipi_irq_base __read_mostly; | ||
34 | -static int nr_ipi __read_mostly = NR_IPI; | ||
35 | -static struct irq_desc *ipi_desc[MAX_IPI] __read_mostly; | ||
36 | +static int ipi_irq_base __ro_after_init; | ||
37 | +static int nr_ipi __ro_after_init = NR_IPI; | ||
38 | +static struct irq_desc *ipi_desc[MAX_IPI] __ro_after_init; | ||
39 | |||
40 | static void ipi_setup(int cpu); | ||
41 | |||
42 | -- | ||
43 | 2.42.0.283.g2d96d420d3-goog | diff view generated by jsdifflib |