Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1383710rdb; Tue, 30 Jan 2024 17:49:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRi1Ea0ELRoDjKlEb+RhWrJObNBoHJD1+F9rCNTM9uTAULqSxix3zo30odBYBjBVAADZrs X-Received: by 2002:a05:6214:2468:b0:68c:668b:c610 with SMTP id im8-20020a056214246800b0068c668bc610mr451701qvb.2.1706665767365; Tue, 30 Jan 2024 17:49:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706665767; cv=pass; d=google.com; s=arc-20160816; b=SoDrI8g2Tg7DfBoUB4CooKNVmo2oLKrPILrW6y6Bs5B7+iC9qOqGRvV3VgPax0r39b IXpbYWkIedbXtzK7TE3+9rVEBALf9tiJFF4YkOTc7H1SUAaVF4OGL8NGs44mTRUQKGTl YBiPayrJpZQrKE9tGbWrLa5U4d6rfWDd2it7n4E4zF/2t2Luim8RuEAGCjlv3WMDB+zL WsR/79s7Ug80r8WoA4yj6MwTRRXDsux/d465yIhIyVSzs1c16GG5Fp0MAiKz9Rt8pwlf VIfWk+oT6E0ZZjYiKXKD9qX1BO+AMCRTjltIVmbvol3yeOBQK4mqDHxgD7qf6S9xCewB /hlQ== 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=JdG1KVU/njo7PApRXford/HnaGUTjmthKcJoPmpTjfU=; fh=UHAjpVsDhaWFSqOQehIv4AljXDiIydyGpQrJG8mmGc4=; b=hdWERHMaiPOdETu1A+PaJfFNVZEHhXbAQlKim2skkGNFbEbDXQcARqYeHIGhqCxf+B Wgbjlgooj+aoNctwMokCcgjJBzbHT3jZfjfBYZHBjyI0yPY7oqBhyyVfTmHxkPOsDvB7 AU35y7ega526xhDAxsEvLpAfHTVYnPwpgcilcR+zNB4MGfxiZIkUjLN58FQvhwDio7i2 Z5x1UunoXGeWddJwZ1drNQJS3TnqJqFmKoOK8DOVdwwRSIzheNWEs6v8OZdAmW6Dlnlv FL9ULniou/vblciki3SDO8dnaxb2twnmUp96nSGlK+j3Zk6glLzB2D5QgmxOxxzi441Z 15Yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DgAniXR1; 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-45608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45608-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCWVnN7anfdVhe4ck6dSTD1KOcSpdWWt+bn/2DOYEg8FtUGCBkKGtgoRGKmXFkud6a43I331PwLLRX0ixd6XpRNLJqcHQJrDE6+g2bOQtg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r7-20020a056214212700b0068c4200b86dsi8577969qvc.225.2024.01.30.17.49.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 17:49:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45608-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=DgAniXR1; 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-45608-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45608-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 1491B1C25416 for ; Wed, 31 Jan 2024 01:49:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B5595667; Wed, 31 Jan 2024 01:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DgAniXR1" Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 B3597171D5 for ; Wed, 31 Jan 2024 01:48:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706665688; cv=none; b=XWFfxdG+EW4RLgG4CTsng01KDGSDMqoOEF+NelrpcpRc4xhFrGqhMDG3or0kNh86rzGSJaybigOSyvcUbW46ooH0aC0pWUlq5lXWQGAKYMoCIVvL5+TmoE+zMlALLeC+EivnLAcvOzQ1Uglhm90+oqaV6fqPxsI/qvrM68bHelI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706665688; c=relaxed/simple; bh=z18/1NG1zLW5yoDGt3zYqzrbxZEW6XZZsTCTId9IDzI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=u2yP2gVpVhlC8M3P7Bmd1y6ge8rfHC0PIm9nBv+tuYo/SHgNc6bfVpUnt5//AxygD9QQaS+fmpQ7G5c3rR13pgr9zirvZiR98r/MBjw1yBiU5BEOm27+kSbEQlJAULDCPxEfq2Rknu29ZxiZAKk92srVxPXX+pqhzuLAGuPS1gQ= 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=DgAniXR1; arc=none smtp.client-ip=209.85.216.74 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-pj1-f74.google.com with SMTP id 98e67ed59e1d1-294f836a726so4192912a91.1 for ; Tue, 30 Jan 2024 17:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706665686; x=1707270486; 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=JdG1KVU/njo7PApRXford/HnaGUTjmthKcJoPmpTjfU=; b=DgAniXR1jVedgB6qKJXSofURIl06lw5e5OZRvVpd9LmENzgTWAp7O5wpdsl9hoEA2M TgL/iYk6H1zUHf0z0HYpZqfzkQ7qTQXaIRdjhyLnbZkd8bqLI4fNpOj3h6gBgkV/pbpp d2eeK8+DKK19JY6wHVIbXzk7pz8ycIqnCUklsrkhsSOvDfujImbNDG4xwSZzIKDj/+By /bIfLlc7/NvH1Y667azXl37sthpMaj9SUhdNJ+9hAJaB8Ld8AGkJqYoT3TogPr6OCQ/G glBy3bFmSzGzondiheCgKKl3zoD/O9qBeMcmcRliQYWZbsIIfpDGBe3B1CnJqj81kVC/ qPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706665686; x=1707270486; 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=JdG1KVU/njo7PApRXford/HnaGUTjmthKcJoPmpTjfU=; b=vohHAsiuvjjbdDCXFcLDPKYTYqltxXmOm1HQtrS0oar47RZe7DJIbw+Cd5D62S7PN5 rwSc9q9crgwCfdE7NPvW94+VfXApMpZmYJu0yWAqwO9tnp3QyaE6v8tFKHdnmoe8d9gk K9Yp2mwXORFXcpxJDBnJVhmsoxkcRNhnvKaAa3XD6POUuEh3phdDk8QTTm8bL+lp809H U0Ku64oo4kWBbT8VLkOdI62qrfGY4CX/ILcgm4ESfefcJ56DnUKS1A5UtThvRQ/U9p4V c0TeIgAxI/ckn2ddWbK/8HYmfAjP7U4OvLA2wM1egbL1bq5Zq0EXy0occ7LOAdAb2FHN aaXg== X-Gm-Message-State: AOJu0Yw27zaOkniGKxaqCnQfdGJY7LlzKyLZN5VAaNDNYZwn8TdX0B6L BHq0L3HlHr159V+hkeJ4T68pMFblkDgDTI/pmgdre3ouPcOtOiS+zASKk5ZVRi6djv3JXlLRH/8 KjQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:e550:b0:290:fd51:d7be with SMTP id ei16-20020a17090ae55000b00290fd51d7bemr1533pjb.5.1706665686046; Tue, 30 Jan 2024 17:48:06 -0800 (PST) Date: Tue, 30 Jan 2024 17:48:04 -0800 In-Reply-To: <20240126234237.547278-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: <20240126234237.547278-1-jacob.jun.pan@linux.intel.com> <20240126234237.547278-4-jacob.jun.pan@linux.intel.com> Message-ID: Subject: Re: [PATCH 03/15] x86/irq: Use bitfields exclusively 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 Content-Type: text/plain; charset="us-ascii" On Fri, Jan 26, 2024, Jacob Pan wrote: > From: Thomas Gleixner > > Mixture of bitfields and types is weird and really not intuitive, remove > types and use bitfields exclusively. I agree it's weird, and maybe not immediately intuitive, but that doesn't mean there's no a good reason for the code being the way it is, i.e. "it's weird" isn't sufficient justification for touching this type of code. Bitfields almost always generate inferior code when accessing a subset of the overall thing. And even worse, there are subtle side effects that I really don't want to find out whether or not they are benign. E.g. before this change, setting the notification vector is: movb $0xf2,0x62(%rsp) whereas after this change it becomes: mov %eax,%edx and $0xff00fffd,%edx or $0xf20000,%edx mov %edx,0x60(%rsp) Writing extra bytes _shouln't_ be a problem, as KVM needs to atomically write the entire control chunk no matter what, but changing this without very good cause scares me. If we really want to clean things up, my very strong vote is to remove the bitfields entirely. SN is the only bit that's accessed without going through an accessor, and those should be easy enough to fixup one by one (and we can add more non-atomic accessors/mutators if it makes sense to do so). E.g. end up with /* Posted-Interrupt Descriptor */ struct pi_desc { u32 pir[8]; /* Posted interrupt requested */ union { struct { u16 notification_bits; u8 nv; u8 rsvd_2; u32 ndst; }; u64 control; }; u32 rsvd[6]; } __aligned(64);