diff mbox series

powerpc: Fix flush_cache() speed regression

Message ID b5c81fba9aae7ee9e8b6fcb515e7051385b7ae4a.1688568690.git.christophe.leroy@csgroup.eu
State Accepted
Commit 64948e247e83c58adc485b808acc539ea2c5d3c9
Delegated to: Tom Rini
Headers show
Series powerpc: Fix flush_cache() speed regression | expand

Commit Message

Christophe Leroy July 5, 2023, 2:51 p.m. UTC
Flushing kernel image after decompression was taking 113 milliseconds
with U-boot 2022.10. With U-boot 2023.01 and 2023.04, flushing
the same amount of memory takes approx 1.5 seconds. With
U-boot 2023.07-rc6, it takes 6.5 seconds.

powerpc flush_cache() function used to call WATCHDOG_RESET() after
flushing every cacheline. At that time WATCHDOG_RESET() was light
so the operation was almost seamless.

But commit 29caf9305b6 ("cyclic: Use schedule() instead of
WATCHDOG_RESET()") replaced WATCHDOG_RESET() by schedule() and that
started to hurt with U-boot 2022.10.

And in U-boot 2023.07-rc6 that's even worse after
commit 26e8ebcd7cb ("watchdog: mpc8xxx: Make it generic").

In the meantime commit 729c1fe656 ("powerpc: introduce
CONFIG_CACHE_FLUSH_WATCHDOG_THRESHOLD") gives us the opportinity to
only call schedule() every given chunk of data instead of every
cacheline. As explained in that commit there is no point in pinging
the watchdog after every cacheline flush, so lets define a sensible
default chunk size of 4k which matches to size of a page on most
powerpc platforms.

With that new default threshold, the culprit flushing performed after
kernel image decompression now takes 85 milliseconds on a powerpc 8xx.

Fixes: 29caf9305b6 ("cyclic: Use schedule() instead of WATCHDOG_RESET()")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/lib/Kconfig | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Tom Rini July 15, 2023, 3:03 p.m. UTC | #1
On Wed, Jul 05, 2023 at 04:51:37PM +0200, Christophe Leroy wrote:

> Flushing kernel image after decompression was taking 113 milliseconds
> with U-boot 2022.10. With U-boot 2023.01 and 2023.04, flushing
> the same amount of memory takes approx 1.5 seconds. With
> U-boot 2023.07-rc6, it takes 6.5 seconds.
> 
> powerpc flush_cache() function used to call WATCHDOG_RESET() after
> flushing every cacheline. At that time WATCHDOG_RESET() was light
> so the operation was almost seamless.
> 
> But commit 29caf9305b6 ("cyclic: Use schedule() instead of
> WATCHDOG_RESET()") replaced WATCHDOG_RESET() by schedule() and that
> started to hurt with U-boot 2022.10.
> 
> And in U-boot 2023.07-rc6 that's even worse after
> commit 26e8ebcd7cb ("watchdog: mpc8xxx: Make it generic").
> 
> In the meantime commit 729c1fe656 ("powerpc: introduce
> CONFIG_CACHE_FLUSH_WATCHDOG_THRESHOLD") gives us the opportinity to
> only call schedule() every given chunk of data instead of every
> cacheline. As explained in that commit there is no point in pinging
> the watchdog after every cacheline flush, so lets define a sensible
> default chunk size of 4k which matches to size of a page on most
> powerpc platforms.
> 
> With that new default threshold, the culprit flushing performed after
> kernel image decompression now takes 85 milliseconds on a powerpc 8xx.
> 
> Fixes: 29caf9305b6 ("cyclic: Use schedule() instead of WATCHDOG_RESET()")
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/powerpc/lib/Kconfig b/arch/powerpc/lib/Kconfig
index b30b5edf7c..d38ba45a99 100644
--- a/arch/powerpc/lib/Kconfig
+++ b/arch/powerpc/lib/Kconfig
@@ -1,9 +1,9 @@ 
 config CACHE_FLUSH_WATCHDOG_THRESHOLD
-	int "Bytes to flush between WATCHDOG_RESET calls"
-	default 0
+	int "Bytes to flush between schedule() calls"
+	default 4096
 	help
 	  The flush_cache() function periodically, and by default for
-	  every cache line, calls WATCHDOG_RESET(). When flushing a
-	  large area, that may add a significant amount of
+	  every 4k block, calls schedule() to reset watchdog. When
+	  flushing a large area, that may add a significant amount of
 	  overhead. This option allows you to set a threshold for how
-	  many bytes to flush between each WATCHDOG_RESET call.
+	  many bytes to flush between each schedule() call.