From patchwork Wed Feb 22 02:50:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 1746105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=LzbueKS5; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PM0yr2jm5z23j7 for ; Wed, 22 Feb 2023 13:51:00 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PM0yn6zSGz3bm9 for ; Wed, 22 Feb 2023 13:50:57 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=LzbueKS5; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::233; helo=mail-oi1-x233.google.com; envelope-from=yury.norov@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=LzbueKS5; dkim-atps=neutral Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PM0yQ6t7Jz3bNj for ; Wed, 22 Feb 2023 13:50:36 +1100 (AEDT) Received: by mail-oi1-x233.google.com with SMTP id w7so6467166oik.13 for ; Tue, 21 Feb 2023 18:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d3FFCt8YZaicmHfmZj/AGkoStrLtSljRIrqwUwWfE5Q=; b=LzbueKS5dUxi8UhgObjgBGQVM9xmvQd2mEA7vYiMJSFq18paUoO6/etb3yX0X1SCn5 2i3I77KPWazwbo/9u9ZSzdms8MNt845ZGDSq8/zWIzeUOafT1u2/Fsgca//TqVlluev4 kRWM8PBoncAtPQu/M2bSAE0MujWHlqcOJBVv92jZSR8unTOXGXhdOHxKmTNHCFW2G0Xr VhkfsxReW4dgFDGZrr7epgr/3Swku8xqUv1rtCcgwlSnwFCuSa1CgeBKdLT+KKXlZYBR ZjpEU5r0iKDvrKp7pU6N7oqfqcKMs+3tS0i7W1pKf4IdYczGqC2sfpfmb/fNYBsgq2ws 20Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d3FFCt8YZaicmHfmZj/AGkoStrLtSljRIrqwUwWfE5Q=; b=yWbs+G3POiT2scxlf6BfJnugsAYn2ZN/bTIFA53fvwS25ruCLz3xXmaxTmdk8IFErN WH+sXzLftxOq2IvLWna+I3gMtoGK4q7Lgnj3VK9xAgrkEAv1luTxd7bHXx32JvlQ5s+w ELLZ7OZVOmj3MKHTZyrr1eOcEU/bgetFUksNnXTiyqKFGagap9Wly18Fx4YNof0QQ1s2 XHfUtmwpQMRK1JrcGG7OJlNpIANY+609NkXMG0frTl6h77Ax91w7nslYrVFdShJaNzxs zuct13VWex7axFFWj0IOigPlqBfCuMXpICud284lrjfUKDqtHiVCPt4RwtUaVf1k438V 04FQ== X-Gm-Message-State: AO0yUKXrmmLGclAZuXLf4ufUOgKpjpvHsxOWcWb1RK8dH9LP/IW8fiOg Z5MglpKyj7jo808xVzrbMdX37S/P+kk= X-Google-Smtp-Source: AK7set/kFB+K3t5utsTeZa2jYSy11RX9Oh54PT1UbsJcbnblK7NKt5QvARs1M9lbIdjBY/pCkMEU9A== X-Received: by 2002:a05:6808:e8a:b0:37e:9955:3e16 with SMTP id k10-20020a0568080e8a00b0037e99553e16mr5897465oil.25.1677034232783; Tue, 21 Feb 2023 18:50:32 -0800 (PST) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id m132-20020acabc8a000000b0037880fdb1f6sm1009627oif.24.2023.02.21.18.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:50:32 -0800 (PST) From: Yury Norov To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] sched/topology: introduce node_has_cpus() macro Date: Tue, 21 Feb 2023 18:50:28 -0800 Message-Id: <20230222025029.453834-1-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Valentin Schneider , Yury Norov , Arnd Bergmann , Barry Song , Nicholas Piggin , Jakub Kicinski , Dietmar Eggemann , Jeremy Kerr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Currently, to check if NUMA node has CPUs, one has to use the nr_cpus_node() macro, which ends up with cpumask_weight. We can do it better with cpumask_empty(), because the latter can potentially return earlier - as soon as 1st set bit found. This patch adds a node_has_cpus() macro to implement that. Signed-off-by: Yury Norov Reviewed-by: Valentin Schneider --- include/linux/topology.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/topology.h b/include/linux/topology.h index fea32377f7c7..7e0d8f8f5a39 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -39,9 +39,11 @@ #define nr_cpus_node(node) cpumask_weight(cpumask_of_node(node)) #endif +#define node_has_cpus(node) (!cpumask_empty(cpumask_of_node(node))) + #define for_each_node_with_cpus(node) \ for_each_online_node(node) \ - if (nr_cpus_node(node)) + if (node_has_cpus(node)) int arch_update_cpu_topology(void); From patchwork Wed Feb 22 02:50:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 1746106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=c1xI3XHK; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PM0zq1sMxz23j7 for ; Wed, 22 Feb 2023 13:51:51 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PM0zq0hfbz3cFr for ; Wed, 22 Feb 2023 13:51:51 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=c1xI3XHK; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::32c; helo=mail-ot1-x32c.google.com; envelope-from=yury.norov@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=c1xI3XHK; dkim-atps=neutral Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4PM0yR02Tcz3bWq for ; Wed, 22 Feb 2023 13:50:37 +1100 (AEDT) Received: by mail-ot1-x32c.google.com with SMTP id h6-20020a9d7986000000b0068bd8c1e836so1212867otm.3 for ; Tue, 21 Feb 2023 18:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=McQi89uTbN7DF8jJyCgZeVyYtI7bAf8jLzdMMiV8l3U=; b=c1xI3XHKGohwQIKFk42Xysj7ExmK5WzvEV05vtimmkIeaaEzd0hMCiE/obU2RZT0Or fVE+TI0pYtvIqwYTWtdw5ca8EW5qdCJ6dKI7otBYNiOkOtim/vyLA7ze80BY+4MUGWcW m6oHEPFivR5zv3hS/2h/tRHTZkQmHJWIZRhgKNA4+bMY9KDfsJahZg3unsQVNu83BTPj f8Lvvcovbx9rMNFB0CQeDZL/BlRlG/FlIm/U/35kCMA5h66CV/KPyaYt7OZh9iv8agF/ 2PfXk0lI+8H1GyUEh0sPj4eeOJO7gOCDTKMC00oKioeclPwHhOGAKHoY+T25MW5kELTr HGSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=McQi89uTbN7DF8jJyCgZeVyYtI7bAf8jLzdMMiV8l3U=; b=CtP0ta1pzQNIMgUjR50tC36AaHoaHI3go7nZCbGkqr5D2+pGicixnSjwUCiFre9RBw DdlyM/Bht/272HJMMT9SZA3LDCg+GhhARcxZ3QfsXB3+InYkc1ophQ4PR4vj2NUhwetl mfwaUljI0Y/6EgLdFZ2baPdkgQrfIDs8iT1VDK8UqMEL73rNBsgAVOh0nJkVJdUxcPsB BDDhRoIk//sihJ25/BzzQmU1/7IRGDtlTokwo/e1Puj8X/ukpeDOEiY4Vt9i/PELjA9R SmmZvS7sFwKavYB59cW2Ih6rBJLletaZX+nAxFNx7N2xyrEnhXG6/IgLaUFkMRSPFAfA TGbA== X-Gm-Message-State: AO0yUKXMplY98f7Ws3txTF/nRVa89RXhWeUJmmxCCkZFcMovZmRwzbyu X1LgiqWwmlmaqrJHNLwyERFWsekNknk= X-Google-Smtp-Source: AK7set+ZgpgMCsnbEoZOPq/ABD4/QpKNx4uG/xScyv0xZvSeje/L+YyfRFjn6mXEkahnuvnyBw4Uog== X-Received: by 2002:a9d:60c1:0:b0:68d:53d5:f7d2 with SMTP id b1-20020a9d60c1000000b0068d53d5f7d2mr7853269otk.31.1677034234476; Tue, 21 Feb 2023 18:50:34 -0800 (PST) Received: from localhost ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id 90-20020a9d06e3000000b0068abc8e786fsm333298otx.10.2023.02.21.18.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:50:34 -0800 (PST) From: Yury Norov To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] powerpc: use node_has_cpus() instead of nr_cpus_node() Date: Tue, 21 Feb 2023 18:50:29 -0800 Message-Id: <20230222025029.453834-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222025029.453834-1-yury.norov@gmail.com> References: <20230222025029.453834-1-yury.norov@gmail.com> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Valentin Schneider , Yury Norov , Arnd Bergmann , Barry Song , Nicholas Piggin , Jakub Kicinski , Dietmar Eggemann , Jeremy Kerr Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Use node_has_cpus() as more efficient alternative to nr_cpus_node() where possible. Signed-off-by: Yury Norov Reviewed-by: Valentin Schneider --- arch/powerpc/platforms/cell/spu_priv1_mmio.c | 2 +- arch/powerpc/platforms/cell/spufs/sched.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.c b/arch/powerpc/platforms/cell/spu_priv1_mmio.c index d150e3987304..55b5024b256b 100644 --- a/arch/powerpc/platforms/cell/spu_priv1_mmio.c +++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.c @@ -64,7 +64,7 @@ static void cpu_affinity_set(struct spu *spu, int cpu) u64 target; u64 route; - if (nr_cpus_node(spu->node)) { + if (node_has_cpus(spu->node)) { const struct cpumask *spumask = cpumask_of_node(spu->node), *cpumask = cpumask_of_node(cpu_to_node(cpu)); diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c index 99bd027a7f7c..9d29cc2c6bcb 100644 --- a/arch/powerpc/platforms/cell/spufs/sched.c +++ b/arch/powerpc/platforms/cell/spufs/sched.c @@ -154,7 +154,7 @@ void spu_update_sched_info(struct spu_context *ctx) static int __node_allowed(struct spu_context *ctx, int node) { - if (nr_cpus_node(node)) { + if (node_has_cpus(node)) { const struct cpumask *mask = cpumask_of_node(node); if (cpumask_intersects(mask, &ctx->cpus_allowed))