kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled
       [not found] <200812072125.45757.rusty@rustcorp.com.au>
@ 2008-12-07 15:55 ` Avi Kivity
  2008-12-08  6:05   ` Rusty Russell
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2008-12-07 15:55 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kvm-devel, linux-kernel, Mike Travis, Avi Kivity

Rusty Russell wrote:
> This changes cpus_hardware_enabled from a cpumask_t to a cpumask_var_t:
> equivalent for CONFIG_CPUMASKS_OFFSTACK=n, otherwise dynamically allocated.
>
>  
> -static cpumask_t cpus_hardware_enabled;
> +static cpumask_var_t cpus_hardware_enabled

This isn't on stack, so it isn't buying us anything.

Is the plan to drop cpumask_t?  If so, we're penalizing non-stack users 
by forcing them to go through another pointer (and cacheline).



-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled
  2008-12-07 15:55 ` [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled Avi Kivity
@ 2008-12-08  6:05   ` Rusty Russell
  2008-12-08  9:46     ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2008-12-08  6:05 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel, linux-kernel, Mike Travis

On Monday 08 December 2008 02:25:50 Avi Kivity wrote:
> Rusty Russell wrote:
> > This changes cpus_hardware_enabled from a cpumask_t to a cpumask_var_t:
> > equivalent for CONFIG_CPUMASKS_OFFSTACK=n, otherwise dynamically allocated.
> >
> >  
> > -static cpumask_t cpus_hardware_enabled;
> > +static cpumask_var_t cpus_hardware_enabled
> 
> This isn't on stack, so it isn't buying us anything.

It's the CONFIG_NR_CPUS=4096 but nr_cpu_ids=4 case which we win using
dynamic allocation.  Gotta love distribution kernels.

> Is the plan to drop cpumask_t?

Yes.  And undefine 'struct cpumask' if CONFIG_CPUMASK_OFFSTACK.  That
will stop assignment and on-stack declarations for all but the most
determined.

> If so, we're penalizing non-stack users 
> by forcing them to go through another pointer (and cacheline).

Not quite.  If !CONFIG_CPUMASK_OFFSTACK, cpumask_var_t == cpumask_t[1].
Blame Linus :)

Cheers,
Rusty.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled
  2008-12-08  6:05   ` Rusty Russell
@ 2008-12-08  9:46     ` Avi Kivity
  2008-12-08 11:50       ` Rusty Russell
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2008-12-08  9:46 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kvm-devel, linux-kernel, Mike Travis

Rusty Russell wrote:
>> This isn't on stack, so it isn't buying us anything.
>>     
>
> It's the CONFIG_NR_CPUS=4096 but nr_cpu_ids=4 case which we win using
> dynamic allocation.  Gotta love distribution kernels.
>
>   

What does it buy? 4096/8 = 512 bytes statically allocated?

I understand passing things as pointers, but allocating everything 
dynamically is unCish.

>> Is the plan to drop cpumask_t?
>>     
>
> Yes.  And undefine 'struct cpumask' if CONFIG_CPUMASK_OFFSTACK.  That
> will stop assignment and on-stack declarations for all but the most
> determined.
>
>   
>> If so, we're penalizing non-stack users 
>> by forcing them to go through another pointer (and cacheline).
>>     
>
> Not quite.  If !CONFIG_CPUMASK_OFFSTACK, cpumask_var_t == cpumask_t[1].
> Blame Linus :)
>   

Hm, is there a C trick which will error out when allocating something on 
the stack, but work when allocating statically?  I can think of 
something to do the reverse, but that doesn't help.

Maybe a weak or visibility attribute?  These don't make sense on 
function locals.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled
  2008-12-08  9:46     ` Avi Kivity
@ 2008-12-08 11:50       ` Rusty Russell
  2008-12-08 14:29         ` Mike Travis
  0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2008-12-08 11:50 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel, linux-kernel, Mike Travis

On Monday 08 December 2008 20:16:44 Avi Kivity wrote:
> Rusty Russell wrote:
> >> This isn't on stack, so it isn't buying us anything.
> >>     
> >
> > It's the CONFIG_NR_CPUS=4096 but nr_cpu_ids=4 case which we win using
> > dynamic allocation.  Gotta love distribution kernels.
> >
> >   
> 
> What does it buy? 4096/8 = 512 bytes statically allocated?

It adds up, and 4096 seems to be only the start of the insanityH^H^Hfun.

> > Not quite.  If !CONFIG_CPUMASK_OFFSTACK, cpumask_var_t == cpumask_t[1].
> > Blame Linus :)
> >   
> 
> Hm, is there a C trick which will error out when allocating something on 
> the stack, but work when allocating statically?  I can think of 
> something to do the reverse, but that doesn't help.

We also need to prevent assignment, eg:

	*foo = *bar;

Because when we allocate them, we'll cut them to size.

Cheers,
Rusty.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled
  2008-12-08 11:50       ` Rusty Russell
@ 2008-12-08 14:29         ` Mike Travis
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Travis @ 2008-12-08 14:29 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Avi Kivity, kvm-devel, linux-kernel

Rusty Russell wrote:
> On Monday 08 December 2008 20:16:44 Avi Kivity wrote:
>> Rusty Russell wrote:
>>>> This isn't on stack, so it isn't buying us anything.
>>>>     
>>> It's the CONFIG_NR_CPUS=4096 but nr_cpu_ids=4 case which we win using
>>> dynamic allocation.  Gotta love distribution kernels.
>>>
>>>   
>> What does it buy? 4096/8 = 512 bytes statically allocated?
> 
> It adds up, and 4096 seems to be only the start of the insanityH^H^Hfun.

The real win though is when cpumask_size represents the actual size of the
cpumask (based on # of possible cpus) instead of the pre-configured size
of NR_CPUS.  So for 99.9% of the systems (having 64 or fewer cpus), the
savings will be 504 bytes not allocated.

> 
>>> Not quite.  If !CONFIG_CPUMASK_OFFSTACK, cpumask_var_t == cpumask_t[1].
>>> Blame Linus :)
>>>   
>> Hm, is there a C trick which will error out when allocating something on 
>> the stack, but work when allocating statically?  I can think of 
>> something to do the reverse, but that doesn't help.
> 
> We also need to prevent assignment, eg:
> 
> 	*foo = *bar;
> 
> Because when we allocate them, we'll cut them to size.
> 
> Cheers,
> Rusty.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-08 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200812072125.45757.rusty@rustcorp.com.au>
2008-12-07 15:55 ` [PATCH 2/2] kvm: use cpumask_var_t for cpus_hardware_enabled Avi Kivity
2008-12-08  6:05   ` Rusty Russell
2008-12-08  9:46     ` Avi Kivity
2008-12-08 11:50       ` Rusty Russell
2008-12-08 14:29         ` Mike Travis

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).