linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation
@ 2020-04-16 22:01 Matthew Wilcox
  2020-04-16 22:01 ` [PATCH v3 03/11] m68k: Add clear_bit_unlock_is_negative_byte implementation Matthew Wilcox
  2020-04-17  7:28 ` [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-04-16 22:01 UTC (permalink / raw)
  To: linux-mm, linux-fsdevel
  Cc: Matthew Wilcox (Oracle),
	linux-alpha, linux-ia64, linux-m68k, linux-mips, linux-riscv,
	linux-s390

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

PageWaiters is used by PageWriteback and PageLocked (and no other page
flags), so it makes sense to use the same codepaths that have already been
optimised for PageLocked, even if there's probably no real performance
benefit to be had.

Unfortunately, clear_bit_unlock_is_negative_byte() isn't present on every
architecture, and the default implementation is only available in filemap.c
while I want to use it in page-writeback.c.  Rather than move the default
implementation to a header file, I've done optimised implementations for
alpha and ia64.  I can't figure out optimised implementations for m68k,
mips, riscv and s390, so I've just replicated the effect of the generic
implementation in them.  I leave it to the experts to fix that (... or
convert over to using asm-generic/bitops/lock.h ...)

v3:
 - Added implementations of clear_bit_unlock_is_negative_byte()
   to architectures which need it

v2: Rebased to 5.7-rc1
 - Split up patches better
 - Moved the BUG() from end_page_writeback() to __clear_page_writeback()
   as requested by Jan Kara.
 - Converted the BUG() to WARN_ON()
 - Removed TestClearPageWriteback

Matthew Wilcox (Oracle) (11):
  alpha: Add clear_bit_unlock_is_negative_byte implementation
  ia64: Add clear_bit_unlock_is_negative_byte implementation
  m68k: Add clear_bit_unlock_is_negative_byte implementation
  mips: Add clear_bit_unlock_is_negative_byte implementation
  riscv: Add clear_bit_unlock_is_negative_byte implementation
  s390: Add clear_bit_unlock_is_negative_byte implementation
  mm: Remove definition of clear_bit_unlock_is_negative_byte
  mm: Move PG_writeback into the bottom byte
  mm: Convert writeback BUG to WARN_ON
  mm: Use clear_bit_unlock_is_negative_byte for PageWriteback
  mm: Remove TestClearPageWriteback

 arch/alpha/include/asm/bitops.h | 23 ++++++++++++++++++
 arch/ia64/include/asm/bitops.h  | 20 ++++++++++++++++
 arch/m68k/include/asm/bitops.h  |  7 ++++++
 arch/mips/include/asm/bitops.h  |  7 ++++++
 arch/riscv/include/asm/bitops.h |  7 ++++++
 arch/s390/include/asm/bitops.h  |  9 +++++++
 include/linux/page-flags.h      |  8 +++----
 mm/filemap.c                    | 41 ++++----------------------------
 mm/page-writeback.c             | 42 ++++++++++++++++++++-------------
 9 files changed, 107 insertions(+), 57 deletions(-)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 03/11] m68k: Add clear_bit_unlock_is_negative_byte implementation
  2020-04-16 22:01 [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Matthew Wilcox
@ 2020-04-16 22:01 ` Matthew Wilcox
  2020-04-17  7:28 ` [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Geert Uytterhoeven
  1 sibling, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-04-16 22:01 UTC (permalink / raw)
  To: linux-mm, linux-fsdevel
  Cc: Matthew Wilcox (Oracle), Geert Uytterhoeven, linux-m68k

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

This is the generic implementation.  Someone who knows m68k assembly
can probably do better (the BFCLR instruction appears to set the N bit
appropriately).

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
---
 arch/m68k/include/asm/bitops.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h
index 10133a968c8e..bfb34e0748fe 100644
--- a/arch/m68k/include/asm/bitops.h
+++ b/arch/m68k/include/asm/bitops.h
@@ -524,6 +524,13 @@ static inline int __fls(int x)
 #define clear_bit_unlock	clear_bit
 #define __clear_bit_unlock	clear_bit_unlock
 
+static inline bool clear_bit_unlock_is_negative_byte(unsigned int nr,
+						volatile unsigned long *p)
+{
+	clear_bit_unlock(nr, p);
+	return test_bit(7, p);
+}
+
 #include <asm-generic/bitops/ext2-atomic.h>
 #include <asm-generic/bitops/le.h>
 #include <asm-generic/bitops/fls64.h>
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation
  2020-04-16 22:01 [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Matthew Wilcox
  2020-04-16 22:01 ` [PATCH v3 03/11] m68k: Add clear_bit_unlock_is_negative_byte implementation Matthew Wilcox
@ 2020-04-17  7:28 ` Geert Uytterhoeven
  2020-04-17 11:12   ` Matthew Wilcox
  1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2020-04-17  7:28 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Linux MM, Linux FS Devel, linux-s390, linux-ia64,
	open list:BROADCOM NVRAM DRIVER, linux-m68k, alpha, linux-riscv

Hi Matthew,

On Fri, Apr 17, 2020 at 12:01 AM Matthew Wilcox <willy@infradead.org> wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
> PageWaiters is used by PageWriteback and PageLocked (and no other page
> flags), so it makes sense to use the same codepaths that have already been
> optimised for PageLocked, even if there's probably no real performance
> benefit to be had.
>
> Unfortunately, clear_bit_unlock_is_negative_byte() isn't present on every
> architecture, and the default implementation is only available in filemap.c
> while I want to use it in page-writeback.c.  Rather than move the default
> implementation to a header file, I've done optimised implementations for
> alpha and ia64.  I can't figure out optimised implementations for m68k,
> mips, riscv and s390, so I've just replicated the effect of the generic
> implementation in them.  I leave it to the experts to fix that (... or
> convert over to using asm-generic/bitops/lock.h ...)
>
> v3:
>  - Added implementations of clear_bit_unlock_is_negative_byte()
>    to architectures which need it

I have two questions here?
  1. Why not implement arch_clear_bit_unlock_is_negative_byte()
     instead, so the kasan check in asm-generic is used everywhere?
  2. Why not add the default implementation to
     include/asm-generic/bitops/instrumented-lock.h, in case an arch_*()
     variant is not provided yet?

Note that you did 1 for s390.
Thanks!

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation
  2020-04-17  7:28 ` [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Geert Uytterhoeven
@ 2020-04-17 11:12   ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2020-04-17 11:12 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Linux MM, Linux FS Devel, linux-s390, linux-ia64,
	open list:BROADCOM NVRAM DRIVER, linux-m68k, alpha, linux-riscv

On Fri, Apr 17, 2020 at 09:28:14AM +0200, Geert Uytterhoeven wrote:
> On Fri, Apr 17, 2020 at 12:01 AM Matthew Wilcox <willy@infradead.org> wrote:
> > v3:
> >  - Added implementations of clear_bit_unlock_is_negative_byte()
> >    to architectures which need it
> 
> I have two questions here?
>   1. Why not implement arch_clear_bit_unlock_is_negative_byte()
>      instead, so the kasan check in asm-generic is used everywhere?

That would be a larger change.  As I understand it (and I may misunderstand
it), I would need to rename all the clear_bit(), __clear_bit(), change_bit(),
... functions to have an 'arch_' prefix and then include instrumented-lock.h

>   2. Why not add the default implementation to
>      include/asm-generic/bitops/instrumented-lock.h, in case an arch_*()
>      variant is not provided yet?
> 
> Note that you did 1 for s390.

Well, s390 already uses instrumented-lock.h so I followed along with
what they're doing.  I don't think instrumented-lock.h is used at all on
these other architectures, but the whole bitops header files are such a
mess that I could easily have built a completely wrong mental model of
what's going on.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-17 11:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 22:01 [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Matthew Wilcox
2020-04-16 22:01 ` [PATCH v3 03/11] m68k: Add clear_bit_unlock_is_negative_byte implementation Matthew Wilcox
2020-04-17  7:28 ` [PATCH v3 00/11] Make PageWriteback use the PageLocked optimisation Geert Uytterhoeven
2020-04-17 11:12   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).