linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: [PATCH 3/3] vfree, kvfree: Add debug might sleeps.
Date: Fri, 14 Sep 2018 16:05:12 +0300	[thread overview]
Message-ID: <20180914130512.10394-3-aryabinin@virtuozzo.com> (raw)
In-Reply-To: <20180914130512.10394-1-aryabinin@virtuozzo.com>

Add might_sleep() calls to vfree(), kvfree() to catch potential
sleep-in-atomic bugs earlier.

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/util.c    | 2 ++
 mm/vmalloc.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/mm/util.c b/mm/util.c
index 7f1f165f46af..929ed1795bc1 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -446,6 +446,8 @@ EXPORT_SYMBOL(kvmalloc_node);
  */
 void kvfree(const void *addr)
 {
+	might_sleep_if(!in_interrupt());
+
 	if (is_vmalloc_addr(addr))
 		vfree(addr);
 	else
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index d00d42d6bf79..97d4b25d0373 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1587,6 +1587,8 @@ void vfree(const void *addr)
 
 	kmemleak_free(addr);
 
+	might_sleep_if(!in_interrupt());
+
 	if (!addr)
 		return;
 	if (unlikely(in_interrupt()))
-- 
2.16.4

  parent reply	other threads:[~2018-09-14 13:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 13:05 [PATCH 1/3] kvfree(): Fix misleading comment Andrey Ryabinin
2018-09-14 13:05 ` [PATCH 2/3] mm/vmalloc: Improve vfree() kerneldoc Andrey Ryabinin
2018-09-14 13:05 ` Andrey Ryabinin [this message]
2018-09-18  8:52   ` [LKP] [vfree, kvfree] a79ed8bfb2: BUG:sleeping_function_called_from_invalid_context_at_mm/util.c kernel test robot
2018-09-18  9:43     ` Andrey Ryabinin
2018-09-19  5:07       ` Rong Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180914130512.10394-3-aryabinin@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox