From: Segher Boessenkool <segher@kernel.crashing.org>
To: LEROY Christophe <christophe.leroy2@cs-soprasteria.com>
Cc: Christoph Hellwig <hch@lst.de>,
Christian Lamparter <christian.lamparter@isd.uni-stuttgart.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Stan Johnson <userm57@yahoo.com>,
Finn Thain <fthain@linux-m68k.org>
Subject: Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode
Date: Fri, 23 Aug 2024 08:06:00 -0500 [thread overview]
Message-ID: <20240823130600.GI28254@gate.crashing.org> (raw)
In-Reply-To: <e6acf664-5ebd-4273-9330-cbec283ede23@cs-soprasteria.com>
Hi!
On Thu, Aug 22, 2024 at 06:39:33AM +0000, LEROY Christophe wrote:
> Le 22/08/2024 à 07:32, Christoph Hellwig a écrit :
> > On Thu, Aug 22, 2024 at 05:25:10AM +0000, 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 all the time. Note that uncached
> > memory != __iomem memory, for which you DO have to use memset_io.
> >
>
> Then we have a subject here.
>
> 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 ("powerpc/32: memset(0): use cacheable_memzero"))
>
> But that instruction generates an alignment exception when used on
> non-cached memory (whether it is RAM or not doesn't matter).
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).
M=0 memory shouldn't ever have memset done on it, that is insane. And
I=1 memory should not have the same optimised routines used, since
those only make things slower still.
> It is then
> emulated by the kernel but it of course leads to a serious performance
> degradation, hence the warning added by commit cbe654c77961 ("powerpc:
> warn on emulation of dcbz instruction in kernel mode"). Until now it
> helped identify and fix use of memset() on IO memory.
>
> But if memset() is expected to be used with non-cached RAM, then I don't
> know what to do. Any suggestion ?
If memset() is expected to be used with M=0, you cannot do any serious
optimisations to it at all. If memset() is expected to be used with I=1
it should use a separate code path for it, probably the caller should
make the distinction.
Segher
next prev parent reply other threads:[~2024-08-23 13:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-16 14:52 [PATCH v2] powerpc: warn on emulation of dcbz instruction in kernel mode Christophe Leroy
2021-09-16 14:52 ` Christophe Leroy
2021-11-02 10:11 ` Michael Ellerman
2021-11-02 10:11 ` Michael Ellerman
2024-08-21 22:39 ` Christian Lamparter
2024-08-22 5:25 ` LEROY Christophe
2024-08-22 5:32 ` Christoph Hellwig
2024-08-22 6:39 ` LEROY Christophe
2024-08-22 7:14 ` Christoph Hellwig
2024-08-22 9:53 ` Benjamin Herrenschmidt
2024-08-22 18:19 ` Christian Lamparter
2024-08-23 8:07 ` Christoph Hellwig
2024-08-23 13:06 ` Segher Boessenkool [this message]
2024-08-23 13:54 ` Christoph Hellwig
2024-08-23 19:19 ` Segher Boessenkool
2024-08-23 23:43 ` Christian Lamparter
2024-08-24 9:01 ` LEROY Christophe
2024-08-24 17:17 ` Segher Boessenkool
2024-08-27 7:29 ` Christoph Hellwig
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=20240823130600.GI28254@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=benh@kernel.crashing.org \
--cc=christian.lamparter@isd.uni-stuttgart.de \
--cc=christophe.leroy2@cs-soprasteria.com \
--cc=fthain@linux-m68k.org \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=userm57@yahoo.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.