Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp240092rdb; Thu, 25 Jan 2024 13:52:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0zMjQ/x6FXKt6VbIKaSTC/wCfKquiVXuYrs4wtf++spCxZe/AiUj8dbhijawcwWUXaCE8 X-Received: by 2002:a05:620a:44d1:b0:783:b5f7:e1f8 with SMTP id y17-20020a05620a44d100b00783b5f7e1f8mr275770qkp.78.1706219553501; Thu, 25 Jan 2024 13:52:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706219553; cv=pass; d=google.com; s=arc-20160816; b=JyG/4WTgr6oIHvPGwp/x9OnNGxUTum8PmOBxQwqAJL8iX6BYqyI5v9F28O3eshKd80 QIe1Ib4RUVQhxHP+f8pUWzVH8QuRTZIQI+dqos0XRaLJcwY57zotkShgShEsryafKOc2 vmgJlnecRZKakODkH3LQJt0OjTXGfBUvxwQSinqlXwlF+QBWjpTuDhiyAQsPPTctdA8U rgJoPp0kftPpSfZNWwXn3VDc+5bgDQkeWaPWULAhNs29VOlpmLRoqw8CHLZzTMjbPuN/ vNmKDdSkNxwS2s8A+c8wYXkmNEmgtC/RtfoRZIpfHBFoR6fBW6hM3svJH0B/C4NoqtMq gsgg== 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:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LKPMpNOlBfzeyFmcYV6+eZV2Kz5jSoWgf9+EQT76dnU=; fh=BMNDMsdGl5GDdwtEr0jLEXRIPHurduPEY3y/xcIlZvE=; b=EJ8XM2PK+C1rODA9c18n4vaKzIoGcC4nVQtrCLonlMR50Mf9NlqUIQXlYyg3Q1yL8e 9cqMU6ZppOqF8eyhWQHMpsEfPDKJlMe50d0HIV+4CQadka6IWBvDRRInrP6EHfRzlDIK 0pt9/5eP6cCL4I69OYH72nP0wFef3Fkvhl/tdlkKiu9SBkfeglkvPUZr+6ECYhUL6fG6 kJWEHl4o5uaVZqhGyla23rkiLAal5p0Y0PJbzxXz8C0tXcbJxMSLIZVbgMEF5w4yLtpO 5pE5GB6T2iX63ENY3614WJiOmyntBLlfjAKBsl3lB59h393UAEZ04KkTJ3v9Y0S8Ownt 2MVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DjKPBOn5; 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-39337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39337-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. [147.75.199.223]) by mx.google.com with ESMTPS id qp28-20020a05620a389c00b00783b601abcasi4225143qkn.608.2024.01.25.13.52.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 13:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DjKPBOn5; 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-39337-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39337-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 467141C22A6D for ; Thu, 25 Jan 2024 21:52:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3081C13AA25; Thu, 25 Jan 2024 21:52:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="DjKPBOn5" 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 E11B83173A for ; Thu, 25 Jan 2024 21:52:24 +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=1706219546; cv=none; b=i1taoC4aEzIEGApIBljSq5nV1ZZyQg5dNLh7wM71WIqIFY6yKUn+ftTu2l6kM/DKpfJd5FaegChgbi4a8eC66H8761H82VTvbuSbkzx4NoaorsF6k0xewM/P65R6UrfPvbANTBVs3xHOjn5WPshazKE+4crvWfnUrMtWjH3kT3Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219546; c=relaxed/simple; bh=HmHb/1j56mYypkJHtCxMuyE8iJQuLLhZ2r3pRbNJ0Ek=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=o7S9Yqqbu2NokAYvfWdWFz34tdOcSFViSsFqHVF9+17NpBdqhPpwfpFd3zV2jhc+pu60fDh8cn8eKt3BSajqzyEN55w13nyPxf9KSnu2+iG2PyI2iN4b9TClRvtaZstTt8BP75sB4Jz47LWf0sTcFqJDL489c9ARHj/D7jhKwqg= 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=DjKPBOn5; 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=1706219543; bh=HmHb/1j56mYypkJHtCxMuyE8iJQuLLhZ2r3pRbNJ0Ek=; h=Date:Subject:To:References:From:In-Reply-To:From; b=DjKPBOn5DkLFgqwP0WrFz5zmWSBPLMUa00i2AzL5gujzFWsxBQJZtLk7yLL4Fk3mw qmf8pOZT2aIxEOOBFymm2cbk1Njwpow9/hYB9Dk8zf/mhLP307VzkWdqq4xBJF8wLf tlsvHel51nr4LS9KByd5zZvHCDSOwM61iCe7TAo8h0bWYUdSRNwZixl4i54JTwVIm6 yFQaOuEc9iAfV7ZRTQ4jdqHSm1HsPVgPgqP/FIYD2UOvIMWRoFH4wpvvrVhztuII52 DN7YkZbkTJfLwGjonrp80UCfEH/C+yzfA/rfDazDfJeZw/6PzT2FLOrO2Mlo4WEFVO a/Iznos2DQfjg== 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 C958D37813DA; Thu, 25 Jan 2024 21:52:21 +0000 (UTC) Message-ID: Date: Fri, 26 Jan 2024 00:52:19 +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 09/30] drm/shmem-helper: Add and use lockless drm_gem_shmem_get_pages() Content-Language: en-US To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?UTF-8?Q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Boris Brezillon , 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-10-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/25/24 20:24, Daniel Vetter wrote: > On Fri, Jan 05, 2024 at 09:46:03PM +0300, Dmitry Osipenko wrote: >> Add lockless drm_gem_shmem_get_pages() helper that skips taking reservation >> lock if pages_use_count is non-zero, leveraging from atomicity of the >> refcount_t. Make drm_gem_shmem_mmap() to utilize the new helper. >> >> Acked-by: Maxime Ripard >> Reviewed-by: Boris Brezillon >> Suggested-by: Boris Brezillon >> Signed-off-by: Dmitry Osipenko >> --- >> drivers/gpu/drm/drm_gem_shmem_helper.c | 19 +++++++++++++++---- >> 1 file changed, 15 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c >> index cacf0f8c42e2..1c032513abf1 100644 >> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c >> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c >> @@ -226,6 +226,20 @@ void drm_gem_shmem_put_pages_locked(struct drm_gem_shmem_object *shmem) >> } >> EXPORT_SYMBOL_GPL(drm_gem_shmem_put_pages_locked); >> >> +static int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem) >> +{ >> + int ret; > > Just random drive-by comment: a might_lock annotation here might be good, > or people could hit some really interesting bugs that are rather hard to > reproduce ... > -Sima Thanks for the suggestion! -- Best regards, Dmitry