mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Ungerer <gregungerer@westnet.com.au>
To: Matthew Wilcox <willy@infradead.org>
Cc: David Laight <David.Laight@aculab.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
	Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH 09/17] m68k: Implement xor_unlock_is_negative_byte
Date: Wed, 4 Oct 2023 00:14:10 +1000	[thread overview]
Message-ID: <9d73b9e2-502e-4ef5-bb49-bc89d478329a@westnet.com.au> (raw)
In-Reply-To: <ZRsi7smLotWDwoNP@casper.infradead.org>


On 3/10/23 06:07, Matthew Wilcox wrote:
> On Wed, Sep 20, 2023 at 05:22:33PM +1000, Greg Ungerer wrote:
>> On 20/9/23 01:14, Matthew Wilcox wrote:
>>> I have a 68020 book; what I don't have is a Coldfire manual.
>>
>> You can find it here: https://www.nxp.com/docs/en/reference-manual/CFPRM.pdf
> 
> Thanks, Greg.  This is almost good:
> 
> static inline bool xor_unlock_is_negative_byte(unsigned long mask,
>                  volatile unsigned long *p)
> {
> #ifdef CONFIG_COLDFIRE
>          __asm__ __volatile__ ("eorl %1, %0"
>                  : "+m" (*p)
>                  : "d" (mask)
>                  : "memory");
>          return *p & (1 << 7);
> #else
>          char result;
>          char *cp = (char *)p + 3;       /* m68k is big-endian */
> 
>          __asm__ __volatile__ ("eor.b %1, %2; smi %0"
>                  : "=d" (result)
>                  : "di" (mask), "o" (*cp)
>                  : "memory");
>          return result;
> #endif
> }
> 
> folio_end_read() does about as well as can be expected:
> 
> 00000708 <folio_end_read>:
>       708:       206f 0004       moveal %sp@(4),%a0
>       70c:       7009            moveq #9,%d0
>       70e:       4a2f 000b       tstb %sp@(11)
>       712:       6602            bnes 716 <folio_end_read+0xe>
>       714:       7001            moveq #1,%d0
>       716:       b190            eorl %d0,%a0@
>       718:       2010            movel %a0@,%d0
>       71a:       4a00            tstb %d0
>       71c:       6a0c            bpls 72a <folio_end_read+0x22>
>       71e:       42af 0008       clrl %sp@(8)
>       722:       2f48 0004       movel %a0,%sp@(4)
>       726:       6000 fcfe       braw 426 <folio_wake_bit>
>       72a:       4e75            rts
> 
> However, it seems that folio_unlock() could shave off an instruction:
> 
> 00000918 <folio_unlock>:
>       918:       206f 0004       moveal %sp@(4),%a0
>       91c:       7001            moveq #1,%d0
>       91e:       b190            eorl %d0,%a0@
>       920:       2010            movel %a0@,%d0
>       922:       4a00            tstb %d0
>       924:       6a0a            bpls 930 <folio_unlock+0x18>
>       926:       42a7            clrl %sp@-
>       928:       2f08            movel %a0,%sp@-
>       92a:       4eba fafa       jsr %pc@(426 <folio_wake_bit>)
>       92e:       508f            addql #8,%sp
>       930:       4e75            rts
> 
> We could use eori instead of eorl, at least according to table 3-9 on
> page 3-8:
> 
> EOR Dy,<ea>x L Source ^ Destination → Destination ISA_A
> EORI #<data>,Dx L Immediate Data ^ Destination → Destination ISA_A
> 
> but gas is unhappy with everything I've tried to use eori.  I'm building

I can't seem to get it to always use it either. This comes close:

         __asm__ __volatile__ ("eorl %1, %0"
                 : "+d" (*p)
                 : "di" (mask)
                 : "memory");
         return *p & (1 << 7);

Using eoril for folio_unlock, but not for folio_end_read:

400413e6 <folio_unlock>:
400413e6:       206f 0004       moveal %sp@(4),%a0
400413ea:       2010            movel %a0@,%d0
400413ec:       0a80 0000 0001  eoril #1,%d0
400413f2:       2080            movel %d0,%a0@
400413f4:       2010            movel %a0@,%d0
400413f6:       4a00            tstb %d0
400413f8:       6c0a            bges 40041404 <folio_unlock+0x1e>
400413fa:       42a7            clrl %sp@-
400413fc:       2f08            movel %a0,%sp@-
400413fe:       4eba ff30       jsr %pc@(40041330 <folio_wake_bit>)
40041402:       508f            addql #8,%sp
40041404:       4e75            rts

But that is still worse anyway.

> with stmark2_defconfig, which I assume should work.

Yes, or any of amcore, m5208evb, m5249evb, m5272c3, m5275evb, m5307c3, m5407c3.

Regards
Greg


  reply	other threads:[~2023-10-03 14:14 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 18:36 [PATCH 00/17] Add folio_end_read Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 01/17] iomap: Hold state_lock over call to ifs_set_range_uptodate() Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 02/17] iomap: Protect read_bytes_pending with the state_lock Matthew Wilcox (Oracle)
2023-09-16  0:11   ` Linus Torvalds
2023-09-16  0:15     ` Linus Torvalds
2023-09-16 15:50     ` Matthew Wilcox
2023-09-15 18:36 ` [PATCH 03/17] mm: Add folio_end_read() Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 04/17] ext4: Use folio_end_read() Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 05/17] buffer: " Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 06/17] iomap: " Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 07/17] bitops: Add xor_unlock_is_negative_byte() Matthew Wilcox (Oracle)
2023-09-15 18:36 ` [PATCH 08/17] alpha: Implement xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-09-16  0:27   ` Linus Torvalds
2023-09-16  0:38     ` Matthew Wilcox
2023-09-16  2:01       ` Linus Torvalds
2023-09-16  2:14         ` Linus Torvalds
2023-09-16 15:59         ` Matthew Wilcox
2023-09-15 18:36 ` [PATCH 09/17] m68k: " Matthew Wilcox (Oracle)
2023-09-16 13:11   ` Greg Ungerer
2023-09-16 14:34     ` Matthew Wilcox
2023-09-18 14:37       ` Greg Ungerer
2023-09-20  7:45         ` Greg Ungerer
2023-09-20 16:58           ` Linus Torvalds
2023-09-19 13:23       ` David Laight
2023-09-19 14:26         ` Matthew Wilcox
2023-09-19 14:35           ` David Laight
2023-09-19 15:14             ` Matthew Wilcox
2023-09-19 15:22               ` David Laight
2023-09-19 15:47                 ` Matthew Wilcox
2023-09-19 15:57                   ` David Laight
2023-09-20  7:15                     ` Greg Ungerer
2023-09-20  7:22               ` Greg Ungerer
2023-10-02 20:07                 ` Matthew Wilcox
2023-10-03 14:14                   ` Greg Ungerer [this message]
2023-10-03 20:07                     ` Matthew Wilcox
2023-10-04 12:06                       ` Greg Ungerer
2023-09-15 18:37 ` [PATCH 10/17] mips: " Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 11/17] powerpc: Implement arch_xor_unlock_is_negative_byte on 32-bit Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 12/17] riscv: Implement xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 13/17] s390: Implement arch_xor_unlock_is_negative_byte Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 14/17] mm: Delete checks for xor_unlock_is_negative_byte() Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 15/17] mm: Add folio_xor_flags_has_waiters() Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 16/17] mm: Make __end_folio_writeback() return void Matthew Wilcox (Oracle)
2023-09-15 18:37 ` [PATCH 17/17] mm: Use folio_xor_flags_has_waiters() in folio_end_writeback() Matthew Wilcox (Oracle)
2023-09-16  0:31 ` [PATCH 00/17] Add folio_end_read Linus Torvalds

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=9d73b9e2-502e-4ef5-bb49-bc89d478329a@westnet.com.au \
    --to=gregungerer@westnet.com.au \
    --cc=David.Laight@aculab.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®