public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: "André Almeida" <andrealmeid@igalia.com>,
	"Uros Bizjak" <ubizjak@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Darren Hart <dvhart@infradead.org>,
	Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [PATCH v2] futex: Rewrite get_inode_sequence_number() to make code simpler
Date: Thu, 10 Oct 2024 03:47:33 +0200	[thread overview]
Message-ID: <87ed4oiv9m.ffs@tglx> (raw)
In-Reply-To: <bb91d63d-c61a-4063-bf14-4cbbb62bec12@igalia.com>

On Wed, Oct 09 2024 at 16:43, André Almeida wrote:
> Em 04/10/2024 05:52, Uros Bizjak escreveu:
>> Rewrite get_inode_sequence_number() to make code simpler:
>> 
>> a) Rewrite FOR loop to a DO-WHILE loop with returns moved
>> out of the loop.
>> 
>> b) Use atomic64_inc_return() instead of atomic64_add_return().
>> 
>> c) Use !atomic64_try_cmpxchg_relaxed(*ptr, &old, new) instead of
>> atomic64_cmpxchg_relaxed (*ptr, old, new) != old.  x86 CMPXCHG
>> instruction returns success in ZF flag, so this change also saves
>> a compare instruction after CMPXCHG.
>
> Remember, it's easy to see in the diff that you replace the function, 
> but might be not so clear why you did so. I think it would be better to 
> understand if you write like:
>
> We are trying to set a value for the i_sequence, that we expect that is 
> zero, but if we fail to do so, we are happy to use the current non-zero 
> i_sequence value that we found. Instead of using 
> atomic64_cmpxchg_relaxed(), use atomic64_try_cmpxchg_relaxed() which 
> provides a better semantic for this situation.

We are not expecting, trying, happy.. That's non-technical babbling.

See Documentation/process/* for futher explanation.

I agree with you that the change log should be more informative about
the why instead of listing the what, but not for the price of a
non-technical 'we' novel.

Thanks,

        tglx

  reply	other threads:[~2024-10-10  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04  8:52 [PATCH v2] futex: Rewrite get_inode_sequence_number() to make code simpler Uros Bizjak
2024-10-09 19:43 ` André Almeida
2024-10-10  1:47   ` Thomas Gleixner [this message]
2024-10-10  6:20   ` Uros Bizjak

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=87ed4oiv9m.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=andrealmeid@igalia.com \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ubizjak@gmail.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