From: Jan Kiszka Subject: [PATCH] ipipe: Avoid recursive faults on root work overflow Message-ID: Date: Thu, 1 Jul 2021 09:19:24 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xenomai From: Jan Kiszka 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 --- 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(-) diff --git a/kernel/ipipe/core.c b/kernel/ipipe/core.c index 99a88e4d620e..485db973b81b 100644 --- a/kernel/ipipe/core.c +++ b/kernel/ipipe/core.c @@ -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); -- 2.26.2