Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp590426ybz; Wed, 15 Apr 2020 14:41:11 -0700 (PDT) X-Google-Smtp-Source: APiQypKJgFHiV4pGY4my7/kXFMhAvLtSaKzyDY5mxDdk9qm/s+8yk87l8pQJYoaxnS8+gpqNo+pl X-Received: by 2002:a05:6402:221c:: with SMTP id cq28mr8678663edb.50.1586986870908; Wed, 15 Apr 2020 14:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986870; cv=none; d=google.com; s=arc-20160816; b=JcKjDzScb7xdIo6kF1ZBVFd3osN/2JZbuepCwzjgiWyBrJpyeRKJOwnzlqEGBzxUxJ WxBnrYlLhPrmZRA73Bhg7t8WuGRxICMlZaZTOYhTgHzevcDBWBsohqbb+3h9ah4LNwLV JiO4D4UcS7/EqqW2/JnJSSVNmlg6G6+m2v1R2QLM/maT9eL0ERPhxnB7NtXO14sn1W/t K38asEexa/9tuRHOEog9eZJqI19I74Yoo2c3uQo1N3mfUESY2KJR1O9789OuTu6rt557 OxlFLjEpMBUQITLoxoq6qobmqjGfKDN83HzcG3zPafr5bdH45Fm59e4L+NumDI9Tj6k/ OJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=cw+3RQjlTqDDz3EbdVrE7ixVTej/ehw+ZaL23WvtHao=; b=pa0yx0+BJ7ByxT1IXDhq6Z/gTLIIrX/G+8hb9MqE4rJ3C7tHcxY2NnUb9les7AJMzg tDgClTAh+G7C+AV6K887TsassoMeSi4CslEHPjVYeNb3QS8nYUm4yk/gWkA/K+vVwvhm jljKXV3dmOG/zHX90w5TvYS+3PUXqbDndvigcccW3wMS0lYX6C3CV9T0G8xRJ9fA+Cnq jLktdK+UzE3oiheHDF46JNzDOGf1lbyelxwreOkZcT6Ty8XaPkJNRhTMqtKdT1YPhQnx aqHSkpzPCfMetKY+NvuvBLSBbPUHhyM392hWk/QnyERlXtKQv6KRQ/3bbq2GFqiSdCOP A7LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si10849476ejj.432.2020.04.15.14.40.47; Wed, 15 Apr 2020 14:41:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440186AbgDNPHR (ORCPT + 99 others); Tue, 14 Apr 2020 11:07:17 -0400 Received: from foss.arm.com ([217.140.110.172]:57686 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407297AbgDNPGu (ORCPT ); Tue, 14 Apr 2020 11:06:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 264B5101E; Tue, 14 Apr 2020 08:06:49 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 10E7E3F73D; Tue, 14 Apr 2020 08:06:46 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra Cc: Qais Yousef , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Andrew Morton , Thomas Gleixner , Yury Norov , Paul Turner , Alexey Dobriyan , Josh Don , Pavan Kondeti , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] cpumask: Convert cpumask_any_but() to the new random function Date: Tue, 14 Apr 2020 16:05:55 +0100 Message-Id: <20200414150556.10920-4-qais.yousef@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200414150556.10920-1-qais.yousef@arm.com> References: <20200414150556.10920-1-qais.yousef@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cpumask_any() and cpumask_any_and() are now truly, move the cpumask_any_but() to behave in a similar manner. Signed-off-by: Qais Yousef CC: Juri Lelli CC: Vincent Guittot CC: Dietmar Eggemann CC: Steven Rostedt CC: Ben Segall CC: Mel Gorman CC: Andrew Morton CC: Thomas Gleixner CC: Yury Norov CC: Paul Turner CC: Alexey Dobriyan CC: Josh Don CC: Pavan Kondeti CC: linux-kernel@vger.kernel.org --- include/linux/cpumask.h | 2 +- lib/cpumask.c | 44 ++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 7fb25d256043..f04e983e9dd0 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -254,10 +254,10 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp) } int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *); -int cpumask_any_but(const struct cpumask *mask, unsigned int cpu); unsigned int cpumask_local_spread(unsigned int i, int node); int cpumask_any(const struct cpumask *srcp); int cpumask_any_and(const struct cpumask *src1p, const struct cpumask *src2p); +int cpumask_any_but(const struct cpumask *srcp, unsigned int cpu); /** * for_each_cpu - iterate over every cpu in a mask diff --git a/lib/cpumask.c b/lib/cpumask.c index bcac63e45374..0295cf5486ab 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -42,26 +42,6 @@ int cpumask_next_and(int n, const struct cpumask *src1p, } EXPORT_SYMBOL(cpumask_next_and); -/** - * cpumask_any_but - return a "random" in a cpumask, but not this one. - * @mask: the cpumask to search - * @cpu: the cpu to ignore. - * - * Often used to find any cpu but smp_processor_id() in a mask. - * Returns >= nr_cpu_ids if no cpus set. - */ -int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) -{ - unsigned int i; - - cpumask_check(cpu); - for_each_cpu(i, mask) - if (i != cpu) - break; - return i; -} -EXPORT_SYMBOL(cpumask_any_but); - /** * cpumask_next_wrap - helper to implement for_each_cpu_wrap * @n: the cpu prior to the place to search @@ -283,3 +263,27 @@ int cpumask_any(const struct cpumask *srcp) return next; } EXPORT_SYMBOL(cpumask_any); + +/** + * cpumask_any_but - return a "random" in a cpumask, but not this one. + * @srcp: the cpumask to search + * @cpu: the cpu to ignore. + * + * Often used to find any cpu but smp_processor_id() in a mask. + * Returns >= nr_cpu_ids if no cpus set. + */ +int cpumask_any_but(const struct cpumask *srcp, unsigned int cpu) +{ + unsigned int i; + + cpumask_check(cpu); + + for_each_cpu(i, srcp) { + i = cpumask_any(srcp); + if (i != cpu) + return i; + } + + return nr_cpu_ids; +} +EXPORT_SYMBOL(cpumask_any_but); -- 2.17.1