Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp316912lqb; Tue, 16 Apr 2024 17:39:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5ju0kAIshlf95VICjTqIeFHLgLQpj+c7VISzf6Y0dgT6y+EL+DOry6G7mqqnkuxx4xeaJYSSk0V+PpY24+b0abkrwaakMH4bAF2BS/w== X-Google-Smtp-Source: AGHT+IEQbFDL2ozriml8yXki1pc1XmiCF3/dH5HXQOMLRDGBxlKYVgEnIPHoRxcv7fa5N8A5zQRr X-Received: by 2002:a05:622a:198c:b0:436:a38b:707a with SMTP id u12-20020a05622a198c00b00436a38b707amr16919806qtc.26.1713314396563; Tue, 16 Apr 2024 17:39:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713314396; cv=pass; d=google.com; s=arc-20160816; b=P6Ll9XVeVI6y8rO8DtEGeZnKtWy768CRU0vzNUqr2AKRbNyV+LrwrqNuGgzLFhJk1P DP/3xYeLUUjsTGW73osNeqjaZkNCYf6tBZHQfFADsYJXTL5YkzxW7J+HKXtldYh157+Y W0uKhh14zaCiwlOAgmMnbqOZiaoTMaU57UOZG3e3VMcKe65i19xVpmuS+eQ9jBW2z5Ga 6U4Iv1pNa1DDnY4Mxr1ByQ0Y2qXUdK1Nfd6T1qzpuJt4IPOxyotx2tdJidmle7qTijto q7T4J/aDzZ4xgqqwXzAAW1L1mCTdzwN3NMD/jrNjC61KiU6Kw0zag9Q4JuKPr9f2e1b6 6/bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=vnQ65n10C6Pq0ZkKHds3ZlpX5TuDQlyTU6+t/yldsJg=; fh=qfHCYFn00CUF7pCCkKZ4atPGmtzAAk+K28625pFZ7HM=; b=TlkLlXR8bquNsWg4nznIbfk0XRcOf9rSPnHREmr6bD3NI/5FGXC70tkRWlm/2qFaZD kVjFhYxrKrz6hJRHbh05ialAE48mMwKEQcuiJcWLfN19ByYohEAuTOz8zwVB4OyQE6nS AFOgMSYKl8DM4AT40kwaTVwMnAy4cL/n0OjStqs1pHz1YV7wN5RPuQ0Wf14vNTwZLYTU DxLvj0+7/G7rSWl+yV6xSuSrKdCVW1DLWE4v9Mcn1x4a8jbjR59LqwRgn2ES2lxiMaA9 jyhytfiBJWqOK2BmBkSdSn/VtfvtTnkH13YxxCcUKgf+/bAkzBBLsSO1F0fFA8mmlDcy cQ4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Za2yJcOg; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-147808-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f4-20020a05620a15a400b0078d63b3a3ebsi13339212qkk.448.2024.04.16.17.39.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 17:39:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147808-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Za2yJcOg; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-147808-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3CA781C212E4 for ; Wed, 17 Apr 2024 00:39:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62F0C1860; Wed, 17 Apr 2024 00:39:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Za2yJcOg" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 A9F077FB for ; Wed, 17 Apr 2024 00:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713314388; cv=none; b=YtBWPt8oKCS0vyV+DK1CKqHoI7QeYCHiioBOpUNplKCI+yvFbyS7hvyFiIjouEoo4hcV9BBNYynvYIIAKl38l3gA40FdGVzfKCiQ8VaTKbGWy0fu2iCD/rUwhOzRAnhvj+FyXJRJSA791zlgSLtQ4mlA+9T0iXcoS61N5GvyeIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713314388; c=relaxed/simple; bh=FbyNbtK36AqmEzY194l7ZNmnDo1F52tA9CX+PzaMTXY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EjOSTQRSR0b9cD6/nX2asiB35yvGjuxD6xI4/ox2bEhJb7rc5NrF531KXqD4mRNPdgwDbD4dOG+VFPk5Eryv4Ei6Pdr0e62D/3wdMqXooq+KdF6YzhQc/ZK0ndxPpGYZqpEPhOgRUDFlLrAv7MHWcQWCNz+1USzoBoGUKWiRchk= 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=Za2yJcOg; arc=none smtp.client-ip=209.85.219.202 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 Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcd94cc48a1so8490798276.3 for ; Tue, 16 Apr 2024 17:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713314384; x=1713919184; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vnQ65n10C6Pq0ZkKHds3ZlpX5TuDQlyTU6+t/yldsJg=; b=Za2yJcOgwtPcIdgdC3T3QXK6MZsAJoI/rMRdX3QB04XSkD5JMnOwIa9EDDzHJCJYYP 10belE5g6mcN4jI3t0HyvT+x/Q7ImGO2PUWtiDRIOsjiwcP9nowt1M1xoJfrcx24S8wr 8W85rk3yUIiN5TjU4myh3oBjU61Q4YvPGBxdYoIYQDovEfpFUN5i3wTsiuFD2Kr15ElO Wvp0ZgR47fHSLNIfGC6mhFJrM6Cbd6q5NmdSFtqTqv2uCVnDckTFFn0hYJn0LjGaMCi9 rwKrJ67YApiI3SK6sk5i58pHUIF5oFIk6HS03RhynSH8pDhb/x2CuRgu0SDZIO9uTD/Q Dbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713314385; x=1713919185; h=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; bh=vnQ65n10C6Pq0ZkKHds3ZlpX5TuDQlyTU6+t/yldsJg=; b=JJrsSg2QdEDMfT0TnghNpf8j1ZLPTbTCaUPkLq7DilAE59DiXeJKR2TMb+uxMnks14 7fc7tjD4aheP6Epd3nX9gCd77yI6aVsqwQ0sFC9oapnj+F8jhwj8FKXBfEV0mDEEahka UMhuE0cqwPnyG36fmQWVd7LZyB4d36DAmxCDh3r8QcDxQNH0XigbMMNN/TkzHP3yclNS 2bfjPIN7HkB+nVE3RLH6yGTVodhZshZP4CzTMiNAouQTTG8lLxbGRBtcspYQBfBbMAYa pPojV5SqN4IHuqbq9EArLqTBuB+AE0wZ3bDb2hb06yko9SZaSmIEafKDrB9fmr5VVPS7 z2gA== X-Gm-Message-State: AOJu0Yz1gXaf52tMU3tfGq2mbElfSa/e00+0WMP7h3T9xmyGzNQeWh+M zyYlevJAiYrNe38q5vjBeBFZb4DEC0x6S9dr5EvruU83UptXvz4n9HkRX6EIzG3QavO9HIE+4qQ APg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1081:b0:dc7:8e30:e2e3 with SMTP id v1-20020a056902108100b00dc78e30e2e3mr4432687ybu.2.1713314384627; Tue, 16 Apr 2024 17:39:44 -0700 (PDT) Date: Tue, 16 Apr 2024 17:39:42 -0700 In-Reply-To: <20240405223110.1609888-4-jacob.jun.pan@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240405223110.1609888-1-jacob.jun.pan@linux.intel.com> <20240405223110.1609888-4-jacob.jun.pan@linux.intel.com> Message-ID: Subject: Re: [PATCH v2 03/13] x86/irq: Remove bitfields in posted interrupt descriptor From: Sean Christopherson To: Jacob Pan Cc: LKML , X86 Kernel , Peter Zijlstra , iommu@lists.linux.dev, Thomas Gleixner , Lu Baolu , kvm@vger.kernel.org, Dave Hansen , Joerg Roedel , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Paul Luse , Dan Williams , Jens Axboe , Raj Ashok , Kevin Tian , maz@kernel.org, Robin Murphy , jim.harris@samsung.com, a.manzanares@samsung.com, Bjorn Helgaas , guang.zeng@intel.com, robert.hoo.linux@gmail.com Content-Type: text/plain; charset="us-ascii" "KVM" here would be nice too. On Fri, Apr 05, 2024, Jacob Pan wrote: > Mixture of bitfields and types is weird and really not intuitive, remove > bitfields and use typed data exclusively. > > Link: https://lore.kernel.org/all/20240404101735.402feec8@jacob-builder/T/#mf66e34a82a48f4d8e2926b5581eff59a122de53a > Suggested-by: Sean Christopherson > Suggested-by: Thomas Gleixner > Signed-off-by: Jacob Pan > > --- > v2: > - Replace bitfields, no more mix. > --- > arch/x86/include/asm/posted_intr.h | 10 +--------- > arch/x86/kvm/vmx/posted_intr.c | 4 ++-- > arch/x86/kvm/vmx/vmx.c | 2 +- > 3 files changed, 4 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/include/asm/posted_intr.h b/arch/x86/include/asm/posted_intr.h > index acf237b2882e..c682c41d4e44 100644 > --- a/arch/x86/include/asm/posted_intr.h > +++ b/arch/x86/include/asm/posted_intr.h > @@ -15,17 +15,9 @@ struct pi_desc { > }; > union { > struct { > - /* bit 256 - Outstanding Notification */ > - u16 on : 1, > - /* bit 257 - Suppress Notification */ > - sn : 1, > - /* bit 271:258 - Reserved */ > - rsvd_1 : 14; > - /* bit 279:272 - Notification Vector */ > + u16 notif_ctrl; /* Suppress and outstanding bits */ > u8 nv; > - /* bit 287:280 - Reserved */ > u8 rsvd_2; > - /* bit 319:288 - Notification Destination */ > u32 ndst; > }; > u64 control; > diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c > index af662312fd07..592dbb765675 100644 > --- a/arch/x86/kvm/vmx/posted_intr.c > +++ b/arch/x86/kvm/vmx/posted_intr.c > @@ -107,7 +107,7 @@ void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) > * handle task migration (@cpu != vcpu->cpu). > */ > new.ndst = dest; > - new.sn = 0; > + new.notif_ctrl &= ~POSTED_INTR_SN; At the risk of creating confusing, would it make sense to add double-underscore, non-atomic versions of the set/clear helpers for ON and SN? I can't tell if that's a net positive versus open coding clear() and set() here and below. > /* > * Restore the notification vector; in the blocking case, the > @@ -157,7 +157,7 @@ static void pi_enable_wakeup_handler(struct kvm_vcpu *vcpu) > &per_cpu(wakeup_vcpus_on_cpu, vcpu->cpu)); > raw_spin_unlock(&per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu)); > > - WARN(pi_desc->sn, "PI descriptor SN field set before blocking"); > + WARN(pi_desc->notif_ctrl & POSTED_INTR_SN, "PI descriptor SN field set before blocking"); This can use pi_test_sn(), as test_bit() isn't atomic, i.e. doesn't incur a LOCK. > > old.control = READ_ONCE(pi_desc->control); > do { > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index d94bb069bac9..50580bbfba5d 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -4843,7 +4843,7 @@ static void __vmx_vcpu_reset(struct kvm_vcpu *vcpu) > * or POSTED_INTR_WAKEUP_VECTOR. > */ > vmx->pi_desc.nv = POSTED_INTR_VECTOR; > - vmx->pi_desc.sn = 1; > + vmx->pi_desc.notif_ctrl |= POSTED_INTR_SN;