From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Brezillon Subject: Re: [PATCH 8/8] drm/panfrost: Make sure the shrinker does not reclaim referenced BOs Date: Mon, 2 Dec 2019 14:32:24 +0100 Message-ID: <20191202143224.445ad75d@collabora.com> References: <20191129135908.2439529-1-boris.brezillon@collabora.com> <20191129135908.2439529-9-boris.brezillon@collabora.com> <7258aca4-115d-d511-4c0a-fb3ba142f382@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <7258aca4-115d-d511-4c0a-fb3ba142f382@arm.com> Sender: stable-owner@vger.kernel.org To: Robin Murphy Cc: Rob Herring , Tomeu Vizoso , Alyssa Rosenzweig , Steven Price , stable@vger.kernel.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Mon, 2 Dec 2019 12:50:20 +0000 Robin Murphy wrote: > On 29/11/2019 1:59 pm, Boris Brezillon wrote: > > Userspace might tag a BO purgeable while it's still referenced by GPU > > jobs. We need to make sure the shrinker does not purge such BOs until > > all jobs referencing it are finished. > > Nit: for extra robustness, perhaps it's worth using the refcount_t API > rather than bare atomic_t? I considered doing that. The problem is, we start counting from 0, not 1, and the refcount API assumes counters start at 0, and should never see a 0 -> 1 transition. I guess we could do if (refcount_inc_not_zero()) { ... } else { refcount_set(1); ... } so we at least get the integer overflow/underflow protection. Anyway, I'm reworking the gem_shmem code so we can refcount the sgt users (I actually re-use the page_use_count counter and turn into a refcount_t so we don't need to take the lock if it's > 0). With this change I think I won't need the gpu_usecount. 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 6841FC432C0 for ; Mon, 2 Dec 2019 13:32:31 +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 4821B20833 for ; Mon, 2 Dec 2019 13:32:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4821B20833 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 7578A89AFF; Mon, 2 Dec 2019 13:32:30 +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 04E5989AF3 for ; Mon, 2 Dec 2019 13:32:29 +0000 (UTC) Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (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 B11C128F684; Mon, 2 Dec 2019 13:32:27 +0000 (GMT) Date: Mon, 2 Dec 2019 14:32:24 +0100 From: Boris Brezillon To: Robin Murphy Subject: Re: [PATCH 8/8] drm/panfrost: Make sure the shrinker does not reclaim referenced BOs Message-ID: <20191202143224.445ad75d@collabora.com> In-Reply-To: <7258aca4-115d-d511-4c0a-fb3ba142f382@arm.com> References: <20191129135908.2439529-1-boris.brezillon@collabora.com> <20191129135908.2439529-9-boris.brezillon@collabora.com> <7258aca4-115d-d511-4c0a-fb3ba142f382@arm.com> 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: stable@vger.kernel.org, Steven Price , Rob Herring , dri-devel@lists.freedesktop.org, Alyssa Rosenzweig Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Message-ID: <20191202133224.UMdUK2y_ci0zFuoHrWBA5-Zu3MFvFFE4ZfgQb9wb5PU@z> T24gTW9uLCAyIERlYyAyMDE5IDEyOjUwOjIwICswMDAwClJvYmluIE11cnBoeSA8cm9iaW4ubXVy cGh5QGFybS5jb20+IHdyb3RlOgoKPiBPbiAyOS8xMS8yMDE5IDE6NTkgcG0sIEJvcmlzIEJyZXpp bGxvbiB3cm90ZToKPiA+IFVzZXJzcGFjZSBtaWdodCB0YWcgYSBCTyBwdXJnZWFibGUgd2hpbGUg aXQncyBzdGlsbCByZWZlcmVuY2VkIGJ5IEdQVQo+ID4gam9icy4gV2UgbmVlZCB0byBtYWtlIHN1 cmUgdGhlIHNocmlua2VyIGRvZXMgbm90IHB1cmdlIHN1Y2ggQk9zIHVudGlsCj4gPiBhbGwgam9i cyByZWZlcmVuY2luZyBpdCBhcmUgZmluaXNoZWQuICAKPiAKPiBOaXQ6IGZvciBleHRyYSByb2J1 c3RuZXNzLCBwZXJoYXBzIGl0J3Mgd29ydGggdXNpbmcgdGhlIHJlZmNvdW50X3QgQVBJIAo+IHJh dGhlciB0aGFuIGJhcmUgYXRvbWljX3Q/CgpJIGNvbnNpZGVyZWQgZG9pbmcgdGhhdC4gVGhlIHBy b2JsZW0gaXMsIHdlIHN0YXJ0IGNvdW50aW5nIGZyb20gMCwgbm90CjEsI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