Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp114128ybt; Thu, 25 Jun 2020 16:49:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJsMcMiUqgeaUacWxPYM9P9Hd0ccRCo66DuUdzuugV9ObCCVER+mTo/4YbTQz0ZSrrXjqq X-Received: by 2002:a17:906:af48:: with SMTP id ly8mr240682ejb.28.1593128973864; Thu, 25 Jun 2020 16:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593128973; cv=none; d=google.com; s=arc-20160816; b=KgJnMfATadWHUH9o3mcOKcF/qyjyiOyzxPwPgz8TdEifqg7Y0CQeuofLHyrUjffj/c Lqn0gTUoTqwqYloaxS33DONwP1vLvnF8/7QKZ0djuCQsaEd3vkfnXzcLczJlHnXAvLmT dW0RULFFBWuo9lYMB0tfUUvXJ4IY0ZdMHgIf4z4jOEL0tpMwMAY1zJeSVwtiI+9z8jHI 1G/pIsqZvR/2JfuBi+E1EGU7vyz+NUZ5r4I1HWIRE5PzNZuZzDBDDY9CNvaMgfBtCj3y cDcwhworo2hvrrSzjhnrAJFciQ2KI3EvW43Eij6uG/tMCY0DXl+xCtu5aaCiYG5S5+1C N71A== 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=cUfz3o3YYU3sytCUwyBAIKiRdwfoDCo4v+fG8cImphQ=; b=LLng+a226PDQPgYx2no0Ru0tV7blRTmseB5oP2x1eahY74EyMhOttH6vK7LmhWsaS3 LK4q4iKI5HIRdRNAHGJuy2/sjeGG4FS0RCK919noa4dK3NdzlOureNJqRt7P6/G7mCPx /pAOegzQmsVvL8y1XZjtUKf7ZabuCCUqid8Uol7+gF5RrS14uWTrvbyTid1i2HU34LPd p4qLKdhgIsOthHxcqMS+0Wc4KWMxqUVsgUzxfm9z1SUsY4sphp/dd6VLPtV+KlDY4eoN fAvQDVy6Yw+unwpRRzbU2r36Uk92JwfEPnXckzos4Kc0fwiNa7+zMRzupk3Ik01gQ3HD 0nbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H8TxRbyM; 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 dn12si19199433ejc.287.2020.06.25.16.49.10; Thu, 25 Jun 2020 16:49:33 -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=H8TxRbyM; 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 S2406759AbgFYWjb (ORCPT + 99 others); Thu, 25 Jun 2020 18:39:31 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:21419 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404170AbgFYWja (ORCPT ); Thu, 25 Jun 2020 18:39:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593124768; 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=cUfz3o3YYU3sytCUwyBAIKiRdwfoDCo4v+fG8cImphQ=; b=H8TxRbyMjjTRUEc6cqrWv/jYYw4I+wWhsa5oOX4RA/RkTuFssaer5cMqALc0eo9C5niTz9 3oyhbPPqj4p4HF+nSVnQXlKdA9GDGvWM1947Zq7RxJCnrw2robHVm3kdbPpvwR9QscqF77 DqXLWbtH/f1yXe6zM3tKFuojvyOJKuE= 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-364-U4NzPTVeN52i0_fvhm98PA-1; Thu, 25 Jun 2020 18:39:26 -0400 X-MC-Unique: U4NzPTVeN52i0_fvhm98PA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A48E800C60; Thu, 25 Jun 2020 22:39: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 D98A57FEA6; Thu, 25 Jun 2020 22:39:21 +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, jinyuqi@huawei.com, zhangshaokun@hisilicon.com Subject: [Patch v4 1/3] lib: Restrict cpumask_local_spread to houskeeping CPUs Date: Thu, 25 Jun 2020 18:34:41 -0400 Message-Id: <20200625223443.2684-2-nitesh@redhat.com> In-Reply-To: <20200625223443.2684-1-nitesh@redhat.com> References: <20200625223443.2684-1-nitesh@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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..85da6ab4fbb5 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_MANAGED_IRQ; + 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