From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169AbYEKPZL (ORCPT ); Sun, 11 May 2008 11:25:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752466AbYEKPY6 (ORCPT ); Sun, 11 May 2008 11:24:58 -0400 Received: from palinux.external.hp.com ([192.25.206.14]:50466 "EHLO mail.parisc-linux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752015AbYEKPY5 (ORCPT ); Sun, 11 May 2008 11:24:57 -0400 Date: Sun, 11 May 2008 09:24:40 -0600 From: Matthew Wilcox To: Alexander van Heukelum Cc: Andrew Morton , Paul Jackson , Ingo Molnar , Thomas Gleixner , linux-arch , LKML , heukelum@fastmail.fm Subject: Re: [PATCH] Make for_each_cpu_mask a bit smaller Message-ID: <20080511152440.GX19219@parisc-linux.org> References: <20080511135039.GA3286@mailshack.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080511135039.GA3286@mailshack.com> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 11, 2008 at 03:50:39PM +0200, Alexander van Heukelum wrote: > #if NR_CPUS > 1 > -#define for_each_cpu_mask(cpu, mask) \ > - for ((cpu) = first_cpu(mask); \ > - (cpu) < NR_CPUS; \ > - (cpu) = next_cpu((cpu), (mask))) > +#define for_each_cpu_mask(cpu, mask) \ > + for ((cpu) = 0; \ > + (cpu) = find_next_cpu_mask((cpu), &(mask)), \ > + (cpu) < NR_CPUS; (cpu)++) For anyone else having similar cognitive dissonance while reading this thinking "But won't the first call to find_next_cpu_mask return a number > 0", the answer is "no, find_next_bit returns the next set bit that's >= the number passed in, which is why we need both the cpu++ and find_next_cpu_mask". > +int find_next_cpu_mask(int n, const cpumask_t *srcp) > +{ > + return find_next_bit(srcp->bits, NR_CPUS, n); > +} > +EXPORT_SYMBOL(find_next_cpu_mask); Maybe a better name for this function would help. I can't think of a good one right now though. -- Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."