From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECFCB632 for ; Tue, 29 Sep 2026 00:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790643540; cv=none; b=sAPPTqvys5JWrelEBsHzO//siELKCCvx5o4Jo3+o6MzvUmOFLBroubcFYrSEcr8SVT4aFl77GeHn1GBIp7lhrSVWqRu+bBul8YqIqquEeBiAYjjW3j4AY6xp1UNPPjpVN+YRf4zdnRZGUsymOWws7KDZ7bxL27BJubiqwIduKYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790643540; c=relaxed/simple; bh=QmNge30+mb61r8mkp//EH7IPSYGFg+oxdlOC6/zFrAs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ArM408emDJvbqwtSMZ6AQe4OCfc+Jnh86rDCuguI7ZxFce5bFPi1TqWbX1xFwEZRefUvaZY6fgoB9ZS8egpsrlKnQRQiwq+SdWHS1dQze+6Jc7k1mYEn2w3cr6txruwORdlsqEFygw4V+uUET5ByRIjr091mL6xuIICBP2IChho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=bBhWcl29; arc=none smtp.client-ip=209.85.216.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bBhWcl29" Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-39512608fb1so5778838a91.1 for ; Mon, 28 Sep 2026 17:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790643538; x=1791248338; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2qcic7usam/SHffcGqMIC38VmM+lEsSPmwJ4C5RzOkA=; b=bBhWcl29+kW6i9fXLUhv30ehYNmX9QSiEvCWtkK1cbcaEqoW5zQEInkicFBQXX9eZY iEAWGgLU8jQEItPs2ZRIr03Oc3+59P9kiQb2ZqMe1Lmz3QwliwjYDpNNzWiqG5MzRJ2i S1lWELV2WLpWcjcCLzWeoj9SCcRCWhBKOG+DD9TLVvEPd4OhTENWDZGDBiHWU6UXIJ6t eli+OiM0Y6uR38WJYVduhlsQ3/cpWZ1Gl/RQ1YtwdvGPOJKiiltCNpxnhw6VmcTbdnQZ 6//k+DhfuOjMS/3bBYo6jdl62aHIOUEoVdHonpZCucQWymGApcD00E23sjXkTBnD010V 7ZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790643538; x=1791248338; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2qcic7usam/SHffcGqMIC38VmM+lEsSPmwJ4C5RzOkA=; b=nl09NRSicJoRlOWboI7lRoBPCSOlSYV1bV0HjCbGh8GhRP3Pw2MalAWp3QJrBFmury HEqwTpDMInUwCa4ZJkNBSoZYeOR7vBZL6Rmj/ZhRRRtBZFT1no3w8rPqyHRoYZXf0y7r h4FZzehd1F2Ix1KHXrKonjBaP/E1r0eIuPZrKiSD1NgOSLh2AyM/ovbANXYGRwsd7tUH u3uuvXH6Y2ar6W0dkTBgM4Tje1ZYtos83KVkbELgvMmZSv1M2GZBTyyIxgCii3LqrUAg jD6QWJrPpLWfwzxKYpOwill+rhCEOwTNDOr0Xwb1XUWI8Utd9FBDUOBUOw0ONfMKu/MX R8kw== X-Forwarded-Encrypted: i=1; AKwUvBwWEzIk6JSu1fpMfZfMj+KM0uS7+x7qu9oAjHnazQyplwQHacLOojfBzuup8wNaSxUjp2l49mbjXJ30Yi0=@vger.kernel.org X-Gm-Message-State: AFq9FYIkgemBgSR/9XI+McLmJ2Egw15UcpLf+CoA62OY2uUA635+XVaf /q+iS2IYcvfeK36IEu5KgrkCdEefjT8rCsOQy14jlAiQNWIELcmxwVFbA57H76MWgt5kXuYDchY /M5PWPw== X-Received: from pjth13.prod.google.com ([2002:a17:90a:c38d:b0:3a4:7cb3:b0be]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:48c9:b0:3a4:7730:33dd with SMTP id 98e67ed59e1d1-3a477304d8emr2885569a91.58.1790643537918; Mon, 28 Sep 2026 17:58:57 -0700 (PDT) Date: Mon, 28 Sep 2026 17:58:57 -0700 In-Reply-To: <20260920022649.3145701-1-peng.fan@oss.nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260920022649.3145701-1-peng.fan@oss.nxp.com> Message-ID: Subject: Re: [PATCH] KVM: x86: use assign_bit() where applicable From: Sean Christopherson To: "Peng Fan (OSS)" Cc: Vitaly Kuznetsov , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Peng Fan , kvm@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Sun, Sep 20, 2026, Peng Fan (OSS) wrote: > From: Peng Fan > > 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 > --- > 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.