Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1319152pxk; Fri, 25 Sep 2020 11:31:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7dh7CdwTEhDvbf67q3/PP/bbHjZeAedDo64dwlrMqcjo5UvQQJCi3BQ9ljZ/4T3+P13ug X-Received: by 2002:a05:6402:b72:: with SMTP id cb18mr2647948edb.299.1601058685855; Fri, 25 Sep 2020 11:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601058685; cv=none; d=google.com; s=arc-20160816; b=WbIx47DgdKbi5MQCI4Z6q7AD1zu40+SUgKSP2F93PnY4mzYhoxzo6Ob2YdCQBY4XFO nxlUcPGr231Z+2zumL1txBfxfeaC04unQeL/ArisS3mpg/ZVEJhgMLbuUUPea/aWO3Rf RSkK4FcIRZwt/P+WiwdysHmA6oD/kDNTI/hxkHylSBbj9cRnchjcaDV2UEPfPBSHpN+c TDblCOlAg0iAoBc96+ykQF+sWEfPCecWKjw86yApgvTp5wrWO0+UC7Hhg+b6TQweGvwp E7wrUWr5pl5t+8jJiD65OCxqA1z2YoGnOKFaB7cD8Vsyje7V6UR/rJh4qoDT0y/Yv+UB FxyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature; bh=rRcKZ8I6kczvYIrMGUe8rB/gq5sgstXC59hVf7TDlHU=; b=RrFI+WWGrYivBzfUVV6vZQj9iN5v4bwmCxqC9PHyEAEaiFbsUYyKJQJo1kuo/Fpspq Xqrvx5muoBV6qMSb9br+vugF9TQvMUXXSq1S1cF8NOg8F3hG3uqupGYOrEL19eeTt2LC AojwzVOGuGaNPgr+ssMbqCJuObN6LyV3kKMsSL585hcbev5AuQK/a7Gev4P/EqOldFfT HhBj7Pg/9fMFU693KtOjb8KUYwj1oQFcJw8zffbIw1V9QucVKuPoagcQdqtRWB81kSXC vS45MdE+5yzbcH4jmfbYchtO4DUx8Ow5sNhVMuVDXtMMq6CoHbwgYbCw1spQCfG1AxIA wRJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WFAT6hK3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si2239976ejb.476.2020.09.25.11.31.01; Fri, 25 Sep 2020 11:31:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WFAT6hK3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729778AbgIYS1X (ORCPT + 99 others); Fri, 25 Sep 2020 14:27:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25384 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729769AbgIYS1S (ORCPT ); Fri, 25 Sep 2020 14:27:18 -0400 Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601058437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:in-reply-to:in-reply-to:references:references; bh=rRcKZ8I6kczvYIrMGUe8rB/gq5sgstXC59hVf7TDlHU=; b=WFAT6hK3J5IS3OJKEUtDBbYo7EHf1AcdLZhu5qB2oPFcOaww7CQZ9WKhOzlQw93gtPYMRG pHBT7s8BGPNCexJhNEF5ecwDBaTWjqmBYAwsG7U10dh++GzF8TF2/NEzWhvm++urVFZu2J A9Zy5kQeYm0mv+uKT3pAaZxSYnbmKKY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-FZhrcYxJO-OgZXPDVOWqFQ-1; Fri, 25 Sep 2020 14:27:13 -0400 X-MC-Unique: FZhrcYxJO-OgZXPDVOWqFQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2F0188EF1F; Fri, 25 Sep 2020 18:27:10 +0000 (UTC) Received: from virtlab719.virt.lab.eng.bos.redhat.com (virtlab719.virt.lab.eng.bos.redhat.com [10.19.153.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BBA878810; Fri, 25 Sep 2020 18:27:09 +0000 (UTC) From: Nitesh Narayan Lal To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, intel-wired-lan@lists.osuosl.org, frederic@kernel.org, mtosatti@redhat.com, sassmann@redhat.com, jesse.brandeburg@intel.com, lihong.yang@intel.com, helgaas@kernel.org, nitesh@redhat.com, jeffrey.t.kirsher@intel.com, jacob.e.keller@intel.com, jlelli@redhat.com, hch@infradead.org, bhelgaas@google.com, mike.marciniszyn@intel.com, dennis.dalessandro@intel.com, thomas.lendacky@amd.com, jiri@nvidia.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, lgoncalv@redhat.com Subject: [PATCH v3 4/4] PCI: Limit pci_alloc_irq_vectors() to housekeeping CPUs Date: Fri, 25 Sep 2020 14:26:54 -0400 Message-Id: <20200925182654.224004-5-nitesh@redhat.com> In-Reply-To: <20200925182654.224004-1-nitesh@redhat.com> References: <20200925182654.224004-1-nitesh@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we have isolated CPUs dedicated for use by real-time tasks, we try to move IRQs to housekeeping CPUs from the userspace to reduce latency overhead on the isolated CPUs. If we allocate too many IRQ vectors, moving them all to housekeeping CPUs may exceed per-CPU vector limits. When we have isolated CPUs, limit the number of vectors allocated by pci_alloc_irq_vectors() to the minimum number required by the driver, or to one per housekeeping CPU if that is larger. Signed-off-by: Nitesh Narayan Lal --- include/linux/pci.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 835530605c0d..a7b10240b778 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -1797,6 +1798,22 @@ static inline int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags) { + unsigned int hk_cpus; + + hk_cpus = housekeeping_num_online_cpus(HK_FLAG_MANAGED_IRQ); + /* + * If we have isolated CPUs for use by real-time tasks, to keep the + * latency overhead to a minimum, device-specific IRQ vectors are moved + * to the housekeeping CPUs from the userspace by changing their + * affinity mask. Limit the vector usage to keep housekeeping CPUs from + * running out of IRQ vectors. + */ + if (hk_cpus < num_online_cpus()) { + if (hk_cpus < min_vecs) + max_vecs = min_vecs; + else if (hk_cpus < max_vecs) + max_vecs = hk_cpus; + } return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, NULL); } -- 2.18.2