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: 60306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp348994wrd; Tue, 21 Feb 2023 18:51:16 -0800 (PST) X-Google-Smtp-Source: AK7set9v1oSqlPTvlYWGTcknDVPFxj1+cFcT+f4UdU2gEf8wiIg6ppxSP0M6KFnp/VFl+0s4vemB X-Received: by 2002:a17:906:d78b:b0:8b1:2dd5:d860 with SMTP id pj11-20020a170906d78b00b008b12dd5d860mr14507007ejb.39.1677034276705; Tue, 21 Feb 2023 18:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677034276; cv=none; d=google.com; s=arc-20160816; b=ovWK2igeBlyqOo6h9Lpz1sog4eL2lm0ELJQKvcf4eG8RwUigOy+Jz6N/5A6+wyzVX5 YnZR1ABpYLCyVPiVPUfQThzFHIT0fuB5xJuiKAMl/feiEs1cLEQevOSYBTMTC5FUkW91 +lgiQU6bZr9nI2EzSHkZwG8oWEcnBTisSmLiIBQuFQDKTXvzkiQ2ZymE91RPE+BbaaLy Yb7NcmlCmpljYJ2Z4Zrr0Ab632RRPv6Q52HCxibL/furHG4rc5xsfyLtx5pd6waxhYcm aAnBccm2AZe0pdFxs88L6Y/KtAa9Rb2F3NoeToSL8ynKhj+bcvv/O4wbBTqLNOSYlLQZ ZcxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=d3FFCt8YZaicmHfmZj/AGkoStrLtSljRIrqwUwWfE5Q=; b=sgoCpZZoDXOxQveuMUBP6qg4CHE+KgyiVWw7+GiBeAEZUGsBZBTZa2cwm09ckAJ75Q 91WHsf6gyBliAtAzyxqgv3CuN+XU5B/ftaRQYs99uxdjLrtuSvO/WvGYLlYlFJbPSFBz VIERIiHSqBB/Ne0gAbQsBVkLBwZ8LE9szYFF1w5iwtATzktoiKCYp8p+5cAh1zV7fcJg 7rhJNpeKBzoLYT+dCrF5yWov/qniOvCb6Wek1MC2eVNHr2ca5/viQDFVmF7mRaVM8qi9 pidqL3f+34uuRE2YxxqphoOO1ECQ+RZawI2Sax8RDRBxlhJWl6vgtj1wcejNNJrslZcv l1FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LzbueKS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a17090610c900b008c03e7b183dsi16263839ejv.264.2023.02.21.18.50.50; Tue, 21 Feb 2023 18:51:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LzbueKS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjBVCur (ORCPT + 99 others); Tue, 21 Feb 2023 21:50:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231707AbjBVCun (ORCPT ); Tue, 21 Feb 2023 21:50:43 -0500 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9059B3402F for ; Tue, 21 Feb 2023 18:50:33 -0800 (PST) Received: by mail-oi1-x22a.google.com with SMTP id be35so6411069oib.4 for ; Tue, 21 Feb 2023 18:50:33 -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=HUbPCw1BgVbcFboC6Rpbqr6Ve0j+G5LBNLm0GO3bVXMSZkT0wzByBCXNX2M2JJpGQK hmMsxlZJzXYOANb9+Voj9SFmstxRb01QSdDrMrmkZrYCnArrsBcwGHTtorsToh6HIvpI VgO8oBt38OYodm4dvNs7ZHF2WBuLVMHhcSWoJuzETsgGHZf3T5ICN0LdhFPXaydX6Xbi p9QSXdh7ESFlv6L0cwGrGjC7uU9LYShc6gMAYMQ4fxL454hLRc2Mnatr7dQjUWq3cZSZ 6K+BbOiPqArFDxjCQFz0Vk5QuXvvAvd4vLKm0TsKhRoaYKzJoFXhZNratjxj7diGc0ZY +D+Q== X-Gm-Message-State: AO0yUKX0j4vE3VV3pSUfkDPxx3e1MXDQBki9edCNcQU3jk54dB2CooNK eyKXdIvC9p59YB9KNGRcJ5I= 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 Cc: Yury Norov , Arnd Bergmann , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jeremy Kerr , Jakub Kicinski , Valentin Schneider , Dietmar Eggemann , Barry Song 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758497893366066886?= X-GMAIL-MSGID: =?utf-8?q?1758497893366066886?= 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: 60307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp349041wrd; Tue, 21 Feb 2023 18:51:26 -0800 (PST) X-Google-Smtp-Source: AK7set9JnY+Y/bXYC2HFY+nP+dAmLZgKZBoGV+AiIWE7PSkE6OcrKqzHlh1zQ6pUWczJ22ZPKrTG X-Received: by 2002:a05:6402:34d5:b0:4ae:eae1:2be0 with SMTP id w21-20020a05640234d500b004aeeae12be0mr5958928edc.14.1677034286064; Tue, 21 Feb 2023 18:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677034286; cv=none; d=google.com; s=arc-20160816; b=hqsAcFfG7BIYcFGxCRPbWfr3FSYMOa4Zlb7c6xaFBGBqR4IWEIY5xW2W/n3FnOQd9v ZMd0i+WqwbKM5aH8yNA8g5jVdrLnpDeHW9pke6REQ9Iv+9XkE+vj2J3jAc9WxRKPqTNi 2M4DVVi36YCp/hI4ORuM9zC1uP/Zs6beRyqxpLv9eae+0sp6h3LE+pQYr2ufytSnw0hz JYvAjHZDoVzls5EJjKgsJlbvq7X3lW8FJyOCnkJjhmgLo1vp956Xik05Y0gCUcqSCa/g 0mc/J5AuoPrya3KiUhQVIZ8lsXxSgRqj+CJ1p/L88qmvtgigUzaKlnel+FW4+0KC1nD1 yj1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=McQi89uTbN7DF8jJyCgZeVyYtI7bAf8jLzdMMiV8l3U=; b=NvmyQHWEuPbuaDeMJajmZsivMyjoTwFWBaqhXQAKs8wfvxq+fJhEbbX1BcemA3s1NF 1tziicRX48qMaC4EGKRYKKIceKxSd2espRTsxK+SECDdcuj8eUFk7WQF+bb24dbCNn8w /qZoWMScNvKyIZiP3DF7zVOitL3LMGI0+JvPCecquc67gQmISwu1eGyz8i2lBc1kbxmv FbNyEua/5n4B8M1IV/zwO7eP6TVNAjrmTh4OsffcPGXyhw2khTKkEcoUAsiAzMHewhnx SKMSh4ztE+wFWAlJstBZqIweogXewlcGs/Fl6qn6mfgvle7mVIxqKe8cSJcM/TB1tDfw l1qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=c1xI3XHK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t22-20020aa7d716000000b004accbc7602bsi8052682edq.235.2023.02.21.18.51.00; Tue, 21 Feb 2023 18:51:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=c1xI3XHK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbjBVCut (ORCPT + 99 others); Tue, 21 Feb 2023 21:50:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231714AbjBVCuo (ORCPT ); Tue, 21 Feb 2023 21:50:44 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 479EB33471 for ; Tue, 21 Feb 2023 18:50:35 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id v1-20020a9d6041000000b0068d4a8a8d2dso1271923otj.12 for ; Tue, 21 Feb 2023 18:50:35 -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=iYQczpT79PTbEjGIzJvPn9MrBX8x3jsr9V1QdIDBFYgUczCrHNtZeS6lexsbL6saay +e/EYKfY/h2CTWAwEngaISqSAd9x0vupeGcKJrlOJIFKyqU0Znkhv+Jz2l6fu68fRZwr 4BvC6AApEuYpEMvlHDeiPZqLWYURzOzCxm5NEZNu1GiKc2E0XmMosJIH6415wehjj5so tA5rE/LYm4GBRglmlyIBp2CX9AmLbinT5g5hfPgSNzYCIyvPE5C1Rpeiz8hK9m29GlCO 5Oc6E9tN1UvqV4OZxTAIFLKA9bld6FcGF2FZ+QTX9WMZq31IXmRNTeS1RRaJ7OystEQx WX9w== X-Gm-Message-State: AO0yUKXL7H9uWV0SSv1pzG3drU4MmzW0+G228H8zXKkzSBzU52ZOTT+k 4fw7W0PndHr0f2AJEulv42k= 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 Cc: Yury Norov , Arnd Bergmann , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Jeremy Kerr , Jakub Kicinski , Valentin Schneider , Dietmar Eggemann , Barry Song 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758497903406762915?= X-GMAIL-MSGID: =?utf-8?q?1758497903406762915?= 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))