From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (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 1E926230996 for ; Mon, 7 Apr 2025 09:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744019825; cv=none; b=QlpfHgnn0R7eEHfe6PwsQsZRbK8haoVHCUgfeyi/tDE9rDXB7o3/Kf7cJ7XuqOw38rj97ewn0SxcK0fQpnc4DsAV5NPgoC1vafUcNlaA9NAQQ66M9Vp9kITKj0AFuDT9bC4DMIc40LHf+v/o9CCeyzpV1SGB6rBLosnRc+4Ly7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744019825; c=relaxed/simple; bh=ECIQQcTVtg/hv39ybDI897PJaXrGxDcq2VT2bEcU6rU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QEPBDlfPfuwBmACIltCrpBHMBBV8Sa0w3ET96upLdZZRzOkDj8UJM44j6kcn1wMmzZwXhp1HvvH0JGD3VdFBlhNu9q4W9QpuI0LYJDYY8V25ukYVhwmLB3ApupbMoX/WnAHoU5fdHkryfwr+D1uGrhdN17az+Y/Vpz1+Bcs6BYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=baK0FbfF; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="baK0FbfF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1744019821; bh=ECIQQcTVtg/hv39ybDI897PJaXrGxDcq2VT2bEcU6rU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=baK0FbfFY0YlYV41bgu/R7tTtxwh18jci8auDNjRN15GWCxMEQETpAoUYHtx/Qp0h vXh13n1xlrAU6BaqCE4xvrBR1UptiwW3CQgaYdQWFjKr5a8nGHUJ8//RbtN2u2JceR mBrdlQFFpm7IuhycGuTx4ny+iPhW84ReEHppr8HEX/tQNb8JVKOPtDH0E53q2MHrFl 7bxkTKwGp0zwLY2sZZxKUfLAQVFsMyXs3N9sm2vfaD61xMd9U91vYYefQecY4RxEaZ Rrc/HBIFhwymshCskIEA/JNqhLbrtbbX5q7wD30ooFDvxvwwGCJPsBlGgNGtDyFCFk /41UxKO/+5YDw== Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (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 bali.collaboradmins.com (Postfix) with ESMTPSA id 6891E17E001E; Mon, 7 Apr 2025 11:57:00 +0200 (CEST) Date: Mon, 7 Apr 2025 11:56:54 +0200 From: Boris Brezillon To: Thomas Zimmermann Cc: Dmitry Osipenko , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Christian =?UTF-8?B?S8O2bmln?= , Gerd Hoffmann , Qiang Yu , Steven Price , Frank Binns , Matt Coster , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v20 09/10] drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin Message-ID: <20250407115654.761ddaa6@collabora.com> In-Reply-To: References: <20250322212608.40511-1-dmitry.osipenko@collabora.com> <20250322212608.40511-10-dmitry.osipenko@collabora.com> <710cdbd4-2c6e-48b7-b12b-972ab6d12abf@collabora.com> <20250402152102.01d9cfee@collabora.com> <20250403105053.788b0f6e@collabora.com> <29cfb98b-fe27-4243-abe4-ce66aa504573@suse.de> <20250404165233.139814ee@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; 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, 4 Apr 2025 16:58:20 +0200 Thomas Zimmermann wrote: > Hi > > Am 04.04.25 um 16:52 schrieb Boris Brezillon: > > On Fri, 4 Apr 2025 10:01:50 +0200 > > Thomas Zimmermann wrote: > > > >>>> In your case, vmap an pin both intent to hold the shmem pages in memory. > >>>> They might be build on top of the same implementation, but one should > >>>> not be implemented with the other because of their different meanings. > >>> But that's not what we do, is it? Sure, in drm_gem_shmem_vmap_locked(), > >>> we call drm_gem_shmem_pin_locked(), but that's an internal function to > >>> make sure the pages are allocated and stay around until > >>> drm_gem_shmem_vunmap_locked() is called. > >>> > >>> I guess we could rename pin_count into hard_refcount or > >>> page_residency_count or xxx_count, and change the pin/unpin_locked() > >>> function names accordingly, but that's just a naming detail, it doesn't > >>> force you to call drm_gem_pin() to vmap() your GEM, it's something we > >>> do internally. > >> Such a rename would be much appreciated. page_residency_count seems > >> appropriate. > > On a second thought, I think I prefer > > 'unevictable_count/inc_unevictable()/dec_unevictable()'. But looking at > > Ok > > > the gem-vram changes you just posted, it looks like gem-shmem is not the > > only one to use the term 'pin' for this page pinning thing, so if we go > > and plan for a rename, I'd rather make it DRM-wide than gem-shmem being > > the outlier yet again :-). > > Which one do you mean? > > - The code in gem-vram does pinning in the TTM sense of the term. Sorry, but I still don't see why pinning should be a TTM only thing. If I read the doc of drm_gem_vram_pin(): " Pinning a buffer object ensures that it is not evicted from a memory region. A pinned buffer object has to be unpinned before it can be pinned to another region. If the pl_flag argument is 0, the buffer is pinned at its current location (video RAM or system memory). " And this pinning is not so different from the pinning we have in gem-shmem: making buffer object memory unevictable/unmovable. > > - From the client code, the pinning got removed. > > - The GEM pin/unpin callbacks are still there, but the long-term plan is > to go to dma-buf pin callbacks AFAICT. > > - Renaming the dma-buf pin/unpin would be a kernel-wide change. Not > likely to happen. Again, I'm not sure why we'd want to do that anyway. Just because the TTM pinning semantics might be slightly different from the GEM/dma-buf ones doesn't mean the pinning term should be prohibited outside the TTM scope. The concept of pinning is pretty generic and applies to system memory too AFAICT.