Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3538668pxp; Tue, 8 Mar 2022 16:58:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJynpNDeTqvgS8nqN2Q8n+nCr7QWttXmokUJGlkO6gJZBkWUPmA6CaHyGOeCPFtTYK4Bf05Q X-Received: by 2002:a17:90a:4e87:b0:1bf:1d62:b710 with SMTP id o7-20020a17090a4e8700b001bf1d62b710mr7763467pjh.36.1646787483926; Tue, 08 Mar 2022 16:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646787483; cv=none; d=google.com; s=arc-20160816; b=dhGxd61kOgCXrSG8NAOO/NkuK2o6A8GB1Z8/SYtHxb92zIdhkO32bRGaqlRnDZgNJW 7b96U+fx1HF6SqYKdgnknRUbgqglLt1PQ2pJJQQpOlOw7Yhmwwut0CkCMxpsTO5f7+GM uiekoN4JxAodywGosP7zfDKD/k7+Pj/POdQBbjogjKvz84KJlQLLJs1/8Cs+VVtlitJ8 igfcFqXutEYgUuwDisButLL8RZnP9ajm44KB+T4QqmjpDGpeeWK8lCoTw6HOAWTfxfIW JYz9k8WzRpPv3VfhJ+AZEXZGYK7KXQZoTiIFHes/xeNw418VE4m6MmxxiRmkqY0+VX39 egfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SYDOiiE/T/Y7VYsIB3p/zW4CbpW2wGMyym0vbgifcOE=; b=vqE6LJ5NU+OiZUFBVr8EiUymY2f3ALEsO+epPhFO+AZe/eBD0okGweVs2UIp33mM5x mN7F6BRzQL7vPBGzOplb1u5Qzn0Y4mbJ7I3nWKg0OcdBJ75Hta5vnsXg5l2mzHNuFMNC lzWTX4byopMs1ykHrxdKedJU0xhqCCdWBJrcXYy8spmKPZ9wJT2z68Tr83iVg9wcup5u kIEIMnol8eckXA1xugd0g8spmQgw40Wl4PbqcgW6tOjXFHB0AEnSNmG+GrNEW2yhJX0j jiucjLf2qayHJ+38tvS3PhrFo4BJaiTBnl1NjgvAUS9GstvjT4tmhPhF4jm02bZKu430 oUfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WNVHOSyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r199-20020a632bd0000000b0038007ef2a69si421513pgr.336.2022.03.08.16.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 16:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WNVHOSyN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AEDFB15B9A0; Tue, 8 Mar 2022 16:06:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348066AbiCHQaC (ORCPT + 99 others); Tue, 8 Mar 2022 11:30:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345048AbiCHQaB (ORCPT ); Tue, 8 Mar 2022 11:30:01 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108E24A92C for ; Tue, 8 Mar 2022 08:29:05 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id q14so13858724wrc.4 for ; Tue, 08 Mar 2022 08:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SYDOiiE/T/Y7VYsIB3p/zW4CbpW2wGMyym0vbgifcOE=; b=WNVHOSyNNfjEW9O3TED1BUUpsZlmtWZ5GMHSHHEVFGg7+rjPoN4aQMb1uneNNfYFmJ t6flvC3RMKFIUdsgeIjsapRQTl+EqkEfyUY61YObOG7prCe8glX8SziJdfhIhh9ntGtw 5PYICSaCHkWCxD9iay5Qo/8n1YfjEmPAl5TY6IFLzCxewPS15FEJr6ImSYwI3RRgUul9 d9JvnyrG3dWs1ImlSIkqz7bMqSZA+4UTu3JYiEOZaBJrz5b/y8MOqLgL3Glvr7MJ561P SaAw9NkYUHoo0W3dRhvxVTpr/NdQMotVJH1ht/KW0KosH4wu3toSK3wPypEvUgLGA8UK OAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SYDOiiE/T/Y7VYsIB3p/zW4CbpW2wGMyym0vbgifcOE=; b=FMml7PWR/2K0+2wUG3z24pFDZ58n/Ndf8N5uVfjVZspvMKomPbfCWAvgzqoemIOJf5 WDsUAE83H3ikXa7/zpu/2mNlht5MK9dzG46XD00bkLOTNskmhDXPbItsbezN45TAIcoQ wZ6krG83FKDWZwNIpVZB0t9bgtoIvaxjK+nnacAYDL7z78UpxxwRtcdEPlBmhKyrbl3r EycoM2DBBFRENHMmgDXnzXaojHWZnShn1IvZDvOz3I8fGmg/Urp0hrccjc34NUIsT7kw UelRm377ZLl90ceFAPyiqWkqpFJ5OyKRSi3GKQFP/bfKcz14TBW36l2LlS5uJuBl7jAy Zmnw== X-Gm-Message-State: AOAM531f7wq988DplZfiMgV4hpBy+cNm663Vm8dHZUxuJEiGEBZqgHpH A60NKXPnuG/jCXBpggcd6VRk2XJQsGZ+BXRqOSc= X-Received: by 2002:a5d:5382:0:b0:1f0:2f64:5a5a with SMTP id d2-20020a5d5382000000b001f02f645a5amr12914704wrv.418.1646756943508; Tue, 08 Mar 2022 08:29:03 -0800 (PST) MIME-Version: 1.0 References: <20220308131725.60607-1-dmitry.osipenko@collabora.com> In-Reply-To: <20220308131725.60607-1-dmitry.osipenko@collabora.com> From: Rob Clark Date: Tue, 8 Mar 2022 08:29:32 -0800 Message-ID: Subject: Re: [PATCH v1 0/5] Add memory shrinker to VirtIO-GPU DRM driver To: Dmitry Osipenko Cc: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Tomeu Vizoso , Linux Kernel Mailing List , "open list:VIRTIO GPU DRIVER" , Gustavo Padovan , dri-devel , Dmitry Osipenko , Rob Clark Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Mar 8, 2022 at 5:17 AM Dmitry Osipenko wrote: > > 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. Will host memory pressure already trigger shrinker in guest? This is something I'm quite interested in for "virtgpu native contexts" (ie. native guest driver with new context type sitting on top of virtgpu), since that isn't using host storage BR, -R > This patchset includes couple fixes for problems I found while was working > on the shrinker, it also includes prerequisite DMA API usage improvement > needed by the shrinker. > > The Mesa and IGT patches will be kept on hold until this kernel series > will be approved and applied. > > This patchset was tested using Qemu and crosvm, including both cases of > IOMMU off/on. > > Mesa: https://gitlab.freedesktop.org/digetx/mesa/-/commits/virgl-madvise > IGT: https://gitlab.freedesktop.org/digetx/igt-gpu-tools/-/tree/virtio-madvise > > Dmitry Osipenko (5): > drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling > drm/virtio: Check whether transferred 2D BO is shmem > drm/virtio: Unlock GEM reservations in error code path > drm/virtio: Improve DMA API usage for shmem BOs > drm/virtio: Add memory shrinker > > drivers/gpu/drm/virtio/Makefile | 3 +- > drivers/gpu/drm/virtio/virtgpu_drv.c | 22 +++- > drivers/gpu/drm/virtio/virtgpu_drv.h | 31 ++++- > drivers/gpu/drm/virtio/virtgpu_gem.c | 84 ++++++++++++ > drivers/gpu/drm/virtio/virtgpu_gem_shrinker.c | 124 ++++++++++++++++++ > drivers/gpu/drm/virtio/virtgpu_ioctl.c | 37 ++++++ > drivers/gpu/drm/virtio/virtgpu_kms.c | 17 ++- > drivers/gpu/drm/virtio/virtgpu_object.c | 63 +++------ > drivers/gpu/drm/virtio/virtgpu_plane.c | 17 ++- > drivers/gpu/drm/virtio/virtgpu_vq.c | 30 +++-- > include/uapi/drm/virtgpu_drm.h | 14 ++ > 11 files changed, 373 insertions(+), 69 deletions(-) > create mode 100644 drivers/gpu/drm/virtio/virtgpu_gem_shrinker.c > > -- > 2.35.1 >