[patch 013/111] mm/kasan: don't reduce quarantine in atomic contexts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
Subject: mm/kasan: don't reduce quarantine in atomic contexts

Currently we call quarantine_reduce() for ___GFP_KSWAPD_RECLAIM (implied
by __GFP_RECLAIM) allocation.  So, basically we call it on almost every
allocation.  quarantine_reduce() sometimes is heavy operation, and calling
it with disabled interrupts may trigger hard LOCKUP:

 NMI watchdog: Watchdog detected hard LOCKUP on cpu 2irq event stamp: 1411258
 Call Trace:
  <NMI>  [<ffffffff98a48532>] dump_stack+0x68/0x96
  [<ffffffff98357fbb>] watchdog_overflow_callback+0x15b/0x190
  [<ffffffff9842f7d1>] __perf_event_overflow+0x1b1/0x540
  [<ffffffff98455b14>] perf_event_overflow+0x14/0x20
  [<ffffffff9801976a>] intel_pmu_handle_irq+0x36a/0xad0
  [<ffffffff9800ba4c>] perf_event_nmi_handler+0x2c/0x50
  [<ffffffff98057058>] nmi_handle+0x128/0x480
  [<ffffffff980576d2>] default_do_nmi+0xb2/0x210
  [<ffffffff980579da>] do_nmi+0x1aa/0x220
  [<ffffffff99a0bb07>] end_repeat_nmi+0x1a/0x1e
  <<EOE>>  [<ffffffff981871e6>] __kernel_text_address+0x86/0xb0
  [<ffffffff98055c4b>] print_context_stack+0x7b/0x100
  [<ffffffff98054e9b>] dump_trace+0x12b/0x350
  [<ffffffff98076ceb>] save_stack_trace+0x2b/0x50
  [<ffffffff98573003>] set_track+0x83/0x140
  [<ffffffff98575f4a>] free_debug_processing+0x1aa/0x420
  [<ffffffff98578506>] __slab_free+0x1d6/0x2e0
  [<ffffffff9857a9b6>] ___cache_free+0xb6/0xd0
  [<ffffffff9857db53>] qlist_free_all+0x83/0x100
  [<ffffffff9857df07>] quarantine_reduce+0x177/0x1b0
  [<ffffffff9857c423>] kasan_kmalloc+0xf3/0x100

Reduce the quarantine_reduce iff direct reclaim is allowed.

Fixes: 55834c59098d("mm: kasan: initial memory quarantine implementation")
Link: http://lkml.kernel.org/r/1470062715-14077-2-git-send-email-aryabinin@xxxxxxxxxxxxx
Signed-off-by: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>
Reported-by: Dave Jones <davej@xxxxxxxxxxxxxxxxx>
Acked-by: Alexander Potapenko <glider@xxxxxxxxxx>
Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/kasan/kasan.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff -puN mm/kasan/kasan.c~mm-kasan-dont-reduce-quarantine-in-atomic-contexts mm/kasan/kasan.c
--- a/mm/kasan/kasan.c~mm-kasan-dont-reduce-quarantine-in-atomic-contexts
+++ a/mm/kasan/kasan.c
@@ -565,7 +565,7 @@ void kasan_kmalloc(struct kmem_cache *ca
 	unsigned long redzone_start;
 	unsigned long redzone_end;
 
-	if (flags & __GFP_RECLAIM)
+	if (gfpflags_allow_blocking(flags))
 		quarantine_reduce();
 
 	if (unlikely(object == NULL))
@@ -596,7 +596,7 @@ void kasan_kmalloc_large(const void *ptr
 	unsigned long redzone_start;
 	unsigned long redzone_end;
 
-	if (flags & __GFP_RECLAIM)
+	if (gfpflags_allow_blocking(flags))
 		quarantine_reduce();
 
 	if (unlikely(ptr == NULL))
_
--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]
  Powered by Linux