All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Jisheng Zhang' <jszhang@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] riscv: add irq stack support
Date: Mon, 7 Mar 2022 14:32:34 +0000	[thread overview]
Message-ID: <f7f46323619e4084b4cfc551cdb47dd0@AcuMS.aculab.com> (raw)
In-Reply-To: <20220307140804.1400-1-jszhang@kernel.org>

From: Jisheng Zhang
> Sent: 07 March 2022 14:08
> Currently, IRQs are still handled on the kernel stack of the current
> task on riscv platforms. If the task has a deep call stack at the time
> of interrupt, and handling the interrupt also requires a deep stack,
> it's possible to see stack overflow.
> 
...
I'd have thought that a single page is (probably) enough for the
IRQ stack.
Certainly its sizing isn't really related to the normal thread
stack size.

> From another side, after this patch, it's possible to reduce the
> THREAD_SIZE to 8KB for RV64 platforms. This is especially useful for
> those systems with small memory size, e.g the Allwinner D1S platform
> which is RV64 but only has 64MB DDR.

Are you sure?
Is the stack use likely to be very much less than that of x86-64?
The real problem isn't the stack use of the test you are doing,
but the horrid worst case stack of some path that has multiple
1k+ buffers on stack.

Apart from compiler fubar (which usually hit KASAN) that stack
is actually likely to be architecture independent.
(The difference between 32bit and 64bit is also likely to be
relatively small - unless there are on-stack arrays of 'long'.)

For VMAP stacks is there a 'guard' KVA page allocated below
all of the stacks?
64bit systems should have lots of KVA so this shouldn't be
a problem.
Then stack overruns will fault and panic rather than trashing
another data area - which is really hard to debug.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


WARNING: multiple messages have this Message-ID (diff)
From: David Laight <David.Laight@ACULAB.COM>
To: 'Jisheng Zhang' <jszhang@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: "linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2] riscv: add irq stack support
Date: Mon, 7 Mar 2022 14:32:34 +0000	[thread overview]
Message-ID: <f7f46323619e4084b4cfc551cdb47dd0@AcuMS.aculab.com> (raw)
In-Reply-To: <20220307140804.1400-1-jszhang@kernel.org>

From: Jisheng Zhang
> Sent: 07 March 2022 14:08
> Currently, IRQs are still handled on the kernel stack of the current
> task on riscv platforms. If the task has a deep call stack at the time
> of interrupt, and handling the interrupt also requires a deep stack,
> it's possible to see stack overflow.
> 
...
I'd have thought that a single page is (probably) enough for the
IRQ stack.
Certainly its sizing isn't really related to the normal thread
stack size.

> From another side, after this patch, it's possible to reduce the
> THREAD_SIZE to 8KB for RV64 platforms. This is especially useful for
> those systems with small memory size, e.g the Allwinner D1S platform
> which is RV64 but only has 64MB DDR.

Are you sure?
Is the stack use likely to be very much less than that of x86-64?
The real problem isn't the stack use of the test you are doing,
but the horrid worst case stack of some path that has multiple
1k+ buffers on stack.

Apart from compiler fubar (which usually hit KASAN) that stack
is actually likely to be architecture independent.
(The difference between 32bit and 64bit is also likely to be
relatively small - unless there are on-stack arrays of 'long'.)

For VMAP stacks is there a 'guard' KVA page allocated below
all of the stacks?
64bit systems should have lots of KVA so this shouldn't be
a problem.
Then stack overruns will fault and panic rather than trashing
another data area - which is really hard to debug.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2022-03-07 14:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 14:08 [PATCH v2] riscv: add irq stack support Jisheng Zhang
2022-03-07 14:08 ` Jisheng Zhang
2022-03-07 14:32 ` David Laight [this message]
2022-03-07 14:32   ` David Laight
2022-05-15  5:20   ` Jisheng Zhang
2022-05-15  5:20     ` Jisheng Zhang
2022-03-07 19:19 ` Arnd Bergmann
2022-03-07 19:19   ` Arnd Bergmann
2022-05-15  5:14   ` Jisheng Zhang
2022-05-15  5:14     ` Jisheng Zhang
2022-05-23  8:16     ` Arnd Bergmann
2022-05-23  8:16       ` Arnd Bergmann
2022-05-26 14:05       ` Arnd Bergmann
2022-05-26 14:05         ` Arnd Bergmann

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=f7f46323619e4084b4cfc551cdb47dd0@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=jszhang@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /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.