Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp241843rdb; Thu, 25 Jan 2024 13:58:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBxzs5BgzyNW63VJ+E4JVskqewoeDUn33iDwwNzjjyoWLhlZeZupi7sZ+iQxd+dA37SJBZ X-Received: by 2002:a05:6808:14c3:b0:3bd:a8b3:f5f5 with SMTP id f3-20020a05680814c300b003bda8b3f5f5mr460854oiw.75.1706219886741; Thu, 25 Jan 2024 13:58:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706219886; cv=pass; d=google.com; s=arc-20160816; b=BGM8jd4RCt+9vmnvtcRIXVGB0UXI3Y09T2ZEG/DUpNqNZw+BhxVW2skdmzRljBEKUm 3AE6cI6vowuQQyjxNX0w8jHc72d7Eu4y7j4EM1L5tAsMiLK7y08I7xfOH5nDkDfoOvrm XhylcvaI+Gfgc8GHKnbjVygr69LwY0ZU69nMQ1biGbRbGqQh0R8/wG05qEJBp93gh+iC D6h2V4+vIQA+3hYQkXHiH6GEC/9qcHoG4DFb3RE8giwh9ptCUDKOZLO/i0f2b6esebNv oZrf86FHi08cMthNINmBfrkD1nV81YliSBXkObj6aP6jdiddKLuaLZQGdqHV6fXdYd/P ZP7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=PRRQDV2mn1MC8rBADDauNmvlbxXpJ2S/iIJyPxuTIsg=; fh=zv3b7agrNaeEFRhY4GDwVw5suxM+XDJg1xiQ9xbDO0E=; b=mY6PJcSvkhZxu17LPESr5phXfekkgBJV8Lv0/yNCbBz0jKUyRZOCKdXhhvFwJdzBN8 hjNWCR8KIRXmr5mllCM8Nxlr8trE2ZaIoFy5nMLZksOJwV2BTZIXiEqB48LBSonuBq7X X05VOTCgqapZ0mYXZLGsSkbdlZ5YOm2fmzM6XQ3k3tdjiBNgHN1l2roJmfIs1CVeIVoA h1W/cg5g0tqWYXr/8NGl8XovV1dmxY4fiKfJAwDmKyFQnuoU9QUtw8Hvke/ptiVf9k05 5JZik9KS0LiUQC4OOTNk2yR6kGzAK8u7XNAcP/lorIGJECD9Sm8hureEIYwN/grAtLqY uqlw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=39qnnPbd; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-39343-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vu11-20020a05620a560b00b00783826269ccsi13133555qkn.250.2024.01.25.13.58.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 13:58:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39343-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=39qnnPbd; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-39343-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 316DA1C25C38 for ; Thu, 25 Jan 2024 21:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0C8B13D4EB; Thu, 25 Jan 2024 21:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="39qnnPbd" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D07713AA3C for ; Thu, 25 Jan 2024 21:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219815; cv=none; b=C4PH7YzZXZYmRGcAKqvZaWMBkfi4iHuxhFmMYw/MGbJr8DwysbJoqOBYJz9EsjmxucW6OPOq/1SxKWiaynroH8WqGpIBrYazSJdsWAkBqEfAUzBMROs+VIpgLWc1sD2BEUU+b7DEzV0k24jXEfI+dW/hfibJQKSzZOavVJz1a94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219815; c=relaxed/simple; bh=a8hfMqHEGvH+hPCINRceKqJZjJJ3zaZm6oEEjXubXRo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=lwHfPxG2fJ1+xeLpc+cUgV1aId6Gz3JrIanSXdfMnNFFUI6zvvXIo3W3CkvYhYvm8GDbNIkULqRa9u6twpsxv2yN+cs6ibl9FFeZr6fWrEkfMig9Wv5yjxvMTC88k2CTpwkNDMwUfb4u3UOq1dYFGLmT0K37cMOfwwaWjkWlNtg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=39qnnPbd; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1706219811; bh=a8hfMqHEGvH+hPCINRceKqJZjJJ3zaZm6oEEjXubXRo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=39qnnPbdvuaxnc0JNHB37AqfHZ2dDcwUCODaMGK3NDGhG3Z1pwywzkSb4/dk4w+RO oa2tf+XNJLuYgc+yPLAlmMzEyIupgjUqQGGLhAYl4pxNyXK2/+uVG8G+tjuRlSfjjs uar3dsg+Zi+i4HsOUXTDQoNS99T9wr/YXMH9g+jUxhHjrCzyr6SLyKcTY2HlvaL2pV RcC8tY53zLvW8a6WaYbhMc4y0aMSYDAk1X8IHSQT0G5sRdwSObfNvAJtvIpCrZcz0C 0q+PBIp4FH4P4i+hpiD4Adr1/oVdXKBy1p5FEugk/ALABkPNqKqIB3kR14S2/DBpKY lpGTII6la0koQ== Received: from [100.109.49.129] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 5803137813DA; Thu, 25 Jan 2024 21:56:50 +0000 (UTC) Message-ID: Date: Fri, 26 Jan 2024 00:56:47 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Content-Language: en-US To: Boris Brezillon Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?UTF-8?Q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Emma Anholt , Melissa Wen , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com, virtualization@lists.linux-foundation.org References: <20240105184624.508603-1-dmitry.osipenko@collabora.com> <20240105184624.508603-23-dmitry.osipenko@collabora.com> <20240125111946.797a1e1e@collabora.com> From: Dmitry Osipenko In-Reply-To: <20240125111946.797a1e1e@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/25/24 13:19, Boris Brezillon wrote: > On Fri, 5 Jan 2024 21:46:16 +0300 > Dmitry Osipenko wrote: > >> +static bool drm_gem_shmem_is_evictable(struct drm_gem_shmem_object *shmem) >> +{ >> + return (shmem->madv >= 0) && shmem->base.funcs->evict && >> + refcount_read(&shmem->pages_use_count) && >> + !refcount_read(&shmem->pages_pin_count) && >> + !shmem->base.dma_buf && !shmem->base.import_attach && >> + !shmem->evicted; > > Are we missing > > && dma_resv_test_signaled(shmem->base.resv, > DMA_RESV_USAGE_BOOKKEEP) > > to make sure the GPU is done using the BO? > The same applies to drm_gem_shmem_is_purgeable() BTW. > > If you don't want to do this test here, we need a way to let drivers > provide a custom is_{evictable,purgeable}() test. > > I guess we should also expose drm_gem_shmem_shrinker_update_lru_locked() > to let drivers move the GEMs that were used most recently (those > referenced by a GPU job) at the end of the evictable LRU. We have the signaled-check in the common drm_gem_evict() helper: https://elixir.bootlin.com/linux/v6.8-rc1/source/drivers/gpu/drm/drm_gem.c#L1496 -- Best regards, Dmitry