linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
To: Michal Hocko <mhocko@kernel.org>, Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm,oom: Teach lockdep about oom_lock.
Date: Thu, 14 Mar 2019 22:55:34 +0900	[thread overview]
Message-ID: <195f38a9-5409-180c-2ccc-807942ab1994@i-love.sakura.ne.jp> (raw)
In-Reply-To: <20190312153140.GU5721@dhcp22.suse.cz>

On 2019/03/13 0:31, Michal Hocko wrote:
>> @@ -1120,8 +1129,25 @@ void pagefault_out_of_memory(void)
>>  	if (mem_cgroup_oom_synchronize(true))
>>  		return;
>>  
>> -	if (!mutex_trylock(&oom_lock))
>> +	if (!mutex_trylock(&oom_lock)) {
>> +		/*
>> +		 * This corresponds to prepare_alloc_pages(). Lockdep will
>> +		 * complain if e.g. OOM notifier for global OOM by error
>> +		 * triggered pagefault OOM path.
>> +		 */
>> +		oom_reclaim_acquire(GFP_KERNEL);
>> +		oom_reclaim_release(GFP_KERNEL);
>>  		return;
>> +	}
>> +	/*
>> +	 * Teach lockdep to consider that current thread is not allowed to
>> +	 * involve (even indirectly via dependency) __GFP_DIRECT_RECLAIM &&
>> +	 * !__GFP_NORETRY allocation from this function, for such allocation
>> +	 * will have to wait for completion of this function when
>> +	 * __alloc_pages_may_oom() is called.
>> +	 */
>> +	oom_reclaim_release(GFP_KERNEL);
>> +	oom_reclaim_acquire(GFP_KERNEL);
> 
> This part is not really clear to me. Why do you release&acquire when
> mutex_trylock just acquire the lock? If this is really needed then this
> should be put into the comment.

I think there is a reason lockdep needs to distinguish trylock and lock.
I don't know how lockdep utilizes "trylock or lock" information upon validation, but
explicitly telling lockdep that "oom_lock acts as if held by lock" should not harm.

#define mutex_acquire(l, s, t, i)               lock_acquire_exclusive(l, s, t, NULL, i)
#define lock_acquire_exclusive(l, s, t, n, i)           lock_acquire(l, s, t, 0, 1, n, i)
void lock_acquire(struct lockdep_map *lock, unsigned int subclass, int trylock, int read, int check, struct lockdep_map *nest_lock, unsigned long ip);

> 
>>  	out_of_memory(&oc);
>>  	mutex_unlock(&oom_lock);
>>  }
> 


  reply	other threads:[~2019-03-14 13:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 10:22 Tetsuo Handa
2019-03-08 11:03 ` Michal Hocko
2019-03-08 11:29   ` Tetsuo Handa
2019-03-08 11:54     ` Michal Hocko
2019-03-08 11:58       ` Michal Hocko
2019-03-08 15:01         ` Peter Zijlstra
2019-03-08 15:13           ` Michal Hocko
2019-03-09  6:02             ` Tetsuo Handa
2019-03-11 10:30               ` Michal Hocko
2019-03-12 14:06                 ` Tetsuo Handa
2019-03-12 15:31                   ` Michal Hocko
2019-03-14 13:55                     ` Tetsuo Handa [this message]
2019-03-12  8:24               ` Peter Zijlstra

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=195f38a9-5409-180c-2ccc-807942ab1994@i-love.sakura.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=peterz@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