From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A970223244D for ; Tue, 14 Jan 2025 15:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736866991; cv=none; b=lMRQxAqeBwJ/f1OyjFDDK2+nQ0UutQReLt6HVvB+EbD3MnS0i8hyzeNg7qPvVRSG4S/FRboR+w68fdy53/xdZ2VLBI2o1rrDKvzeEiU1JUIQlZbDjYsKIU4s7INdWyjPMAqm1PnpufbPtHgbWbyfoCuvp2Cgyn0xRUIT1ukg104= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736866991; c=relaxed/simple; bh=snpVoGEM/MHxSesGpSgkB6oYxqjsYVkT+3fg4XMnes8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=obqMYDewoHlAjBcq8xUMEyTC1MZt0rzWNr+OxLLzty4qAtPdxvG0Sn3vRebf7m2NGL/xRhgOG+Z+KPKrFLoxj3jP52s2xtDaXgtS/9n6XZVseANOz1IcE2SAb8xy94PlK/84LzCELFd3OXcMAMnqJojZtl6+saOzkOyxBk5Q1sM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 716A911FB; Tue, 14 Jan 2025 07:03:31 -0800 (PST) Received: from J2N7QTR9R3.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF3893F673; Tue, 14 Jan 2025 07:03:01 -0800 (PST) Date: Tue, 14 Jan 2025 15:02:59 +0000 From: Mark Rutland To: I Hsin Cheng Cc: Yury Norov , linux@rasmusvillemoes.dk, jserv@ccns.ncku.edu.tw, linux-kernel@vger.kernel.org, visitorckw@gmail.com Subject: Re: [RFC PATCH] cpumask: Implement "random" version of cpumask_any_but() Message-ID: References: <20250113061839.22131-1-richard120310@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jan 14, 2025 at 03:15:43PM +0800, I Hsin Cheng wrote: > On Mon, Jan 13, 2025 at 01:00:56PM -0500, Yury Norov wrote: > > On Mon, Jan 13, 2025 at 11:05:19AM +0000, Mark Rutland wrote: > > > On Mon, Jan 13, 2025 at 02:18:39PM +0800, I Hsin Cheng wrote: > > > > Original implementation of "cpumask_any_but()" isn't actually random as > > > > the comment claims itself to be. It's behavior is in fact to select the > > > > first cpu in "mask" which isn't equal to "cpu". > > > > > > What it says specifically is: > > > > > > cpumask_any_but - return a "random" in a cpumask, but not this one. > > > > > > ... and by "random", it really means "arbitrary". > > > > > > The idea here is that the caller is specifying that it doesn't care > > > which specific CPU is chosen, but this is not required to be a random > > > selection. > I now realize "random" here is more of a convention for the caller to > states that it doesn't matter which cpu it gets, maybe we should > rephrase the comment to make it less confusing? Because I think "random" > itself does stands for a particular meaning. FWIW, I agree. I reckon (as above), we could replace "random" with arbitrary, i.e. replace return a "random" cpu in a cpumask ... ... with: return an arbitrary cpu in a cpumask ... Looking again I see that the comment for cpumask_any_but() misses the word "cpu" too, so it'd be nice to clean that up regardless. Mark.