Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp92114lqp; Fri, 12 Apr 2024 11:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcD9/eW1wimri7dSQTaa53QoRA+ZZM0QwN0Wrkowv7/De44HlHuUL2V+aGm7/vTpvgA8jpnslDfvlC2HdntvP23YjNXr/yWUzhlCz9lw== X-Google-Smtp-Source: AGHT+IF1/hF/Tp36zm00fDB987HG7VDzjz9WLdDTtgDFHyA45cfpirSoh8EvVpDWuQLAaLUaj/P8 X-Received: by 2002:ac8:5847:0:b0:436:a18c:7e5d with SMTP id h7-20020ac85847000000b00436a18c7e5dmr1932865qth.0.1712945951096; Fri, 12 Apr 2024 11:19:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712945951; cv=pass; d=google.com; s=arc-20160816; b=Qw2nbMF4N1AIXGuGsOLN5VhD8cpYhSTuFLXmR1qSzQwYcDbahc8FNQsUZEthQ2rus4 g/aHT+Ul2HmZY6AKp9I0vmaNuQ4DpF4J8EbyEsyAt5kyvDhqLk8hyzvbTQ52bVPo6SQ8 vSCSSWbjM7EhWH+c+vwYk5YwChkD6CQ8w5KF2vUqdHzHxxYE4AX+yZTk0YNFvuW8/1Qn 5tZcr9omU4YWj4R9VLITcTF+cgao64ioFJOFfg+1FKQNUH9gUwNrlTv3ZEuXoukp3whb Y+R6oKWO4SNLmLUb0JmtPP9ccXHGfbnf++2bYFMFKmjDZMorYtZxDf8UmaX63EE00BX8 1IgQ== 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=AmqI2K3BLJoIkWMOTB2NMmDx9MVNq6Vi6wiLbAEjFdQ=; fh=iIbByhqKpdfyTItIciddKFOP4nvaIKAiExEaeTuP1mM=; b=I7SAO9bxEPIsmsIiDqDsXqfE7d+7xD7R4bHEJc0oqkk6th2SX490XcdoiqS5c8rHZH e/ubDTJ8tvyUArrijYtk6xPL1//Wn0fP6lHY69pJGcAAxVFrtKWapxpgcIdoMirmMMp1 nyFNPqgTx/CllfDBu7hth9AofbqaQCCgfqHtgWK9wIqNI3MzsXN6w8LjNiGpBrgDAB/l NSKgjQSXw1WAKrfjvtj9ozY6aT8b1mT2IzOrhFGm+fdPE+iiVcFDEp7IB66xVV86mSAl JVgfEuyCHGevZLsDHaOzKKwt4Uvd6ERW77GcT2tx82RWgU01J8/7h5qVlDtM+XDIJ+WT vUFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j1WD52EX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-143188-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t5-20020a05622a148500b004365107d35bsi4402068qtx.727.2024.04.12.11.19.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 11:19:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143188-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=@intel.com header.s=Intel header.b=j1WD52EX; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-143188-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143188-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A2A4D1C22F60 for ; Fri, 12 Apr 2024 18:19:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D25A14EC57; Fri, 12 Apr 2024 18:19:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="j1WD52EX" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 9053B14D708; Fri, 12 Apr 2024 18:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712945941; cv=none; b=mxSbPN/gns5b8Tx20nbzvCjW7QDP/rU3KgNeFc1fiQdyDEs43spsrDCSqjANBRl6uECAYM6KwlF4ncRQkw7Kl+IzGJLqLC4WT6C2k+Ry0a/D6vpzxxOdxQF57grFE5y3K/dhfhL0KIu4qk1HxUSmk1l8mrtEChYsvtT5G2EWEJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712945941; c=relaxed/simple; bh=qcfdW48aCV8kl2oRwl5wUXBZK6N010eZxw0UUUS0LKk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ienWCaW78/eDv/yW6BINJ9TjeVx2kk9Uz2t9c7sReELIGBnQyiMu5B+CCbGgbPHtbxjkUveaS42C6pweuVx+bWWMrvYctqjGuRPRMvuhzbdxEHPk1FV803op7je8kOjCFRmLW4CBZ8OCYSqqGkVtR8sTkuH+d0WO8FiHjyfGCSc= 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=j1WD52EX; arc=none smtp.client-ip=198.175.65.14 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=1712945941; x=1744481941; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qcfdW48aCV8kl2oRwl5wUXBZK6N010eZxw0UUUS0LKk=; b=j1WD52EXiU4hFltMCgEQQe8LFHxnP5a2gsrII3W/jWc/gaN3x2wUX6II qED/L5AILQfNW2Theo7rlT5akbgcv6YbuQrDlhdy0nBgK7kkCZjlT6O4A cd9HofNRx+wdS2JPnFb9v7hCOVvdUxPggsSdzofQjmBqcpQqgl/PRztwN h93Hskkmu+OWPcJ3raGtcIbddgT4iYNUslSTtLj+/O2+t0lz3Db7BLdjh 4PzRGtPfD3rPIZ0/1fpv7Ug6+vVSwgVhC3NRVwPN6cjwFe1O8KFl+gGei Yx1cEzSd6imitzTSQ9rg6sJXOlryAcULjh3KYwrSwNxGDEBjl/zckNWOM w==; X-CSE-ConnectionGUID: ul3xh4s3R76RG/dVQqVbQw== X-CSE-MsgGUID: l+p5st0BSnKajHTsRBjTqA== X-IronPort-AV: E=McAfee;i="6600,9927,11042"; a="12261434" X-IronPort-AV: E=Sophos;i="6.07,196,1708416000"; d="scan'208";a="12261434" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 11:19:00 -0700 X-CSE-ConnectionGUID: taCPYSIGSIW2vzeZM8SWig== X-CSE-MsgGUID: uApujCAuS+uPPT+UvKgEGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,196,1708416000"; d="scan'208";a="21869422" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.54.39.125]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2024 11:18:59 -0700 Date: Fri, 12 Apr 2024 11:23:31 -0700 From: Jacob Pan To: "Tian, Kevin" Cc: LKML , X86 Kernel , Peter Zijlstra , "iommu@lists.linux.dev" , Thomas Gleixner , Lu Baolu , "kvm@vger.kernel.org" , "Hansen, Dave" , Joerg Roedel , "H. Peter Anvin" , Borislav Petkov , Ingo Molnar , "Luse, Paul E" , "Williams, Dan J" , Jens Axboe , "Raj, Ashok" , "maz@kernel.org" , "seanjc@google.com" , Robin Murphy , "jim.harris@samsung.com" , "a.manzanares@samsung.com" , Bjorn Helgaas , "Zeng, Guang" , "robert.hoo.linux@gmail.com" , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v2 10/13] x86/irq: Extend checks for pending vectors to posted interrupts Message-ID: <20240412112331.5a3c1d18@jacob-builder> In-Reply-To: References: <20240405223110.1609888-1-jacob.jun.pan@linux.intel.com> <20240405223110.1609888-11-jacob.jun.pan@linux.intel.com> 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 Kevin, On Fri, 12 Apr 2024 09:25:57 +0000, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Saturday, April 6, 2024 6:31 AM > > > > During interrupt affinity change, it is possible to have interrupts > > delivered to the old CPU after the affinity has changed to the new one. > > To prevent lost interrupts, local APIC IRR is checked on the old CPU. > > Similar checks must be done for posted MSIs given the same reason. > > > > Consider the following scenario: > > Device system agent iommu > > memory CPU/LAPIC > > 1 FEEX_XXXX > > 2 Interrupt request > > 3 Fetch IRTE -> > > 4 ->Atomic Swap > > PID.PIR(vec) Push to Global > > Observable(GO) > > 5 if (ON*) > > i done;* > > there is a stray 'i' will fix, thanks > > > else > > 6 send a > > notification -> > > > > * ON: outstanding notification, 1 will suppress new notifications > > > > If the affinity change happens between 3 and 5 in IOMMU, the old CPU's > > posted > > interrupt request (PIR) could have pending bit set for the vector being > > moved. > > how could affinity change be possible in 3/4 when the cache line is > locked by IOMMU? Strictly speaking it's about a change after 4 and > before 6. SW can still perform affinity change on IRTE and do the flushing on IR cache after IOMMU fectched it (step 3). They are async events. In step 4, the atomic swap is on the PID cacheline, not IRTE. Thanks, Jacob