linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Travis <travis@sgi.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Ingo Molnar <mingo@elte.hu>, David Miller <davem@davemloft.net>,
	Paul Mackerras <paulus@samba.org>,
	Martin Schwidefsky <schwidefsky@googlemail.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Tony Luck <tony.luck@intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-next@vger.kernel.org
Subject: Re: [PATCH 1/1] cpumask: force nr_cpumask_bit to NR_CPUS for CPUMASK_OFFSTACK=n
Date: Thu, 11 Dec 2008 15:10:52 -0800	[thread overview]
Message-ID: <49419DFC.2090501@sgi.com> (raw)
In-Reply-To: <49417B99.7090004@sgi.com>

Mike Travis wrote:
> Re: cpumask conversions, or not?
> 
> Rusty Russell wrote:
>> On Tuesday 09 December 2008 21:26:36 Mike Travis wrote:
>>> Rusty Russell wrote:
>>>> Hi all,
>>>>
>>>>    The new cpumask conversions are going well, but unfortunately Stephen
>>>> uncovered a nasty bug via linux-next: the new cpumask operators only go to
>>>> nr_cpumask_bits which can be less than NR_CPUS if NR_CPUS > BITS_PER_LONG.
>>>> The undefined bits confuse the old cpumask operators.  We fixed one case,
>>>> but I am concerned that we will break archs as we convert more core code.
>>> Hi Rusty,
>>>
>>> I think we can avoid this problem if we make cpumask_bits == NR_CPUS iff
>>> CONFIG_CPUMASK_OFFSTACK=n.  This complies with the current cpumask_t
>>> approach and should cause all cpumask operators to always operate on
>>> all cpumask bits.
>> A very good point.  And it's no worse than the old method.
>>
>> OK, forget about this for now, no urgent conversions needed :)
>> Rusty.
> 
> This probably should be submitted through linux-next for wider test coverage?
> 
> Thanks,
> Mike
> ---
> cpumask: force nr_cpumask_bits to be NR_CPUS when CPUMASK_OFFSTACK is false
> 
> This maintains compatibility with the current cpumask_t.  Once an architecture
> is "cpumask clean" [IOW, all references span 0..(nr_cpus_ids-1) only, ignoring
> any bits >= nr_cpu_ids], then it can set CPUMASK_OFFSTACK=y.
> 
> Signed-off-by: Mike Travis <travis@sgi.com>
> ---
>  include/linux/cpumask.h |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> --- linux-2.6-for-ingo.orig/include/linux/cpumask.h
> +++ linux-2.6-for-ingo/include/linux/cpumask.h
> @@ -510,9 +510,6 @@ extern cpumask_t cpu_active_map;
>  	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD	\
>  }
>  
> -/* This produces more efficient code. */
> -#define nr_cpumask_bits	NR_CPUS
> -
>  #else /* NR_CPUS > BITS_PER_LONG */
>  
>  #define CPU_BITS_ALL						\
> @@ -521,9 +518,20 @@ extern cpumask_t cpu_active_map;
>  	[BITS_TO_LONGS(NR_CPUS)-1] = CPU_MASK_LAST_WORD		\
>  }
>  
> -#define nr_cpumask_bits	nr_cpu_ids
>  #endif /* NR_CPUS > BITS_PER_LONG */
>  
> +#ifndef CONFIG_CPUMASK_OFFSTACK
> +
> +/* This produces more efficient code. */
> +#define nr_cpumask_bits	NR_CPUS
> +
> +#else
> +
> +/* This allows for variabled-sized cpumask's */
> +#define nr_cpumask_bits	nr_cpu_ids
> +
> +#endif
> +
>  /* verify cpu argument to cpumask_* operators */
>  static inline unsigned int cpumask_check(unsigned int cpu)
>  {

I wonder if we should not jump immediately to "variable-sized" cpumasks,
even for CPUMASK_OFFSTACK=y?  That way we could reap the benefits of
allocating the cpumask's on demand, without the restriction that all
code that touches the cpumask is "cpumask clean"?  In other words,
perhaps this would be the right approach:

#ifdef CONFIG_ARCH_HAS_VARIABLE_CPUMASKS
#define nr_cpumask_bits	nr_cpu_ids
#else
#define nr_cpumask_bits	CONFIG_NR_CPUS
#endif

static inline size_t cpumask_size(void)
{
	return BITS_TO_LONG(nr_cpumask_bits) * sizeof(LONG);
}

Then when the code is verified that the cpumasks are handled correctly by
all functions that reference these cpumasks, then ARCH_HAS_VARIABLE_CPUMASKS
can be set?

Thanks,
Mike

  reply	other threads:[~2008-12-11 23:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200812082136.33212.rusty@rustcorp.com.au>
     [not found] ` <493E4EE4.6010609@sgi.com>
     [not found]   ` <200812101019.42908.rusty@rustcorp.com.au>
2008-12-11 20:44     ` [PATCH 1/1] cpumask: force nr_cpumask_bit to NR_CPUS for CPUMASK_OFFSTACK=n Mike Travis
2008-12-11 23:10       ` Mike Travis [this message]
2008-12-13  9:55       ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49419DFC.2090501@sgi.com \
    --to=travis@sgi.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=ralf@linux-mips.org \
    --cc=rusty@rustcorp.com.au \
    --cc=schwidefsky@googlemail.com \
    --cc=sfr@canb.auug.org.au \
    --cc=tony.luck@intel.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).