intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Michal Hocko <mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	christian.koenig-5C7GfCeVMHo@public.gmane.org
Cc: kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Radim Krčmář" <rkrcmar-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Tetsuo Handa"
	<penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>,
	"Joonas Lahtinen"
	<joonas.lahtinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"Sudeep Dutt"
	<sudeep.dutt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org,
	"Andrea Arcangeli"
	<aarcange-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"David (ChunMing) Zhou"
	<David1.Zhou-5C7GfCeVMHo@public.gmane.org>,
	"Dimitri Sivanich" <sivanich-sJ/iWh9BUns@public.gmane.org>,
	"Jason Gunthorpe" <jgg-uk2M96/98Pc@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	"David Airlie" <airlied-cv59FeDIM0c@public.gmane.org>,
	"Doug Ledford" <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"David Rientjes"
	<rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	"Jani Nikula"
	<jani.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	"Leon Romanovsky"
	<leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	"Jérôme Glisse" <jglisse-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Rodrigo Vivi"
	<rodrigo.vivi-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"Boris Ostrovsky"
	<boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] mm, oom: distinguish blockable mode for mmu notifiers
Date: Fri, 24 Aug 2018 13:57:52 +0200	[thread overview]
Message-ID: <a27ad1a3-34bd-6b7d-fd09-7737ec3c888d@gmail.com> (raw)
In-Reply-To: <20180824115226.GK29735-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>

Am 24.08.2018 um 13:52 schrieb Michal Hocko:
> On Fri 24-08-18 13:43:16, Christian König wrote:
>> Am 24.08.2018 um 13:32 schrieb Michal Hocko:
>>> On Fri 24-08-18 19:54:19, Tetsuo Handa wrote:
>>>> Two more worries for this patch.
>>>>
>>>>
>>>>
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mn.c
>>>>> @@ -178,12 +178,18 @@ void amdgpu_mn_unlock(struct amdgpu_mn *mn)
>>>>>     *
>>>>>     * @amn: our notifier
>>>>>     */
>>>>> -static void amdgpu_mn_read_lock(struct amdgpu_mn *amn)
>>>>> +static int amdgpu_mn_read_lock(struct amdgpu_mn *amn, bool blockable)
>>>>>    {
>>>>> -       mutex_lock(&amn->read_lock);
>>>>> +       if (blockable)
>>>>> +               mutex_lock(&amn->read_lock);
>>>>> +       else if (!mutex_trylock(&amn->read_lock))
>>>>> +               return -EAGAIN;
>>>>> +
>>>>>           if (atomic_inc_return(&amn->recursion) == 1)
>>>>>                   down_read_non_owner(&amn->lock);
>>>> Why don't we need to use trylock here if blockable == false ?
>>>> Want comment why it is safe to use blocking lock here.
>>> Hmm, I am pretty sure I have checked the code but it was quite confusing
>>> so I might have missed something. Double checking now, it seems that
>>> this read_lock is not used anywhere else and it is not _the_ lock we are
>>> interested about. It is the amn->lock (amdgpu_mn_lock) which matters as
>>> it is taken in exclusive mode for expensive operations.
>> The write side of the lock is only taken in the command submission IOCTL.
>>
>> So you actually don't need to change anything here (even the proposed
>> changes are overkill) since we can't tear down the struct_mm while an IOCTL
>> is still using.
> I am not so sure. We are not in the mm destruction phase yet. This is
> mostly about the oom context which might fire right during the IOCTL. If
> any of the path which is holding the write lock blocks for unbound
> amount of time or even worse allocates a memory then we are screwed. So
> we need to back of when blockable = false.

Oh, yeah good point. Haven't thought about that possibility.

>
>>> Is that correct Christian? If this is correct then we need to update the
>>> locking here. I am struggling to grasp the ref counting part. Why cannot
>>> all readers simply take the lock rather than rely on somebody else to
>>> take it? 1ed3d2567c800 didn't really help me to understand the locking
>>> scheme here so any help would be appreciated.
>> That won't work like this there might be multiple
>> invalidate_range_start()/invalidate_range_end() pairs open at the same time.
>> E.g. the lock might be taken recursively and that is illegal for a
>> rw_semaphore.
> I am not sure I follow. Are you saying that one invalidate_range might
> trigger another one from the same path?

No, but what can happen is:

invalidate_range_start(A,B);
invalidate_range_start(C,D);
...
invalidate_range_end(C,D);
invalidate_range_end(A,B);

Grabbing the read lock twice would be illegal in this case.

Regards,
Christian.
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-08-24 11:57 UTC|newest]

Thread overview: 54+ 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 12:24 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev7) Patchwork
2018-07-16 23:12 ` [PATCH] mm, oom: distinguish blockable mode for mmu notifiers 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
     [not found] ` <20180716115058.5559-1-mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-07-19  9:12   ` Michal Hocko
2018-07-21  0:09 ` Andrew Morton
     [not found]   ` <20180720170902.d1137060c23802d55426aa03-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
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-07-24 14:33 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev8) Patchwork
2018-07-25 15:08 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev9) Patchwork
2018-08-24 10:54 ` [PATCH] mm, oom: distinguish blockable mode for mmu notifiers Tetsuo Handa
2018-08-24 11:32   ` Michal Hocko
     [not found]     ` <20180824113248.GH29735-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-08-24 11:43       ` Christian König
     [not found]         ` <b088e382-e90e-df63-a079-19b2ae2b985d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-08-24 11:52           ` Michal Hocko
     [not found]             ` <20180824115226.GK29735-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-08-24 11:57               ` Christian König [this message]
2018-08-24 12:03                 ` Michal Hocko
     [not found]                   ` <20180824120339.GL29735-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2018-08-24 12:18                     ` Christian König
     [not found]                       ` <eb546bcb-9c5f-7d5d-43a7-bfde489f0e7f-5C7GfCeVMHo@public.gmane.org>
2018-08-24 12:33                         ` Michal Hocko
2018-08-24 12:52                           ` Christian König
     [not found]                             ` <b11df415-baf8-0a41-3c16-60dfe8d32bd3-5C7GfCeVMHo@public.gmane.org>
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
     [not found]                                               ` <b78f8b3a-7bc6-0dea-6752-5ea798eccb6b-1yMVhJb1mP/7nzcFbJAaVXf5DAMn2ifp@public.gmane.org>
2018-08-27  7:41                                                 ` Christian König
2018-09-06 22:46                                                   ` Tetsuo Handa
2018-08-24 15:08                           ` Jerome Glisse
     [not found]   ` <8cbfb09f-0c5a-8d43-1f5e-f3ff7612e289-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
2018-08-24 11:36     ` Michal Hocko
2018-08-24 13:02       ` Tetsuo Handa
     [not found]         ` <103b1b33-1a1d-27a1-dcf8-5c8ad60056a6-1yMVhJb1mP/7nzcFbJAaVXf5DAMn2ifp@public.gmane.org>
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
2018-08-24 11:47 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev10) Patchwork
2018-08-24 13:32 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev11) Patchwork
2018-08-24 13:43 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev12) Patchwork
2018-08-24 13:53 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev13) Patchwork
2018-08-24 17:04 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev14) Patchwork
2018-08-26  8:42 ` ✗ Fi.CI.BAT: failure for mm, oom: distinguish blockable mode for mmu notifiers (rev15) Patchwork

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=a27ad1a3-34bd-6b7d-fd09-7737ec3c888d@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=David1.Zhou-5C7GfCeVMHo@public.gmane.org \
    --cc=aarcange-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=boris.ostrovsky-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=jani.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=jgg-uk2M96/98Pc@public.gmane.org \
    --cc=jglisse-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=joonas.lahtinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhocko-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=penguin-kernel-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org \
    --cc=rientjes-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=rkrcmar-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=rodrigo.vivi-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=sivanich-sJ/iWh9BUns@public.gmane.org \
    --cc=sudeep.dutt-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.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).