Guest User

Untitled

a guest
Oct 11th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. mm: compaction: check pfn_valid when entering a new MAX_ORDER_NR_PAGE…
  2. …S block during isolation for migration
  3.  
  4. commit 0bf380b upstream.
  5.  
  6. When isolating for migration, migration starts at the start of a zone
  7. which is not necessarily pageblock aligned. Further, it stops isolating
  8. when COMPACT_CLUSTER_MAX pages are isolated so migrate_pfn is generally
  9. not aligned. This allows isolate_migratepages() to call pfn_to_page() on
  10. an invalid PFN which can result in a crash. This was originally reported
  11. against a 3.0-based kernel with the following trace in a crash dump.
  12.  
  13. PID: 9902 TASK: d47aecd0 CPU: 0 COMMAND: "memcg_process_s"
  14. #0 [d72d3ad0] crash_kexec at c028cfdb
  15. #1 [d72d3b24] oops_end at c05c5322
  16. #2 [d72d3b38] __bad_area_nosemaphore at c0227e60
  17. #3 [d72d3bec] bad_area at c0227fb6
  18. #4 [d72d3c00] do_page_fault at c05c72ec
  19. #5 [d72d3c80] error_code (via page_fault) at c05c47a4
  20. EAX: 00000000 EBX: 000c0000 ECX: 00000001 EDX: 00000807 EBP: 000c0000
  21. DS: 007b ESI: 00000001 ES: 007b EDI: f3000a80 GS: 6f50
  22. CS: 0060 EIP: c030b15a ERR: ffffffff EFLAGS: 00010002
  23. #6 [d72d3cb4] isolate_migratepages at c030b15a
  24. #7 [d72d3d14] zone_watermark_ok at c02d26cb
  25. #8 [d72d3d2c] compact_zone at c030b8de
  26. #9 [d72d3d68] compact_zone_order at c030bba1
  27. #10 [d72d3db4] try_to_compact_pages at c030bc84
  28. #11 [d72d3ddc] __alloc_pages_direct_compact at c02d61e7
  29. #12 [d72d3e08] __alloc_pages_slowpath at c02d66c7
  30. #13 [d72d3e78] __alloc_pages_nodemask at c02d6a97
  31. #14 [d72d3eb8] alloc_pages_vma at c030a845
  32. #15 [d72d3ed4] do_huge_pmd_anonymous_page at c03178eb
  33. #16 [d72d3f00] handle_mm_fault at c02f36c6
  34. #17 [d72d3f30] do_page_fault at c05c70ed
  35. #18 [d72d3fb0] error_code (via page_fault) at c05c47a4
  36. EAX: b71ff000 EBX: 00000001 ECX: 00001600 EDX: 00000431
  37. DS: 007b ESI: 08048950 ES: 007b EDI: bfaa3788
  38. SS: 007b ESP: bfaa36e0 EBP: bfaa3828 GS: 6f50
  39. CS: 0073 EIP: 080487c8 ERR: ffffffff EFLAGS: 00010202
  40.  
  41. It was also reported by Herbert van den Bergh against 3.1-based kernel
  42. with the following snippet from the console log.
  43.  
  44. BUG: unable to handle kernel paging request at 01c00008
  45. IP: [<c0522399>] isolate_migratepages+0x119/0x390
  46. *pdpt = 000000002f7ce001 *pde = 0000000000000000
  47.  
  48. It is expected that it also affects 3.2.x and current mainline.
  49.  
  50. The problem is that pfn_valid is only called on the first PFN being
  51. checked and that PFN is not necessarily aligned. Lets say we have a case
  52. like this
  53.  
  54. H = MAX_ORDER_NR_PAGES boundary
  55. | = pageblock boundary
  56. m = cc->migrate_pfn
  57. f = cc->free_pfn
  58. o = memory hole
  59.  
  60. H------|------H------|----m-Hoooooo|ooooooH-f----|------H
  61.  
  62. The migrate_pfn is just below a memory hole and the free scanner is beyond
  63. the hole. When isolate_migratepages started, it scans from migrate_pfn to
  64. migrate_pfn+pageblock_nr_pages which is now in a memory hole. It checks
  65. pfn_valid() on the first PFN but then scans into the hole where there are
  66. not necessarily valid struct pages.
  67.  
  68. This patch ensures that isolate_migratepages calls pfn_valid when
  69. necessary.
  70.  
  71. Reported-by: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
  72. Tested-by: Herbert van den Bergh <herbert.van.den.bergh@oracle.com>
  73. Signed-off-by: Mel Gorman <mgorman@suse.de>
  74. Acked-by: Michal Nazarewicz <mina86@mina86.com>
  75. Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  76. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  77. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add Comment
Please, Sign In to add comment