From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Subject: Re: [PATCH 2/3] drm/scheduler: Don't call wait_event_killable for signaled process. Date: Fri, 18 May 2018 10:46:39 +0200 Message-ID: <12c806f9-f283-5bed-d137-7719ba73205a@daenzer.net> References: <87muxsbmkp.fsf@xmission.com> <8840ac96-50c4-f94d-eb7c-f007940163f3@amd.com> <877eowa5qh.fsf@xmission.com> <20180425135552.GD7592@redhat.com> <20180425171757.GA10441@redhat.com> <874ljyu98e.fsf@xmission.com> <20180430160006.GB10583@redhat.com> <79b2ce10-2cd7-b6f2-551e-0b4ae21072af@amd.com> <28de0150-0a31-f51a-4f56-0a71f741e07e@amd.com> <3ff3a5f4-c109-bf86-2772-9d88abc419df@amd.com> <662c84bf-ac38-db28-1a11-b17719c9b8d0@daenzer.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------93B4086DC54382A13E477DD4" Return-path: Received: from netline-mail3.netline.ch (mail.netline.ch [148.251.143.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 919146EC85 for ; Fri, 18 May 2018 08:46:41 +0000 (UTC) In-Reply-To: Content-Language: en-CA List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Andrey Grodzovsky Cc: "Koenig, Christian" , ML dri-devel List-Id: dri-devel@lists.freedesktop.org This is a multi-part message in MIME format. --------------93B4086DC54382A13E477DD4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 2018-05-17 09:05 PM, Andrey Grodzovsky wrote: > On 05/17/2018 10:48 AM, Michel Dänzer wrote: >> On 2018-05-17 01:18 PM, Andrey Grodzovsky wrote: >>> Hi Michele and others, I am trying to implement the approach bellow to >>> resolve AMDGPU's hang when commands are stuck in pipe during process >>> exit. >>> >>> I noticed that once I implemented the file_operation.flush callback >>> then during run of X, i see the flush callback gets called not only for >>> Xorg process but for other >>> >>> processes such as 'xkbcomp' and even 'sh', it seems like Xorg passes his >>> FDs to children, Christian mentioned he remembered a discussion to >>> always set FD_CLOEXEC flag when opening the hardware device file, so >>> >>> we suspect a bug in Xorg with regard to this behavior. >> Try the libdrm patch below. >> >> Note that the X server passes DRM file descriptors to DRI3 clients. > > Tried it, didn't help. I still see other processes calling .flush for > /dev/dri/card0 Try the attached xserver patch on top. With these patches, I no longer see any DRM file descriptors being opened without O_CLOEXEC running Xorg -pogo in strace. Anyway, the kernel can't rely on userspace using O_CLOEXEC. If the flush callback being called from multiple processes is an issue, maybe the flush callback isn't appropriate after all. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer --------------93B4086DC54382A13E477DD4 Content-Type: text/x-patch; name="xserver-DRM-always-CLOEXEC.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xserver-DRM-always-CLOEXEC.diff" diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers= /modesetting/driver.c index 5d8906d63..306541f33 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -200,12 +200,12 @@ open_hw(const char *dev) int fd; =20 if (dev) - fd =3D open(dev, O_RDWR, 0); + fd =3D open(dev, O_RDWR | O_CLOEXEC, 0); else { dev =3D getenv("KMSDEVICE"); - if ((NULL =3D=3D dev) || ((fd =3D open(dev, O_RDWR, 0)) =3D=3D -= 1)) { + if ((NULL =3D=3D dev) || ((fd =3D open(dev, O_RDWR | O_CLOEXEC, = 0)) =3D=3D -1)) { dev =3D "/dev/dri/card0"; - fd =3D open(dev, O_RDWR, 0); + fd =3D open(dev, O_RDWR | O_CLOEXEC, 0); } } if (fd =3D=3D -1) diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-s= upport/linux/lnx_platform.c index 11af52c46..70374ace8 100644 --- a/hw/xfree86/os-support/linux/lnx_platform.c +++ b/hw/xfree86/os-support/linux/lnx_platform.c @@ -43,7 +43,7 @@ get_drm_info(struct OdevAttributes *attribs, char *path= , int delayed_index) } =20 if (fd =3D=3D -1) - fd =3D open(path, O_RDWR, O_CLOEXEC); + fd =3D open(path, O_RDWR | O_CLOEXEC, 0); =20 if (fd =3D=3D -1) return FALSE; --------------93B4086DC54382A13E477DD4 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --------------93B4086DC54382A13E477DD4--