Re: [PATCH 3/3] mm, page_alloc: reduce static keys in prep_new_page()

From: David Hildenbrand
Date: Tue Oct 27 2020 - 05:10:59 EST


On 26.10.20 18:33, Vlastimil Babka wrote:
prep_new_page() will always zero a new page (regardless of __GFP_ZERO) when
init_on_alloc is enabled, but will also always skip zeroing if the page was
already zeroed on free by init_on_free or page poisoning.

The latter check implemented by free_pages_prezeroed() can involve two
different static keys. As prep_new_page() is really a hot path, let's introduce
a single static key free_pages_not_prezeroed for this purpose and initialize it
in init_mem_debugging().

Is this actually observable in practice? This smells like micro-optimization to me.

Also, I thought the whole reason for static keys is to have basically no overhead at runtime, so I wonder if replacing two static key checks by a single one actually makes *some* difference.

--
Thanks,

David / dhildenb