Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-27 Thread Christoph Hellwig
On Sat, Aug 24, 2024 at 12:17:57PM -0500, Segher Boessenkool wrote: > > Are these functions also used on DMA coherent memory ? > > Most won't show up high on most profiles, heh. Which you already > can see from the problem not being attacked yet: if it was so obviously > a problem, some people wo

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-24 Thread Segher Boessenkool
On Sat, Aug 24, 2024 at 09:01:33AM +, LEROY Christophe wrote: > Le 23/08/2024 à 21:19, Segher Boessenkool a écrit : > > The memset() code itself could chech for the storage attributes, but > > that is probably more expensive than just assuming the happy case. > > Maybe someone could try it out

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-24 Thread LEROY Christophe
Le 23/08/2024 à 21:19, Segher Boessenkool a écrit : > ***ATTENTION, Sopra Steria Group cannot confirm the identity of this email > sender (SPF record failure). This might be a fake email from an attacker, if > you have any doubts report and delete the email.*** > > ***ATTENTION, Sopra Steria G

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-23 Thread Christian Lamparter
On 8/23/24 9:19 PM, Segher Boessenkool wrote: Hi! On Fri, Aug 23, 2024 at 03:54:59PM +0200, Christoph Hellwig wrote: On Fri, Aug 23, 2024 at 08:06:00AM -0500, Segher Boessenkool wrote: What does "uncached memory" even mean here? Literally it would be I=1 memory (uncachEABLE memory), but more

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-23 Thread Segher Boessenkool
Hi! On Fri, Aug 23, 2024 at 03:54:59PM +0200, Christoph Hellwig wrote: > On Fri, Aug 23, 2024 at 08:06:00AM -0500, Segher Boessenkool wrote: > > What does "uncached memory" even mean here? Literally it would be > > I=1 memory (uncachEABLE memory), but more likely you want M=0 memory > > here ("no

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-23 Thread Christoph Hellwig
On Fri, Aug 23, 2024 at 08:06:00AM -0500, Segher Boessenkool wrote: > What does "uncached memory" even mean here? Literally it would be > I=1 memory (uncachEABLE memory), but more likely you want M=0 memory > here ("non-memory memory", "not well-behaved memory", MMIO often). Regular kernel memory

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-23 Thread Segher Boessenkool
Hi! On Thu, Aug 22, 2024 at 06:39:33AM +, LEROY Christophe wrote: > Le 22/08/2024 à 07:32, Christoph Hellwig a écrit : > > On Thu, Aug 22, 2024 at 05:25:10AM +, LEROY Christophe wrote: > >>> and this results in a call to dma_direct_allocation(), which has one > >>> innocent looking memset(

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-23 Thread Christoph Hellwig
dma_alloc_from_pool is the allocator used when the caller can't sleep, and as that is reusing memory it really has to call memset or a memset-like function on the already uncached memory unfortunately. The dma engine operation that is doing this allocation is documented as not being able to sleep,

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-22 Thread Christian Lamparter
Hi! Thank you all for your insightful insights :-) . ... and derp, used the wrong mail. On 8/22/24 9:14 AM, Christoph Hellwig wrote: On Thu, Aug 22, 2024 at 06:39:33AM +, LEROY Christophe wrote: powerpc has a magic instruction 'dcbz' which clears a full cacheline in one go. It is far more

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-22 Thread Benjamin Herrenschmidt
On Thu, 2024-08-22 at 09:14 +0200, Christoph Hellwig wrote: > > I'd suggest two things: > >  1) remove the warning.  The use case is perfectly valid and everything >     using uncached memory is already slow, so people will just have to >     deal with it.  Maybe offer a trace point instead if pe

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-22 Thread Christoph Hellwig
On Thu, Aug 22, 2024 at 06:39:33AM +, LEROY Christophe wrote: > powerpc has a magic instruction 'dcbz' which clears a full cacheline in > one go. It is far more efficient than a loop to store zeros, and since > 2015 memset(0) has been implemented with that instruction (commit > 5b2a32e80634

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread LEROY Christophe
Le 22/08/2024 à 07:32, Christoph Hellwig a écrit : > On Thu, Aug 22, 2024 at 05:25:10AM +, LEROY Christophe wrote: >>> and this results in a call to dma_direct_allocation(), which has one >>> innocent looking memset(): >> >> >> memset() can't be used on non-cached memory, memset_io() has to b

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread Christoph Hellwig
On Thu, Aug 22, 2024 at 05:25:10AM +, LEROY Christophe wrote: > > and this results in a call to dma_direct_allocation(), which has one > > innocent looking memset(): > > > memset() can't be used on non-cached memory, memset_io() has to be used > instead. No, we use memset on uncached memory

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread LEROY Christophe
+ CC Christoph Hellwig Hi, Le 22/08/2024 à 00:39, Christian Lamparter a écrit : > [Vous ne recevez pas souvent de courriers de > christian.lampar...@isd.uni-stuttgart.de. Découvrez pourquoi ceci est > important à https://aka.ms/LearnAboutSenderIdentification ] > > Sorry to write a reply to this o

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2024-08-21 Thread Christian Lamparter
Sorry to write a reply to this old mail. But after years, I finally decided to tackle an "old" problem that has come up... And unfortunately it is related to this patch. But let me explain. On 9/16/21 4:52 PM, Christophe Leroy wrote: dcbz instruction shouldn't be used on non-cached memory. Using

Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2021-11-02 Thread Michael Ellerman
On Thu, 16 Sep 2021 16:52:09 +0200, Christophe Leroy wrote: > dcbz instruction shouldn't be used on non-cached memory. Using > it on non-cached memory can result in alignment exception and > implies a heavy handling. > > Instead of silentely emulating the instruction and resulting in high > perfor

[PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode

2021-09-16 Thread Christophe Leroy
dcbz instruction shouldn't be used on non-cached memory. Using it on non-cached memory can result in alignment exception and implies a heavy handling. Instead of silentely emulating the instruction and resulting in high performance degradation, warn whenever an alignment exception is taken in kern