1
0
Fork 0
alistair23-linux/Documentation
Vlastimil Babka 8974558f49 mm, page_owner, debug_pagealloc: save and dump freeing stack trace
The debug_pagealloc functionality is useful to catch buggy page allocator
users that cause e.g.  use after free or double free.  When page
inconsistency is detected, debugging is often simpler by knowing the call
stack of process that last allocated and freed the page.  When page_owner
is also enabled, we record the allocation stack trace, but not freeing.

This patch therefore adds recording of freeing process stack trace to page
owner info, if both page_owner and debug_pagealloc are configured and
enabled.  With only page_owner enabled, this info is not useful for the
memory leak debugging use case.  dump_page() is adjusted to print the
info.  An example result of calling __free_pages() twice may look like
this (note the page last free stack trace):

BUG: Bad page state in process bash  pfn:13d8f8
page:ffffc31984f63e00 refcount:-1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0x1affff800000000()
raw: 01affff800000000 dead000000000100 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 ffffffffffffffff 0000000000000000
page dumped because: nonzero _refcount
page_owner tracks the page as freed
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xcc0(GFP_KERNEL)
 prep_new_page+0x143/0x150
 get_page_from_freelist+0x289/0x380
 __alloc_pages_nodemask+0x13c/0x2d0
 khugepaged+0x6e/0xc10
 kthread+0xf9/0x130
 ret_from_fork+0x3a/0x50
page last free stack trace:
 free_pcp_prepare+0x134/0x1e0
 free_unref_page+0x18/0x90
 khugepaged+0x7b/0xc10
 kthread+0xf9/0x130
 ret_from_fork+0x3a/0x50
Modules linked in:
CPU: 3 PID: 271 Comm: bash Not tainted 5.3.0-rc4-2.g07a1a73-default+ #57
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58-prebuilt.qemu.org 04/01/2014
Call Trace:
 dump_stack+0x85/0xc0
 bad_page.cold+0xba/0xbf
 rmqueue_pcplist.isra.0+0x6c5/0x6d0
 rmqueue+0x2d/0x810
 get_page_from_freelist+0x191/0x380
 __alloc_pages_nodemask+0x13c/0x2d0
 __get_free_pages+0xd/0x30
 __pud_alloc+0x2c/0x110
 copy_page_range+0x4f9/0x630
 dup_mmap+0x362/0x480
 dup_mm+0x68/0x110
 copy_process+0x19e1/0x1b40
 _do_fork+0x73/0x310
 __x64_sys_clone+0x75/0x80
 do_syscall_64+0x6e/0x1e0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f10af854a10
...

Link: http://lkml.kernel.org/r/20190820131828.22684-5-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-09-24 15:54:08 -07:00
..
ABI mm, slab: extend slab/shrink to shrink all memcg caches 2019-09-24 15:54:07 -07:00
EDID docs: driver-api: add a series of orphaned documents 2019-07-15 11:03:02 -03:00
PCI Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2019-08-27 14:23:31 -07:00
RCU Merge branches 'consolidate.2019.08.01b', 'fixes.2019.08.12a', 'lists.2019.08.13a' and 'torture.2019.08.01b' into HEAD 2019-08-13 14:30:30 -07:00
accounting docs: add some documentation dirs to the driver-api book 2019-07-15 11:03:02 -03:00
admin-guide mm, page_owner, debug_pagealloc: save and dump freeing stack trace 2019-09-24 15:54:08 -07:00
arm Documentation/arm/samsung-s3c24xx: Remove stray U+FEFF character to fix title 2019-08-12 15:25:32 -06:00
arm64 Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-09-17 11:42:15 -07:00
block docs: block: null_blk: enhance document style 2019-09-11 16:04:22 -06:00
bpf bpf/flow_dissector: document flags 2019-07-25 18:00:41 -07:00
cdrom docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
core-api docs: printk-formats: Stop encouraging use of unnecessary %h[xudi] and %hh[xudi] 2019-09-14 01:57:43 -06:00
cpu-freq Documentation: cpufreq: Update policy notifier documentation 2019-09-02 22:44:05 +02:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-09-18 12:11:14 -07:00
dev-tools Merge branch 'pdf_fixes_v1' of https://git.linuxtv.org/mchehab/experimental into mauro 2019-07-22 13:51:20 -06:00
devicetree RTC for 5.4 2019-09-22 11:05:43 -07:00
doc-guide docs: remove extra conf.py files 2019-07-17 06:57:52 -03:00
driver-api This is the bulk of pin control changes for the v5.4 kernel 2019-09-19 14:19:33 -07:00
fault-injection docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
fb docs conversion for v5.3-rc1 2019-07-16 12:21:41 -07:00
features It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
filesystems f2fs-for-5.4-rc1 2019-09-21 14:26:33 -07:00
firmware-guide Documentation: ACPI: DSD: Convert LED documentation to ReST 2019-08-20 23:53:46 +02:00
firmware_class
fpga Documentation: fpga: dfl: add descriptions for virtualization and new interfaces. 2019-09-03 19:35:42 -07:00
gpu Merge drm/drm-next into drm-intel-next-queued 2019-08-22 00:10:36 -07:00
hid docs: add some documentation dirs to the driver-api book 2019-07-15 11:03:02 -03:00
hwmon It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
i2c docs: i2c: convert to ReST and add to driver-api bookset 2019-07-31 13:25:27 -06:00
ia64 docs: add SPDX tags to new index files 2019-07-15 11:03:03 -03:00
ide docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
iio docs: add some documentation dirs to the driver-api book 2019-07-15 11:03:02 -03:00
infiniband Documentation/infiniband: update name of some functions 2019-09-13 16:55:55 -03:00
input Input: docs: fix spelling mistake "potocol" -> "protocol" 2019-08-06 11:24:49 -06:00
ioctl fs-verity: add UAPI header 2019-07-28 16:59:16 -07:00
isdn docs: isdn: convert to ReST and add to kAPI bookset 2019-07-31 13:30:25 -06:00
kbuild Modules updates for v5.4 2019-09-22 10:34:46 -07:00
kernel-hacking docs: Add documentation for Symbol Namespaces 2019-09-10 10:30:49 +02:00
leds leds: core: Add support for composing LED class device names 2019-07-25 20:07:52 +02:00
livepatch docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
locking doc🔒 remove reference to clever use of read-write lock 2019-09-14 01:53:27 -06:00
m68k docs: README.buddha: convert to ReST and add to m68k book 2019-07-31 13:30:10 -06:00
maintainer docs: Fix typo on pull requests guide 2019-08-12 15:14:14 -06:00
media drm main pull for 5.4-rc1 2019-09-19 16:24:24 -07:00
mic docs: driver-api: add remaining converted dirs to it 2019-07-15 11:03:03 -03:00
mips Main MIPS changes for v5.4: 2019-09-22 09:30:30 -07:00
misc-devices Docs: misc: xilinx_sdfec: Add documentation 2019-08-15 17:54:38 +02:00
netlabel docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
networking Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2019-09-18 12:34:53 -07:00
nios2 docs: nios2: add it to the main Documentation body 2019-07-31 13:31:51 -06:00
openrisc docs: openrisc: convert to ReST and add to documentation body 2019-07-31 13:30:20 -06:00
parisc docs: parisc: convert to ReST and add to documentation body 2019-07-31 13:30:15 -06:00
pcmcia docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
power Merge branches 'pm-opp', 'pm-qos', 'acpi-pm', 'pm-domains' and 'pm-tools' 2019-09-17 09:49:19 +02:00
powerpc docs: powerpc: Add missing documentation reference 2019-09-17 23:59:34 +10:00
process It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
riscv It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
s390 Documentation/s390: remove outdated debugging390 documentation 2019-08-21 12:41:43 +02:00
scheduler sched/fair: Fix low cpu usage with high throttling by removing expiration of cpu-local slices 2019-08-08 09:09:30 +02:00
scsi scsi: ufs: Documentation: Announce ufs-tool v1.0 2019-06-26 22:47:51 -04:00
security It's a somewhat calmer cycle for docs this time, as the churn of the mass 2019-09-17 16:22:26 -07:00
sh docs: remove extra conf.py files 2019-07-17 06:57:52 -03:00
sound sound updates for 5.4 2019-09-17 17:43:33 -07:00
sparc docs: add arch doc directories to the index 2019-07-15 11:03:01 -03:00
sphinx Documentation: sphinx: Don't parse socket() as identifier reference 2019-08-12 14:55:30 -06:00
sphinx-static
spi spi: docs: convert to ReST and add it to the kABI bookset 2019-07-31 14:13:13 -06:00
target docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
timers docs: add some directories to the main documentation index 2019-07-15 11:03:03 -03:00
trace Tracing updates: 2019-09-20 11:19:48 -07:00
translations doc: arm64: fix grammar dtb placed in no attributes region 2019-09-06 08:44:34 -06:00
usb USB: Move wusbcore and UWB to staging as it is obsolete 2019-08-08 07:52:01 +02:00
userspace-api docs: remove extra conf.py files 2019-07-17 06:57:52 -03:00
virt * More selftests 2019-09-11 18:06:15 +02:00
virtual cpuidle: add haltpoll governor 2019-07-30 17:27:37 +02:00
vm Merge branch 'odp_fixes' into hmm.git 2019-08-21 20:58:18 -03:00
w1 docs: w1: convert to ReST and add to the kAPI group of docs 2019-07-31 14:16:17 -06:00
watchdog Merge branch 'pdf_fixes_v1' of https://git.linuxtv.org/mchehab/experimental into mauro 2019-07-22 13:51:20 -06:00
x86 dma-mapping: fix filename references 2019-09-03 08:36:30 +02:00
xtensa docs: add arch doc directories to the index 2019-07-15 11:03:01 -03:00
.gitignore
COPYING-logo docs: logo.txt: rename it to COPYING-logo 2019-07-15 09:20:27 -03:00
Changes
CodingStyle
DMA-API-HOWTO.txt docs: DMA-API-HOWTO.txt: fix an unmarked code block 2019-07-15 09:20:24 -03:00
DMA-API.txt dma-mapping: remove dma_release_declared_memory 2019-09-04 11:13:19 +02:00
DMA-ISA-LPC.txt Documentation/DMA-ISA-LPC: fix an incorrect reference 2019-02-11 08:23:07 -07:00
DMA-attributes.txt
IPMI.txt
IRQ-affinity.txt
IRQ-domain.txt
IRQ.txt
Kconfig docs: Kbuild/Makefile: allow check for missing docs at build time 2019-06-07 11:33:16 -06:00
Makefile docs: Kbuild/Makefile: allow check for missing docs at build time 2019-06-07 11:33:16 -06:00
SubmittingPatches
atomic_bitops.txt docs: atomic_bitops.txt: add a title for this document 2019-04-11 12:37:02 -06:00
atomic_t.txt Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 16:12:03 -07:00
bus-virt-phys-mapping.txt
conf.py docs: conf.py: only use CJK if the font is available 2019-07-17 06:57:51 -03:00
crc32.txt
debugging-modules.txt
debugging-via-ohci1394.txt
digsig.txt
docutils.conf doc-rst: Add missing newline at end of file 2019-06-20 14:16:56 -06:00
dontdiff kbuild: create *.mod with full directory path and remove MODVERDIR 2019-07-18 02:19:31 +09:00
futex-requeue-pi.txt
hwspinlock.txt hwspinlock: add the 'in_atomic' API 2019-06-29 21:08:14 -07:00
index.rst Main MIPS changes for v5.4: 2019-09-22 09:30:30 -07:00
io-mapping.txt
io_ordering.txt
irqflags-tracing.txt
kobject.txt
kprobes.txt Merge branch 'parisc-5.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux 2019-05-07 19:34:17 -07:00
kref.txt
logo.gif
lzo.txt lib/lzo: fix bugs for very short or empty input 2019-04-05 16:02:30 -10:00
mailbox.txt
memory-barriers.txt docs: fix broken doc references due to renames 2019-07-17 06:57:51 -03:00
nommu-mmap.txt
padata.txt padata: allocate workqueue internally 2019-09-13 21:15:39 +10:00
percpu-rw-semaphore.txt
pi-futex.txt docs: locking: convert docs to ReST and rename to *.rst 2019-07-15 08:53:27 -03:00
preempt-locking.txt x86/fpu: Remove fpu__restore() 2019-04-09 19:27:42 +02:00
rbtree.txt docs: rbtree.txt: fix Sphinx build warnings 2019-07-15 09:20:24 -03:00
remoteproc.txt remoteproc: add vendor resources handling 2019-06-29 12:02:17 -07:00
robust-futex-ABI.txt
robust-futexes.txt futex: Update comments and docs about return values of arch futex code 2019-04-26 13:57:55 +01:00
rpmsg.txt
speculation.txt docs: speculation.txt: mark example blocks as such 2019-04-11 12:37:03 -06:00
static-keys.txt
tee.txt Documentation: tee: Grammar s/the its/its/ 2019-06-07 11:23:38 -06:00
this_cpu_ops.txt
unaligned-memory-access.txt docs: unaligned-memory-access.txt: use a lowercase title 2019-04-11 12:37:03 -06:00
xz.txt