All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, <linux-kernel@vger.kernel.org>,
	Peng Fan <peng.fan@nxp.com>, <kvm@vger.kernel.org>
Subject: Re: [PATCH] KVM: x86: use assign_bit() where applicable
Date: Wed, 7 Oct 2026 18:53:08 -0700	[thread overview]
Message-ID: <asb3hGpSWVQk93cX@aschofie-mobl2.lan> (raw)
In-Reply-To: <arsNUfVv0NhKZ6zT@google.com>

On Mon, Sep 28, 2026 at 05:58:57PM -0700, Sean Christopherson wrote:
> On Sun, Sep 20, 2026, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> > 
> > Convert open-coded if/else with set_bit/clear_bit and their
> > non-atomic __set_bit/__clear_bit variants to the assign_bit/__assign_bit
> > API.
> 
> ...
> 
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  arch/x86/kvm/hyperv.c  | 12 ++++--------
> >  arch/x86/kvm/svm/pmu.c |  6 ++----
> >  arch/x86/kvm/x86.c     | 11 +++--------
> >  3 files changed, 9 insertions(+), 20 deletions(-)
> > 
> > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
> > index 8d2669d8ef34..c131d9a3c550 100644
> > --- a/arch/x86/kvm/hyperv.c
> > +++ b/arch/x86/kvm/hyperv.c
> > @@ -114,17 +114,13 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
> >  	if (vector < HV_SYNIC_FIRST_VALID_VECTOR)
> >  		return;
> >  
> > -	if (synic_has_vector_connected(synic, vector))
> > -		__set_bit(vector, synic->vec_bitmap);
> > -	else
> > -		__clear_bit(vector, synic->vec_bitmap);
> > +	__assign_bit(vector, synic->vec_bitmap,
> > +		     synic_has_vector_connected(synic, vector));
> >  
> >  	auto_eoi_old = !bitmap_empty(synic->auto_eoi_bitmap, 256);
> >  
> > -	if (synic_has_vector_auto_eoi(synic, vector))
> > -		__set_bit(vector, synic->auto_eoi_bitmap);
> > -	else
> > -		__clear_bit(vector, synic->auto_eoi_bitmap);
> > +	__assign_bit(vector, synic->auto_eoi_bitmap,
> > +		     synic_has_vector_auto_eoi(synic, vector));
> 
> Am I the only one that finds the assign_bit() code signficantly harder to follow?
> Maybe it's just that I haven't seen assign_bit() much, but I've come back to this
> patch several times, and I've had the same reaction every time.  IMO, this is a
> solution looking for a problem.


A place for me to pile on, hopefully constructively. :)

I looked at the DAX patch doing same initially and set it aside. After a few
review tags came in, I took a closer look and decided to NAK it.

A few things contributed to that decision.

These patches were sent individually, all with "where applicable" in the subject,
but without explaining why the conversion was appropriate in each case. That leaves
reviewers to establish the justification for the change, rather than evaluate the
justification provided by the author.

I would have preferred to see these as a series, so reviewers could see the scope of
the proposed conversions and discuss the approach as a whole.

Looking through the history of assign_bit(), I found that it was introduced for a
specific use case, then later moved into bitops.h when someone else had a need for it.
I didn't find any indication that the existing if/else pattern was considered
problematic or that there was an intent to replace it more broadly.

In the DAX case, the conversion /drivers/dax/super.c` didn't appear to simplify the code
or make the intent any clearer.

I'm not opposed to using `assign_bit()` where it improves the code, but I don't think the
existence of a helper is, by itself, sufficient justification for converting existing code.
I'd rather see these conversions motivated by a concrete improvement than by the
opportunity to replace an open-coded pattern.

-- Alison


      parent reply	other threads:[~2026-10-08  1:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20  2:26 [PATCH] KVM: x86: use assign_bit() where applicable Peng Fan (OSS)
2026-09-29  0:58 ` Sean Christopherson
2026-09-29  1:12   ` Peng Fan
2026-09-29  8:15   ` David Laight
2026-10-08  1:53   ` Alison Schofield [this message]

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=asb3hGpSWVQk93cX@aschofie-mobl2.lan \
    --to=alison.schofield@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.