Vlastimil Babka 8db26a3d47 mm, page_poison: use static key more efficiently
Commit 11c9c7edae06 ("mm/page_poison.c: replace bool variable with static
key") changed page_poisoning_enabled() to a static key check.  However,
the function is not inlined, so each check still involves a function call
with overhead not eliminated when page poisoning is disabled.

Analogically to how debug_pagealloc is handled, this patch converts
page_poisoning_enabled() back to boolean check, and introduces
page_poisoning_enabled_static() for fast paths.  Both functions are
inlined.

The function kernel_poison_pages() is also called unconditionally and does
the static key check inside.  Remove it from there and put it to callers.
Also split it to two functions kernel_poison_pages() and
kernel_unpoison_pages() instead of the confusing bool parameter.

Also optimize the check that enables page poisoning instead of
debug_pagealloc for architectures without proper debug_pagealloc support.
Move the check to init_mem_debugging_and_hardening() to enable a single
static key instead of having two static branches in
page_poisoning_enabled_static().

Link: https://lkml.kernel.org/r/20201113104033.22907-3-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Laura Abbott <labbott@kernel.org>
Cc: Mateusz Nosek <mateusznosek0@gmail.com>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-15 12:13:46 -08:00
..
2020-11-27 10:44:59 -08:00
2020-10-30 14:51:01 -07:00
2020-11-18 16:42:07 -08:00
2020-11-15 10:15:17 -08:00
2020-11-20 10:23:49 -08:00
2020-12-15 12:13:37 -08:00
2020-12-15 12:13:37 -08:00
2020-12-15 12:13:37 -08:00
2020-11-16 15:02:33 -08:00
2020-12-03 10:00:23 +01:00
2020-12-09 09:59:14 -08:00
2020-10-16 12:21:15 -07:00
2020-10-24 10:39:22 -07:00
2020-12-13 10:36:23 -08:00
2020-12-08 08:15:49 +01:00
2020-10-24 10:39:22 -07:00
2020-09-28 12:17:36 +02:00
2020-10-14 15:56:58 -07:00
2020-12-15 12:13:42 -08:00
2020-10-25 11:12:31 -07:00
2020-12-15 12:13:37 -08:00
2020-10-27 19:23:04 +01:00
2020-10-24 10:33:08 -07:00
2020-10-22 12:56:33 -07:00
2020-10-24 10:39:22 -07:00
2020-10-22 12:58:21 -07:00
2020-10-21 11:22:08 -07:00
2020-12-12 12:57:12 -08:00
2020-11-26 22:07:22 +01:00
2020-10-01 22:59:55 +02:00
2020-11-25 10:35:44 -08:00
2020-11-20 16:24:28 -08:00
2020-11-27 14:48:03 -08:00
2020-12-04 17:39:58 +01:00
2020-12-15 12:13:37 -08:00
2020-11-23 15:29:03 -08:00
2020-10-24 10:33:08 -07:00