linux/include
Waiman Long af161bee93 include/linux/sched/mm.h: optimize current_gfp_context()
The current_gfp_context() converts a number of PF_MEMALLOC_* per-process
flags into the corresponding GFP_* flags for memory allocation.  In that
function, current->flags is accessed 3 times.  That may lead to duplicated
access of the same memory location.

This is not usually a problem with minimal debug config options on as the
compiler can optimize away the duplicated memory accesses.  With most of
the debug config options on, however, that may not be the case.  For
example, the x86-64 object size of the __need_fs_reclaim() in a debug
kernel that calls current_gfp_context() was 309 bytes.  With this patch
applied, the object size is reduced to 202 bytes.  This is a saving of 107
bytes and will probably be slightly faster too.

Use READ_ONCE() to access current->flags to prevent the compiler from
possibly accessing current->flags multiple times.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Michel Lespinasse <walken@google.com>
Link: http://lkml.kernel.org/r/20200618212936.9776-1-longman@redhat.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-12 10:57:57 -07:00
..
acpi ACPI updates for 5.9-rc1 2020-08-03 20:37:22 -07:00
asm-generic Merge branch 'akpm' (patches from Andrew) 2020-08-07 11:39:33 -07:00
clocksource
crypto mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
drm drm next for 5.9-rc1 2020-08-05 19:50:06 -07:00
dt-bindings This is the bulk of the pin control changes for the v5.9 2020-08-09 12:52:28 -07:00
keys It's been a busy cycle for documentation - hopefully the busiest for a 2020-08-04 22:47:54 -07:00
kunit
kvm
linux include/linux/sched/mm.h: optimize current_gfp_context() 2020-08-12 10:57:57 -07:00
math-emu
media media updates for v5.9-rc1 2020-08-07 13:00:53 -07:00
memory
misc
net A set of locking fixes and updates: 2020-08-10 19:07:44 -07:00
pcmcia
ras
rdma RDMA 5.9 merge window pull request 2020-08-06 16:43:36 -07:00
scsi
soc It looks like a smaller batch of clk updates this time around. In the core 2020-08-07 13:35:51 -07:00
sound ALSA: hda: Add dma stop delay variable 2020-08-05 12:27:47 +02:00
target
trace mm/vmstat: add events for THP migration without split 2020-08-12 10:57:57 -07:00
uapi Highlights: 2020-08-09 13:58:04 -07:00
vdso
video
xen xen: branch for v5.9-rc1 2020-08-07 10:53:02 -07:00