Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3854845ybt; Tue, 23 Jun 2020 12:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd9RqGljT4ly0SCjY8/lT4QDaSyWL/hTRVpREXcmL+eNuwS+yU6dtbX+za6ARcKQ4/COZ4 X-Received: by 2002:a17:907:1002:: with SMTP id ox2mr8084272ejb.358.1592940302408; Tue, 23 Jun 2020 12:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592940302; cv=none; d=google.com; s=arc-20160816; b=DxlL1upHfPN0FLMEVfQy9k14vwhpnhTCtG3CmGTdHTUNdRiGT+F8/swP8sfEOw4np+ nyla66EptskQiy6rCJc1EVuKBGxjGuCtEBHA34VDuOjq7l2TPaG4YseDV/xjkdWbUplr Upa3EirwkfmLw8Esz7RYrip9cHeYDf+TsTOn7kj1ZVqXTnN35cIRK616LMI+5o/FTPZU tYZBO2vdy9vKV/UHDA3U6XoEyI4d2AS7ZWF1OKqtSxcH+xbkvRQAwVsCQ0a1dTtzR4MZ vC842IsNnzHK3E2BaKjvxBs572xaMzi65gBDlkMVrlc7gbYvQ83Ga1sc/zBANFNTVjLh EdKg== 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:to:from:dkim-signature; bh=TdM3UQkfMsN3V/UvtqwuaPyQU6d6l4GBM/lycOPWluc=; b=V33Z1CK5h+HD0Ex4gyc2anRSitinG5E1IWyXlBsZwgUu0aomrrEFemG+RWqujNfP7o qBKkcXXNgL6T7+HdpvcP4nvviC0Gp8st1VjR07Axn9dtKAEdUqk7hgAY5owS3QvGINmt haJ1qVZ2SX1hAyBn0UapImikWYDGqxTF4GM1Kc8rT/EZfkv7FWYOLCUqKwmijXwS2XNN hSQ044Oz91ixODCEpjsijsPU+XPEEyxflTM4zerYM9FJvA3KrBVrf8+5dG1+kmcwNjsi rRsAaTWgnyMbIis2L/mH+nh8rHdIhAf1IVmSPNuFvWqnAy/yu4BkbMnlpWkiYJ5ivxq3 Psww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Erlsm5u7; 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 r5si93498ejx.422.2020.06.23.12.24.37; Tue, 23 Jun 2020 12:25:02 -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=Erlsm5u7; 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 S1733305AbgFWTYa (ORCPT + 99 others); Tue, 23 Jun 2020 15:24:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:57974 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733220AbgFWTY3 (ORCPT ); Tue, 23 Jun 2020 15:24:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592940268; 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=TdM3UQkfMsN3V/UvtqwuaPyQU6d6l4GBM/lycOPWluc=; b=Erlsm5u7bEgVXMmXeBGpcDBon5PnRAVtvyJ5bdm2FHxpJGECDzdHigBxY+PgmzbjVUIh+l jwSwmIMrO8dDg7LwRlNUQiSIIqaiTiCSGuLIGRzXr0Ip3VtHWCeqck9k2rtOfUwK+ii0AS UhkgsjPmquqI5w3uR9kB/W22ladFUBM= 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-392-jJdNqlG-OuqdtpPBIQeWoA-1; Tue, 23 Jun 2020 15:24:26 -0400 X-MC-Unique: jJdNqlG-OuqdtpPBIQeWoA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F332E1005513; Tue, 23 Jun 2020 19:24:23 +0000 (UTC) Received: from virtlab423.virt.lab.eng.bos.redhat.com (virtlab423.virt.lab.eng.bos.redhat.com [10.19.152.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D9E7610FD; Tue, 23 Jun 2020 19:24:22 +0000 (UTC) From: Nitesh Narayan Lal To: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, frederic@kernel.org, mtosatti@redhat.com, juri.lelli@redhat.com, abelits@marvell.com, bhelgaas@google.com, linux-pci@vger.kernel.org, rostedt@goodmis.org, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, davem@davemloft.net, akpm@linux-foundation.org, sfr@canb.auug.org.au, stephen@networkplumber.org, rppt@linux.vnet.ibm.com Subject: [Patch v3 1/3] lib: Restrict cpumask_local_spread to houskeeping CPUs Date: Tue, 23 Jun 2020 15:23:29 -0400 Message-Id: <20200623192331.215557-2-nitesh@redhat.com> In-Reply-To: <20200623192331.215557-1-nitesh@redhat.com> References: <20200623192331.215557-1-nitesh@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Belits The current implementation of cpumask_local_spread() does not respect the isolated CPUs, i.e., even if a CPU has been isolated for Real-Time task, it will return it to the caller for pinning of its IRQ threads. Having these unwanted IRQ threads on an isolated CPU adds up to a latency overhead. Restrict the CPUs that are returned for spreading IRQs only to the available housekeeping CPUs. Signed-off-by: Alex Belits Signed-off-by: Nitesh Narayan Lal --- lib/cpumask.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/cpumask.c b/lib/cpumask.c index fb22fb266f93..d73104995981 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -6,6 +6,7 @@ #include #include #include +#include /** * cpumask_next - get the next cpu in a cpumask @@ -205,22 +206,27 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask) */ unsigned int cpumask_local_spread(unsigned int i, int node) { - int cpu; + int cpu, hk_flags; + const struct cpumask *mask; + hk_flags = HK_FLAG_DOMAIN | HK_FLAG_WQ; + mask = housekeeping_cpumask(hk_flags); /* Wrap: we always want a cpu. */ - i %= num_online_cpus(); + i %= cpumask_weight(mask); if (node == NUMA_NO_NODE) { - for_each_cpu(cpu, cpu_online_mask) + for_each_cpu(cpu, mask) { if (i-- == 0) return cpu; + } } else { /* NUMA first. */ - for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask) + for_each_cpu_and(cpu, cpumask_of_node(node), mask) { if (i-- == 0) return cpu; + } - for_each_cpu(cpu, cpu_online_mask) { + for_each_cpu(cpu, mask) { /* Skip NUMA nodes, done above. */ if (cpumask_test_cpu(cpu, cpumask_of_node(node))) continue; -- 2.18.4