From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 811ADC432C0 for ; Fri, 29 Nov 2019 21:45:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F0DB2464A for ; Fri, 29 Nov 2019 21:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbfK2Vpm (ORCPT ); Fri, 29 Nov 2019 16:45:42 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41816 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbfK2Vpl (ORCPT ); Fri, 29 Nov 2019 16:45:41 -0500 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:b93f:9fae:b276:a89a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id DC910292998; Fri, 29 Nov 2019 21:45:39 +0000 (GMT) Date: Fri, 29 Nov 2019 22:45:36 +0100 From: Boris Brezillon To: Daniel Vetter Cc: Steven Price , Rob Herring , dri-devel@lists.freedesktop.org, stable@vger.kernel.org, Alyssa Rosenzweig Subject: Re: [PATCH 2/8] drm/panfrost: Fix a race in panfrost_ioctl_madvise() Message-ID: <20191129224536.6ba79df0@collabora.com> In-Reply-To: <20191129200733.GQ624164@phenom.ffwll.local> References: <20191129135908.2439529-1-boris.brezillon@collabora.com> <20191129135908.2439529-3-boris.brezillon@collabora.com> <20191129153310.2f9c80e1@collabora.com> <20191129200733.GQ624164@phenom.ffwll.local> Organization: Collabora X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, 29 Nov 2019 21:07:33 +0100 Daniel Vetter wrote: > On Fri, Nov 29, 2019 at 02:40:34PM +0000, Steven Price wrote: > > On 29/11/2019 14:33, Boris Brezillon wrote: > > > On Fri, 29 Nov 2019 14:24:48 +0000 > > > Steven Price wrote: > > > > > >> On 29/11/2019 13:59, Boris Brezillon wrote: > > >>> If 2 threads change the MADVISE property of the same BO in parallel we > > >>> might end up with an shmem->madv value that's inconsistent with the > > >>> presence of the BO in the shrinker list. > > >> > > >> I'm a bit worried from the point of view of user space sanity that you > > >> observed this - but clearly the kernel should be robust! > > > > > > It's not something I observed, just found the race by inspecting the > > > code, and I thought it was worth fixing it. > > > > Good! ;) Your cover letter referring to a "debug session" made me think > > you'd actually hit all these. > > Time for some igt to make sure this is actually correct? That's not something I can easily trigger without instrumenting the code: I need 2 threads doing MADVISE with 2 different values, and there has to be a context switch between the drm_gem_shmem_madvise() call and the mutex_lock(shrinker_lock) one. And last but not least, I'll need a way to report such inconsistencies to userspace (trace?). From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CC7C432C3 for ; Fri, 29 Nov 2019 21:45:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0EB82464A for ; Fri, 29 Nov 2019 21:45:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0EB82464A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EBD326E967; Fri, 29 Nov 2019 21:45:42 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7953B6E967 for ; Fri, 29 Nov 2019 21:45:41 +0000 (UTC) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:b93f:9fae:b276:a89a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id DC910292998; Fri, 29 Nov 2019 21:45:39 +0000 (GMT) Date: Fri, 29 Nov 2019 22:45:36 +0100 From: Boris Brezillon To: Daniel Vetter Subject: Re: [PATCH 2/8] drm/panfrost: Fix a race in panfrost_ioctl_madvise() Message-ID: <20191129224536.6ba79df0@collabora.com> In-Reply-To: <20191129200733.GQ624164@phenom.ffwll.local> References: <20191129135908.2439529-1-boris.brezillon@collabora.com> <20191129135908.2439529-3-boris.brezillon@collabora.com> <20191129153310.2f9c80e1@collabora.com> <20191129200733.GQ624164@phenom.ffwll.local> Organization: Collabora X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Alyssa Rosenzweig , stable@vger.kernel.org, dri-devel@lists.freedesktop.org, Steven Price Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Message-ID: <20191129214536.W97wBtijX3LiHZzRBUkZ9Y-gdfLFPq7GJPVfDlFxYmw@z> T24gRnJpLCAyOSBOb3YgMjAxOSAyMTowNzozMyArMDEwMApEYW5pZWwgVmV0dGVyIDxkYW5pZWxA ZmZ3bGwuY2g+IHdyb3RlOgoKPiBPbiBGcmksIE5vdiAyOSwgMjAxOSBhdCAwMjo0MDozNFBNICsw MDAwLCBTdGV2ZW4gUHJpY2Ugd3JvdGU6Cj4gPiBPbiAyOS8xMS8yMDE5IDE0OjMzLCBCb3JpcyBC cmV6aWxsb24gd3JvdGU6ICAKPiA+ID4gT24gRnJpLCAyOSBOb3YgMjAxOSAxNDoyNDo0OCArMDAw MAo+ID4gPiBTdGV2ZW4gUHJpY2UgPHN0ZXZlbi5wcmljZUBhcm0uY29tPiB3cm90ZToKPiA+ID4g ICAKPiA+ID4+IE9uIDI5LzExLzIwMTkgMTM6NTksIEJvcmlzIEJyZXppbGxvbiB3cm90ZTogIAo+ ID4gPj4+IElmIDIgdGhyZWFkcyBjaGFuZ2UgdGhlIE1BRFZJU0UgcHJvcGVydHkgb2YgdGhlIHNh bWUgQk8gaW4gcGFyYWxsZWwgd2UKPiA+ID4+PiBtaWdodCBlbmQgdXAgd2l0aCBhbiBzaG1lbS0+ bWFkdiB2YWx1ZSB0aGF0J3MgaW5jb25zaXN0ZW50IHdpdGggdGhlCj4gPiA+Pj4gcHJlc2VuY2Ug b2YgdGh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