From patchwork Mon Sep 25 02:51:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Gong X-Patchwork-Id: 144338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1097184vqu; Mon, 25 Sep 2023 03:05:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfnQBpWhS1BQCxOxRx9EivDj5wUmIkvrt3NYrd1fCuUYUQktYaiArON5jSUaqO8aXzdmiF X-Received: by 2002:a17:902:7043:b0:1c5:f7b0:75d2 with SMTP id h3-20020a170902704300b001c5f7b075d2mr4186152plt.29.1695636302025; Mon, 25 Sep 2023 03:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695636302; cv=none; d=google.com; s=arc-20160816; b=uftvslDBjpITTglYPsEAmt3+KNyH+muIQ0qP/LKS+bI9B60ZfAx1RBmA7iEsA2Bcuy el0hfGNQuTRlJCj+ulhTq1S7k3VsMtqhM0UJF4io3Pb8wvOUREAbSICfTO3SEmnLLlK5 K4ge+L5T1e9NXjdacrdq+MfShQgb/FhcH0nafijEtJPZqGSzjhoEDDa7KTfKJ6gPpYNK jFf6U8UkHaPkgZc7If/fNdDmONbynVLgrKUFosYyp06U7QP+A5QUuG8G3wdgD+eET8UE 7GUsw3grTYWLhtuCWTJFRt56UIaEcZLij3X7bOxCtDVTz1X31r23FCeHnq9lc8zDyIdo Q9ww== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xqbrouaImx5KBoP6AYN1d+wBdtJOt9nHHasbW1/FriU=; fh=3U/aSPvhlJUoR5OEUNoYI9odFhnPbJnmZVfaEYVfoA0=; b=NkY8JTVNrDPV7UeEIqGRK1lWHJT5Cgf7Z361ixWCxA+MZS7VtTz1ppRJc9PvPTN6iX FePNuar0frbXYX4kA0uLJZI3u9HAC8xrXAavyT+Jt+La0a5FsxLZ5FCetz6PsSR8GRrl JqLF7NlmN/0+yzxGFoKFEb6JH0/Vt2s2XtGTz4wP0jXxWcBaBss2Z8aar4QDn161saBg qtZnsY+kPjmUiSr4YzMvMRC6Ozv/D8FCTkfKhwZciQKjWFkow2z24hIu1y6pVTMm/xlJ oRmgHJJHVraBHOeCymlulzZ2fpi6/zQsOzciNTm77oCHZW4egugn141KEq7699Hu54qD +EKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X8A6zbP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u15-20020a170902e5cf00b001b895a2c09esi9922328plf.381.2023.09.25.03.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 03:05:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X8A6zbP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8F48A819704F; Sun, 24 Sep 2023 19:52:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjIYCwL (ORCPT + 30 others); Sun, 24 Sep 2023 22:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbjIYCwK (ORCPT ); Sun, 24 Sep 2023 22:52:10 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D554FB for ; Sun, 24 Sep 2023 19:52:03 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-577e62e2adfso3358028a12.2 for ; Sun, 24 Sep 2023 19:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695610323; x=1696215123; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xqbrouaImx5KBoP6AYN1d+wBdtJOt9nHHasbW1/FriU=; b=X8A6zbP+K5TtNV3tpMuIrzAHno5Aqq0JNx+MkI4wTxqe4h/enuJoJhEBAfWYJrpRDV h7y3U57M2rbv+/jLviKiKqtxfH9z0U5+XUgDhAZfabInpOizExi4lEu8IXteSuXmj/RG gB1qEHQAEJ8k8ZvYAckUJ6d3AKOU3B/qx6svebR3lHJQIGDkli9PGPX1/9cxZ2AmnfiP 4L7aPuSdLI8iHDKu0le3psQPvwsS7Fy4MMcwBgE6jTLGwraudIM48hjnwqTBy3SS0QR7 NRX45b3cE1Odz6GgSo5rfYk7DycA+YAqMC7LnbdOm2iYDfZYGqjIHI1BhXCAP4HXoqWF lByA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695610323; x=1696215123; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xqbrouaImx5KBoP6AYN1d+wBdtJOt9nHHasbW1/FriU=; b=ZunEgwx1yj/IW0huIkfcSgXtZYRy+0ilixJX/RTHgeTsE6kHgyBxgj2HgE77hw7Nh6 8FRiB0wL8mD7jh5uiehqbSevw93emxxHj3g5Tevb+xKM5RQtAXWdu09psxmiwOzCDW9j CsgBrYNF8jg7ewWCHKxpdCcHm4kg/B/hbvSS8Zx5t2JaVJ+fLK0JiVJwHZOpKq3uNgWN 2zXaqEvCCWyP+brikXZ2xJSKkjl3okhVeMPy7fuvPIujh4fsOBGU3tghn9nr0qNt0w2m w4T6mROzohDOsQqViMaGPHnnlwLy/xEzxJd6KgeOMUi82joCGmWmHL182zYD+fw/ccvB X73g== X-Gm-Message-State: AOJu0Yy3+iYHulbe81Ml15N/OQFqvFFu33aVDXGxho6ftgryfzJRhUh1 YVukVkCWgpVJL2yCLimpjUJ2UzrpYi4= X-Received: by 2002:a05:6a20:4421:b0:14e:429e:b0e3 with SMTP id ce33-20020a056a20442100b0014e429eb0e3mr4772065pzb.52.1695610322822; Sun, 24 Sep 2023 19:52:02 -0700 (PDT) Received: from localhost.localdomain ([111.108.111.133]) by smtp.gmail.com with ESMTPSA id j5-20020a170902da8500b001bb99e188fcsm7511962plx.194.2023.09.24.19.52.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Sep 2023 19:52:02 -0700 (PDT) From: Wei Gong To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Wei Gong Subject: [PATCH v2] genirq: avoid long loops in handle_edge_irq Date: Mon, 25 Sep 2023 10:51:54 +0800 Message-Id: <20230925025154.37959-1-gongwei833x@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:52:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778003530932160684 X-GMAIL-MSGID: 1778003530932160684 When there are a large number of interrupts occurring on the tx queue(irq smp_affinity=1) of the network card, changing the CPU affinity of the tx queue (echo 2 > /proc/irq/xx/smp_affinity) will cause handle_edge_irq to loop for a long time in the do {} while() loop. After setting the IRQ CPU affinity, the next interrupt will only be activated when it arrives. Therefore, the next interrupt will still be on CPU 0. When a new CPU affinity is activated on CPU 0, subsequent interrupts will be processed on CPU 1. cpu 0 cpu 1 - handle_edge_irq - apic_ack_irq - irq_do_set_affinity - handle_edge_irq - do { - handle_irq_event - istate &= ~IRQS_PENDIN - IRQD_IRQ_INPROGRESS - spin_unlock() - spin_lock() - istate |= IRQS_PENDIN - handle_irq_event_percpu - mask_ack_irq() - spin_unlock() - spin_unlock } while(IRQS_PENDIN && !irq_disable) Therefore, when determining whether to continue looping, we add a check to see if the current CPU belongs to the affinity table of the interrupt. Signed-off-by: Wei Gong --- kernel/irq/chip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index dc94e0bf2c94..6da455e1a692 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -831,7 +831,8 @@ void handle_edge_irq(struct irq_desc *desc) handle_irq_event(desc); } while ((desc->istate & IRQS_PENDING) && - !irqd_irq_disabled(&desc->irq_data)); + !irqd_irq_disabled(&desc->irq_data) && + cpumask_test_cpu(smp_processor_id(), irq_data_get_affinity_mask(&desc->irq_data))); out_unlock: raw_spin_unlock(&desc->lock);