From patchwork Sat Jan 21 04:24: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: 46768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp567086wrn; Fri, 20 Jan 2023 20:26:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXt2ofYxPIV2NBZTQXv/IdjSQlTK6aTfBnRgjHSQJUVo5LH+1tnFU+8YOsZWOyzy+DQzIYte X-Received: by 2002:aa7:cd89:0:b0:49d:14cf:5f4a with SMTP id x9-20020aa7cd89000000b0049d14cf5f4amr17606320edv.39.1674275196750; Fri, 20 Jan 2023 20:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674275196; cv=none; d=google.com; s=arc-20160816; b=PoDxGz5ORsRBktYRueZBtzXrkYaks80MKQL6e6gqRAnkItouqKaf1DSkHFFSc++O0y plAyZQoYQkGBphJ6twuQNDy1sWmAKDjtCo+y6nvjbikyPeB4QDB+FecAW+OUUMrk6Fgu 5hJni6OpkKtjscOTU1iJmU2M7Pl4kmzbbEP/Bl8Vjq9vbYyZAwuR8El4HhguN4EFEzih sfImHBfjzsbeGC15ALtT9EecPNmd2fF7Z/JGEqHARcyNgQPxmPfm4Jb09njjZGryZadj W8sC5GTI1cUD/MpiodT+Bl/OETiI6o97e32NAYDVT/C3yx1FVVI+Al4tZv6bl9RUp/3k llbA== 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=WJDoNgHHINrCbuwq1iSTb+uK/rqsM0fqmFaN0vHyvak=; b=Oepw9UC14V6f7kjQJyv/MG9AXoGl6hGoZ9cipaBLU9EjmerLZhKlKIm8pTDbB9rkPF 1j65+p+htSXrnYH/SwN6YwVQuLqaOE1fcpG7m4hlJfwu9qlS5dt+dVPxBzxfmFaQtkkG mbkjr+PNhErd9Ojn7lEqiQWHGLp2JeKOaY7mBYNAD3Q8OVoJo+pVjLnOUAmqNkYFqzAV 9Wze2Vx/yaVmOi0VPgZzbojZ9jjpiezw1MZxWOB55NXZScsX42G5tMC5umco3ElkJsnD sIl4PM5HDn8X+loZHS/X5SSLgK0CDOVfJwFANQ4knlEwxUFNhM7Z/0l0o7FUoHhTz3Cx nGgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jqhz0cRY; 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 dk10-20020a0564021d8a00b0049e0440d49esi13968628edb.29.2023.01.20.20.26.13; Fri, 20 Jan 2023 20:26:36 -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=Jqhz0cRY; 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 S229907AbjAUEZL (ORCPT + 99 others); Fri, 20 Jan 2023 23:25:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjAUEYq (ORCPT ); Fri, 20 Jan 2023 23:24:46 -0500 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B290D4FCF8; Fri, 20 Jan 2023 20:24:43 -0800 (PST) Received: by mail-qv1-xf2d.google.com with SMTP id j9so5243825qvt.0; Fri, 20 Jan 2023 20:24:43 -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=WJDoNgHHINrCbuwq1iSTb+uK/rqsM0fqmFaN0vHyvak=; b=Jqhz0cRYfCQpS/zjF90KMvOTK02E3o9qpdRZlGwEW4cocE3H5NsKl2zJaBwazrc3XK sPBzcj/azPDRhd6MJnoywMNrFUUwuBBNUI+rnM2CL4aNLGSv0W/mmmuuzOE05/dVpMUS 1m0NfxS72zjlo5IinxUwwd1vpCR/Wj5yp/cyRLpFCP6NwBt2VdtftCn7Nzxa7UBOpM4z Nby+cBRpwvkBTsi0rhpJrcsiEF1izLkf1yDoDwk3gm7ElZSla8KKA+QIGGwKloBSaUBL NxbYs0DTgbqoxFuxM8e+Ut8VsVXH/yzsJjrgb0ytgZ5pqUIEWhO/a7mzI6wSNUDxAJDC tvkw== 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=WJDoNgHHINrCbuwq1iSTb+uK/rqsM0fqmFaN0vHyvak=; b=4gxf498YG70mfiEPI90ty1Nm0pB5/iDSF508uVE6EYFnIG3HxtLr5ZPx2hVhd9jCDY UWC+0K4qLAlk0eCYQD/33XWY57aK1CsQUleKkY/xMAxu1GePTqVqKreUluJfCRkamxSH xyujwQWJVD/fUDdqEpXg4ullbIx5Jzfl6KZ2lIvM2jzDtbk0XiFyysD3lsvzI2ME6LRr sVu27LA2GAjwx1Fh6ehsGaj91IKVkRrNkOBi45k1NSftcbGiNTF7dy6uZ2VrJ06UYd3x Zz+5aqaVx/IBxatVkUEe2EmxmW+9xErcYnpOmtwwPR9XikuKwv6IZCec/JC2n+tQL4Tq lHbA== X-Gm-Message-State: AFqh2kpv7w/aIhpJ/5t9ZmZf6++2Pf1VLBS8yX6wzG9N2tiP22UTrTJE BB0+x2erNucI0nHFr0fv073mpSpzh0Q= X-Received: by 2002:a0c:e8c4:0:b0:534:7cf3:44b4 with SMTP id m4-20020a0ce8c4000000b005347cf344b4mr24906622qvo.50.1674275082339; Fri, 20 Jan 2023 20:24:42 -0800 (PST) Received: from localhost (50-242-44-45-static.hfc.comcastbusiness.net. [50.242.44.45]) by smtp.gmail.com with ESMTPSA id c5-20020a05620a268500b006e8f8ca8287sm22782385qkp.120.2023.01.20.20.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 20:24:41 -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 2/9] cpumask: introduce cpumask_nth_and_andnot Date: Fri, 20 Jan 2023 20:24:29 -0800 Message-Id: <20230121042436.2661843-3-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?1755604788583229228?= X-GMAIL-MSGID: =?utf-8?q?1755604788583229228?= Introduce cpumask_nth_and_andnot() based on find_nth_and_andnot_bit(). It's used in the following patch to traverse cpumasks without storing intermediate result in temporary cpumask. Signed-off-by: Yury Norov Acked-by: Tariq Toukan Reviewed-by: Jacob Keller Reviewed-by: Peter Lafreniere --- include/linux/cpumask.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index c2aa0aa26b45..7b16aede7ac5 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -391,6 +391,26 @@ unsigned int cpumask_nth_andnot(unsigned int cpu, const struct cpumask *srcp1, nr_cpumask_bits, cpumask_check(cpu)); } +/** + * cpumask_nth_and_andnot - get the Nth cpu set in 1st and 2nd cpumask, and clear in 3rd. + * @srcp1: the cpumask pointer + * @srcp2: the cpumask pointer + * @srcp3: the cpumask pointer + * @cpu: the N'th cpu to find, starting from 0 + * + * Returns >= nr_cpu_ids if such cpu doesn't exist. + */ +static __always_inline +unsigned int cpumask_nth_and_andnot(unsigned int cpu, const struct cpumask *srcp1, + const struct cpumask *srcp2, + const struct cpumask *srcp3) +{ + return find_nth_and_andnot_bit(cpumask_bits(srcp1), + cpumask_bits(srcp2), + cpumask_bits(srcp3), + nr_cpumask_bits, cpumask_check(cpu)); +} + #define CPU_BITS_NONE \ { \ [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \