From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753382AbdBFNsY (ORCPT ); Mon, 6 Feb 2017 08:48:24 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:49443 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550AbdBFNsW (ORCPT ); Mon, 6 Feb 2017 08:48:22 -0500 Date: Mon, 6 Feb 2017 14:48:13 +0100 From: Peter Zijlstra To: Mark Rutland Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Andrew Morton , Rusty Russell Subject: Re: [PATCH] cpumask: add cpumask_any_and_but() Message-ID: <20170206134813.GL6515@twins.programming.kicks-ass.net> References: <1486381132-5610-1-git-send-email-mark.rutland@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1486381132-5610-1-git-send-email-mark.rutland@arm.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 06, 2017 at 11:38:52AM +0000, Mark Rutland wrote: > In some cases, it's useful to be able to select a random cpu from the > intersection of two masks, excluding a particular CPU. > > For example, in some systems an uncore PMU is shared by a subset of > CPUs, and management of this PMU is assigned to some arbitrary CPU in > this set. Whenever the management CPU is hotplugged out, we wish to > migrate responsibility to another arbitrary CPU which is both in this > set and online. > > Today we can use cpumask_any_and() to select an arbitrary CPU in the > intersection of two masks. We can also use cpumask_any_but() to select > any arbitrary cpu in a mask excluding, a particular CPU. > > To do both, we either need to use a temporary cpumask, which is > wasteful, or use some lower-level cpumask helpers, which can be unclear. > > This patch adds a new cpumask_any_and_but() to cater for these cases. > > Signed-off-by: Mark Rutland > Cc: Thomas Gleixner > Cc: Andrew Morton > Cc: Peter Zijlstra > Cc: Rusty Russell > Cc: linux-kernel@vger.kernel.org > --- > include/linux/cpumask.h | 3 +++ > lib/cpumask.c | 23 +++++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > This patch would help in cases like the Qualcomm L2 cache PMU driver [1]. If > people are happy with this patch, I'd like to take it along with that patch > (modified to use the new helper). I'm also happy to leave this as a subsequent > cleanup. Have at; looks ok I suppose.