Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp118601iof; Sun, 5 Jun 2022 22:56:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8DfLJVvbty5DLdg7dKeINEoqBamGXfvBPjeDsddpgBg9Za2dmEb9x0uojLsNoP3YfgOhq X-Received: by 2002:a17:902:7087:b0:161:88a4:db37 with SMTP id z7-20020a170902708700b0016188a4db37mr22246397plk.131.1654494973498; Sun, 05 Jun 2022 22:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654494973; cv=none; d=google.com; s=arc-20160816; b=oLseoTpL0NKPfpMArYk+YR4ozfxC+NBN0aazPzrN3Qdp1xu3uMjzwtpVYdKYlZvp6S Am/1JAByPe3wwJgt5IHtTF2MRdaY+m1bFYywkyelruH5m2V8sR7TCtvGsinmTq6iaDgJ Z8pD8kyXTyl2p637jYuipl/OVnk0ZqCg0XX53SHdkgiwmj9A2Xloj/4QO7KQ14bLxZJ2 kkLElKCDfPeWSC2Qb47SYQHHwOvnqn7q4hiYmlIPoLQ714KhvsfORjAcDr15Zd7bvAr1 XcLoX0tkg/g93tbBOVwd2W5QUIvM/XbH+o7P93U3t4nabd8tbNu5stC9muahbJ8hygOo bKlg== 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=UmyaFQVp9aEpKb+oKQXkJfXH9xvYY1MiNgw55GvfXww=; b=eSFDb5rwZyoHT+NPSFXRZyzE+60KxJR/8PtA9vQHvzsOZQPywCPVX/gRrTbs55Xrh2 mCfv5z8XSZoqRFGSyEeiCLna2J2tz043eetvxhdwIHk8apoAEVMygrUjysM+sAWsSA5t 7R9QmeSyoyrbav+rNS3aNpXypU8PZl+eVv+bjA2KBMgz7yLazuShYSdJqFyFp3qHvEJs b0BdOPHzXHJ1p6pOswtwGo9cd7SxYuZ/QGLkLBsSYDZWnizGet/prg431vSQRC2Pp9f9 IPBI1IDpX8qrK8ckJC1/Tox1H++fpcoA1Kp8jnLQ9KWer6KJnnbm888Bu82hqkorn3jx 3YGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=IrnXPRgL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u24-20020a631418000000b003c14249f5a1si19856902pgl.410.2022.06.05.22.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:56:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@svanheule.net header.s=mail1707 header.b=IrnXPRgL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svanheule.net Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 875AD2D56FB; Sun, 5 Jun 2022 21:45:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349535AbiFEGXN (ORCPT + 99 others); Sun, 5 Jun 2022 02:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349270AbiFEGW4 (ORCPT ); Sun, 5 Jun 2022 02:22:56 -0400 Received: from polaris.svanheule.net (polaris.svanheule.net [84.16.241.116]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA1E13DFF for ; Sat, 4 Jun 2022 23:22:54 -0700 (PDT) Received: from terra.. (unknown [IPv6:2a02:a03f:eaf9:8401:aa9f:5d01:1b2a:e3cd]) (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) (Authenticated sender: sander@svanheule.net) by polaris.svanheule.net (Postfix) with ESMTPSA id C16BC2E2DA5; Sun, 5 Jun 2022 08:22:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svanheule.net; s=mail1707; t=1654410169; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UmyaFQVp9aEpKb+oKQXkJfXH9xvYY1MiNgw55GvfXww=; b=IrnXPRgL42of0XLHyMhniXuwbzv5JP2LnhHVsMeXwk1yKKQVUjd73E7kvf9k6mOkRrCOHd 9+Kex8z756+YX2Zkz4YcPL3bH+ZOayQbDDirgbrjIg1NTVM8fHDtFFTjabov4VvqTeJoc7 a/7K+e0GghmXPik2iSrykQ4R5NVxAeB6RBdzFdXcynw9sitC1kRBkCq4ZLiTGJZEvQmAN6 4Mh8NxqBzlnwkj0edQaNBaNEzvGw3aRlNKlleVlrsMTB2oz/MRKLnO04ZqGUFHfFu1aOSg VcRm/zgvrQQFcZ0d0r2oGv/yIhblPzVfehfZ7uC9vvR6nH7MJbz3wkRxHDFr7g== From: Sander Vanheule To: Peter Zijlstra , Yury Norov , Andrew Morton , Valentin Schneider , Thomas Gleixner , Greg Kroah-Hartman , Marco Elver Cc: linux-kernel@vger.kernel.org, Andy Shevchenko , Sander Vanheule Subject: [PATCH v3 3/4] cpumask: Add UP optimised for_each_*_cpu versions Date: Sun, 5 Jun 2022 08:22:40 +0200 Message-Id: <4e7b263017a237f2ae0cf6d9a8d05a1ccafe7eaa.1654410109.git.sander@svanheule.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On uniprocessor builds, the following loops will always run over a mask that contains one enabled CPU (cpu0): - for_each_possible_cpu - for_each_online_cpu - for_each_present_cpu Provide uniprocessor-specific macros for these loops, that always run exactly once. Signed-off-by: Sander Vanheule --- include/linux/cpumask.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index d6add0e29ef4..7ccddbc27ac3 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -731,9 +731,16 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); /* First bits of cpu_bit_bitmap are in fact unset. */ #define cpu_none_mask to_cpumask(cpu_bit_bitmap[0]) +#if NR_CPUS == 1 +/* Uniprocessor: the possible/online/present masks are always "1" */ +#define for_each_possible_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++) +#define for_each_online_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++) +#define for_each_present_cpu(cpu) for ((cpu) = 0; (cpu) < 1; (cpu)++) +#else #define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask) #define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask) #define for_each_present_cpu(cpu) for_each_cpu((cpu), cpu_present_mask) +#endif /* Wrappers for arch boot code to manipulate normally-constant masks */ void init_cpu_present(const struct cpumask *src); -- 2.36.1