Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10309388imu; Sun, 30 Dec 2018 19:03:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/VrDqCMRCUruBq4xaCfw/KYIe78sN6BlEZGfUXxnzkozufvrl1SLkBOuFTb2CK3KrMXKwgS X-Received: by 2002:a62:8985:: with SMTP id n5mr37167087pfk.255.1546225399933; Sun, 30 Dec 2018 19:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546225399; cv=none; d=google.com; s=arc-20160816; b=alv4E1AJC9SNkJUrOAntLOlCwIUlUHhXAksp5ZQHrpY4MEBYLoh+EBExm/17pJUIU+ hVeBKwlrxv3p9EiRTH8r/37Uk8yePNISXRe5g/ajtg5jAh4KUduKHf05cPWEs4zuONwK 5hxoPcQ2hUG0lglp1VCJ8i7S8jYxoHaGBBN+sIKzudX4HbYYv0j9F+Gw4oAI8ELyuWcG jaWPQw3YhLS3zp8lHP3VB2kk2Xi8LrcB0yNGzlS1fIVRwRXP1mjLFFwhUlcPzMIwkZZC h31RC3g5P8ZCs3wUE+DoH5dwZlB+E+rTqgb2gdQa8pPUXpQFbS3faAgjx6NWTR+BB9Qa aGBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=0mGdjxHYv3EMsZoOLv88KdxsU/ATCRh8+Xrkp0fw/Mw=; b=OUcXIXHl0M3/jHKWDcQwGDnrkpGxGtwMsbsc0YFKQYvG2QUcXsbKrRGYTRAyy7smc8 Bju3fKvIKtEEUXm+Ncoitcf2WGuCxirTbylVfqZ6preVFjMPAZf2HBbbpz/zVEeyJbQg IMgB1DE9pCGAk6CiTjnrCRzmSpVbHzPnsq+wXbxtcq5yAsneNw91LRMLgt8byziLdVAr LuA78VTnIwlf9MfysCz1upC+u1jIrE1/giIUF9kKIev20li3DbXtpx3bGWYvUTC2+od2 Oo/jCLDhbghTS7HgBeEgusIz50ZKvcyK9X4N+P2PlA4oTL34QXspFdyqhsqYYncllojr /emg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZbfJ17HM; 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 a24si44119304pgd.248.2018.12.30.19.03.04; Sun, 30 Dec 2018 19:03:19 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZbfJ17HM; 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 S1726944AbeLaDCS (ORCPT + 99 others); Sun, 30 Dec 2018 22:02:18 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43511 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbeLaDCR (ORCPT ); Sun, 30 Dec 2018 22:02:17 -0500 Received: by mail-pl1-f193.google.com with SMTP id gn14so12217577plb.10; Sun, 30 Dec 2018 19:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=0mGdjxHYv3EMsZoOLv88KdxsU/ATCRh8+Xrkp0fw/Mw=; b=ZbfJ17HMMEfZO5Rr7UufNe1pNvrZX9QAI1WUrDMf37nRv84tN/44r9uLPynpvjLfzu g5XFyXkULy/Gd0Qwt1H/qiL2kQxvQLc5aElI0iiL0NyTmyaw544mRUdmBmAj/cbopThg 9Qul/0Zgf0WsPe3RH9gZVNClaUzON1U60R8+r7usRL8WyiZZLELTGzdk3/C7QLvUGkvC Glk2kCIZZPBXc+RPmpQTvBwKOg+PhyzLPmykfkb2RIvJ92JREJS4b1jVOzMvZWaLqTrm 8KdrSrrVMKpF/3RHVIj+OHLT5RaEsuI77+Ew7Jn4PbFI6Z7uBNDnXkWMlEb+QQLu1/1r JvvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=0mGdjxHYv3EMsZoOLv88KdxsU/ATCRh8+Xrkp0fw/Mw=; b=HnXoLTiQOlp6aEsS1da3wrH6yYWd8ZN9KdbAyEQ689/yabyk/MPJ+c/Z3bu2z7R3Hw mZXnbmHhakXyMRgL8+eOBlYzb9xoqSv0l4Wu6WUarZBlLIdhrXoAf8mb/8gptiCdkrHC YtkSI8Tj/DbOXQkxAXsmPcMwspkeTfoxfm8VtS4S3gaJ1HDWrDUd064HbEatqE5imujH dOvrzJvjQhwpgQLLciiUTCSmFRVCyJrG7Ssm73nu2+mfcaIJUWVGxl9Dz1C8zBlyaAw0 RUcisf882NRmPi+QwrdodOoAx+6XIXNuRzPVN1DCJzJq/hWAqHvFEp8YNava/2icKodD pmeQ== X-Gm-Message-State: AJcUukfIatCfd+r9x8FW+wrkjehUJXmbTxixEbU5AgNgnG/1MXDwDDUO aVAmZkZ41XnRdIItiRD2SKI= X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr34963585plv.94.1546225335915; Sun, 30 Dec 2018 19:02:15 -0800 (PST) Received: from software.domain.org ([172.247.34.138]) by smtp.gmail.com with ESMTPSA id 85sm72097374pfw.17.2018.12.30.19.02.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 30 Dec 2018 19:02:15 -0800 (PST) From: Huacai Chen To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Fuxin Zhang , Zhangjin Wu , Huacai Chen , stable@vger.kernel.org, Christoph Hellwig , Michael Hernandez Subject: [PATCH] genirq/affinity: Assign default affinity to pre/post vectors Date: Mon, 31 Dec 2018 11:03:24 +0800 Message-Id: <1546225404-6775-1-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Generally, irq_create_affinity_masks() assign default affinity to pre/ post vectors correctly. However, it ignore the case that there are only pre/post vectors (when nvecs == affd->pre_vectors + affd->post_vectors) and return NULL. This case usually happens when nvecs = 1 (e.g. in nvme driver when MSI-X is unavailable and fallback to MSI) and will trigger the warning in pci_irq_get_affinity(). This patch fix the corner case. Fixes: 6f9a22bc5775d231ab8f ("PCI/MSI: Ignore affinity if pre/post vector count is more than min_vecs") Cc: stable@vger.kernel.org Cc: Christoph Hellwig Cc: Michael Hernandez Signed-off-by: Huacai Chen --- kernel/irq/affinity.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index 45b68b4..9b766eb 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -240,13 +240,6 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) struct irq_affinity_desc *masks = NULL; int i, nr_sets; - /* - * If there aren't any vectors left after applying the pre/post - * vectors don't bother with assigning affinity. - */ - if (nvecs == affd->pre_vectors + affd->post_vectors) - return NULL; - node_to_cpumask = alloc_node_to_cpumask(); if (!node_to_cpumask) return NULL; @@ -255,6 +248,17 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) if (!masks) goto outnodemsk; + /* + * If there aren't any vectors left after applying the pre/post + * vectors then just assign the default affinity to all vectors. + */ + if (nvecs == affd->pre_vectors + affd->post_vectors) { + /* Fill all vectors that don't need affinity */ + for (curvec = 0; curvec < nvecs; curvec++) + cpumask_copy(&masks[curvec].mask, irq_default_affinity); + goto outnodemsk; + } + /* Fill out vectors at the beginning that don't need affinity */ for (curvec = 0; curvec < affd->pre_vectors; curvec++) cpumask_copy(&masks[curvec].mask, irq_default_affinity); -- 2.7.0