public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Magnus Lindholm <linmag7@gmail.com>
Cc: richard.henderson@linaro.org, mattst88@gmail.com,
	glaubitz@physik.fu-berlin.de, ink@unseen.parts, kees@kernel.org,
	arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-alpha@vger.kernel.org
Subject: Re: [PATCH 1/1] alpha: Fix pte_swp_exclusive on alpha
Date: Sun, 16 Feb 2025 17:17:41 +0000	[thread overview]
Message-ID: <20250216171741.GG1977892@ZenIV> (raw)
In-Reply-To: <20250216170748.2258-2-linmag7@gmail.com>

On Sun, Feb 16, 2025 at 06:04:53PM +0100, Magnus Lindholm wrote:
> Function pte_swp_exclusive() checks if _PAGE_SWP_EXCLUSIVE bit is set in
> PTE but returns lower 32-bits only. Shift bits right by 32 to return upper
> 32-bits of PTE which contain the _PAGE_SWP_EXCLUSIVE bit. On alpha this is
> bit 39 but on most other architectures this bit already resides somewhere
> in the first 32-bits and hence a shift is not necessary on those archs.

Just make it return bool and be done with that - all users are either
if (pte_swp_exclusive(...)) or if (!pte_swp_exclusive(...)) or assignments
to bool variable.

No need to shift anything - compiler probably will figure out that
	if ((int)((x & (1UL<<39)>>32)))
is equivalent to
	if (x & (1UL<<39))
but why bother with such convolutions in the first place?

Seriously, just make it

bool pte_swp_exclusive(pte_t pte)
{
	return pte_val(pte) & _PAGE_SWP_EXCLUSIVE;
}

and that's it - conversion from arithmetical types to bool will do the right thing.

  reply	other threads:[~2025-02-16 17:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-16 17:04 [PATCH 0/1] alpha: Fix pte_swp_exclusive on alpha Magnus Lindholm
2025-02-16 17:04 ` [PATCH 1/1] " Magnus Lindholm
2025-02-16 17:17   ` Al Viro [this message]
2025-02-16 17:22     ` Al Viro
2025-02-16 17:26     ` Al Viro
2025-02-17 10:54     ` Magnus Lindholm

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=20250216171741.GG1977892@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=arnd@arndb.de \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=ink@unseen.parts \
    --cc=kees@kernel.org \
    --cc=linmag7@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --cc=richard.henderson@linaro.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