Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp79947rdb; Fri, 26 Jan 2024 20:15:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE00VP3OKmQZ2HEqT7hWPIKLfkaToS8iorWhfV+QAr/AWz8zgxfLDdsMc15Rz4h7P6Dey2H X-Received: by 2002:a17:902:7482:b0:1d7:690f:a961 with SMTP id h2-20020a170902748200b001d7690fa961mr942153pll.44.1706328932030; Fri, 26 Jan 2024 20:15:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706328932; cv=pass; d=google.com; s=arc-20160816; b=Zd4AihWFyGjzPLnFUFtkEr/zQDVEUhZmH/uLOjStJGOpr6lv6Kaep6LSOgcZjserOi 6ixr3skGN0cOSbSnOixVAFaJR87AcnWaIiGNzU4JSiumOSaAs2X8KPw03Mk5k0gPb0Ue 3TNJ98p7CcCeIpbNzo+z+3DFfdrT287/tDF/rtai6RDTCEI0KCCNfPyN024ZhRUNshMq 9oaHLNmbij3L6mznzX/o7fwZW/OGgrvCp2Yy0rqFX0ZuWuQXfY/7chb75HnRuejapuXs +E2OL775rJdySNvZjwpWS/g+ISO99MnCPtRaoG2wufRhoPBAh0n6SJ6LJYTnCdRHm+Ef lUQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=yGsGBeabBXw/xy5u519IeP1ZqLbt0aggUO3UstrYpo0=; fh=ZvpbeHpP0Y0v3u+CaZzOwTVebjaGJIGbrjWY8xhkDeQ=; b=j2ZkpVXHGkCyJ+qgier9dFeVkV+PQYQqdHwtmsDCbHxckeW+7jDkeN3M+BlN8kzpdK GtNLQgA1Ub5FrSs3xfjIWtXuSnQLKIPJgZaF3veo6gfJWJcddHvtwGeBn7/YVEfUBl0J Ejl+9bI1aoviIeKvuJqZA80tFjEC7rtkDIMmQEvUt7vuCqmZ2nKkV5I8NwasumtolAI0 7b7IxJVWsSIgcSHJ9vx22eByzyjLtXyelYAVb8ZtzfcJ0usHRU51vox/tBzP99FJLT27 690w3zW1LWkhANiZHRz4p5OPrxbfaqu2ZnIFabZdbdvz5Nh4KOsQRqGa1z9zffG5+jkN vlYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="LEp07/0+"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40847-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40847-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q6-20020a170902b10600b001d78f440061si2101429plr.385.2024.01.26.20.15.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 20:15:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40847-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="LEp07/0+"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40847-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40847-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2EC6BB2489C for ; Fri, 26 Jan 2024 23:27:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 978695914A; Fri, 26 Jan 2024 23:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LEp07/0+" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DDA4224CF; Fri, 26 Jan 2024 23:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.88 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706311551; cv=none; b=jgrGRmvs7bMcixXtVtJewkXvjRMCu9MHE7UUill1RUSy/7sM8LsK3jgzkjgBfk1eEkTOlr6DsJJBqs4E+yfDJoCnXroulcUOE5C1cq5FQL89Mc8QfZKkNSAkTskhJahLYjtZ7KQ1DBG/wyENt7zdRyGwabTBMfvuXj7VwKmsUWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706311551; c=relaxed/simple; bh=OT63v6nV293o1ccgnhbVK00HEvGSO8K/GxmBZEmDAWM=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HyBUg/Xn0nmnSkN4FsZUznA+piv1XTVz7d1KzN+PGI26Pa4yllru98UprMUyvJatBoU3lc75XfP5MT2Y/jv+lEHbG8T154/+RC+pjNzyhsUJfn1TdH6CLKxP4B4ieUOrAzaDWzlxEoNfcKtDEXa/8VZC2D34NjQYa/IKQtk9lHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=LEp07/0+; arc=none smtp.client-ip=192.55.52.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706311550; x=1737847550; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OT63v6nV293o1ccgnhbVK00HEvGSO8K/GxmBZEmDAWM=; b=LEp07/0+/69DLaGxN9FvpiLz3w2IlkIwAgDffihYL7rfofRH/qA48cJQ oufZuSiT9IELyZ4qJPuMIf7sCnFXm7/FjPBA/g/WdYhfl8YW7WqzMEDQQ TrxyxtjIURiASUBdnVy52oKwLEG8uqmMOT24M1zCtIdN2k9j7up8V0Fy1 2/85Gu/v8N+pn29tI+xMSl1FokMUHr2MKo45ugncNblKWfEp12SJTwWm3 aIoXGs9ALvT3lL8kZ1o2Rk6jeZJo+uqTWBEZ0Gdp0D9IZtWQ0Bng8KHr3 w/ojkj61x+EYW5xVQ3OSsOvTwfXU6A6L1AjW9b5pZvAd/EoFd2L7ekzev Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="433757928" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="433757928" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 15:25:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="910489872" X-IronPort-AV: E=Sophos;i="6.05,220,1701158400"; d="scan'208";a="910489872" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.24.100.114]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 15:25:48 -0800 Date: Fri, 26 Jan 2024 15:31:08 -0800 From: Jacob Pan To: Thomas Gleixner Cc: LKML , X86 Kernel , iommu@lists.linux.dev, Lu Baolu , kvm@vger.kernel.org, Dave Hansen , Joerg Roedel , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , Raj Ashok , "Tian, Kevin" , maz@kernel.org, peterz@infradead.org, seanjc@google.com, Robin Murphy , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH RFC 07/13] x86/irq: Add helpers for checking Intel PID Message-ID: <20240126153108.2a6bbb9e@jacob-builder> In-Reply-To: <87il5bupb1.ffs@tglx> References: <20231112041643.2868316-1-jacob.jun.pan@linux.intel.com> <20231112041643.2868316-8-jacob.jun.pan@linux.intel.com> <87il5bupb1.ffs@tglx> Organization: OTC X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi Thomas, On Wed, 06 Dec 2023 20:02:58 +0100, Thomas Gleixner wrote: > On Sat, Nov 11 2023 at 20:16, Jacob Pan wrote: > > That 'Intel PID' in the subject line sucks. What's wrong with writing > things out? > > x86/irq: Add accessors for posted interrupt descriptors > will do. > Hmm? > > > Intel posted interrupt descriptor (PID) stores pending interrupts in its > > posted interrupt requests (PIR) bitmap. > > > > Add helper functions to check individual vector status and the entire > > bitmap. > > > > They are used for interrupt migration and runtime demultiplexing posted > > MSI vectors. > > This is all backwards. > > Posted interrupts are controlled by and pending interrupts are marked in > the posted interrupt descriptor. The upcoming support for host side > posted interrupts requires accessors to check for pending vectors. > > Add .... > > > #ifdef CONFIG_X86_POSTED_MSI > > +/* > > + * Not all external vectors are subject to interrupt remapping, e.g. > > IOMMU's > > + * own interrupts. Here we do not distinguish them since those vector > > bits in > > + * PIR will always be zero. > > + */ > > +static inline bool is_pi_pending_this_cpu(unsigned int vector) > > Can you please use a proper name space pi_.....() instead of this > is_...() muck which is horrible to grep for. It's documented .... > good idea, will do. > > +{ > > + struct pi_desc *pid; > > + > > + if (WARN_ON(vector > NR_VECTORS || vector < > > FIRST_EXTERNAL_VECTOR)) > > + return false; > > Haha. So much about your 'can use the full vector space' dreams .... And > WARN_ON_ONCE() please. > yes, will do. Not enough motivation for the full vector space. > > + > > + pid = this_cpu_ptr(&posted_interrupt_desc); > > Also this can go into the declaration line. will do > > > + > > + return (pid->pir[vector >> 5] & (1 << (vector % 32))); > > __test_bit() perhaps? > > > +} > > > +static inline bool is_pir_pending(struct pi_desc *pid) > > +{ > > + int i; > > + > > + for (i = 0; i < 4; i++) { > > + if (pid->pir_l[i]) > > + return true; > > + } > > + > > + return false; > > This is required because pi_is_pir_empty() is checking the other way > round, right? > This function is not needed anymore in the next version. I was thinking performance is better if we bail out while encountering the first set bit. > > +} > > + > > extern void intel_posted_msi_init(void); > > > > #else > > +static inline bool is_pi_pending_this_cpu(unsigned int vector) {return > > false; } > > lacks space before 'return' > will fix. > > + > > static inline void intel_posted_msi_init(void) {}; > > > > #endif /* X86_POSTED_MSI */ Thanks, Jacob