Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4925371imu; Wed, 19 Dec 2018 02:40:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/VuJpKHP9EkT4PR+ACe2+Tpd6PI/Gp6yPChTre3n/QH14IQjouen8c3QBldoSSc97j5jh2q X-Received: by 2002:a63:9d05:: with SMTP id i5mr2280730pgd.98.1545216028528; Wed, 19 Dec 2018 02:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545216028; cv=none; d=google.com; s=arc-20160816; b=E/JTCyfgX9b3V7Q7S5nQydxHyiNxrpc1vM01SnZoiqCFcLcBedY02Gb2ewLZboOW8R rRJJoWTFgBD/ylqEGDxck9T03Biwo+jdDKMFsXXUs+oMRb4cPDC5DiqC0ozBKmvISmE+ 6Ns7384ZGCZuY8atpMsCw+qARlbZ6n89FnPnNDUPvbAYpyjTy/MGmO5sNnx+Mrru8fXU /UgOnpSTofK6afDTqdHJVuS38TSl2EtBj4K/4BpIt9SMw8AeWXyjgrjO6aYzkQKA/Sok mnLnCmVNOcIaFliuPy9sG6Z3rKeqt3aI2gDkUmOk00M0T4mj6DquA5vjyl9/6SRIGCix QeuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=j3xPLA+ahCXMVJ+woqmU7por9E8AlGW70k2aidqFeEM=; b=FNjQZNrwOYQaXzpeCzkFFFJ4pGVi7GB2Mg95eQCbuQJERvxkIT53ta7pRxm6mdCl/M JKaEfiXpnnRZKLekTWmGhFkuSrBZkzfPqs6VJKyf5WLlfo3JCVO99DeSTQ3ijrXE08iH ZfjonQIYP2CXbh4vl8Z2UZvQsVqA5otMIWV3Q1H4Ue/tIq2AmDrcB84K7RFkhxbfFK7h oMllreZSdFa9HslPnsscXOcmztnlfajYBpzZVfHLtzw72sOyKa+NXWgJNMC2kaSpjDN/ TJDomSor23qOcvS9k0nP2GinWYYN5twJSqoD4/M118Y686dvqxpfJ8SnHtMrWJI5LG34 KUsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1si4625508pgm.194.2018.12.19.02.40.12; Wed, 19 Dec 2018 02:40:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729100AbeLSKiL (ORCPT + 99 others); Wed, 19 Dec 2018 05:38:11 -0500 Received: from terminus.zytor.com ([198.137.202.136]:41925 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727419AbeLSKiL (ORCPT ); Wed, 19 Dec 2018 05:38:11 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id wBJAc5B63192586 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 19 Dec 2018 02:38:05 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id wBJAc5gN3192583; Wed, 19 Dec 2018 02:38:05 -0800 Date: Wed, 19 Dec 2018 02:38:05 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Dou Liyang Message-ID: Cc: sumit.saxena@broadcom.com, hpa@zytor.com, tglx@linutronix.de, douliyangs@gmail.com, mingo@kernel.org, linux-kernel@vger.kernel.org, kashyap.desai@broadcom.com Reply-To: tglx@linutronix.de, hpa@zytor.com, sumit.saxena@broadcom.com, kashyap.desai@broadcom.com, linux-kernel@vger.kernel.org, mingo@kernel.org, douliyangs@gmail.com In-Reply-To: <20181204155122.6327-3-douliyangs@gmail.com> References: <20181204155122.6327-3-douliyangs@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq/affinity: Add is_managed to struct irq_affinity_desc Git-Commit-ID: c410abbbacb9b378365ba17a30df08b4b9eec64f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=1.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c410abbbacb9b378365ba17a30df08b4b9eec64f Gitweb: https://git.kernel.org/tip/c410abbbacb9b378365ba17a30df08b4b9eec64f Author: Dou Liyang AuthorDate: Tue, 4 Dec 2018 23:51:21 +0800 Committer: Thomas Gleixner CommitDate: Wed, 19 Dec 2018 11:32:08 +0100 genirq/affinity: Add is_managed to struct irq_affinity_desc Devices which use managed interrupts usually have two classes of interrupts: - Interrupts for multiple device queues - Interrupts for general device management Currently both classes are treated the same way, i.e. as managed interrupts. The general interrupts get the default affinity mask assigned while the device queue interrupts are spread out over the possible CPUs. Treating the general interrupts as managed is both a limitation and under certain circumstances a bug. Assume the following situation: default_irq_affinity = 4..7 So if CPUs 4-7 are offlined, then the core code will shut down the device management interrupts because the last CPU in their affinity mask went offline. It's also a limitation because it's desired to allow manual placement of the general device interrupts for various reasons. If they are marked managed then the interrupt affinity setting from both user and kernel space is disabled. That limitation was reported by Kashyap and Sumit. Expand struct irq_affinity_desc with a new bit 'is_managed' which is set for truly managed interrupts (queue interrupts) and cleared for the general device interrupts. [ tglx: Simplify code and massage changelog ] Reported-by: Kashyap Desai Reported-by: Sumit Saxena Signed-off-by: Dou Liyang Signed-off-by: Thomas Gleixner Cc: linux-pci@vger.kernel.org Cc: shivasharan.srikanteshwara@broadcom.com Cc: ming.lei@redhat.com Cc: hch@lst.de Cc: bhelgaas@google.com Cc: douliyang1@huawei.com Link: https://lkml.kernel.org/r/20181204155122.6327-3-douliyangs@gmail.com --- include/linux/interrupt.h | 1 + kernel/irq/affinity.c | 4 ++++ kernel/irq/irqdesc.c | 13 ++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index c44b7844dc83..c672f34235e7 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -263,6 +263,7 @@ struct irq_affinity { */ struct irq_affinity_desc { struct cpumask mask; + unsigned int is_managed : 1; }; #if defined(CONFIG_SMP) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index c0fe591b0dc9..45b68b4ea48b 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -289,6 +289,10 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) for (; curvec < nvecs; curvec++) cpumask_copy(&masks[curvec].mask, irq_default_affinity); + /* Mark the managed interrupts */ + for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++) + masks[i].is_managed = 1; + outnodemsk: free_node_to_cpumask(node_to_cpumask); return masks; diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index cb401d6c5040..ee062b7939d3 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -453,27 +453,30 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node, struct module *owner) { struct irq_desc *desc; - unsigned int flags; int i; /* Validate affinity mask(s) */ if (affinity) { - for (i = 0; i < cnt; i++) { + for (i = 0; i < cnt; i++, i++) { if (cpumask_empty(&affinity[i].mask)) return -EINVAL; } } - flags = affinity ? IRQD_AFFINITY_MANAGED | IRQD_MANAGED_SHUTDOWN : 0; - for (i = 0; i < cnt; i++) { const struct cpumask *mask = NULL; + unsigned int flags = 0; if (affinity) { - node = cpu_to_node(cpumask_first(affinity)); + if (affinity->is_managed) { + flags = IRQD_AFFINITY_MANAGED | + IRQD_MANAGED_SHUTDOWN; + } mask = &affinity->mask; + node = cpu_to_node(cpumask_first(mask)); affinity++; } + desc = alloc_desc(start + i, node, flags, mask, owner); if (!desc) goto err;