Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4410986rdb; Mon, 11 Dec 2023 20:21:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhdiLTeG1ivlXBKI5ZXeJiO/y8nVwglp4CJ+7dlHPrjJm27Ditlo/NJpoYvVw42wGvD1en X-Received: by 2002:a05:6808:2390:b0:3b5:6432:e0eb with SMTP id bp16-20020a056808239000b003b56432e0ebmr6742414oib.38.1702354900809; Mon, 11 Dec 2023 20:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702354900; cv=none; d=google.com; s=arc-20160816; b=XMW6XZJtgAO9M4XYIoPJLSrhYr9pvkG7Bt/wgqi2Q8ODPzeFh6Gk1p4bEXdTOsPeHO SOfzdapkMDiLbAKj9e3JOUJcyve6bmQY8C8Za7h205TTR4gK+o47vzWlC3uLxiPovM7G 9yvdNjImYAlouFQt3WFbue1u8BRUyL/yTvonPKCF0BvjQH5uaQZ1tN5/8smx7LeR1kh4 2nwjDoS097D8gP1uB9vr2qoq5tzGMNJtSjuitqpdn1dS74hDjrIge8PtBmgItncBeHKn yqFTc6BXADG9nPNkALPzg1Z1rniudGdj4HpDHgaaSiwV0CA73Yjt36DDgxVx3RBtRMY0 FNgA== 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=kL/RA2Gd9NuQcovU0+7My8qgZ6xDrReyLO6zCGgffAQ=; b=g8iLOyZtLPBH0PMZACEprFeUNaQUajogMlfXs5iHExuHY+H8HoUVrPd8E1E499EWiH Wr2x0eOU0HmuB1hOmFyUJkapLcM5el3oGoupLxs43ojzf0GWdJCK6ctW/kZELs2ITqKk N+GjXnJ0exQ8dLs7MXU1tZhVho5k7mw1mhyvzQgDP8d9lRll62eTD6owSBbOq90FoGak cO3i6ewsvIqiRLnvupkYxgz6oB3cVpjvD1qOJvyjaCn1VS5QOGesIU09qH5uxorW4kID +SFmcsm83xmNei+5vaSuEAatv7NIVXfBg8MWbk9Dg0C/zcgjnZ1WZqJ3dGXEhS0RBy3k l+Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KFhC6+sG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l3-20020a056a00140300b006cd989cfe42si7138499pfu.7.2023.12.11.20.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 20:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KFhC6+sG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 1C946805743E; Mon, 11 Dec 2023 20:21:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229534AbjLLEVJ (ORCPT + 99 others); Mon, 11 Dec 2023 23:21:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbjLLEVG (ORCPT ); Mon, 11 Dec 2023 23:21:06 -0500 Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8100BC for ; Mon, 11 Dec 2023 20:21:12 -0800 (PST) Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5d34f8f211fso51824747b3.0 for ; Mon, 11 Dec 2023 20:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702354872; x=1702959672; 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=KFhC6+sG0Yct0kbrjF8kru2+7eFqJ+jyWXZ8zx09j3ICTxS4R5J7BJwET1Pa/46csG hnRMJDSXiv7080WkfDc6oD1A/X11udEChsOy6yKF8zHOxxwLDWJ+4PXU1uYFbe0boYiu JrAgU1NLoRSBqsFr6LnH/vSq8GS/UgT8T6oP4Bd1Xd2VuDJ8Mw5j5KYJYjoI4vaN4bRA pAG80H6VUw012GJ0to3+X1f1CZp/Su8wdVIpOO9oOZVvIeFnSkH68VggVP0zVO3KAaKW 2PTEZeMM5HZKdOpRt3hiwwCALimP6npekktcCWXVqav/Yx2IcJbGGoTTyoZ9EpgzsKIX Lbsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702354872; x=1702959672; 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=AGRkyAt5vj/8FP1pyssl/6GJS6vkRAaJqWQc/XxSRTnZdo/Ln/0iJDb0Eaf4l1YN6U UD4CMh3uXDnOIboXFjPE+WYPcKrJOdd1rkcJKqTvtoKwPZOcemUdF7nSMUBkln4lV0Ii RVuO5evz5i8UUo/GgKddX//hxvXyeoPadFEa+BupVTzilm6ypXUUjlkSCO3ZRpA82lmR 7Ync0gjXAWqJf3G7dMqell+nUe42YngggrjvpaEW0Oeo7f20ajEWJjk8oMEcQB3KYEnF 8WHQx38JHqBgwXThn8tpAlFdaEo6vqpPDP1qLY9u+d/a1RqJvtMEw6ozwfpjQwcoYdIs NH7Q== X-Gm-Message-State: AOJu0YyzjVBQVdwvw1kHZfC98Mle2ZoVyGkIt/LShYc/NyvJq/S01Tbo bejMCJOAoIu8v25QX3BbaGk= X-Received: by 2002:a81:8357:0:b0:5de:99bb:e94 with SMTP id t84-20020a818357000000b005de99bb0e94mr4783843ywf.5.1702354871979; Mon, 11 Dec 2023 20:21:11 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:38aa:1c88:df05:9b73]) by smtp.gmail.com with ESMTPSA id eo18-20020a05690c2c1200b005e1764a7a33sm612703ywb.52.2023.12.11.20.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 20:21:11 -0800 (PST) From: Yury Norov To: Andrew Morton , Thomas Gleixner , Ming Lei , linux-kernel@vger.kernel.org Cc: Yury Norov , Andy Shevchenko , Rasmus Villemoes Subject: [PATCH v3 1/7] cpumask: introduce for_each_cpu_and_from() Date: Mon, 11 Dec 2023 20:21:01 -0800 Message-Id: <20231212042108.682072-2-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212042108.682072-1-yury.norov@gmail.com> References: <20231212042108.682072-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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 11 Dec 2023 20:21:36 -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