Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp122527imj; Wed, 13 Feb 2019 05:46:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IaRMsPgteF0+tMl270YBdFMe/SwTC8a7I834mUhnQ5Tlhu7CsZgEojXIYt0i+Vaoqg+dTI1 X-Received: by 2002:a17:902:f095:: with SMTP id go21mr592999plb.199.1550065606207; Wed, 13 Feb 2019 05:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550065606; cv=none; d=google.com; s=arc-20160816; b=DC+gG/S4wWbeZUq0XUu35v3Re5YUgzRItANuQL+BSbOWS4q+O6xwguF6Gl+tscnkdf pLV8BvLtv4dOM4hLPRnzgE6rKqR6YFjdGfgXjsJtRdIF5S56oyZ6I1zNpSO2TmLvI4bo +7oaXi3LhxU9nh4JrPes89nZ0BF8gT0gB9YVnqxrlrab7Bvn6mr6U3uqUWFHRzFkwYrt dvNcCQ9yAT2rlgzNF1xsLqYnVEuDggcBlPCjmjT2Pgl/B+eqRC46YTo807OdcRiqlEFr L45HMPcNxN0lQ65nGPRlX5k6C+k6hWoeVS3okzKMOvgiKMHT519pvPgwJ2B2iux0gj/3 i0DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=MYAz9v11+f43fx8v+Go3KNDpV+AXN41+ReC9VEXkEdI=; b=d23Rk8VqCdzwD5SPTdtEX0WoORzsBLBqosDzuhnVQ8fEfEu2vrJBQ8a+EG5W3sy+Ix bTvsPEIJFhT9tHT3DqAAfIBSJfEcaD3RwKi3FIoW4jRtFWkRgdA+P57vgd9ofgPMUr3e mEktEZNHpfD+G0vFjVuhN+M/REbngd5LGzAbyI5RTgEMhDMdI49bANnGbX+Qeqvd8Mqf 85glCH3hTp/KY2qfaJEUk//gALoB69wcRqDEcGvUIxx/0yT9Cg4OfThZU7oyeZthkj63 i4wCFEZYQRibaA1tvBt/iT4HNgV/U05g4sHaT6E2NLaI70tbfbiZgGjiJ02ZeNF0wEop casQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l85si767979pfi.272.2019.02.13.05.46.27; Wed, 13 Feb 2019 05:46:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391625AbfBMKvO (ORCPT + 99 others); Wed, 13 Feb 2019 05:51:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51626 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387957AbfBMKvN (ORCPT ); Wed, 13 Feb 2019 05:51:13 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5F3D81F01; Wed, 13 Feb 2019 10:51:12 +0000 (UTC) Received: from localhost (ovpn-8-32.pek2.redhat.com [10.72.8.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F2FC101E843; Wed, 13 Feb 2019 10:51:08 +0000 (UTC) From: Ming Lei To: Christoph Hellwig , Bjorn Helgaas , Thomas Gleixner Cc: Jens Axboe , linux-block@vger.kernel.org, Sagi Grimberg , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Keith Busch , Ming Lei Subject: [PATCH V3 3/5] genirq/affinity: add new callback for caculating set vectors Date: Wed, 13 Feb 2019 18:50:39 +0800 Message-Id: <20190213105041.13537-4-ming.lei@redhat.com> In-Reply-To: <20190213105041.13537-1-ming.lei@redhat.com> References: <20190213105041.13537-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 13 Feb 2019 10:51:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently pre-caculated set vectors are provided by driver for allocating & spread vectors. This way only works when drivers passes same 'max_vecs' and 'min_vecs' to pci_alloc_irq_vectors_affinity(), also requires driver to retry the allocating & spread. As Bjorn and Keith mentioned, the current usage & interface for irq sets is a bit awkward because the retrying should have been avoided by providing one resonable 'min_vecs'. However, if 'min_vecs' isn't same with 'max_vecs', number of the allocated vectors is unknown before calling pci_alloc_irq_vectors_affinity(), then each set's vectors can't be pre-caculated. Add a new callback of .calc_sets into 'struct irq_affinity' so that driver can caculate set vectors after IRQ vector is allocated and before spread IRQ vectors. Add 'priv' so that driver may retrieve its private data via the 'struct irq_affinity'. Suggested-by: Thomas Gleixner Signed-off-by: Ming Lei --- include/linux/interrupt.h | 4 ++++ kernel/irq/affinity.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index a20150627a32..7a27f6ba1f2f 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -269,12 +269,16 @@ struct irq_affinity_notify { * the MSI(-X) vector space * @nr_sets: Length of passed in *sets array * @set_vectors: Number of affinitized sets + * @calc_sets: Callback for caculating set vectors + * @priv: Private data of @calc_sets */ struct irq_affinity { int pre_vectors; int post_vectors; int nr_sets; int set_vectors[IRQ_MAX_SETS]; + void (*calc_sets)(struct irq_affinity *, int nvecs); + void *priv; }; /** diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c index b868b9d3df7f..2341b1f005fa 100644 --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -267,7 +267,9 @@ irq_create_affinity_masks(int nvecs, struct irq_affinity *affd) * Spread on present CPUs starting from affd->pre_vectors. If we * have multiple sets, build each sets affinity mask separately. */ - if (!affd->nr_sets) { + if (affd->calc_sets) { + affd->calc_sets(affd, nvecs); + } else if (!affd->nr_sets) { affd->nr_sets = 1; affd->set_vectors[0] = affvecs; } @@ -316,7 +318,9 @@ int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity if (resv > minvec) return 0; - if (affd->nr_sets) { + if (affd->calc_sets) { + set_vecs = vecs; + } else if (affd->nr_sets) { int i; for (i = 0, set_vecs = 0; i < affd->nr_sets; i++) -- 2.9.5