Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp880076pxp; Wed, 9 Mar 2022 14:55:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTgQdHEomSC3hor/HbI+ylZG2LYcdCbTDdjBZ7TFAIgyaDSQIWGv4ySeqeBtqpdRTsU2Jn X-Received: by 2002:a17:903:1c8:b0:150:12cd:a02d with SMTP id e8-20020a17090301c800b0015012cda02dmr1855637plh.174.1646866545611; Wed, 09 Mar 2022 14:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646866545; cv=none; d=google.com; s=arc-20160816; b=s0u+64H+hlM+iNS9j/eebSNpaxg93GbrrIG90rC9eJJ4MQxGEU7lc1yEzeor9GSBYq CMyJRGcMJHzufCoCvg7JwxxpxoKf+za9ikZFckoJfPVfeUSBfxdXKEKcWwYSVpxRHeeW CaJi5sc4I6oxZ80HpYXpCDp/mAzOQVpMWE+SqumKhgw4kdltWbZaqBV1C5zSz1atE9S5 8yVIeb1IEnACKnSnrluK2O8G7yIDjLReIFK2ccl8pdAlMnAv68LTrDRWNeNrh6l63//8 +74b8RBuYU9Oq6MJIB6Olcv6Eh10bMIhOTGfH5+EXhlMCFln7h8TLab3bA76CJplxoZh PnUw== 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=JKasNcIW2HWAznmZNKbc2RVbi1A3xljCi2+NEfyCj44=; b=Ryf9SxiEvBdaDmICm9RAr/0AhsB8HFA7TnmwhvawhDETJLieNk/r1Dj1sCJ1hURcdF uDsIMudh+JUc85TKHIvv3JJOuBC9gQDFkk/OYEK0mvbgGKW8JnY/1eclZX50SijdsCDi VU7ImpeHqgTrvLEDjxvqcwv9GJnYmgg6BX4qapXgzEDDbQMlNF2ot7zLtihmBNPgPR+r UxsbDI8wOid4yEopAQo6xWqCQ4VCxk5v1PbSW8rs0scJldvIKl4BCeOPwmEr3sj/RnbL e/elYJSZMGIB045mHLQgbc1f7q2p740KoaPNTjdOrS79Fs+WmSMF3WAdUuUUONh7VWaC ONiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bYtq1Svt; 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 k19-20020a056a00169300b004c5ce2e6ecbsi3792272pfc.51.2022.03.09.14.55.28; Wed, 09 Mar 2022 14:55:45 -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=bYtq1Svt; 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 S238554AbiCIW0t (ORCPT + 99 others); Wed, 9 Mar 2022 17:26:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237914AbiCIW0s (ORCPT ); Wed, 9 Mar 2022 17:26:48 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33C9120F60 for ; Wed, 9 Mar 2022 14:25:48 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 53FAF1F44EA2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646864747; bh=AkGj7nTWMoomWRkdJCvTLzW+5BnCOQ1RLk59S45H2G8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bYtq1SvtGMZR3ZztKfmLLKr3S6w7A/3ieWCdJW6Hvi4gb7anwVpCJV+P2kKdLrSPP DtilhNyxqMiS43VK8FyDxExEbZb3GVpxppM8+ghaWBRlhywOvc+Bmtnzd+SSqCdPID HvJBrhazTBG12TNiMP4+qwwC8jvK/neSj6hl9+gbC+EQMKP5fVXKVfEXLZ/p69TksO 6j6bgZ5CxWVGr+IKaYRnpXWTCymJeMzVPM2RES9Yp9dwFuPTVTAsW8oSQA4AIpA4AN wRc733Fi0sIBKLseZ5T9clbuDF7K2wYaQiyTFT/mDAo6eCtaz6V2OAc2XnomeoJwEv 5Z6e+h1b42hZA== Message-ID: Date: Thu, 10 Mar 2022 01:25:43 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1 0/5] Add memory shrinker to VirtIO-GPU DRM driver Content-Language: en-US To: Thomas Zimmermann , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny Cc: Tomeu Vizoso , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Gustavo Padovan , dri-devel@lists.freedesktop.org, Dmitry Osipenko References: <20220308131725.60607-1-dmitry.osipenko@collabora.com> <4ce1e172-799c-cba3-0a72-4a6fdf2c6d2f@suse.de> From: Dmitry Osipenko In-Reply-To: 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/9/22 22:28, Thomas Zimmermann wrote: > Hi > > Am 09.03.22 um 12:55 schrieb Dmitry Osipenko: >> Hello, >> >> On 3/9/22 11:59, Thomas Zimmermann wrote: >>> Hi >>> >>> Am 08.03.22 um 14:17 schrieb Dmitry Osipenko: >>>> Hello, >>>> >>>> This patchset introduces memory shrinker for the VirtIO-GPU DRM driver. >>>> During OOM, the shrinker will release BOs that are marked as "not >>>> needed" >>>> by userspace using the new madvise IOCTL. The userspace in this case is >>>> the Mesa VirGL driver, it will mark the cached BOs as "not needed", >>>> allowing kernel driver to release memory of the cached shmem BOs on >>>> lowmem >>>> situations, preventing OOM kills. >>> >>> Virtio-gpu is build on top of GEM shmem helpers. I have a prototype >>> patchset that adds a shrinker to these helpers. If you want to go >>> further, you could implement something like that instead. Panfrost and >>> lima also have their own shrinker and could certainly be converted to >>> the gem-shmem shrinker. >> >> I had a thought that it could be possible to unify shrinkers into a >> common DRM framework. Could you please give me a link to yours prototype >> patchset? > > I uploaded the patches to > > > https://gitlab.freedesktop.org/tzimmermann/linux/-/commits/gem-shmem-cached-mappings > > > it's incomplete and un-debugged, but it shows what needs to be done. It > has the infrastructure, but lacks the changes to the GEM shmem code. > > 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? > The patchset adds new helpers for BO purging to struct > drm_gem_object_funcs. With this, I think it might be possible to have > one global DRM shrinker and let it handle all BOs; independent of each > BO's memory manager. Thank you, I'll give it a try.