From patchwork Sat Jan 21 04:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 46770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp567294wrn; Fri, 20 Jan 2023 20:27:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvKCzOf+fuSeIVe8sBgddE8avIdHVNDO5DSV6Uq8FYNEUMIVUA4C8+w+Wft/X2ycg0uGLYf X-Received: by 2002:a17:907:2bdd:b0:857:b916:94c2 with SMTP id gv29-20020a1709072bdd00b00857b91694c2mr12801210ejc.35.1674275248061; Fri, 20 Jan 2023 20:27:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674275248; cv=none; d=google.com; s=arc-20160816; b=Pmc1BpNL2YpafkxbXqX8KqO2lpOTSmrd4lGI+25D39pr7+OBRmsRSpopg6zFNXhIXg 774NeTSOyfWngEcwgk0G9Yn8FWRECkDXcL9YD1aTg1AVo/FHr0C+qebyuI7VXv7BWR/g PauCOv1Iw4VsrReENhV7Q6Dbtma1MXTj8gt/5S4bxTpxgQjgeEQuUkcw7ZeroGWXViyc 4XOn9BJcktZX8A6cEj/b754MRHQBJggxy8+P6sVUCG/UWtqX4SswDRs2sK8Bi8PVRsnl 9XmJGHFUSpH5NogxFmPfBKBhDirWFRMd+PX0C52/t/UL/PZjBmpc+9EENZseqOevnW4N SOfg== 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=GwdL6i5RDIaOTjKHDRQpPnyPsA8RatFMsU5WrNy3SA0=; b=VzGQB3yFkwrXvvQU61S0lED/RL+LrdhtjX7sxQzgWI56U7QIKBhMve7wbrroC+tVyf mIuYLWoOO64V8+TvGE7WDGXfex/AlHUyavPqDiZX5T/rKbQL8hUzXhHn7rcG+1WC6dI6 /1V+X6kE7Br14BEEpudBhYuMmCVPTeKETkYnWYIwW0g+7LLgh2qcIAVbSPhRwI6BTRJr O1c2uuvK6Dx0eKPrrnWo/qv30xVRB63yn9CVdQ5kC7voEgyRwb+E5qWLXsZz8A4Qer5d lSVd4Di6xiFruVqWwT+qjSFFKBXvBk8hTTObi9Z8skry1DvYvlMgj51nj67fWxCK4FPf J5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lOKIeoFZ; 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 b60-20020a509f42000000b0049eeeff0949si2555276edf.234.2023.01.20.20.27.04; Fri, 20 Jan 2023 20:27:28 -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=lOKIeoFZ; 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 S229782AbjAUEZ1 (ORCPT + 99 others); Fri, 20 Jan 2023 23:25:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229867AbjAUEYs (ORCPT ); Fri, 20 Jan 2023 23:24:48 -0500 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1CB518D6; Fri, 20 Jan 2023 20:24:47 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id o5so5796684qtr.11; Fri, 20 Jan 2023 20:24:47 -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=GwdL6i5RDIaOTjKHDRQpPnyPsA8RatFMsU5WrNy3SA0=; b=lOKIeoFZ2XmWttrm+5mhAr+EoKXQrXKDkyPM0i9zjpJ7oEZ7xf20CcBTFzpC7sbxpP HYGr+UfCS7Y6l0DcfL0vfyfshN+LQYevRg6KS5hazTyVvRIfZ1zOP8onArDxsjjx8szU 1Hi8MUAbBTPnxKBkZ/ri41lTBruU6fn35huesBk939D+g/+bJxbXsov3j2O3od+KvYPW qkJjJmYKbWoMLYP/WnEu3Yl+5uWM/ixSGDHJ28Wj9E/laWGUAySoIIq+Ug+0ONRY4Dlq Gdi129W9RHo8gvEFNm3Bye67FtlnI1xoGS9Zd2kKnJsTpOEJG17fDNPvCNJSSRlyiOW1 BqeQ== 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=GwdL6i5RDIaOTjKHDRQpPnyPsA8RatFMsU5WrNy3SA0=; b=si/SsffpTv9+J57PbXFX82yptkZ0wmcSpiS2O8SaBzyqNbV7UiCgb1tlDjVZxrfuM7 ossxus4MNqDWDAceX5hitbZuvVg+bG/g7N4fgIloYGJ+dl4CA3LTZGUxiWgRZ5uVLpWV AAeliZ504Cf9Q6LMwxjFB0F1bGFMvk24I2F8TLEi5KjyN5hfVajWn9za5TIj57DAXGP7 AcjEQPhRAJRRFiYIc25W+03SkQNIjVXuj+eh4bp8fx0yRChxZkhWxrp+Fwm19qFmh3hN RYlJVqd2xlKhswzrJ4fgnktchm02IPzq19ER4pcxDjGJGj8CDM/ABNfgHJZ7XgMlu6sW MD6A== X-Gm-Message-State: AFqh2krMWxWG+SnLiNOyeinOB9KeHNpVM9EVUtk10oQNNe8XbTK/LqXw woK4YwCL1NW68e4XUXIiV2gOaovAgOs= X-Received: by 2002:ac8:604d:0:b0:39c:da20:f7ac with SMTP id k13-20020ac8604d000000b0039cda20f7acmr23825028qtm.9.1674275086283; Fri, 20 Jan 2023 20:24:46 -0800 (PST) Received: from localhost (50-242-44-45-static.hfc.comcastbusiness.net. [50.242.44.45]) by smtp.gmail.com with ESMTPSA id jt14-20020a05622aa00e00b003adc7f652a0sm17772522qtb.66.2023.01.20.20.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 20:24:45 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, "David S. Miller" , Andy Shevchenko , Barry Song , Ben Segall , Dietmar Eggemann , Gal Pressman , Greg Kroah-Hartman , Haniel Bristot de Oliveira , Heiko Carstens , Ingo Molnar , Jacob Keller , Jakub Kicinski , Jason Gunthorpe , Jesse Brandeburg , Jonathan Cameron , Juri Lelli , Leon Romanovsky , Linus Torvalds , Mel Gorman , Peter Lafreniere , Peter Zijlstra , Rasmus Villemoes , Saeed Mahameed , Steven Rostedt , Tariq Toukan , Tariq Toukan , Tony Luck , Valentin Schneider , Vincent Guittot Cc: Yury Norov , linux-crypto@vger.kernel.org, netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH 5/9] lib/cpumask: reorganize cpumask_local_spread() logic Date: Fri, 20 Jan 2023 20:24:32 -0800 Message-Id: <20230121042436.2661843-6-yury.norov@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230121042436.2661843-1-yury.norov@gmail.com> References: <20230121042436.2661843-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?1755604842574915677?= X-GMAIL-MSGID: =?utf-8?q?1755604842574915677?= Now after moving all NUMA logic into sched_numa_find_nth_cpu(), else-branch of cpumask_local_spread() is just a function call, and we can simplify logic by using ternary operator. While here, replace BUG() with WARN_ON(). Signed-off-by: Yury Norov Acked-by: Tariq Toukan Reviewed-by: Jacob Keller Reviewed-by: Peter Lafreniere --- lib/cpumask.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/cpumask.c b/lib/cpumask.c index 255974cd6734..10aa15715c0d 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -127,16 +127,12 @@ unsigned int cpumask_local_spread(unsigned int i, int node) /* Wrap: we always want a cpu. */ i %= num_online_cpus(); - if (node == NUMA_NO_NODE) { - cpu = cpumask_nth(i, cpu_online_mask); - if (cpu < nr_cpu_ids) - return cpu; - } else { - cpu = sched_numa_find_nth_cpu(cpu_online_mask, i, node); - if (cpu < nr_cpu_ids) - return cpu; - } - BUG(); + cpu = (node == NUMA_NO_NODE) ? + cpumask_nth(i, cpu_online_mask) : + sched_numa_find_nth_cpu(cpu_online_mask, i, node); + + WARN_ON(cpu >= nr_cpu_ids); + return cpu; } EXPORT_SYMBOL(cpumask_local_spread);