Re: [PATCH v3] sched: Micro optimization in pick_next_task() and in check_preempt_curr()
From: Steven Rostedt
Date: Thu Dec 19 2019 - 16:04:27 EST
On Thu, 19 Dec 2019 20:12:15 +0000
Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> wrote:
> This introduces an optimization based on xxx_sched_class addresses
> in two hot scheduler functions: pick_next_task() and check_preempt_curr().
>
> It is possible to compare pointers to sched classes to check, which
> of them has a higher priority, instead of current iterations using
> for_each_class().
>
> One more result of the patch is that size of object file becomes a little
> less (excluding added BUG_ON(), which goes in __init section):
>
> $size kernel/sched/core.o
> text data bss dec hex filename
> before: 66446 18957 676 86079 1503f kernel/sched/core.o
> after: 66398 18957 676 86031 1500f kernel/sched/core.o
>
> Signed-off-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
Care to resend, not as a mime image?
-- Steve
> Content-Type: text/plain; charset="utf-8"
> Content-ID: <C1D028DDF0B4064595B78514E3E235C5@xxxxxxxxxxxxxxxxxxxxxxxxx>
> Content-Transfer-Encoding: base64
> MIME-Version: 1.0
> X-OriginatorOrg: virtuozzo.com
> X-MS-Exchange-CrossTenant-Network-Message-Id: 63724e70-f5a2-4d04-bbaa-08d784bfbdf9
> X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2019 20:12:16.0672
> (UTC)
> X-MS-Exchange-CrossTenant-fromentityheader: Hosted
> X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f
> X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
> X-MS-Exchange-CrossTenant-userprincipalname: wYML0eHmbgTBU2jD+X1IMNyAYqtN3rJ3EgoGfPJQcQ2Wqq2KJfyClc/7Q5BfozgXMC5ZM7OdiAJShPtJE7UvuA==
> X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3343
>
> VGhpcyBpbnRyb2R1Y2VzIGFuIG9wdGltaXphdGlvbiBiYXNlZCBvbiB4eHhfc2NoZWRfY2xhc3Mg
> YWRkcmV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