linux/include/trace/events
Mel Gorman d0164adc89 mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd
__GFP_WAIT has been used to identify atomic context in callers that hold
spinlocks or are in interrupts.  They are expected to be high priority and
have access one of two watermarks lower than "min" which can be referred
to as the "atomic reserve".  __GFP_HIGH users get access to the first
lower watermark and can be called the "high priority reserve".

Over time, callers had a requirement to not block when fallback options
were available.  Some have abused __GFP_WAIT leading to a situation where
an optimisitic allocation with a fallback option can access atomic
reserves.

This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
cannot sleep and have no alternative.  High priority users continue to use
__GFP_HIGH.  __GFP_DIRECT_RECLAIM identifies callers that can sleep and
are willing to enter direct reclaim.  __GFP_KSWAPD_RECLAIM to identify
callers that want to wake kswapd for background reclaim.  __GFP_WAIT is
redefined as a caller that is willing to enter direct reclaim and wake
kswapd for background reclaim.

This patch then converts a number of sites

o __GFP_ATOMIC is used by callers that are high priority and have memory
  pools for those requests. GFP_ATOMIC uses this flag.

o Callers that have a limited mempool to guarantee forward progress clear
  __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
  into this category where kswapd will still be woken but atomic reserves
  are not used as there is a one-entry mempool to guarantee progress.

o Callers that are checking if they are non-blocking should use the
  helper gfpflags_allow_blocking() where possible. This is because
  checking for __GFP_WAIT as was done historically now can trigger false
  positives. Some exceptions like dm-crypt.c exist where the code intent
  is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
  flag manipulations.

o Callers that built their own GFP flags instead of starting with GFP_KERNEL
  and friends now also need to specify __GFP_KSWAPD_RECLAIM.

The first key hazard to watch out for is callers that removed __GFP_WAIT
and was depending on access to atomic reserves for inconspicuous reasons.
In some cases it may be appropriate for them to use __GFP_HIGH.

The second key hazard is callers that assembled their own combination of
GFP flags instead of starting with something like GFP_KERNEL.  They may
now wish to specify __GFP_KSWAPD_RECLAIM.  It's almost certainly harmless
if it's missed in most cases as other activity will wake kswapd.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Vitaly Wool <vitalywool@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 17:50:42 -08:00
..
9p.h net/9p/tracing: Export enums in tracepoints to userspace 2015-04-08 09:39:59 -04:00
asoc.h ASoC: dapm: Consolidate path trace events 2015-08-13 12:40:16 +01:00
bcache.h
block.h
btrfs.h btrfs: qgroup: Cleanup the old ref_node-oriented mechanism. 2015-06-10 09:26:11 -07:00
clk.h
cma.h mm: cma: add trace events for CMA allocations and freeings 2015-04-15 16:35:19 -07:00
compaction.h mm, compaction: distinguish contended status in tracepoints 2015-11-05 19:34:48 -08:00
context_tracking.h
ext4.h ext4: minor cleanup of ext4_da_reserve_space() 2015-06-21 21:37:05 -04:00
f2fs.h f2fs: add a tracepoint for f2fs_read_data_pages 2015-10-12 14:00:34 -07:00
fence.h
fib.h net: Make table id type u32 2015-09-01 14:32:44 -07:00
filelock.h locks: change tracepoint for generic_add_lease 2015-09-21 07:26:45 -04:00
filemap.h tracing, mm: Record pfn instead of pointer to struct page 2015-04-13 11:44:52 -03:00
gfpflags.h mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
gpio.h
host1x.h
hswadsp.h
i2c.h
intel-sst.h
iommu.h
ipi.h
irq.h irq/tracing: Export enums in tracepoints to user space 2015-04-08 09:40:00 -04:00
jbd2.h
kmem.h tracing/mm: don't trace mm_page_pcpu_drain on offline cpus 2015-05-28 18:25:18 -07:00
kvm.h kvm: move new trace event outside #ifdef CONFIG_KVM_ASYNC_PF 2015-09-08 11:16:40 +02:00
libata.h
lock.h
mce.h
migrate.h mm: tracing: Export enums in tracepoints to user space 2015-04-08 09:40:01 -04:00
module.h
napi.h
net.h
nmi.h
oom.h
pagemap.h
power.h This patch series contains several clean ups and even a new trace clock 2015-06-26 14:02:43 -07:00
power_cpu_migrate.h
printk.h
random.h
rcu.h rcu: Apply rcu_seq operations to _rcu_barrier() 2015-07-17 14:58:57 -07:00
regulator.h
rpm.h
sched.h sched/core: Fix trace_sched_switch() 2015-10-06 17:08:15 +02:00
scsi.h
signal.h
skb.h
sock.h
spi.h
spmi.h spmi: add command tracepoints for SPMI 2015-08-05 12:27:09 -07:00
sunrpc.h net: sunrpc: fix tracepoint Warning: unknown op '->' 2015-08-31 16:32:15 -04:00
swiotlb.h
syscalls.h
target.h target: Minimize SCSI header #include directives 2015-06-02 08:03:25 -07:00
task.h tracing: Don't make assumptions about length of string on task rename 2015-08-31 10:47:14 -04:00
thermal.h thermal: add trace events to the power allocator governor 2015-05-04 21:27:52 -07:00
thermal_power_allocator.h thermal: consistently use int for temperatures 2015-08-03 23:15:50 +08:00
thp.h
timer.h timer: Replace timer base by a cpu index 2015-06-19 15:18:27 +02:00
tlb.h x86, mm: trace when an IPI is about to be sent 2015-09-04 16:54:41 -07:00
udp.h
v4l2.h [media] v4l2: add support for SDR transmitter 2015-10-20 15:40:50 -02:00
vb2.h [media] media: videobuf2: Prepare to divide videobuf2 2015-10-20 15:12:45 -02:00
vmscan.h tracing, mm: Record pfn instead of pointer to struct page 2015-04-13 11:44:52 -03:00
workqueue.h
writeback.h writeback: update writeback tracepoints to report cgroup 2015-08-18 15:49:15 -07:00
xen.h x86: expose number of page table levels on Kconfig level 2015-04-14 16:49:02 -07:00