public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Will Deacon <will@kernel.org>
Cc: catalin.marinas@arm.com, maz@kernel.org, broonie@kernel.org,
	oliver.upton@linux.dev, miko.lenczewski@arm.com,
	kevin.brodsky@arm.com, ardb@kernel.org, suzuki.poulose@arm.com,
	lpieralisi@kernel.org, yangyicong@hisilicon.com,
	scott@os.amperecomputing.com, joey.gouly@arm.com,
	yuzenghui@huawei.com, pbonzini@redhat.com, shuah@kernel.org,
	mark.rutland@arm.com, arnd@arndb.de,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v11 RESEND 6/9] arm64: futex: support futex with FEAT_LSUI
Date: Wed, 21 Jan 2026 14:16:23 +0000	[thread overview]
Message-ID: <aXDfty/c9c9YD8u5@e129823.arm.com> (raw)
In-Reply-To: <aXDZGhFQDvoSwdc_@willie-the-truck>

Hi Will,

> On Mon, Jan 19, 2026 at 10:17:47PM +0000, Yeoreum Yun wrote:
> > > > +"2:\n"
> > > > +	_ASM_EXTABLE_UACCESS_ERR(1b, 2b, %w0)
> > > > +	: "+r" (ret), "+Q" (*uaddr), "+r" (*oldval)
> > > > +	: "r" (newval)
> > > > +	: "memory");
> > >
> > > Don't you need to update *oldval here if the CAS didn't fault?
> >
> > No. if CAS doesn't make fault the oldval update already.
>
> Sorry, it was the "+r" constraint with a pointer dereference that threw
> me but you have the "memory" clobber so it looks like this will work.
>
> > > > +
> > > > +	for (i = 0; i < FUTEX_MAX_LOOPS; i++) {
> > > > +		if (get_user(oval64.raw, uaddr64))
> > > > +			return -EFAULT;
> > >
> > > Since oldval is passed to us as an argument, can we get away with a
> > > 32-bit get_user() here?
> >
> > It's not a probelm. but is there any sigificant difference?
>
> I think the code would be clearer if you only read what you actually
> use.
>
> > > > +		nval64.raw = oval64.raw;
> > > > +
> > > > +		if (futex_on_lo) {
> > > > +			oval64.lo_futex.val = oldval;
> > > > +			nval64.lo_futex.val = newval;
> > > > +		} else {
> > > > +			oval64.hi_futex.val = oldval;
> > > > +			nval64.hi_futex.val = newval;
> > > > +		}
> > > > +
> > > > +		orig64.raw = oval64.raw;
> > > > +
> > > > +		if (__lsui_cmpxchg64(uaddr64, &oval64.raw, nval64.raw))
> > > > +			return -EFAULT;
> > > > +
> > > > +		if (futex_on_lo) {
> > > > +			oldval = oval64.lo_futex.val;
> > > > +			other = oval64.lo_futex.other;
> > > > +			orig_other = orig64.lo_futex.other;
> > > > +		} else {
> > > > +			oldval = oval64.hi_futex.val;
> > > > +			other = oval64.hi_futex.other;
> > > > +			orig_other = orig64.hi_futex.other;
> > > > +		}
> > > > +
> > > > +		if (other == orig_other) {
> > > > +			ret = 0;
> > > > +			break;
> > > > +		}
> > > > +	}
> > > > +
> > > > +	if (!ret)
> > > > +		*oval = oldval;
> > >
> > > Shouldn't we set *oval to the value we got back from the CAS?
> >
> > Since it's a "success" case, the CAS return and oldval must be the same.
> > That's why it doesn't matter to use got back from the CAS.
> > Otherwise, it returns error and *oval doesn't matter for
> > futex_atomic_cmpxchg_inatomic().
>
> Got it, but then the caller you have is very weird because e.g.
> __lsui_futex_atomic_eor() goes and does another get_user() on the next
> iteration instead of using the value returned by the CAS.
>
> It would probably be clearer if you restructured your CAS helper to look
> more like try_cmpxchg() and then the loop around it would be minimal.
> You might need to distinguish the faulting case from the comparison
> failure case with e.g. -EFAULT vs -EAGAIN.


Oh, thanks for pointing this out.I understand your point clearly now.
Yes, I’ll respin the patch accordingly. Thanks again!

--
Sincerely,
Yeoreum Yun


  reply	other threads:[~2026-01-21 14:17 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-14 11:22 [PATCH v11 RESEND 0/9] support FEAT_LSUI Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 1/9] arm64: cpufeature: add FEAT_LSUI Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 2/9] KVM: arm64: expose FEAT_LSUI to guest Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 3/9] KVM: arm64: kselftest: set_id_regs: add test for FEAT_LSUI Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 4/9] arm64: Kconfig: Detect toolchain support for LSUI Yeoreum Yun
2026-01-19 15:50   ` Will Deacon
2026-01-19 15:54     ` Mark Brown
2026-01-20 11:35       ` Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 5/9] arm64: futex: refactor futex atomic operation Yeoreum Yun
2026-01-19 15:57   ` Will Deacon
2026-01-19 22:19     ` Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 6/9] arm64: futex: support futex with FEAT_LSUI Yeoreum Yun
2026-01-19 16:37   ` Will Deacon
2026-01-19 22:17     ` Yeoreum Yun
2026-01-20 15:44       ` Yeoreum Yun
2026-01-21 13:48       ` Will Deacon
2026-01-21 14:16         ` Yeoreum Yun [this message]
2025-12-14 11:22 ` [PATCH v11 RESEND 7/9] arm64: separate common LSUI definitions into lsui.h Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 8/9] arm64: armv8_deprecated: convert user_swpX to inline function Yeoreum Yun
2025-12-14 11:22 ` [PATCH v11 RESEND 9/9] arm64: armv8_deprecated: apply FEAT_LSUI for swpX emulation Yeoreum Yun
2025-12-15  9:33   ` Marc Zyngier
2025-12-15  9:56     ` Yeoreum Yun
2026-01-19 15:34       ` Will Deacon
2026-01-19 22:32         ` Yeoreum Yun
2026-01-20  9:32           ` Yeoreum Yun
2026-01-20  9:46           ` Mark Rutland
2026-01-20 10:07             ` Yeoreum Yun
2026-01-20 11:50               ` Will Deacon
2026-01-20 12:14                 ` Yeoreum Yun
2026-01-20 17:59                 ` Yeoreum Yun
2026-01-21 13:56                   ` Will Deacon
2026-01-21 14:51                     ` Yeoreum Yun
2026-01-21 16:20                       ` Will Deacon
2026-01-21 16:31                         ` Yeoreum Yun
2026-01-21 16:36                           ` Will Deacon
2026-01-21 16:51                             ` Yeoreum Yun
2025-12-31 10:07 ` [PATCH v11 RESEND 0/9] support FEAT_LSUI Yeoreum Yun

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=aXDfty/c9c9YD8u5@e129823.arm.com \
    --to=yeoreum.yun@arm.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kevin.brodsky@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=miko.lenczewski@arm.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=scott@os.amperecomputing.com \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.com \
    --cc=yuzenghui@huawei.com \
    /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