ipipe: Avoid recursive faults on root work overflow
PATCH 1/1 ipipe: Avoid recursive faults on root work overflow
From: Jan Kiszka <[email protected]>
On some archs, WARN* is implemented by triggering a fault. This can cause troubles if we are already in a fault and try to submit too much root work. Convert to open-coded warning and stack dump.
---
Doesn't solve the overflow you've seen, Mauro, but should give a better hint.
kernel/ipipe/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/ipipe/core.c +9 -2
@@ -2027,9 +2027,16 @@ void __ipipe_post_work_root(struct ipipe_work_header *work) cpu =ipipe_processor_id (); tail =per_cpu (work_tail, cpu); -if (WARN_ON_ONCE ((unsigned char *)tail + work->size >= -per_cpu (work_buf, cpu) +WORKBUF_SIZE )) +if (unlikely ((unsigned char *)tail + work->size >= +per_cpu (work_buf, cpu) +WORKBUF_SIZE )) { +static volatile unsigned long once; +if (!test_and_set_bit (0 , &once)) { +ipipe_prepare_panic (); +pr_err ("I-pipe root work queue overflow! System may be unstable now.\n" ); +dump_stack (); + } goto out; + }/* Work handling is deferred, so data has to be copied. */ memcpy (tail, work, work->size);
Signature · 1 line
2.26.2
Quoted 29 lines · Jan Kiszka via Xenomai
From: Jan Kiszka <[email protected]>
On some archs, WARN* is implemented by triggering a fault. This can cause troubles if we are already in a fault and try to submit too much root work. Convert to open-coded warning and stack dump.
Signed-off-by Jan Kiszka <[email protected]>---
Doesn't solve the overflow you've seen, Mauro, but should give a better hint.
kernel/ipipe/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)kernel/ipipe/core.c +3
-2@@ -2027,9 +2027,16 @@ void __ipipe_post_work_root(struct ipipe_work_header *work) cpu =ipipe_processor_id (); tail =per_cpu (work_tail, cpu); -if (WARN_ON_ONCE ((unsigned char *)tail + work->size >= -per_cpu (work_buf, cpu) +WORKBUF_SIZE )) +if (unlikely ((unsigned char *)tail + work->size >= +per_cpu (work_buf, cpu) +WORKBUF_SIZE )) { +static volatile unsigned long once;
kernel/ipipe/core.c void __ipipe_post_work_root(struct ipipe_work_header *work) · line 2042
Quoted 10 lines
kernel/ipipe/core.c +6
-0+if (!test_and_set_bit (0 , &once)) { +ipipe_prepare_panic (); +pr_err ("I-pipe root work queue overflow! System may be unstable now.\n" ); +dump_stack (); + } goto out; + }/* Work handling is deferred, so data has to be copied. */ memcpy (tail, work, work->size);
Possibly relevant for ARM/64 as well. Patch is in 4.19 and head noarch trees now.
Jan
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 43 lines · Jan Kiszka
kernel/ipipe/core.c void __ipipe_post_work_root(struct
Quoted 20 lines · Jan Kiszka via Xenomai
From: Jan Kiszka <[email protected]>
On some archs, WARN* is implemented by triggering a fault. This can cause troubles if we are already in a fault and try to submit too much root work. Convert to open-coded warning and stack dump.
Signed-off-by Jan Kiszka <[email protected]>---
Doesn't solve the overflow you've seen, Mauro, but should give a better hint.
kernel/ipipe/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)kernel/ipipe/core.c +0
-0@@ -2027,9 +2027,16 @@ void __ipipe_post_work_root(struct
ipipe_work_header*work)kernel/ipipe/core.c void __ipipe_post_work_root(struct ipipe_work_header *work)
Quoted 11 lines
kernel/ipipe/core.c +6
-2cpu =ipipe_processor_id (); tail =per_cpu (work_tail, cpu); -if (WARN_ON_ONCE ((unsigned char *)tail + work->size >= -per_cpu (work_buf, cpu) +WORKBUF_SIZE )) +if (unlikely ((unsigned char *)tail + work->size >= +per_cpu (work_buf, cpu) +WORKBUF_SIZE )) { +static volatile unsigned long once; +if (!test_and_set_bit (0 , &once)) { +ipipe_prepare_panic (); + pr_err("I-pipe root work queue overflow! Systemmay be unstable now.\n");
kernel/ipipe/core.c void __ipipe_post_work_root(struct ipipe_work_header *work) · line 2042
Quoted 8 lines
kernel/ipipe/core.c +3
-0+dump_stack (); + } goto out; + }/* Work handling is deferred, so data has to be copied. */ memcpy (tail, work, work->size);
Quoted 8 lines
Possibly relevant for ARM/64 as well. Patch is in 4.19 and head noarch trees now.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
Thanks, I’ll pull these in and do a new release shortly.
Greg