All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-mm@kvack.org, Dmitry Vyukov <dvyukov@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH] lockdep: Add debug printk() for downgrade_write() warning.
Date: Sun, 6 Jan 2019 20:19:41 -0800	[thread overview]
Message-ID: <20190106201941.49f6dc4a4d2e9d15b575f88a@linux-foundation.org> (raw)
In-Reply-To: <e1a38e21-d5fe-dee3-7081-bc1a12965a68@i-love.sakura.ne.jp>

On Sun, 6 Jan 2019 19:56:59 +0900 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> syzbot is frequently hitting downgrade_write(&mm->mmap_sem) warning from
> munmap() request, but I don't know why it is happening. Since lockdep is
> not printing enough information, let's print more. This patch is meant for
> linux-next.git only and will be removed after the problem is solved.
> 
> --- a/kernel/locking/lockdep.c
> +++ b/kernel/locking/lockdep.c
> @@ -50,6 +50,7 @@
>  #include <linux/random.h>
>  #include <linux/jhash.h>
>  #include <linux/nmi.h>
> +#include <linux/rwsem.h>
>  
>  #include <asm/sections.h>
>  
> @@ -3550,6 +3551,24 @@ static int __lock_downgrade(struct lockdep_map *lock, unsigned long ip)
>  	curr->lockdep_depth = i;
>  	curr->curr_chain_key = hlock->prev_chain_key;
>  
> +#if defined(CONFIG_RWSEM_XCHGADD_ALGORITHM) && defined(CONFIG_DEBUG_AID_FOR_SYZBOT)
> +	if (hlock->read && curr->mm) {
> +		struct rw_semaphore *sem = container_of(lock,
> +							struct rw_semaphore,
> +							dep_map);
> +
> +		if (sem == &curr->mm->mmap_sem) {
> +#if defined(CONFIG_RWSEM_SPIN_ON_OWNER)
> +			pr_warn("mmap_sem: hlock->read=%d count=%ld current=%px, owner=%px\n",
> +				hlock->read, atomic_long_read(&sem->count),
> +				curr, READ_ONCE(sem->owner));
> +#else
> +			pr_warn("mmap_sem: hlock->read=%d count=%ld\n",
> +				hlock->read, atomic_long_read(&sem->count));
> +#endif
> +		}
> +	}
> +#endif
>  	WARN(hlock->read, "downgrading a read lock");
>  	hlock->read = 1;
>  	hlock->acquire_ip = ip;

I tossed it in there.

But I wonder if anyone is actually running this code.  Because

--- a/lib/Kconfig.debug~info-task-hung-in-generic_file_write_iter
+++ a/lib/Kconfig.debug
@@ -2069,6 +2069,12 @@ config IO_STRICT_DEVMEM
 
 	  If in doubt, say Y.
 
+config DEBUG_AID_FOR_SYZBOT
+       bool "Additional debug code for syzbot"
+       default n
+       help
+         This option is intended for testing by syzbot.
+

       reply	other threads:[~2019-01-07  4:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1546771139-9349-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp>
     [not found] ` <e1a38e21-d5fe-dee3-7081-bc1a12965a68@i-love.sakura.ne.jp>
2019-01-07  4:19   ` Andrew Morton [this message]
2019-01-07  5:58     ` [PATCH] lockdep: Add debug printk() for downgrade_write() warning Dmitry Vyukov
2019-01-07  5:58       ` Dmitry Vyukov
2019-01-09 11:47       ` Tetsuo Handa
2019-01-09 18:22         ` Waiman Long
2019-01-10 10:12       ` Tetsuo Handa

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=20190106201941.49f6dc4a4d2e9d15b575f88a@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.