Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1377403lqj; Mon, 3 Jun 2024 22:12:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC9zyUPNjlO9qQan8clsfCGEt/Vc5lOiwVRCziugnfga/HCi5u0NXepd+spKqZcPmAbtu8RWjmDYbJU/BGiD4x6ryu2lSt14XV56Hc9w== X-Google-Smtp-Source: AGHT+IHN/xaBwcKUG7J/0GA/7jkkt2kyzU2EpLXQ9X140nObmUzyOKhMPnRRAN6GnVI4QZ3IBNdX X-Received: by 2002:a50:d582:0:b0:57a:2ccb:b3f1 with SMTP id 4fb4d7f45d1cf-57a36448228mr6386374a12.26.1717477962723; Mon, 03 Jun 2024 22:12:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717477962; cv=pass; d=google.com; s=arc-20160816; b=sIY6iiF5Xj18CHa36V9A/aXwi/3tebbD70dhHBbZfk6DELpxvn3kvOWex7IaGetSzR eqY1sOEg+9Qc2WlrKRVO2rR6H1cle9T0N+oTTdA8HmpcvcApS7qr9Yh0a1ecddB6VymE TdNUDw5C/NtyakEZ0reYdkTNfo5uyAleCPxLFzZuwAaQKJKWoowSi4WyDEZxsgf4xTgw IeMFIFEbpK041KFhy0rXm7DcHb0a3awdx2g8WhgWrB7VRUEuk84sPYHMrlHUf5EWUtYx z1mFIFerc1OVVCXuwYlSM2AenTlEqZRM0aMVIeGMyCrXT/j15SlIvce24OlQs/O1hyv0 /cbA== 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:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=4rqdND7i4OjEglrNB2gz2qk2VRnqZQkQh3OgdrDACL0=; fh=yhs+2+h5CSO96kW1zDuyWisXYB/net6VMHwL0ibWd/s=; b=SuGbAP3U2xt9FNvp0YVemKisVRxyFAIHG+zKDy+nlVpbMjo9RN5zd2Vy0WMRft8W3p HV5QnDcBHfKV/0UJKEFI8NUkUQKPXr5Ubkh3SMVnTKQt7kD002yzw4hL24SzcTZJIv/Q zH1KoeVYGhJO7tace7qPpX59+6ng78Sc2Ncqz0ee98CdWcB2QLuOUtdEoCAHl6uAeR44 n6bMVrJdIAC1Ujfw/ytGj9E1LrO7BHcqOQ3rKwdQqkpU7icPZfggn+eCylzZgsQXdhHH bQ2ibdj390+7txuXbDcxyCXQSzWx8bL7reTvMIHj1DVbNlHKk1uAT4av3d/i+BoLCenk YStw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ps3vhxnn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ba55e9si4668424a12.147.2024.06.03.22.12.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 22:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Ps3vhxnn; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-200039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 47A171F24974 for ; Tue, 4 Jun 2024 05:12:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77D391422AC; Tue, 4 Jun 2024 05:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ps3vhxnn" Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (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 CCB791411D3; Tue, 4 Jun 2024 05:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717477846; cv=none; b=KVPCJk01vyZ/v+XERGbc/S3nIwSESzfbr1KLfn8D2K30xMultZPXf5ggDR0m6k+N9Ff7vMN79w7bHjdehoTARCSXd6HvL0OlfjXGvY7nRzHpNaW/gVMj4sVV6nPD6yJqMvMm6CwScxTpsDxXGhuy3unk2m4VoME6p7LC8zgUbKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717477846; c=relaxed/simple; bh=8vTFceAsLpgln0QaJDr9UyqQci5nGMvow5UnG1jar74=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VvzWN10bIqWwEbtQkGeC4RIbngO4SEdmCwfBLAIeHTLOHZHThxgxHb+fWB9V4Oy9zJR/ECI2xiVMAzvKUMhb6+l+vkjNh1/4WbZvDsfThWH9bW6PTEcMWJbrFWFPLSXT9Qg+V6NfI/WMSZLFPqhKM85MU7xAu4cQ5iGNlFYSdWw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ps3vhxnn; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-250928a8580so1789045fac.3; Mon, 03 Jun 2024 22:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717477844; x=1718082644; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=4rqdND7i4OjEglrNB2gz2qk2VRnqZQkQh3OgdrDACL0=; b=Ps3vhxnnB6Mzkc6z5PlgzSzjc8xrBBm30l8Krf6cM6CMGWUwGQ7KsSAZHSIgjusci8 II2B5+jWoSmMr/NTEdtBlBmymUMWa0Khg+HEnR3mWzKdUEF5RE01OvnRNoo4LFTvUZvV ZrldILl2/IKN4uxmYGACUmTNMQOli4yF9ngsH6wFJyMUlwnFTW6aiEvPfRoolGKFOBmK 7R+4tI5fwdtXTCrKECOjqgisnaM8sQPGPzcJtTKgEuwEadzhT+mnRx3gjZj9XjNzMLXi RBeUz8GD3nlqQT+dvsvtzgjQ5K3ptZHBjveUiG0uwxoKOAHJ7uXQIUIEGaWDTJVOvZbC Yytw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717477844; x=1718082644; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4rqdND7i4OjEglrNB2gz2qk2VRnqZQkQh3OgdrDACL0=; b=IcJZ10gut1WIAzxC6UgNKi7L8GW6w8yHxJZL6ldqyi1pf0yNn4m+0MG7kc7M7aZPfV BpymUMizf+40hsd0BJgdgFlAmblEIo9oblrsxwFCK+wtuNEAbqJqRteCJIFoCEvqAhP1 +Rli56umprjOFy78ip9ISYCN67ORCwEhkSDNYSx8VqTcUsZZPr1SK3+uMONcR9PDIcNR V1odRfk21Xg8ommS2Z27HWkwfanXU7jCQDvy0aN+evs7p0AuzY7lbXL5w54kyY1DPAbb MCVaA8fxo7MudthfW3aubxJuUxUjJwMb+QH9Lg07bMwFn9c6ZbrQhq3w5GwDHlPJNTW8 vWrA== X-Forwarded-Encrypted: i=1; AJvYcCVd1qWSZC/cuQmFORrMRJ4+olxyRxGjqbl0Rsp1E48sUgxCD6hngVLgnp5z0tuJDGr1W7wf/+++eroYHZC4ZNrdwhWXYAg9XbPvmOPRddjIMmXxWMZn7fAJnYpo0qk6n4+ou3J+9/1NNu0mjk8a0apDqteu1ezwA2K7BOP6NSnWYP0BJ9HEFphdA3Ar+sr49iqNe2+d4wIC188AabQCw8HBjRzsgBajXpoVMD1y6gIgV2jJxRNPKpAZsZHLvUg= X-Gm-Message-State: AOJu0YwUfB176z1En4w/tCC6/QTeZk37+VJQEvS98viyHtsfqKMwvPOH uSuf3nNNxHe1Ouj0eSnOGcq/UTMD/uyEATP4eSsyBlawZuFIU0gh X-Received: by 2002:a05:6870:1702:b0:24f:e3a3:4431 with SMTP id 586e51a60fabf-2508b9efb87mr10561586fac.13.1717477843743; Mon, 03 Jun 2024 22:10:43 -0700 (PDT) Received: from localhost.localdomain (c-67-161-114-176.hsd1.wa.comcast.net. [67.161.114.176]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70242c270c7sm6298153b3a.220.2024.06.03.22.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 22:10:43 -0700 (PDT) From: mhkelley58@gmail.com X-Google-Original-From: mhklinux@outlook.com To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com, arnd@arndb.de, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org, linux-arch@vger.kernel.org Cc: maz@kernel.org, den@valinux.co.jp, jgowans@amazon.com, dawei.li@shingroup.cn Subject: [RFC 06/12] genirq: Add per-cpu flow handler with conditional IRQ stats Date: Mon, 3 Jun 2024 22:09:34 -0700 Message-Id: <20240604050940.859909-7-mhklinux@outlook.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240604050940.859909-1-mhklinux@outlook.com> References: <20240604050940.859909-1-mhklinux@outlook.com> Reply-To: mhklinux@outlook.com Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Michael Kelley Hyper-V VMBus devices generate interrupts that are multiplexed onto a single per-CPU architectural interrupt. The top-level VMBus driver ISR demultiplexes these interrupts and invokes per-device handlers. Currently, these per-device handlers are not modeled as Linux IRQs, so /proc/interrupts shows all VMBus interrupts as accounted to the top level architectural interrupt. Visibility into per-device interrupt stats requires accessing VMBus-specific entries in sysfs. The top-level VMBus driver ISR also handles management-related interrupts that are not attributable to a particular VMBus device. As part of changing VMBus to model VMBus per-device handlers as normal Linux IRQs, the top-level VMBus driver needs to conditionally account for interrupts. If it passes the interrupt off to a device-specific IRQ, the interrupt stats are done by that IRQ handler, and accounting for the interrupt at the top level is duplicative. But if it handles a management-related interrupt itself, then it should account for the interrupt itself. Introduce a new flow handler that provides this functionality. The new handler parallels handle_percpu_irq(), but does stats only if the ISR returns other than IRQ_NONE. The existing handle_untracked_irq() can't be used because it doesn't work for per-cpu IRQs, and it doesn't provide conditional stats. Signed-off-by: Michael Kelley --- include/linux/irq.h | 1 + kernel/irq/chip.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index a217e1029c1d..8825b95cefe5 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -656,6 +656,7 @@ extern void handle_edge_eoi_irq(struct irq_desc *desc); extern void handle_simple_irq(struct irq_desc *desc); extern void handle_untracked_irq(struct irq_desc *desc); extern void handle_percpu_irq(struct irq_desc *desc); +extern void handle_percpu_demux_irq(struct irq_desc *desc); extern void handle_percpu_devid_irq(struct irq_desc *desc); extern void handle_bad_irq(struct irq_desc *desc); extern void handle_nested_irq(unsigned int irq); diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index dc94e0bf2c94..1f37a9db4a4d 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -910,6 +910,35 @@ void handle_percpu_irq(struct irq_desc *desc) chip->irq_eoi(&desc->irq_data); } +/** + * handle_percpu_demux_irq - Per CPU local irq handler for IRQs + * that may demultiplex to other IRQs + * @desc: the interrupt description structure for this irq + * + * For per CPU interrupts on SMP machines without locking requirements. + * Used for IRQs that may demultiplex to other IRQs that will do the + * stats tracking and randomness. If the handler result indicates no + * demultiplexing is done, account for the interrupt on this IRQ. + */ +void handle_percpu_demux_irq(struct irq_desc *desc) +{ + struct irq_chip *chip = irq_desc_get_chip(desc); + + if (chip->irq_ack) + chip->irq_ack(&desc->irq_data); + + if (__handle_irq_event_percpu(desc)) + /* + * PER CPU interrupts are not serialized. Do not touch + * desc->tot_count. + */ + __kstat_incr_irqs_this_cpu(desc); + + if (chip->irq_eoi) + chip->irq_eoi(&desc->irq_data); +} +EXPORT_SYMBOL_GPL(handle_percpu_demux_irq); + /** * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids * @desc: the interrupt description structure for this irq -- 2.25.1