Re: performance differences: "maxcpus=1" vs. "echo 0 > /sys/devices/system/cpu/cpu1/online"

From: Wander Winkelhorst
Date: Tue Mar 25 2008 - 13:49:24 EST


On Tue, Mar 25, 2008 at 6:23 PM, Michael Meyer <mike65134@xxxxxxxx> wrote:
>
> --- Andi Kleen <andi@xxxxxxxxxxxxxx> schrieb:
>
>
> > Luciano Rocha <luciano@xxxxxxxxxxx> writes:
> >
> > > On Tue, Mar 25, 2008 at 02:47:50PM +0100, Michael
> > Meyer wrote:
> > > > Hi,
> > > >
> > > > what is the difference between booting a dual
> > core
> > > > machine with "maxcpus=1" or by deactivating the
> > second
> > > > core at run time with "echo 0 >
> > > > /sys/devices/system/cpu/cpu1/online"?
> > >
> > > maxcpus=1 should turn off the SMP alternative and
> > switch to UP only,
> > > optimising some locks and instructions.
> >
> > CPU hot unplug will do the same. But it is unlikely
> > it accounts
> > for that much performance difference.
> >
> > If he used maxcpus=0 it would make sense. maxcpus=0
> > disables
> > the IO-APIC which likely makes a large difference.
> > But it should
> > be actually slower.
> >
> > There should be actually no difference in theory
> > between max_cpus=1
> > and hot unplug to one CPU. Might be some bug.
>
> I had the following time values:
>
> maxcpus=1:
> real 0m1.642s
> user 0m1.528s
> sys 0m0.068s
>
> maxcpus=2 and
> echo 1 > /sys/devices/system/cpu/cpu1/online:
> real 0m2.579s
> user 0m4.096s
> sys 0m0.160s
>
> maxcpus=2 and
> echo 0 > /sys/devices/system/cpu/cpu1/online:
> real 0m3.757s
> user 0m3.632s
> sys 0m0.112s
>
>

What kind of CPU are you using? Some Intel CPU's do "funny stuff",
like dynamically overclocking itself when working on a single thread,
or using all of the 2nd level cache instead of sharing it with the
second core.

Regards,
Wander Winkelhorst.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/