Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp590311ybz; Wed, 15 Apr 2020 14:41:02 -0700 (PDT) X-Google-Smtp-Source: APiQypKD8ewhFCpQ9GHzljEFRpJ1YuwEnAuQNhkknuio3ZDaOrT4X/QsAQ+oY4Z7NVBqP8JUbZrs X-Received: by 2002:a05:6402:4ce:: with SMTP id n14mr13616595edw.32.1586986862720; Wed, 15 Apr 2020 14:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586986862; cv=none; d=google.com; s=arc-20160816; b=XEu/NOxWbQbnTACGDvV7kfY9XRhpivb2qTSFDiYPqrzI5N0Bb+Gba+hHVL2ltPDpVY 6OzWS+qghcsaSdg8Ub3KEE00Y8rzM/AXmZWiiuhU+aFDNlpF2ZxIikMqK1XujPgV6zbf TtwzAaTFU3JDda6+860Bbo5k5Bhk+Xf7n/F+4yX/6lNUW/u4eQNxlzplOvPnS4zbKxt8 joMqq2ukZrRp6NIKOoXxsoSRhBkw4q2GJn9J8S15jux0ukzYkqoWPLX1EM9bm/mHKxO5 xZI4volVPBAzDwPtA41IFyNIpoqNjO6dYksFdxSoTIVJMQqpjGLBU17cl/g7oMWLIDJ9 2oHw== 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=LrLoHIYCXF7m1J4FGSOwikl5YMFUfSz1jYpqrzqlAFM=; b=JUAX/Wcj9H2Fanvlhv6uPJ0K2anc3wyFOGiRjyVpRgBqWA+vD+9E4i6bzbU3hU03KM h62dkMm4jfp98JCY9zWSi344xJwpHuh3SEykXkc7e1it67yoE9LF7ffuJTAAVptuth3o 0Ygnf4DHohXqlEVxLdiqh/eF0fnmB0GXUYdnC45h3ldHBLd7k2FY7j8P9hXCroGsoUED e4a2htbwVHJQc/xdwyA1RsciiPjOlMx+Xtx5dSn2AQoczx9548rloJ/X1dtY4nxAqpqu jT2WkNBdiflepyHnas6eRD07iUaJ5fBg42RWdBLeUsMaPlfeGSSmktMmslAMzg8PxAZb belg== 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 l1si12224732edq.314.2020.04.15.14.40.39; Wed, 15 Apr 2020 14:41:02 -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 S2436487AbgDNPGz (ORCPT + 99 others); Tue, 14 Apr 2020 11:06:55 -0400 Received: from foss.arm.com ([217.140.110.172]:57634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407289AbgDNPGn (ORCPT ); Tue, 14 Apr 2020 11:06:43 -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 7F17031B; Tue, 14 Apr 2020 08:06:42 -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 66F823F73D; Tue, 14 Apr 2020 08:06:40 -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 1/4] cpumask: Rename cpumask_any_and_distribute Date: Tue, 14 Apr 2020 16:05:53 +0100 Message-Id: <20200414150556.10920-2-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 The function is actually an alias of cpumask_any_and(), except that the new function does the randomization and the old implementation didn't. Rename the new function to cpumask_any_and() so that old users can take advantage of its 'enhanced' randomness. 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 | 17 ++++------------- kernel/sched/core.c | 2 +- lib/cpumask.c | 14 ++++++-------- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index f0d895d6ac39..e4d6d140a67c 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -194,8 +194,9 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node) return 0; } -static inline int cpumask_any_and_distribute(const struct cpumask *src1p, - const struct cpumask *src2p) { +static inline int cpumask_any_and(const struct cpumask *src1p, + const struct cpumask *src2p) +{ return cpumask_next_and(-1, src1p, src2p); } @@ -250,8 +251,7 @@ 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_and_distribute(const struct cpumask *src1p, - const struct cpumask *src2p); +int cpumask_any_and(const struct cpumask *src1p, const struct cpumask *src2p); /** * for_each_cpu - iterate over every cpu in a mask @@ -617,15 +617,6 @@ static inline void cpumask_copy(struct cpumask *dstp, */ #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p)) -/** - * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 - * @mask1: the first input cpumask - * @mask2: the second input cpumask - * - * Returns >= nr_cpu_ids if no cpus set. - */ -#define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2)) - /** * cpumask_of - the cpumask containing just a given cpu * @cpu: the cpu (<= nr_cpu_ids) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index c1f923d647ee..7942ebc83e6e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1655,7 +1655,7 @@ static int __set_cpus_allowed_ptr(struct task_struct *p, * for groups of tasks (ie. cpuset), so that load balancing is not * immediately required to distribute the tasks within their new mask. */ - dest_cpu = cpumask_any_and_distribute(cpu_valid_mask, new_mask); + dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask); if (dest_cpu >= nr_cpu_ids) { ret = -EINVAL; goto out; diff --git a/lib/cpumask.c b/lib/cpumask.c index fb22fb266f93..b527a153b023 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c @@ -236,15 +236,13 @@ EXPORT_SYMBOL(cpumask_local_spread); static DEFINE_PER_CPU(int, distribute_cpu_mask_prev); /** - * Returns an arbitrary cpu within srcp1 & srcp2. + * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 + * @mask1: the first input cpumask + * @mask2: the second input cpumask * - * Iterated calls using the same srcp1 and srcp2 will be distributed within - * their intersection. - * - * Returns >= nr_cpu_ids if the intersection is empty. + * Returns >= nr_cpu_ids if no cpus set. */ -int cpumask_any_and_distribute(const struct cpumask *src1p, - const struct cpumask *src2p) +int cpumask_any_and(const struct cpumask *src1p, const struct cpumask *src2p) { int next, prev; @@ -260,4 +258,4 @@ int cpumask_any_and_distribute(const struct cpumask *src1p, return next; } -EXPORT_SYMBOL(cpumask_any_and_distribute); +EXPORT_SYMBOL(cpumask_any_and); -- 2.17.1