Messages in this thread | | | Date | Fri, 9 Jul 2021 13:26:01 +0100 | From | Mel Gorman <> | Subject | Re: [PATCH 2/2] mm/page_alloc: avoid counting event if no successful allocation |
| |
On Fri, Jul 09, 2021 at 06:28:55PM +0800, Yanfei Xu wrote: > While the nr_populated is non-zero, however the nr_account might be > zero if allocating fails. In this case, not to count event can save > some cycles. >
The much more likely path is that nr_account is positive so we avoid a branch in the common case.
> And this commit extract the check of "page_array" from a while > statement to avoid unnecessary checks for it. >
I'm surprised the compiler does not catch that page_array is invariant for the loop. Did you check if gcc generates different code is page_array is explicitly checked once instead of putting it in the loop?
-- Mel Gorman SUSE Labs
| |