From patchwork Thu Oct 25 21:16:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10656619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A72A14DE for ; Thu, 25 Oct 2018 21:16:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F2CB2C63D for ; Thu, 25 Oct 2018 21:16:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42D5B2C64C; Thu, 25 Oct 2018 21:16:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D000E2C463 for ; Thu, 25 Oct 2018 21:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726065AbeJZFvL (ORCPT ); Fri, 26 Oct 2018 01:51:11 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:43158 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727265AbeJZFvL (ORCPT ); Fri, 26 Oct 2018 01:51:11 -0400 Received: by mail-io1-f65.google.com with SMTP id y10-v6so6390135ioa.10 for ; Thu, 25 Oct 2018 14:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RdTXcoUkTq5K7EWsZETMPuhG8fwGUygYDmWiHM5puJA=; b=Ly4bcscD6GbJCU7u76fx+8s8P4RCvOwcwJT5eRNpl6oZoKjfoLhBIM36L9RmsV1/6S iPLeVklwGnoYEVi74HNR2YbckDz4aeU6gGLWfPzNKFKl9sRHwFL47vQC5ce04fsxUU4E mfNZ4tfC8pmTplQnDNiThB5pGFWU1SwLKrdFyQKHuK7OxD4zOc9iUS7vq1Z6HpD+vHnD Vi1pKp/sonPsfbaIGSlcrGxiEx0NeNEzHx4tftVPJkCy0d6S2oj4Ah0aBjfPWCdelW+3 MsQbxdHRW8HPdhsfQFRz/jHKXcqY8t07sB54SaAqJLoum1WdU2nwnByi6E9jUn0bn2k6 ckpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RdTXcoUkTq5K7EWsZETMPuhG8fwGUygYDmWiHM5puJA=; b=rW4kW+qiVOf1M4E2qrCVosCy/N8MbuKsg4blkkXr7d9mhYxWtbfKOyXmR/hJBI3hCl V1WX5kyy4mb4UXehxm/9Bo+ryRVly7k33EnbmixbG5S5kjJ8Qk7SAV6jsNBPcZahMY38 V675IWFlqoEth2clHwejkAYBesqTISsO2gGsd04jvRX4m56Rxs6DkVCExaGVMdeu39sk 8hguydsliXWnwDvKIGCI2cLvTQ+buQOBae+Jx8Jr7DWftsE3yulsQ4FHVmd9QRv5ghbv P9FuVv6Epqi3ZN75WVqYPrZAYtiHQ2P6AL6ieFl4+QLAVnfUd4qfHJ76qL39mUt7rK5Y uphA== X-Gm-Message-State: AGRZ1gLdJJKfm1I/FFtskLQtUXxmlmPqOm9+/109tdqHUX2BhW+LWKG6 VTS5680PmA918FmpoC6ORqVHJ+b37VbNzQ== X-Google-Smtp-Source: AJdET5cgnM6sQbxJI0Q4G2lSyYMQgtEy3+C0fQnrbJ+j+6BoQ6Hi9E5iJpj1WP7e6Qe0oRWlvhRqsg== X-Received: by 2002:a6b:6201:: with SMTP id f1-v6mr576095iog.11.1540502210964; Thu, 25 Oct 2018 14:16:50 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id l23-v6sm2831890ioj.40.2018.10.25.14.16.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Oct 2018 14:16:49 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Jens Axboe , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH 11/14] irq: add support for allocating (and affinitizing) sets of IRQs Date: Thu, 25 Oct 2018 15:16:23 -0600 Message-Id: <20181025211626.12692-12-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025211626.12692-1-axboe@kernel.dk> References: <20181025211626.12692-1-axboe@kernel.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A driver may have a need to allocate multiple sets of MSI/MSI-X interrupts, and have them appropriately affinitized. Add support for defining a number of sets in the irq_affinity structure, of varying sizes, and get each set affinitized correctly across the machine. Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Signed-off-by: Jens Axboe Reviewed-by: Hannes Reinecke --- include/linux/interrupt.h | 4 ++++ kernel/irq/affinity.c | 31 +++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index eeceac3376fc..9fce2131902c 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -247,10 +247,14 @@ struct irq_affinity_notify { * the MSI(-X) vector space * @post_vectors: Don't apply affinity to @post_vectors at end of * the MSI(-X) vector space + * @nr_sets: Length of passed in *sets array + * @sets: Number of affinitized sets */ struct irq_affinity { int pre_vectors; int post_vectors; + int nr_sets; + int *sets; }; #if defined(CONFIG_SMP) diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index f4f29b9d90ee..0055e252e438 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -180,6 +180,7 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) int curvec, usedvecs; cpumask_var_t nmsk, npresmsk, *node_to_cpumask; struct cpumask *masks = NULL; + int i, nr_sets; /* * If there aren't any vectors left after applying the pre/post @@ -210,10 +211,23 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd) get_online_cpus(); build_node_to_cpumask(node_to_cpumask); - /* Spread on present CPUs starting from affd->pre_vectors */ - usedvecs = irq_build_affinity_masks(affd, curvec, affvecs, - node_to_cpumask, cpu_present_mask, - nmsk, masks); + /* + * Spread on present CPUs starting from affd->pre_vectors. If we + * have multiple sets, build each sets affinity mask separately. + */ + nr_sets = affd->nr_sets; + if (!nr_sets) + nr_sets = 1; + + for (i = 0, usedvecs = 0; i < nr_sets; i++) { + int this_vecs = affd->sets ? affd->sets[i] : affvecs; + int nr; + + nr = irq_build_affinity_masks(affd, curvec, this_vecs, + node_to_cpumask, cpu_present_mask, + nmsk, masks + usedvecs); + usedvecs += nr; + } /* * Spread on non present CPUs starting from the next vector to be @@ -258,13 +272,18 @@ int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity { int resv = affd->pre_vectors + affd->post_vectors; int vecs = maxvec - resv; + int i, set_vecs; int ret; if (resv > minvec) return 0; get_online_cpus(); - ret = min_t(int, cpumask_weight(cpu_possible_mask), vecs) + resv; + ret = min_t(int, cpumask_weight(cpu_possible_mask), vecs); put_online_cpus(); - return ret; + + for (i = 0, set_vecs = 0; i < affd->nr_sets; i++) + set_vecs += affd->sets[i]; + + return resv + max(ret, set_vecs); }