Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1672440rdb; Thu, 25 Jan 2024 02:47:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwOjUviBfbje6+ANA9mVF5qCMlG4bdBGM+f0gHuWY6HuRodi8zcU1JDl1ilE2+UbXLXUL5 X-Received: by 2002:a17:902:d505:b0:1d7:7af5:1f7a with SMTP id b5-20020a170902d50500b001d77af51f7amr755531plg.49.1706179660867; Thu, 25 Jan 2024 02:47:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706179660; cv=pass; d=google.com; s=arc-20160816; b=QJ+l2Cn3PXvB+ZuCjBvIxdcRp9OKALHDJ4hOIgTVbQHBKEedNpTOKCwWghBfVB6suP bTyjbfEqyp/wz4LMxTixofgmW6OM0o815BKh/sLi8DhzeeJvPxUYF85YDc1rsCbdPcZ3 BT9+XBuRCLvR3UkHWAmB6Gvit+KQHtvPf/Np3QfoxXvLKcn5uw25YoNnBJRAkqD0q5Yu Jequy3Pkzp8cNwgNN8QHxWeioxthu4+JTYjBOvxZC+nZBudo1awMX0/2ZhVhxdR9tqYP fLyCGcRijtRtShttZBJuN4eNVOO6tpM39r1+Brvy/+Hm/drd0xT1IM2f8eJt7fdMUcfE 6S2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=DsDCjuZNtTtT2AeNR8QKO14ZZka9+qA1feo5s57uKvU=; fh=uxLNaPoPRUzmkUc1KOgGwCEU/bTSjK8Yed2Up6ovXLY=; b=PIWrAfVooly5CkcA2w3s6qvQ2kA5BTpONlV4oUCiWDUkJ/rBTPvdxuKf7tL1zxEtX5 FKkwXEInwznMcPEMrW1Ux3NqlbnYk0ekhGhN8hfXEQeOs72Q8lWeVEWDB+RLMhC2CptD 5dYfCH825vNJ2YRXUaEQsmMhsOfnNrjS0Rva7TyuKOtYO5SOKRnZjUZEcsM9aFwMo2kp pBiW5FbpfXtHeCUCdk4FnUBOO3rxXqLkqQo7jkaoCP3MKmvSWuN1CbH6g3J4l/Kr6mWb aj5A+K//RkbOFO76Xk1pLkv2b4Jmle6nBw+rwGUFH77jKR83hoe2a5YmoBilBGEG0Aru sW1A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=crzCrYot; 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-38378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u10-20020a17090341ca00b001d7687e661fsi5285082ple.217.2024.01.25.02.47.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 02:47:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=crzCrYot; 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-38378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38378-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F1DDAB24D20 for ; Thu, 25 Jan 2024 10:20:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEB6F1CA84; Thu, 25 Jan 2024 10:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="crzCrYot" 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 8D88E1CA97 for ; Thu, 25 Jan 2024 10:19:50 +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=1706177992; cv=none; b=qgLd4v26pDZGlJjFt/DiH5XcMqgR01xBMK+w1PNkKZt6owXQ6dSO7/VSqqwfgAFqcx1Ys/kPgnfMXs99TU0+ELnM/Q/u77CoC4EZYEbNQLHEeCrbFRZJ1FOtpujTYdeuBKeqzBSTwHB1IZz0Xc0MMFUx7sBS+riFSYZ7J8tbyRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706177992; c=relaxed/simple; bh=SNTqFndHS7fusbc/JoJL6VmM5mMHU74c/gZCl49dXII=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BxBJlIj9Q/CJsGAkf9NDxpO8ZyMYEwekqIvg/6kd//dDstWzrT0YahF9wssmBALQ2ahjzkYPeAbyPPPs1hVZLEjSRKjJN08fckS5X7unmgk9vfs+ntEoRcTnOQtoZ9v/6+EjscCznNl1K9xSmmudY6bsVfqifIz8W+2xS8Z3VbM= 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=crzCrYot; 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=1706177988; bh=SNTqFndHS7fusbc/JoJL6VmM5mMHU74c/gZCl49dXII=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=crzCrYotEFR6vHCVGwVhc8KCpzfBEpAGjgrKWvRQ8thXlbUnvSjkuRRNucJZMkYO3 zpqJs3oi/mRonlfMsnR8WglzPGURtXrGnD/c/EYZ1qzVEvXG5SWZ+3mf0fypx2lfQL L3YMzd1en2ZEJrPhSPIYcmV60/0CrIV3BaDFTOyvRlZGDTWAZan6sjhww3Gi5+rw2s 2U+wIVvsDuFaCAgxTFLxMryEeh3XIyFe/HQpQAcOv69BfzfzdalaQ1yFWDlugbiSn2 qnEmc23s7Q2UktOoh6Hqknk3+8RnVzZLFTFb7lAWGInDP7jaaTmNsmXeVf2H8/RTZN QjpJHe786N2vw== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 657083780FC7; Thu, 25 Jan 2024 10:19:47 +0000 (UTC) Date: Thu, 25 Jan 2024 11:19:46 +0100 From: Boris Brezillon To: Dmitry Osipenko Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Christian =?UTF-8?B?S8O2bmln?= , 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 Subject: Re: [PATCH v19 22/30] drm/shmem-helper: Add common memory shrinker Message-ID: <20240125111946.797a1e1e@collabora.com> In-Reply-To: <20240105184624.508603-23-dmitry.osipenko@collabora.com> References: <20240105184624.508603-1-dmitry.osipenko@collabora.com> <20240105184624.508603-23-dmitry.osipenko@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.2.0 (GTK 3.24.38; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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. > +} > +