From patchwork Mon Jun 19 23:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 110195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3317878vqr; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CcYbwKv/pSVVdb9cYP5+u3qmusKs+n1ciZUCvnVphB1rcgEdcQy9s1iOV6lu8GMHRP3Bb X-Received: by 2002:a17:90b:38d2:b0:25c:267a:da1f with SMTP id nn18-20020a17090b38d200b0025c267ada1fmr11122155pjb.12.1687218709127; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687218709; cv=none; d=google.com; s=arc-20160816; b=DRtfj3WmeoALGhXmqPPEZYbkwHHO9ZfwFuEVPyR2PJD7EFt3XDzMpXumz9w8vpjz1u KmpkkzO/1J0+4QbLSGX1ePb8Q7EpvMnZar643pFPsTq1iX5t6wF2FUETyw1vhW8MKBhi J413EXO3TMvJynW48jCJ0YwfKtKME160UgFyUSZ/SN5nQzYbGQJh5Diuves7m3NY6nyy j0TU4zfvvfxtZq+cZ2tW4qL/LIV1NVYSAroxNcXf5jDfF4lhh4uA+bWc6VOoYdkNk6jT bFf1f7r5P4ztnuyPD4eZlDiUolmQcMtPVxKd0Aa+BnzgQ1zrD5m2Q9qMEcFeIXguaG9/ SEMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W7O2k1ZTC37H1M8kfVwz421KM2tNAbPjST2C0Ngm8pk=; b=Es6VeEBqPld6P/vZvuFVEheTcR9uUKzQBMSqYe0E1w7lqwPVoKhdU0S3b9ZW11762t 5UkLatdW49wu8nJdBszaChzBCFwFXax6U++4A/NUdoTs2zasDxDSIXPU+hdIcnpai0Rz arP5ZyMv794ltwGy3f3/edqX3LSZqRsNWFaqMQvCk7FbqsCVpsK/Q2Dvd5hKeA7sFhyI o3vC7dzbDWZ/5i/cYfrhUnpJTPgUhFES5pqFA5PM59WNesv8bBwlRV8/x3DP4BsCTla/ 8YvqbxRquAYMsfF47wPxf48X6QD7TrVDmrWx8ZvNzs/X+IZ5QmbCKDG7cXVpQIDStBfH YtCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="O9b8/n/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lw13-20020a17090b180d00b0025bc4b71dd5si817138pjb.150.2023.06.19.16.51.36; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="O9b8/n/J"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbjFSXnj (ORCPT + 99 others); Mon, 19 Jun 2023 19:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjFSXng (ORCPT ); Mon, 19 Jun 2023 19:43:36 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888CB134; Mon, 19 Jun 2023 16:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687218215; x=1718754215; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bFAmHT8B0DUdACwd5EopvbtZl1G4nAgQL+houxurEK4=; b=O9b8/n/JAn+2Wa9X0gGZgsPhb59KbUtkzb7YSxcO+2Nynl5509kORQlm s6xd29ljG/PCIKDkKMcL9/Laxpl8Q/ArD5ifGZoh253t+JC6gS8GJV4er NN3mmQscAJDIh9gTD8P589p/CNbQ/rRXYMmVFQKhNxxy/FbOkSdHcAzZr IfKwKuxpi8KNIZ0w6pXD80td4VF6RKuD9skimTFQzAJH43pvnGD8agwzX OvFhhcGTQsgJIFzOkEOAylcAAHQzPx7Xin/NyFYVm9+vNJZSZY278n/2z /Vq42JGnVT17XZNrVfw0oHv2Nyol5ltk+OF27diUqnI9xrFhGZ5ruc6a9 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="340071454" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="340071454" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 16:43:35 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="747789686" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="747789686" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga001.jf.intel.com with ESMTP; 19 Jun 2023 16:43:33 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, iommu@lists.linux.dev, linux-hyperv@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, steve.wahl@hpe.com, mike.travis@hpe.com, dimitri.sivanich@hpe.com, russ.anderson@hpe.com, dvhart@infradead.org, andy@infradead.org, joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org, robin.murphy@arm.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, xin3.li@intel.com, seanjc@google.com, jiangshanlai@gmail.com, jgg@ziepe.ca, yangtiezhu@loongson.cn Subject: [PATCH 1/3] x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup() Date: Mon, 19 Jun 2023 16:16:09 -0700 Message-Id: <20230619231611.2230-2-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619231611.2230-1-xin3.li@intel.com> References: <20230619231611.2230-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769177045376384585?= X-GMAIL-MSGID: =?utf-8?q?1769177045376384585?= From: Thomas Gleixner Rename send_cleanup_vector() to vector_schedule_cleanup() for the next patch to replace vector cleanup IPI with a timer callback. Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li Reviewed-by: Steve Wahl --- arch/x86/include/asm/hw_irq.h | 4 ++-- arch/x86/kernel/apic/vector.c | 8 ++++---- arch/x86/platform/uv/uv_irq.c | 2 +- drivers/iommu/amd/iommu.c | 2 +- drivers/iommu/hyperv-iommu.c | 4 ++-- drivers/iommu/intel/irq_remapping.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index d465ece58151..551829884734 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -97,10 +97,10 @@ extern struct irq_cfg *irqd_cfg(struct irq_data *irq_data); extern void lock_vector_lock(void); extern void unlock_vector_lock(void); #ifdef CONFIG_SMP -extern void send_cleanup_vector(struct irq_cfg *); +extern void vector_schedule_cleanup(struct irq_cfg *); extern void irq_complete_move(struct irq_cfg *cfg); #else -static inline void send_cleanup_vector(struct irq_cfg *c) { } +static inline void vector_schedule_cleanup(struct irq_cfg *c) { } static inline void irq_complete_move(struct irq_cfg *c) { } #endif diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index c1efebd27e6c..aa370bd0d933 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -967,7 +967,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_cleanup) raw_spin_unlock(&vector_lock); } -static void __send_cleanup_vector(struct apic_chip_data *apicd) +static void __vector_schedule_cleanup(struct apic_chip_data *apicd) { unsigned int cpu; @@ -983,13 +983,13 @@ static void __send_cleanup_vector(struct apic_chip_data *apicd) raw_spin_unlock(&vector_lock); } -void send_cleanup_vector(struct irq_cfg *cfg) +void vector_schedule_cleanup(struct irq_cfg *cfg) { struct apic_chip_data *apicd; apicd = container_of(cfg, struct apic_chip_data, hw_irq_cfg); if (apicd->move_in_progress) - __send_cleanup_vector(apicd); + __vector_schedule_cleanup(apicd); } void irq_complete_move(struct irq_cfg *cfg) @@ -1007,7 +1007,7 @@ void irq_complete_move(struct irq_cfg *cfg) * on the same CPU. */ if (apicd->cpu == smp_processor_id()) - __send_cleanup_vector(apicd); + __vector_schedule_cleanup(apicd); } /* diff --git a/arch/x86/platform/uv/uv_irq.c b/arch/x86/platform/uv/uv_irq.c index ee21d6a36a80..4221259a5870 100644 --- a/arch/x86/platform/uv/uv_irq.c +++ b/arch/x86/platform/uv/uv_irq.c @@ -58,7 +58,7 @@ uv_set_irq_affinity(struct irq_data *data, const struct cpumask *mask, ret = parent->chip->irq_set_affinity(parent, mask, force); if (ret >= 0) { uv_program_mmr(cfg, data->chip_data); - send_cleanup_vector(cfg); + vector_schedule_cleanup(cfg); } return ret; diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index dc1ec6849775..b5900e70de60 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3658,7 +3658,7 @@ static int amd_ir_set_affinity(struct irq_data *data, * at the new destination. So, time to cleanup the previous * vector allocation. */ - send_cleanup_vector(cfg); + vector_schedule_cleanup(cfg); return IRQ_SET_MASK_OK_DONE; } diff --git a/drivers/iommu/hyperv-iommu.c b/drivers/iommu/hyperv-iommu.c index 8302db7f783e..8a5c17b97310 100644 --- a/drivers/iommu/hyperv-iommu.c +++ b/drivers/iommu/hyperv-iommu.c @@ -51,7 +51,7 @@ static int hyperv_ir_set_affinity(struct irq_data *data, if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE) return ret; - send_cleanup_vector(cfg); + vector_schedule_cleanup(cfg); return 0; } @@ -257,7 +257,7 @@ static int hyperv_root_ir_set_affinity(struct irq_data *data, if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE) return ret; - send_cleanup_vector(cfg); + vector_schedule_cleanup(cfg); return 0; } diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c index a1b987335b31..55d899f5a14b 100644 --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -1180,7 +1180,7 @@ intel_ir_set_affinity(struct irq_data *data, const struct cpumask *mask, * at the new destination. So, time to cleanup the previous * vector allocation. */ - send_cleanup_vector(cfg); + vector_schedule_cleanup(cfg); return IRQ_SET_MASK_OK_DONE; } From patchwork Mon Jun 19 23:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 110193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3317557vqr; Mon, 19 Jun 2023 16:50:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4n4BtMzwj53qdh2mOhSw7hkRlhzRg/RHkBiIlMCQK8M8B+edyL5B4vxMl/RNKiSU9UPket X-Received: by 2002:a17:902:ea03:b0:1b6:6b03:10e7 with SMTP id s3-20020a170902ea0300b001b66b0310e7mr3282447plg.5.1687218639523; Mon, 19 Jun 2023 16:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687218639; cv=none; d=google.com; s=arc-20160816; b=dJgnF/fADbVguQW93/OaXaAJ9BLfEx3tNl0KydU8oIjpCJzfaivjpkCKix6///oGjV iGZBaWkfbDn88hfeeJMhlhOPnsQ/MKTjDhWT2JX/ph0sbw6lZXWjl0G7EdzfUC7+q69G kKOTRoXwPr+I/BLdIFPk8z6MzvFQtjPtySHaeQ6VdKpQY6T25ukTswXO10IvEU2bTxBT oYtl5kP2MGKBvgdP8UIvuZGcbULuPF3AcuQCM/sh47QpNjH2VJ7OONaQUforcIJ8eRb6 B/NmUrbDqtaOj1IIBxCrdNgO1aNBHBN7GFMaH28AqQfj34K2mVK0IoTqz/kjYfjUmDFR +TfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uCRxSQxqD44jZj48gLQAxqsbdKI6JA/ASQpH7qv8PGY=; b=B9tINFLMsEgtd3DQOR9tmuhUYIzM68FoFHMt3SqsBJUfepIHYynN2Lcfgy0hddG5sZ A4kSK2y/2mhNQoUT43Jsxvbx5C7Teh7/AcWW2bqQzPdjchusTXQm2hZPL9Y4XZ9U70oM 812xYX+uBL4oAPs3nYxWcndYcJ2+ACWmWq+uSEMjbFYp0+tFR4sheN6fWIPeHjsgOxIg GtudxP8nML8cGhEVAxfBZ559lZYunOCRJdirDipm1VimTmBo0CWZtttKB4zEdp7pyR1a EsoOEVzclJhOOfW0eACtH/W2BEzLCJg2MLBTWUypFwlyuAcTpjuZg1LvDvbVj2/8+391 hN3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IEuOwOjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m18-20020a170902e41200b001b516b77c42si629610ple.402.2023.06.19.16.50.27; Mon, 19 Jun 2023 16:50:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IEuOwOjg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229763AbjFSXnm (ORCPT + 99 others); Mon, 19 Jun 2023 19:43:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbjFSXni (ORCPT ); Mon, 19 Jun 2023 19:43:38 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D065134; Mon, 19 Jun 2023 16:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687218217; x=1718754217; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kjdeJrHKQrrbCHSdMm3YTrFoZr8SNMp9Q07vjTANKnk=; b=IEuOwOjg4Fr0QdAJESBVzjt2HrSQeaJBj3xTp/isIVLIwiFVc3IOXABZ YaHelYfQrIL1FKE0vxNumQPAyt1AtuNRRpn+wYbwHCvjOa0MDRJjlTXCz saHCL9AgIQ9QiHmPTf1szfHXvcwySzdi2Gl6IEJY8Kh4bFYtU3jAaBXny y2RSBob1vDv+R+E1VyA4d0+pEqvdthGfkkkj664NvnZrFFdmMzIxl6sN2 3JhbU4YoS421CCSedZksfW+K66EdDzK1niz8QqumPWJ3Pa3+ZR6m/nOIt 0PIZKsYroaK+gZ80ng/4SGcGiDEt9LpQD8ZVDEAyZTbLnleyykFD2hBEL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="340071473" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="340071473" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 16:43:37 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="747789693" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="747789693" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga001.jf.intel.com with ESMTP; 19 Jun 2023 16:43:35 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, iommu@lists.linux.dev, linux-hyperv@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, steve.wahl@hpe.com, mike.travis@hpe.com, dimitri.sivanich@hpe.com, russ.anderson@hpe.com, dvhart@infradead.org, andy@infradead.org, joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org, robin.murphy@arm.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, xin3.li@intel.com, seanjc@google.com, jiangshanlai@gmail.com, jgg@ziepe.ca, yangtiezhu@loongson.cn Subject: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback Date: Mon, 19 Jun 2023 16:16:10 -0700 Message-Id: <20230619231611.2230-3-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619231611.2230-1-xin3.li@intel.com> References: <20230619231611.2230-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769176972452703204?= X-GMAIL-MSGID: =?utf-8?q?1769176972452703204?= From: Thomas Gleixner Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback for cleaning up the leftovers of a moved interrupt. The only new job incurred is to do vector cleanup in lapic_offline() in case the vector cleanup timer has not expired. Signed-off-by: Thomas Gleixner Signed-off-by: Xin Li --- arch/x86/include/asm/idtentry.h | 1 - arch/x86/include/asm/irq_vectors.h | 7 -- arch/x86/kernel/apic/vector.c | 101 +++++++++++++++++++++++------ arch/x86/kernel/idt.c | 1 - 4 files changed, 80 insertions(+), 30 deletions(-) diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index b241af4ce9b4..cd5c10a74071 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -648,7 +648,6 @@ DECLARE_IDTENTRY_SYSVEC(X86_PLATFORM_IPI_VECTOR, sysvec_x86_platform_ipi); #ifdef CONFIG_SMP DECLARE_IDTENTRY(RESCHEDULE_VECTOR, sysvec_reschedule_ipi); -DECLARE_IDTENTRY_SYSVEC(IRQ_MOVE_CLEANUP_VECTOR, sysvec_irq_move_cleanup); DECLARE_IDTENTRY_SYSVEC(REBOOT_VECTOR, sysvec_reboot); DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_SINGLE_VECTOR, sysvec_call_function_single); DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_VECTOR, sysvec_call_function); diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h index 43dcb9284208..3a19904c2db6 100644 --- a/arch/x86/include/asm/irq_vectors.h +++ b/arch/x86/include/asm/irq_vectors.h @@ -35,13 +35,6 @@ */ #define FIRST_EXTERNAL_VECTOR 0x20 -/* - * Reserve the lowest usable vector (and hence lowest priority) 0x20 for - * triggering cleanup after irq migration. 0x21-0x2f will still be used - * for device interrupts. - */ -#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR - #define IA32_SYSCALL_VECTOR 0x80 /* diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index aa370bd0d933..23a3f3b6dd2c 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -44,7 +44,18 @@ static cpumask_var_t vector_searchmask; static struct irq_chip lapic_controller; static struct irq_matrix *vector_matrix; #ifdef CONFIG_SMP -static DEFINE_PER_CPU(struct hlist_head, cleanup_list); + +static void vector_cleanup_callback(struct timer_list *tmr); + +struct vector_cleanup { + struct hlist_head head; + struct timer_list timer; +}; + +static DEFINE_PER_CPU(struct vector_cleanup, vector_cleanup) = { + .head = HLIST_HEAD_INIT, + .timer = __TIMER_INITIALIZER(vector_cleanup_callback, TIMER_PINNED), +}; #endif void lock_vector_lock(void) @@ -841,10 +852,21 @@ void lapic_online(void) this_cpu_write(vector_irq[vector], __setup_vector_irq(vector)); } +static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr); + void lapic_offline(void) { + struct vector_cleanup *cl = this_cpu_ptr(&vector_cleanup); + lock_vector_lock(); + + /* In case the vector cleanup timer has not expired */ + __vector_cleanup(cl, false); + irq_matrix_offline(vector_matrix); + WARN_ON_ONCE(try_to_del_timer_sync(&cl->timer) < 0); + WARN_ON_ONCE(!hlist_empty(&cl->head)); + unlock_vector_lock(); } @@ -934,49 +956,86 @@ static void free_moved_vector(struct apic_chip_data *apicd) apicd->move_in_progress = 0; } -DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_cleanup) +/* + * Called with vector_lock held + */ +static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr) { - struct hlist_head *clhead = this_cpu_ptr(&cleanup_list); struct apic_chip_data *apicd; struct hlist_node *tmp; + bool rearm = false; - ack_APIC_irq(); - /* Prevent vectors vanishing under us */ - raw_spin_lock(&vector_lock); - - hlist_for_each_entry_safe(apicd, tmp, clhead, clist) { + hlist_for_each_entry_safe(apicd, tmp, &cl->head, clist) { unsigned int irr, vector = apicd->prev_vector; /* * Paranoia: Check if the vector that needs to be cleaned - * up is registered at the APICs IRR. If so, then this is - * not the best time to clean it up. Clean it up in the - * next attempt by sending another IRQ_MOVE_CLEANUP_VECTOR - * to this CPU. IRQ_MOVE_CLEANUP_VECTOR is the lowest - * priority external vector, so on return from this - * interrupt the device interrupt will happen first. + * up is registered at the APICs IRR. That's clearly a + * hardware issue if the vector arrived on the old target + * _after_ interrupts were disabled above. Keep @apicd + * on the list and schedule the timer again to give the CPU + * a chance to handle the pending interrupt. + * + * Do not check IRR when called from lapic_offline(), because + * fixup_irqs() was just called to scan IRR for set bits and + * forward them to new destination CPUs via IPIs. */ - irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); + irr = check_irr ? apic_read(APIC_IRR + (vector / 32 * 0x10)) : 0; if (irr & (1U << (vector % 32))) { - apic->send_IPI_self(IRQ_MOVE_CLEANUP_VECTOR); + pr_warn_once("Moved interrupt pending in old target APIC %u\n", apicd->irq); + rearm = true; continue; } free_moved_vector(apicd); } - raw_spin_unlock(&vector_lock); + /* + * Must happen under vector_lock to make the timer_pending() check + * in __vector_schedule_cleanup() race free against the rearm here. + */ + if (rearm) + mod_timer(&cl->timer, jiffies + 1); +} + +static void vector_cleanup_callback(struct timer_list *tmr) +{ + struct vector_cleanup *cl = container_of(tmr, typeof(*cl), timer); + + /* Prevent vectors vanishing under us */ + raw_spin_lock_irq(&vector_lock); + __vector_cleanup(cl, true); + raw_spin_unlock_irq(&vector_lock); } static void __vector_schedule_cleanup(struct apic_chip_data *apicd) { - unsigned int cpu; + unsigned int cpu = apicd->prev_cpu; raw_spin_lock(&vector_lock); apicd->move_in_progress = 0; - cpu = apicd->prev_cpu; if (cpu_online(cpu)) { - hlist_add_head(&apicd->clist, per_cpu_ptr(&cleanup_list, cpu)); - apic->send_IPI(cpu, IRQ_MOVE_CLEANUP_VECTOR); + struct vector_cleanup *cl = per_cpu_ptr(&vector_cleanup, cpu); + + hlist_add_head(&apicd->clist, &cl->head); + + /* + * The lockless timer_pending() check is safe here. If it + * returns true, then the callback will observe this new + * apic data in the hlist as everything is serialized by + * vector lock. + * + * If it returns false then the timer is either not armed + * or the other CPU executes the callback, which again + * would be blocked on vector lock. Rearming it in the + * latter case makes it fire for nothing. + * + * This is also safe against the callback rearming the timer + * because that's serialized via vector lock too. + */ + if (!timer_pending(&cl->timer)) { + cl->timer.expires = jiffies + 1; + add_timer_on(&cl->timer, cpu); + } } else { apicd->prev_vector = 0; } diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index a58c6bc1cd68..f3958262c725 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -131,7 +131,6 @@ static const __initconst struct idt_data apic_idts[] = { INTG(RESCHEDULE_VECTOR, asm_sysvec_reschedule_ipi), INTG(CALL_FUNCTION_VECTOR, asm_sysvec_call_function), INTG(CALL_FUNCTION_SINGLE_VECTOR, asm_sysvec_call_function_single), - INTG(IRQ_MOVE_CLEANUP_VECTOR, asm_sysvec_irq_move_cleanup), INTG(REBOOT_VECTOR, asm_sysvec_reboot), #endif From patchwork Mon Jun 19 23:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xin3" X-Patchwork-Id: 110194 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3317876vqr; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zb5LPIV+WlCrfOZiG/bCLo73a6qv6mB2vRVrMN/60Du6KhXNbrfZrS1bHpdpOEoW0iUoL X-Received: by 2002:a17:90a:35b:b0:259:bf40:b571 with SMTP id 27-20020a17090a035b00b00259bf40b571mr11046050pjf.45.1687218709135; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687218709; cv=none; d=google.com; s=arc-20160816; b=tAgLr0INbizWSj8QAbtnqfUvlXTI3sDg/T5fpkYmYK42ke3eIv+veY4zsS8ZL0Yx4s D57owsj14ycpDvh7SVNkv6Lg1Ie/tQupQj7Vk8UJHp4uu9Mta4xbzolWEzGcu5Wogcde F1iFTj+rZBdJS3D6Q7bE3gnAfbj9ozrke15IrzFCViSM97yPc8pD/pbvFtX0yokSsC+D ECYKNU0OaXlhiPK3IqUo/ZETPhWJ3JEod0U7DaaetzBh/bgSXbmpcTZvAQR+WYnqAieM v8/bO3ixYQcyy6Uvo+xmMVcvQz0k+Uoe9qh0agX05mMpfljWjDs7QU71Uf0Ol5l7G+FR DC1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OFTvk69AkfHqhN0wHykhqIM0OlXsQ+xDnxHwh3M68WA=; b=N0agV4hGll1Vr5Z28xJbszDWz7JXKFsoeu/LqfY0vIspguy7cnj76ytKt8qr32uVY2 XGWp9oMrdAKqPeq4CCK/7L1HrZhpscyQUXwLfe1jTi/UBf/e1ol4997bzt0D+Gomy4i2 hF/jEEBgj21w8ke20WPMtdqrPJm2V2cKK9qVQ+t1OvAZgLXMGvEaCzCQekU4+0IT7sww ubejsavMGSh6AcSeqC4iIPgU2vaxgbY0jvgu4a3F2yBWPwWiL9dwu+f6cKNpDzpCKXJY icrjNKG48CsyafiSZJMMwpR562WDuIMfPkxXTHnD8VSw1uNqsiSiGf5/zEFLkHCeMgXd MJkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DTkuV9hS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu10-20020a17090b1b0a00b0025672b33392si735829pjb.185.2023.06.19.16.51.36; Mon, 19 Jun 2023 16:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DTkuV9hS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbjFSXnx (ORCPT + 99 others); Mon, 19 Jun 2023 19:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjFSXnj (ORCPT ); Mon, 19 Jun 2023 19:43:39 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E0E01A4; Mon, 19 Jun 2023 16:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687218219; x=1718754219; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=93F5iXdL1aFe8xiqIFZhy89J/IUrk/GxSpjv1QQ9jI0=; b=DTkuV9hSKSVd+wYCSoMEpj6y+gTl+n2bl6SwRvDqN5XgyPeGK7u/dQpV QN2epjFjSSvSrTEb2cR/+RqUo1yZ2BLJlgMgk36irYSRAs6ylEe23Ynie dcijUwfU4tf2hpsRLjOWJ7ltkif/7JSXxnG7Bf9eZOVnY0aAJ4M/PrCqf WbvuEon0uFWeQGzlDh92te5hYgloYHpmBrF+mpcQA4Fnma3Xw7RDPW0II //XRmKtnVxTo26it36Gh5C0V3yy9xmxapiVlNJKPiSrZwgA//3fwG7FvG NmmmOFNmDrGqzBg7m7DipOPV6KWhzpkL4Zt2MLrO80UyGn6a97W3SY2Aj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="340071499" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="340071499" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 16:43:38 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="747789703" X-IronPort-AV: E=Sophos;i="6.00,255,1681196400"; d="scan'208";a="747789703" Received: from unknown (HELO fred..) ([172.25.112.68]) by orsmga001.jf.intel.com with ESMTP; 19 Jun 2023 16:43:36 -0700 From: Xin Li To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, iommu@lists.linux.dev, linux-hyperv@vger.kernel.org, linux-perf-users@vger.kernel.org, x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, steve.wahl@hpe.com, mike.travis@hpe.com, dimitri.sivanich@hpe.com, russ.anderson@hpe.com, dvhart@infradead.org, andy@infradead.org, joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org, robin.murphy@arm.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, xin3.li@intel.com, seanjc@google.com, jiangshanlai@gmail.com, jgg@ziepe.ca, yangtiezhu@loongson.cn Subject: [PATCH 3/3] tools: Get rid of IRQ_MOVE_CLEANUP_VECTOR from tools Date: Mon, 19 Jun 2023 16:16:11 -0700 Message-Id: <20230619231611.2230-4-xin3.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230619231611.2230-1-xin3.li@intel.com> References: <20230619231611.2230-1-xin3.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769177045483103006?= X-GMAIL-MSGID: =?utf-8?q?1769177045483103006?= Get rid of IRQ_MOVE_CLEANUP_VECTOR from tools. Signed-off-by: Xin Li --- tools/arch/x86/include/asm/irq_vectors.h | 7 ------- tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/arch/x86/include/asm/irq_vectors.h b/tools/arch/x86/include/asm/irq_vectors.h index 43dcb9284208..3a19904c2db6 100644 --- a/tools/arch/x86/include/asm/irq_vectors.h +++ b/tools/arch/x86/include/asm/irq_vectors.h @@ -35,13 +35,6 @@ */ #define FIRST_EXTERNAL_VECTOR 0x20 -/* - * Reserve the lowest usable vector (and hence lowest priority) 0x20 for - * triggering cleanup after irq migration. 0x21-0x2f will still be used - * for device interrupts. - */ -#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR - #define IA32_SYSCALL_VECTOR 0x80 /* diff --git a/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh b/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh index eed9ce0fcbe6..87dc68c7de0c 100755 --- a/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh +++ b/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh @@ -12,7 +12,7 @@ x86_irq_vectors=${arch_x86_header_dir}/irq_vectors.h # FIRST_EXTERNAL_VECTOR is not that useful, find what is its number # and then replace whatever is using it and that is useful, which at -# the time of writing of this script was: IRQ_MOVE_CLEANUP_VECTOR. +# the time of writing of this script was: 0x20. first_external_regex='^#define[[:space:]]+FIRST_EXTERNAL_VECTOR[[:space:]]+(0x[[:xdigit:]]+)$' first_external_vector=$(grep -E ${first_external_regex} ${x86_irq_vectors} | sed -r "s/${first_external_regex}/\1/g")