From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
To: "Michal Hocko" <mhocko@kernel.org>,
"Christian König" <christian.koenig@amd.com>
Cc: kvm@vger.kernel.org, "Radim Krčmář" <rkrcmar@redhat.com>,
"Sudeep Dutt" <sudeep.dutt@intel.com>,
dri-devel@lists.freedesktop.org, linux-mm@kvack.org,
"Andrea Arcangeli" <aarcange@redhat.com>,
"Dimitri Sivanich" <sivanich@sgi.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org,
"David Airlie" <airlied@linux.ie>,
"Doug Ledford" <dledford@redhat.com>,
"David Rientjes" <rientjes@google.com>,
xen-devel@lists.xenproject.org, intel-gfx@lists.freedesktop.org,
"Leon Romanovsky" <leonro@mellanox.com>,
"Jérôme Glisse" <jglisse@redhat.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Juergen Gross" <jgross@suse.com>,
"Mike Marciniszyn" <mike.marciniszyn@intel.com>,
"Dennis Dalessandro" <dennis.dalessandro@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
"Ashutosh Dixit" <ashutosh.dixit@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Felix Kuehling" <felix.kuehling@amd.com>
Subject: Re: [PATCH] mm, oom: distinguish blockable mode for mmu notifiers
Date: Sun, 26 Aug 2018 17:40:00 +0900 [thread overview]
Message-ID: <b78f8b3a-7bc6-0dea-6752-5ea798eccb6b@i-love.sakura.ne.jp> (raw)
In-Reply-To: <20180824135257.GU29735@dhcp22.suse.cz>
On 2018/08/24 22:52, Michal Hocko wrote:
> @@ -180,11 +180,15 @@ void amdgpu_mn_unlock(struct amdgpu_mn *mn)
> */
> static int amdgpu_mn_read_lock(struct amdgpu_mn *amn, bool blockable)
> {
> - if (blockable)
> - mutex_lock(&amn->read_lock);
> - else if (!mutex_trylock(&amn->read_lock))
> - return -EAGAIN;
> -
> + /*
> + * We can take sleepable lock even on !blockable mode because
> + * read_lock is only ever take from this path and the notifier
> + * lock never really sleeps. In fact the only reason why the
> + * later is sleepable is because the notifier itself might sleep
> + * in amdgpu_mn_invalidate_node but blockable mode is handled
> + * before calling into that path.
> + */
> + mutex_lock(&amn->read_lock);
> if (atomic_inc_return(&amn->recursion) == 1)
> down_read_non_owner(&amn->lock);
> mutex_unlock(&amn->read_lock);
>
I'm not following. Why don't we need to do like below (given that
nobody except amdgpu_mn_read_lock() holds ->read_lock) because e.g.
drm_sched_fence_create() from drm_sched_job_init() from amdgpu_cs_submit()
is doing GFP_KERNEL memory allocation with ->lock held for write?
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
index e55508b..e1cb344 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
@@ -64,8 +64,6 @@
* @node: hash table node to find structure by adev and mn
* @lock: rw semaphore protecting the notifier nodes
* @objects: interval tree containing amdgpu_mn_nodes
- * @read_lock: mutex for recursive locking of @lock
- * @recursion: depth of recursion
*
* Data for each amdgpu device and process address space.
*/
@@ -85,8 +83,6 @@ struct amdgpu_mn {
/* objects protected by lock */
struct rw_semaphore lock;
struct rb_root_cached objects;
- struct mutex read_lock;
- atomic_t recursion;
};
/**
@@ -181,14 +177,9 @@ void amdgpu_mn_unlock(struct amdgpu_mn *mn)
static int amdgpu_mn_read_lock(struct amdgpu_mn *amn, bool blockable)
{
if (blockable)
- mutex_lock(&amn->read_lock);
- else if (!mutex_trylock(&amn->read_lock))
+ down_read(&amn->lock);
+ else if (!down_read_trylock(&amn->lock))
return -EAGAIN;
-
- if (atomic_inc_return(&amn->recursion) == 1)
- down_read_non_owner(&amn->lock);
- mutex_unlock(&amn->read_lock);
-
return 0;
}
@@ -199,8 +190,7 @@ static int amdgpu_mn_read_lock(struct amdgpu_mn *amn, bool blockable)
*/
static void amdgpu_mn_read_unlock(struct amdgpu_mn *amn)
{
- if (atomic_dec_return(&amn->recursion) == 0)
- up_read_non_owner(&amn->lock);
+ up_read(&amn->lock);
}
/**
@@ -410,8 +400,6 @@ struct amdgpu_mn *amdgpu_mn_get(struct amdgpu_device *adev,
amn->type = type;
amn->mn.ops = &amdgpu_mn_ops[type];
amn->objects = RB_ROOT_CACHED;
- mutex_init(&amn->read_lock);
- atomic_set(&amn->recursion, 0);
r = __mmu_notifier_register(&amn->mn, mm);
if (r)
next prev parent reply other threads:[~2018-08-26 8:41 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-16 11:50 [PATCH] mm, oom: distinguish blockable mode for mmu notifiers Michal Hocko
2018-07-16 23:12 ` Andrew Morton
2018-07-17 4:03 ` Leon Romanovsky
2018-07-17 8:12 ` Michal Hocko
2018-07-20 23:01 ` Andrew Morton
2018-07-23 8:43 ` Michal Hocko
2018-07-19 9:12 ` Michal Hocko
2018-07-21 0:09 ` Andrew Morton
2018-07-23 7:03 ` Michal Hocko
2018-07-23 7:11 ` Michal Hocko
2018-07-23 8:11 ` Michal Hocko
2018-07-24 14:17 ` Michal Hocko
2018-07-24 19:53 ` Andrew Morton
2018-07-25 6:17 ` Michal Hocko
2018-07-24 21:07 ` David Rientjes
2018-07-25 6:13 ` Michal Hocko
2018-08-24 10:54 ` Tetsuo Handa
2018-08-24 11:32 ` Michal Hocko
2018-08-24 11:43 ` Christian König
2018-08-24 11:52 ` Michal Hocko
2018-08-24 11:57 ` Christian König
2018-08-24 12:03 ` Michal Hocko
2018-08-24 12:18 ` Christian König
2018-08-24 12:33 ` Michal Hocko
2018-08-24 12:52 ` Christian König
2018-08-24 13:01 ` Michal Hocko
2018-08-24 13:10 ` Christian König
2018-08-24 13:24 ` Michal Hocko
2018-08-24 13:28 ` Christian König
2018-08-24 13:40 ` Michal Hocko
2018-08-24 13:44 ` Christian König
2018-08-24 13:52 ` Michal Hocko
2018-08-26 8:40 ` Tetsuo Handa [this message]
2018-08-27 7:41 ` Christian König
2018-09-06 22:46 ` Tetsuo Handa
2018-08-24 15:08 ` Jerome Glisse
2018-08-24 11:36 ` Michal Hocko
2018-08-24 13:02 ` Tetsuo Handa
2018-08-24 13:32 ` Michal Hocko
2018-08-24 14:52 ` Tetsuo Handa
2018-08-24 15:12 ` Jerome Glisse
2018-08-24 16:40 ` Michal Hocko
2018-08-24 17:33 ` Jerome Glisse
2018-08-24 16:38 ` Michal Hocko
2018-08-24 14:40 ` Jerome Glisse
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=b78f8b3a-7bc6-0dea-6752-5ea798eccb6b@i-love.sakura.ne.jp \
--to=penguin-kernel@i-love.sakura.ne.jp \
--cc=aarcange@redhat.com \
--cc=airlied@linux.ie \
--cc=akpm@linux-foundation.org \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ashutosh.dixit@intel.com \
--cc=boris.ostrovsky@oracle.com \
--cc=christian.koenig@amd.com \
--cc=dennis.dalessandro@intel.com \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=felix.kuehling@amd.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=jgross@suse.com \
--cc=kvm@vger.kernel.org \
--cc=leonro@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=mike.marciniszyn@intel.com \
--cc=pbonzini@redhat.com \
--cc=rientjes@google.com \
--cc=rkrcmar@redhat.com \
--cc=rodrigo.vivi@intel.com \
--cc=sivanich@sgi.com \
--cc=sudeep.dutt@intel.com \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).