linux/crypto
Joonsoo Kim 95813b8faa mm/page_ref: add tracepoint to track down page reference manipulation
CMA allocation should be guaranteed to succeed by definition, but,
unfortunately, it would be failed sometimes.  It is hard to track down
the problem, because it is related to page reference manipulation and we
don't have any facility to analyze it.

This patch adds tracepoints to track down page reference manipulation.
With it, we can find exact reason of failure and can fix the problem.
Following is an example of tracepoint output.  (note: this example is
stale version that printing flags as the number.  Recent version will
print it as human readable string.)

<...>-9018  [004]    92.678375: page_ref_set:         pfn=0x17ac9 flags=0x0 count=1 mapcount=0 mapping=(nil) mt=4 val=1
<...>-9018  [004]    92.678378: kernel_stack:
 => get_page_from_freelist (ffffffff81176659)
 => __alloc_pages_nodemask (ffffffff81176d22)
 => alloc_pages_vma (ffffffff811bf675)
 => handle_mm_fault (ffffffff8119e693)
 => __do_page_fault (ffffffff810631ea)
 => trace_do_page_fault (ffffffff81063543)
 => do_async_page_fault (ffffffff8105c40a)
 => async_page_fault (ffffffff817581d8)
[snip]
<...>-9018  [004]    92.678379: page_ref_mod:         pfn=0x17ac9 flags=0x40048 count=2 mapcount=1 mapping=0xffff880015a78dc1 mt=4 val=1
[snip]
...
...
<...>-9131  [001]    93.174468: test_pages_isolated:  start_pfn=0x17800 end_pfn=0x17c00 fin_pfn=0x17ac9 ret=fail
[snip]
<...>-9018  [004]    93.174843: page_ref_mod_and_test: pfn=0x17ac9 flags=0x40068 count=0 mapcount=0 mapping=0xffff880015a78dc1 mt=4 val=-1 ret=1
 => release_pages (ffffffff8117c9e4)
 => free_pages_and_swap_cache (ffffffff811b0697)
 => tlb_flush_mmu_free (ffffffff81199616)
 => tlb_finish_mmu (ffffffff8119a62c)
 => exit_mmap (ffffffff811a53f7)
 => mmput (ffffffff81073f47)
 => do_exit (ffffffff810794e9)
 => do_group_exit (ffffffff81079def)
 => SyS_exit_group (ffffffff81079e74)
 => entry_SYSCALL_64_fastpath (ffffffff817560b6)

This output shows that problem comes from exit path.  In exit path, to
improve performance, pages are not freed immediately.  They are gathered
and processed by batch.  During this process, migration cannot be
possible and CMA allocation is failed.  This problem is hard to find
without this page reference tracepoint facility.

Enabling this feature bloat kernel text 30 KB in my configuration.

   text    data     bss     dec     hex filename
12127327        2243616 1507328 15878271         f2487f vmlinux_disabled
12157208        2258880 1507328 15923416         f2f8d8 vmlinux_enabled

Note that, due to header file dependency problem between mm.h and
tracepoint.h, this feature has to open code the static key functions for
tracepoints.  Proposed by Steven Rostedt in following link.

https://lkml.org/lkml/2015/12/9/699

[arnd@arndb.de: crypto/async_pq: use __free_page() instead of put_page()]
[iamjoonsoo.kim@lge.com: fix build failure for xtensa]
[akpm@linux-foundation.org: tweak Kconfig text, per Vlastimil]
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-03-17 15:09:34 -07:00
..
asymmetric_keys PKCS#7: Don't require SpcSpOpusInfo in Authenticode pkcs7 signatures 2016-01-25 21:47:45 +08:00
async_tx mm/page_ref: add tracepoint to track down page reference manipulation 2016-03-17 15:09:34 -07:00
.gitignore crypto: rsa - add .gitignore for crypto/*.-asn1.[ch] files 2015-06-25 23:29:24 +08:00
842.c
Kconfig crypto: ghash,poly1305 - select CRYPTO_HASH where needed 2016-01-26 22:27:31 +08:00
Makefile crypto: rsa - RSA padding algorithm 2015-12-09 20:03:57 +08:00
ablk_helper.c
ablkcipher.c crypto: skcipher - Copy iv from desc even for 0-len walks 2015-12-09 20:16:22 +08:00
aead.c crypto: aead - Remove CRYPTO_ALG_AEAD_NEW flag 2015-08-17 16:53:53 +08:00
aes_generic.c
af_alg.c crypto: af_alg - Forbid bind(2) when nokey child sockets are present 2016-01-18 18:16:33 +08:00
ahash.c crypto: hash - Add crypto_ahash_has_setkey 2016-01-18 18:16:11 +08:00
akcipher.c crypto: akcipher - add akcipher declarations needed by templates. 2015-12-09 20:03:57 +08:00
algapi.c crypto: api - use list_first_entry_or_null and list_next_entry 2015-11-23 20:55:50 +08:00
algboss.c crypto: algboss - Remove reference to nivaead 2015-08-17 16:53:41 +08:00
algif_aead.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2016-01-12 18:57:02 -08:00
algif_hash.c crypto: algif_hash - wait for crypto_ahash_init() to complete 2016-01-30 22:05:15 +08:00
algif_rng.c
algif_skcipher.c crypto: algif_skcipher - Do not set MAY_BACKLOG on the async path 2016-02-06 15:23:55 +08:00
ansi_cprng.c
anubis.c
api.c crypto: api - Only abort operations on fatal signal 2015-10-20 21:59:25 +08:00
arc4.c
authenc.c crypto: aead - Remove CRYPTO_ALG_AEAD_NEW flag 2015-08-17 16:53:53 +08:00
authencesn.c crypto: aead - Remove CRYPTO_ALG_AEAD_NEW flag 2015-08-17 16:53:53 +08:00
blkcipher.c crypto: skcipher - Copy iv from desc even for 0-len walks 2015-12-09 20:16:22 +08:00
blowfish_common.c
blowfish_generic.c
camellia_generic.c
cast5_generic.c
cast6_generic.c
cast_common.c
cbc.c
ccm.c crypto: replace scatterwalk_sg_chain with sg_chain 2015-08-17 08:12:54 -06:00
chacha20_generic.c crypto: chacha20 - Export common ChaCha20 helpers 2015-07-17 21:20:21 +08:00
chacha20poly1305.c crypto: chacha20poly1305 - Skip encryption/decryption for 0-len 2015-12-09 20:16:04 +08:00
chainiv.c crypto: chainiv - Offer normal cipher functionality without RNG 2015-06-22 15:49:28 +08:00
cipher.c
cmac.c
compress.c
crc32.c
crc32c_generic.c crypto: crc32c - Fix crc32c soft dependency 2016-01-19 15:52:10 +08:00
crct10dif_common.c
crct10dif_generic.c
cryptd.c crypto: cryptd - Assign statesize properly 2015-12-04 22:29:53 +08:00
crypto_null.c
crypto_user.c crypto: user - lock crypto_alg_list on alg dump 2016-02-06 15:23:55 +08:00
crypto_wq.c
ctr.c
cts.c
deflate.c
des_generic.c
drbg.c crypto: drbg - constify drbg_state_ops structures 2015-12-10 22:39:44 +08:00
ecb.c
echainiv.c crypto: echainiv - Use generic geniv init/exit helpers 2015-08-17 16:53:46 +08:00
eseqiv.c crypto: eseqiv - Offer normal cipher functionality without RNG 2015-06-22 15:49:28 +08:00
fcrypt.c
fips.c
gcm.c Merge branch 'for-4.3/sg' of git://git.kernel.dk/linux-block 2015-09-02 13:22:38 -07:00
gf128mul.c
ghash-generic.c
hash_info.c keys, trusted: select hash algorithm for TPM2 chips 2015-12-20 15:27:12 +02:00
hmac.c
internal.h
jitterentropy-kcapi.c crypto: jitterentropy - remove unnecessary information from a comment 2015-10-14 22:23:16 +08:00
jitterentropy.c crypto: jitterentropy - Delete unnecessary checks before the function call "kzfree" 2015-06-25 23:18:33 +08:00
keywrap.c crypto: keywrap - add key wrapping block chaining mode 2015-10-15 21:05:04 +08:00
khazad.c
lrw.c
lz4.c
lz4hc.c
lzo.c
mcryptd.c crypto: mcryptd - use list_first_entry_or_null() 2015-11-23 20:55:51 +08:00
md4.c
md5.c crypto: hash - add zero length message hash for shax and md5 2015-12-22 20:43:35 +08:00
memneq.c
michael_mic.c
pcbc.c
pcompress.c
pcrypt.c crypto: aead - Remove CRYPTO_ALG_AEAD_NEW flag 2015-08-17 16:53:53 +08:00
poly1305_generic.c crypto: poly1305 - Export common Poly1305 helpers 2015-07-17 21:20:26 +08:00
proc.c
ripemd.h
rmd128.c
rmd160.c
rmd256.c
rmd320.c
rng.c crypto: rng - Do not free default RNG when it becomes unused 2015-06-22 15:49:18 +08:00
rsa-pkcs1pad.c crypto: rsa-pkcs1pad - don't allocate buffer on stack 2015-12-22 20:43:24 +08:00
rsa.c crypto: rsa - RSA padding algorithm 2015-12-09 20:03:57 +08:00
rsa_helper.c crypto: akcipher - Changes to asymmetric key API 2015-10-14 22:23:16 +08:00
rsaprivkey.asn1 crypto: akcipher - Changes to asymmetric key API 2015-10-14 22:23:16 +08:00
rsapubkey.asn1 crypto: akcipher - Changes to asymmetric key API 2015-10-14 22:23:16 +08:00
salsa20_generic.c
scatterwalk.c crypto: scatterwalk - Hide PageSlab call to optimise away flush_dcache_page 2015-06-03 10:51:25 +08:00
seed.c
seqiv.c crypto: seqiv - Use generic geniv init/exit helpers 2015-08-17 16:53:46 +08:00
serpent_generic.c
sha1_generic.c crypto: hash - add zero length message hash for shax and md5 2015-12-22 20:43:35 +08:00
sha256_generic.c crypto: hash - add zero length message hash for shax and md5 2015-12-22 20:43:35 +08:00
sha512_generic.c
shash.c crypto: shash - Fix has_key setting 2016-01-27 20:25:13 +08:00
skcipher.c crypto: skcipher - Add crypto_skcipher_has_setkey 2016-01-18 18:16:12 +08:00
tcrypt.c crypto: tcrypt - fix keysize argument of test_aead_speed for gcm(aes) 2015-11-23 20:55:52 +08:00
tcrypt.h crypto: tcrypt - Add ChaCha20/Poly1305 speed tests 2015-07-17 21:20:20 +08:00
tea.c
testmgr.c crypto: keywrap - add testmgr support 2015-10-15 21:05:08 +08:00
testmgr.h crypto: keywrap - add testmgr support 2015-10-15 21:05:08 +08:00
tgr192.c
twofish_common.c
twofish_generic.c
vmac.c
wp512.c
xcbc.c
xor.c
xts.c
zlib.c