Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp246060pxp; Fri, 11 Mar 2022 03:34:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJy83l8neh2jti8qBREOAd+OCjbjbmwUjljVGLfcDBvr07VprwnDQg24eaEink5Ye5ENvGfC X-Received: by 2002:a17:906:585b:b0:6b7:73bc:5395 with SMTP id h27-20020a170906585b00b006b773bc5395mr8215418ejs.519.1646998462558; Fri, 11 Mar 2022 03:34:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646998462; cv=none; d=google.com; s=arc-20160816; b=DJZtRYt5XOk8IU28Sl4s2OcvcHwXEquj2Bfp1esHcXJODI4unU0KPlDNXHdOqRWGD8 +d5lWQxKbs2lne1f0LJrIwABF1fLvcjoCwzuFozLAE/4/cGGIqshMIHjwZ0eExR5ZRES ZDhhujDOPKlGimWBnHKYGbPK857y3poDJ9lJagZBSfZW6/VFE67vd4n6teOn7J/DgYbg WqJxIIXpqe7UZfuRC2mGzG/laaDK1/1kky3oBNXKgLw2/Sn4VSDB3uWuTYV5pZE7jWnr QJbVXiE2aP4H4G/h6+hwWA46WeMOp0mwWx/I51VQGqd5vfXSmHpIlt3A8Y/OmvEQFxxO r8qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=s0bX3sa84MWF387hA04ZPsnQ/yCxPV9QSsfD9s2iniU=; b=nTeuyDlSRZfYQjxSvzV87E8Y+t9qz5E22PhY8xEmC0UvVA3kRWWMUYZuBx/7HsvyJ4 GKIFeS2zTftf6GLsxHK4nyImb+F7x3X7GJzJWxjKoGxLgB3o6G4Ivy/4Q+IKuizevpWl s1jsM2i3FEKJUmDeGn83TvIWLMakWYyZoUmWsIvzjEd90Oc332cXzL5Kk3t6/XAw7FHV +u/gHGjSVbc/9taSTEeddxG5cmcwGGUUNWdBhi3kyw3yz/39z9mGb6VblD9PH32ckOX2 QbC+5bA8ol3sIAZ1dyI5fwrADkzFsglMnA1FlauKZuqtxwH6KjR9JSxxLb+W+EfYxxOJ A2Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DAjwBk9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a056402254900b004167de7ce21si5736135edb.363.2022.03.11.03.33.57; Fri, 11 Mar 2022 03:34:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DAjwBk9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244009AbiCJVds (ORCPT + 99 others); Thu, 10 Mar 2022 16:33:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236311AbiCJVdr (ORCPT ); Thu, 10 Mar 2022 16:33:47 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F06F8EB78 for ; Thu, 10 Mar 2022 13:32:44 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id C791A1F4625B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646947961; bh=Ad6/roeSAR4BixHcrT4+iGSvNLDw1gu2KhDRPm1QmOI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=DAjwBk9IS4h+tkGWFqJgy653Mej/36sRdc+xbnApxYzqc8yJloEoMOnVFTkkXES6f cpoI4OPaCh3SyI9cA6kBBGardXWx5w6u/YfWEddJGCM04h5ROvuYd7GZlS+8wLkfoW Cqx0asjEytolyRKKJaX5mILV851glPROg3vYET/59Yqjw8iBBH5LxnuresEsIlfZtt gfuFTfdSXcf64glac0pqPyEpWfhCV+UhI2fhKOv3b01+hGZKXP/i0CtjVF2m/bumWS UECBIX3FyQGjThzDNlt6BWweBJ3oNdk/uE2QrR41rAZj509FRn9V56ucG0KXeGr7kQ KXl2tvoSwKVCA== Message-ID: Date: Fri, 11 Mar 2022 00:32:37 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v1 0/5] Add memory shrinker to VirtIO-GPU DRM driver Content-Language: en-US To: Thomas Zimmermann Cc: Tomeu Vizoso , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Gustavo Padovan , dri-devel@lists.freedesktop.org, Dmitry Osipenko , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny References: <20220308131725.60607-1-dmitry.osipenko@collabora.com> <4ce1e172-799c-cba3-0a72-4a6fdf2c6d2f@suse.de> <3caec8f4-1bc8-bd52-4a36-5223b633704e@suse.de> From: Dmitry Osipenko In-Reply-To: <3caec8f4-1bc8-bd52-4a36-5223b633704e@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/10/22 22:02, Thomas Zimmermann wrote: > Hi > > Am 09.03.22 um 23:25 schrieb Dmitry Osipenko: >>> >>> The reason for this work is to keep GEM shmem pages mapped and allocated >>> even while the BO is neither mapped nor pinned.  As it is now, GEM SHMEM >>> creates and releases pages on each pin and unpin, and maps and unmaps >>> memory ranges on each vmap and vunmap.  It's all wasteful. Only the >>> first pin and vmap calls should establish pages and mappings and only >>> the purge and free functions should release them. >> >> Hm, aren't maps and pins already refcounted? > > They are. But even when the refcounter reaches 0 on deref, there's no > need to remove the mapping or free the memory pages. We can keep them > around for the next ref operation.  Only the shrinker's purge or freeing > the object has to do such clean-up operations.  Such behavior is > supported by TTM and we already use it in VRAM helpers as well. When driver won't want to pin BO at the creation time? Looks like all shmem users do this today, and thus, pages shouldn't be freed until BO is destroyed or purged.