From: Brad Boyer <flar@allandria.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>, linux-m68k@lists.linux-m68k.org
Subject: Re: clear_bit_unlock_is_negative_byte
Date: Fri, 21 Jul 2023 13:29:04 -0700 [thread overview]
Message-ID: <20230721202904.GA12851@allandria.com> (raw)
In-Reply-To: <ZLpzNAIVVLH9JYZ1@casper.infradead.org>
On Fri, Jul 21, 2023 at 12:59:48PM +0100, Matthew Wilcox wrote:
> On Fri, Jul 21, 2023 at 08:34:55AM +0200, Andreas Schwab wrote:
> > Why are you using XOR if you want to clear a bit? If it operates on a
> > byte, why does it receive a pointer to long?
>
> It's a clever hack. This function has exactly one user, and it's an
> important one -- folio_unlock(). Bit 7 is set if there are other
> threads waiting for this folio to be unlocked. There are two reasonable
> implementations, depending what kind of CPU you have; you can either
> load-locked; clear the bottom bit, store-conditional, test bit 7. Or
> x86 and m68k have the perfect instruction to clear a bit and set the
> Negative flag if bit 7 is set.
>
> As I said in the earlier email, BCLR doesn't affect the N flag, but
> EORI and ANDI do. We are guaranteed that the bit we're clearing is set,
> so EORI will work. ANDI would also work.
There shouldn't be any performance difference between using eori.b and
andi.b, since the compiler would fully generate the immediate mask
value either way. Wouldn't readability suggest that we should use the
AND operation to make it more obvious what the code is doing and make
it more consistent with the other implementations of this function?
Brad Boyer
flar@allandria.com
next prev parent reply other threads:[~2023-07-21 20:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 19:27 clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-20 22:37 ` clear_bit_unlock_is_negative_byte Michael Schmitz
2023-07-21 1:12 ` clear_bit_unlock_is_negative_byte Michael Schmitz
2023-07-21 1:32 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-21 1:43 ` clear_bit_unlock_is_negative_byte Michael Schmitz
2023-07-21 17:03 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-21 22:07 ` clear_bit_unlock_is_negative_byte Michael Schmitz
2023-07-22 6:24 ` clear_bit_unlock_is_negative_byte Andreas Schwab
2023-07-22 14:45 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-22 15:26 ` clear_bit_unlock_is_negative_byte Andreas Schwab
2023-07-22 15:38 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-21 6:34 ` clear_bit_unlock_is_negative_byte Andreas Schwab
2023-07-21 8:57 ` clear_bit_unlock_is_negative_byte Brad Boyer
2023-07-21 9:18 ` clear_bit_unlock_is_negative_byte Andreas Schwab
2023-07-21 11:59 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-21 12:52 ` clear_bit_unlock_is_negative_byte Andreas Schwab
2023-07-21 20:29 ` Brad Boyer [this message]
2023-07-22 3:42 ` clear_bit_unlock_is_negative_byte Matthew Wilcox
2023-07-22 23:49 ` clear_bit_unlock_is_negative_byte Brad Boyer
2023-07-23 1:08 ` clear_bit_unlock_is_negative_byte Michael Schmitz
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=20230721202904.GA12851@allandria.com \
--to=flar@allandria.com \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=schwab@linux-m68k.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