lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240125102859.6d8a864f@collabora.com>
Date: Thu, 25 Jan 2024 10:28:59 +0100
From: Boris Brezillon <boris.brezillon@...labora.com>
To: Dmitry Osipenko <dmitry.osipenko@...labora.com>
Cc: David Airlie <airlied@...il.com>, Gerd Hoffmann <kraxel@...hat.com>,
 Gurchetan Singh <gurchetansingh@...omium.org>, Chia-I Wu
 <olvaffe@...il.com>, Daniel Vetter <daniel@...ll.ch>, Maarten Lankhorst
 <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>,
 Thomas Zimmermann <tzimmermann@...e.de>, Christian König
 <christian.koenig@....com>, Qiang Yu <yuq825@...il.com>, Steven Price
 <steven.price@....com>, Emma Anholt <emma@...olt.net>, Melissa Wen
 <mwen@...lia.com>, dri-devel@...ts.freedesktop.org,
 linux-kernel@...r.kernel.org, kernel@...labora.com,
 virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v19 24/30] drm/shmem-helper: Optimize unlocked
 get_pages_sgt()

On Fri,  5 Jan 2024 21:46:18 +0300
Dmitry Osipenko <dmitry.osipenko@...labora.com> wrote:

> SGT isn't refcounted. Once SGT pointer has been obtained, it remains the
> same for both locked and unlocked get_pages_sgt(). Return cached SGT
> directly without taking a potentially expensive lock.
> 
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@...labora.com>

but I'm wondering if we should have made this change directly in
'drm/shmem-helper: Change sgt allocation policy'.

> ---
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 8fd7851c088b..e6e6e693ab95 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -962,6 +962,18 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)
>  	    drm_WARN_ON(obj->dev, drm_gem_shmem_is_purgeable(shmem)))
>  		return ERR_PTR(-EBUSY);
>  
> +	/*
> +	 * Drivers that use shrinker should take into account that shrinker
> +	 * may relocate BO, thus invalidating the returned SGT pointer.
> +	 * Such drivers should pin GEM while they use SGT.
> +	 *
> +	 * Drivers that don't use shrinker should take into account that
> +	 * SGT is released together with the GEM pages. Pages should be kept
> +	 * alive while SGT is used.
> +	 */
> +	if (shmem->sgt)
> +		return shmem->sgt;
> +
>  	ret = dma_resv_lock_interruptible(shmem->base.resv, NULL);
>  	if (ret)
>  		return ERR_PTR(ret);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ