Re: question: cpu.shares and parent-children relationshp in the hierarchy

From: Yong Zhang
Date: Wed Feb 16 2011 - 21:00:54 EST


On Wed, Feb 16, 2011 at 8:11 AM, Michal Soltys <soltys@xxxxxxxx> wrote:
> Hi,
>
> I've been testing how this works in practice, and I have few
> configurations I'm not sure why they behave the way they do.
>
> All the test processes just drain cpu with an infinite loop.
> All of them are pinned to single cpu core. cgroup with just
> -o cpu is mounted, and the scenario is following (in brackets
> - assigned cpu.shares):
>
> Â Âroot(1024)
> Â / Â Â Â Â Â\
> Y(1024) Â Â ÂX(4096)
> Â Â Â Â Â Â/ Â Â Â \ \
> Â Â Â Â A(8192) Â B(8192) task-x(1024)

I assume loadme(x) is an process of group X, like above.

If so, there isn't any problem with it.

Thanks,
Yong

>
> Four test processes sit in X, Y, A and B; root is "empty"
> (effectively idle processes). The one in Y expectedly gets
> 20% cpu, A and B divide the cpu share equally, but - why do
> the process in X gets only ~4.75% ? Essentially:
>
> 11:36:45 PM    PID  Â%usr %system Â%guest  Â%CPU  CPU ÂCommand
> 11:36:50 PM Â Â 29472 Â 20.00 Â Â0.00 Â Â0.00 Â 20.00 Â Â 1 Âloadme(y)
> 11:36:50 PM Â Â 29473 Â Â4.80 Â Â0.00 Â Â0.00 Â Â4.80 Â Â 1 Âloadme(x)
> 11:36:50 PM Â Â 29474 Â 37.60 Â Â0.00 Â Â0.00 Â 37.60 Â Â 1 Âloadme(a)
> 11:36:50 PM Â Â 29475 Â 37.60 Â Â0.00 Â Â0.00 Â 37.60 Â Â 1 Âloadme(b)
>
> In the other words - what is the intended relation between ancestor's
> cpu.shares and its children ? Looking at the example above, it looks
> like the task in X should get 4/5 (root unused, 1/5 for Y, the rest
> for X subtree) * 1/5 (from assigned values in X subtree,
> 4096/20480) - but that would be ~16%.
>
> The task in X behaves like if X had 1024 - maybe it's always assumed
> when parent-children relationship is considered, and the actual value
> is used only when dividing cpu between siblings ?
>
> If I move the test task from X to root, the situation will change to:
>
> 11:56:49 PM    PID  Â%usr %system Â%guest  Â%CPU  CPU ÂCommand
> 11:56:54 PM Â Â 29472 Â 16.60 Â Â0.00 Â Â0.00 Â 16.60 Â Â 1 Âloadme(y)
> 11:56:54 PM Â Â 29473 Â 16.60 Â Â0.00 Â Â0.00 Â 16.60 Â Â 1 Âloadme(root)
> 11:56:54 PM Â Â 29474 Â 33.20 Â Â0.20 Â Â0.00 Â 33.40 Â Â 1 Âloadme(a)
> 11:56:54 PM Â Â 29475 Â 33.40 Â Â0.00 Â Â0.00 Â 33.40 Â Â 1 Âloadme(b)
>
> In this scenario, everything seems as expected - 1/6 for Y, 1/6 for root,
> 4/6 for X subtree.
>
> --
> 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/
>



--
Only stand for myself
--
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/