Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1925711rdb; Thu, 7 Dec 2023 12:39:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGWogLly1AgVpPBaw1FhyHSBxaiC0tR/3CLVMyc5F5uZIjZNyaCqo7m54InREXAEj3ejWl X-Received: by 2002:a05:6a20:a39c:b0:18b:ec92:5aa5 with SMTP id w28-20020a056a20a39c00b0018bec925aa5mr2507034pzk.23.1701981563735; Thu, 07 Dec 2023 12:39:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701981563; cv=none; d=google.com; s=arc-20160816; b=jumTJ93ISHpCRNeN8Xj5DqarPqyx7sCtatQggT2zpWDh0RBn9zWWTav3Ll14oIVm8v /vPNLU7SYNbpkeqLKAKKKKSK9Yp6K2Mnpar+UM+bUaRVdOLt1ueU6jOJNwAymAkw5nns rAzlXVfah6apdkOBlptU5dg5Jf94ozIa9gN4BFAd1jO4oCdgEZyqnZot19YWOweXWpEg /4AGAlVDsirA6lg+unMWibmydAvEMvRAy8F8rT9ImIOEiwutkfRa9E5iHKk34xSPcaf+ 8sIrwuVF+w2wlmnSb5qEwXqsY9merWRyfEDeuzZJl8VfGyI/e6RIoLNj3PurcUAo4U58 MEfA== 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=t+ncE/Ke8W/9eSicUFGfjAMk7XfHt6TzmaC+XB67O8c=; fh=1BoNDGd05aaAMfPxVJ9+hJFzTAErL73yhXGdigwpwQY=; b=ijBE2lLzwK/lf0KOYphfBgdRsE5Dvv5VrJnRzqeaBAXXTs7kDGLo3R3xZJ4y3pGz/r 3wsNMEsrVxv96rK7euq1X7bwVo4UwV9ZZb0Xwikvdg90NH2lEnQCnwtI7cUax2d3brFA YpxIjr7aiujOrTGp+QTFJt/cDPMojgZCYKW7Em7VB5vBwRaQbhh28wjmI0NnTFxB2F52 b2FevdQESfN8FPxV+zOpL+XyEiiYoxmnP/+vAxJY955obqR6R9yI9HiVpS49ARcRPHZA iDK27NCxTiIHR0rKtsphKhb3A2EiOkKz4U6jHRG6k7++MpM9CFZHqFJaf/WlOSLO0SSz O+Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Mn6cD47I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m9-20020a056a00080900b006cb75e1d713si152713pfk.193.2023.12.07.12.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Mn6cD47I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9CED7814970D; Thu, 7 Dec 2023 12:39:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443911AbjLGUjB (ORCPT + 99 others); Thu, 7 Dec 2023 15:39:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbjLGUi6 (ORCPT ); Thu, 7 Dec 2023 15:38:58 -0500 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5EB11713 for ; Thu, 7 Dec 2023 12:39:04 -0800 (PST) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-5d226f51f71so12440627b3.3 for ; Thu, 07 Dec 2023 12:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701981544; x=1702586344; darn=vger.kernel.org; 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=t+ncE/Ke8W/9eSicUFGfjAMk7XfHt6TzmaC+XB67O8c=; b=Mn6cD47IEGNhYiJtgTi0Q/J42HOq51Rzpy9lsf1AA5BwEhob3wSOLyCoocML3DAXIq l7zLIztB116RuBHtxHVYsM5P+TtgFrb2Qxubla34kugzXgWtajUVoR7qXgPcA+o4yvcW eIkT2TMoZdFeUDW+HFKM4JIotiZ+3jWmmNMjGhj1pxLCfw1pOrbgfT3Wx9WuWOPkZopJ HWiAP09C2IJRrDA+KBWlEmDDWUYr2qIy383rF1/S2/jVBtUc9fDg63AHKK7lC5UsWU6E AdbIdXv9lpMiht8RLk4pmUN6f0kQVXqsPOyXWepQrRTw3S4m68LWHErWN2m6uM19v2lZ 5/Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701981544; x=1702586344; 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=t+ncE/Ke8W/9eSicUFGfjAMk7XfHt6TzmaC+XB67O8c=; b=KN6Gxw7kIJeZAd49Q3LYMlmjydxPk72CVpOk/jkEgAhQjX8I7cYX6S66LfLwctejU9 jjEfkweBE8k7jfIlHC4gVFsnr31eLCBRxF31yA6NBAW9N2VnvybqLf1krfVJo/H/W2Rk B4pHe0SNonp1gK8zDc0wlwXlbzpPvmP7imq2DPW+ho892vW8X7TDhLiJ0tKIhQi0Xff8 MzmaHXBP/qhRlTYJ20R1aZQNZ0ekJ9puF4EG4TSu/J6nLTjMFoB8IfQSou/lFUH86Wtj oA/sGIQi/A8G8mrqYOOHyQX0bUvZdjA7TAexBx94mopaC1ZSv1uFa4znQYUkC8R+3lek 1gpg== X-Gm-Message-State: AOJu0Yysj9lsNjiu0NlEogAn4/cJEFZKEvgKafN/Vwb+A129aE9p0lDu lQEHqsdDoBMm1WLRMd6AZsY= X-Received: by 2002:a81:574f:0:b0:5d7:545e:3bda with SMTP id l76-20020a81574f000000b005d7545e3bdamr2499373ywb.20.1701981543874; Thu, 07 Dec 2023 12:39:03 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:8f7f:efcd:5388:af4f]) by smtp.gmail.com with ESMTPSA id m132-20020a81718a000000b005d4071e3adasm144853ywc.57.2023.12.07.12.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 12:39:03 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , linux-kernel@vger.kernel.org Cc: Yury Norov , Ming Lei , Andy Shevchenko , Rasmus Villemoes Subject: [PATCH v2 1/6] cpumask: introduce for_each_cpu_and_from() Date: Thu, 7 Dec 2023 12:38:55 -0800 Message-Id: <20231207203900.859776-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231207203900.859776-1-yury.norov@gmail.com> References: <20231207203900.859776-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 12:39:20 -0800 (PST) Similarly to for_each_cpu_and(), introduce a for_each_cpu_and_from(), which is handy when it's needed to traverse 2 cpumasks or bitmaps, starting from a given position. Signed-off-by: Yury Norov --- include/linux/cpumask.h | 11 +++++++++++ include/linux/find.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index cfb545841a2c..73ff2e0ef090 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -332,6 +332,17 @@ unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int sta #define for_each_cpu_and(cpu, mask1, mask2) \ for_each_and_bit(cpu, cpumask_bits(mask1), cpumask_bits(mask2), small_cpumask_bits) +/** + * for_each_cpu_and_from - iterate over every cpu in both masks starting from a given cpu + * @cpu: the (optionally unsigned) integer iterator + * @mask1: the first cpumask pointer + * @mask2: the second cpumask pointer + * + * After the loop, cpu is >= nr_cpu_ids. + */ +#define for_each_cpu_and_from(cpu, mask1, mask2) \ + for_each_and_bit_from(cpu, cpumask_bits(mask1), cpumask_bits(mask2), small_cpumask_bits) + /** * for_each_cpu_andnot - iterate over every cpu present in one mask, excluding * those present in another. diff --git a/include/linux/find.h b/include/linux/find.h index 5e4f39ef2e72..dfd3d51ff590 100644 --- a/include/linux/find.h +++ b/include/linux/find.h @@ -563,6 +563,9 @@ unsigned long find_next_bit_le(const void *addr, unsigned (bit) = find_next_and_bit((addr1), (addr2), (size), (bit)), (bit) < (size);\ (bit)++) +#define for_each_and_bit_from(bit, addr1, addr2, size) \ + for (; (bit) = find_next_and_bit((addr1), (addr2), (size), (bit)), (bit) < (size); (bit)++) + #define for_each_andnot_bit(bit, addr1, addr2, size) \ for ((bit) = 0; \ (bit) = find_next_andnot_bit((addr1), (addr2), (size), (bit)), (bit) < (size);\ -- 2.40.1