Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp347876pxp; Wed, 9 Mar 2022 04:19:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhRb8nWffnOvphzxPLlUyCRZSa/h/aVVtjB+JH28vEfQeGO923DP842+tL3Uqavy8W2o+M X-Received: by 2002:a17:906:1f05:b0:6ce:69ef:5ef0 with SMTP id w5-20020a1709061f0500b006ce69ef5ef0mr18143431ejj.606.1646828386706; Wed, 09 Mar 2022 04:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646828386; cv=none; d=google.com; s=arc-20160816; b=0XFjviYucBexpt11tCgk3fGAKgyg7sulQ5faaMpdVW/XGSWS/u/oj4+Z2DCCoyyGYu gnBCINqZTGaYO2HXQ2HPzMNg7ArMTqSwiowa6E4iDqlRWrFn499Dtf8Fet9M7LTxk8LW zI6VCdTpe/6bVIVyxRTTxZ2fvSy2eOPZSm7FIghG4BGPra/O9qyBN/tae0vMBGKkeofz 3URswNCHgYyaOov0vAYiolK7nMaalz2YiQXQ/vIbzr8m25XLnAnd27Web5gCzw8cd43Y ngpKpxepHLMhhe4vSrPVmM2td+8b3STUUlFA9GNnJdDnaxly+bkxevA6uUSVRXbbEG+x GR3g== 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=7/ufDf/QvGT9MIT4qhSI9A2YcPUfByfNY5rcZskz84U=; b=H1w1zoKHoy7q8RMZTA6K7WQ22hikJYmYDxSCJXNYNFLElTRXLlv+Repa+V37bv6qGu rPBcE/IyWKRuohtfYXQTaroCSf6V7UVD5jgkiLWNs1CX55+o91yOJJdas5NjxT4VynVB BY+hfvgBoiP8afnBgu4eUYMyGj1LJL6elz/pUWvTCMhq9zfPv/4Oc7swx6Ov1Zlc+fpG g17MNclndN+ljvKUZVSM5IgQ4u07MBaiXdpcwDtNGizO4sDFPKBRqEGrHJQFCUP0FBkh ewKqZuFmbW/i51sNVLSAOU4pFKbvmtZRkuqRCCGCdihNsIPitPVWFEc6WMLM2lpGUQ0k Chzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=lzcJwR+x; 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 q21-20020a170906a09500b006d6d8227435si1018640ejy.277.2022.03.09.04.19.23; Wed, 09 Mar 2022 04:19:46 -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=lzcJwR+x; 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 S232528AbiCIL4m (ORCPT + 99 others); Wed, 9 Mar 2022 06:56:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232530AbiCIL4k (ORCPT ); Wed, 9 Mar 2022 06:56:40 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E379A996D for ; Wed, 9 Mar 2022 03:55:41 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 5D8B61F44A74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646826940; bh=dJmw4zOrIHkURAmLQiTZMGndrEkge+z8fLKmyH944ng=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=lzcJwR+xt1Hi8zjGE4UgpY3rbII3w72kn/wdkoJY0oZKJ9pzvD/YNCuQY2JgOUcgu IIMJ4teyyYm+lIooNRL4ucJE4cCnUAK2tGNpc2vZqkp7yjbHxivzwLqJHF+wWk7bd7 AbfK1dYuMW9v4Pj1MHR8nDciE0aJij8ookDYocuwVasuo8i42d6G+I6ORcCYE/rXBc HHpJ3VRi5ynK0kzALfafF87gYjdAAD1w4DzDqYd5MdOdL0Lv0Qg/lZXqz5TIh4xNRd F7qa8nuXGqfb6EFSdLlQt7VUaiqXMzPL7vK78nwEiPw/xoPmUxGl/7kaktl/W6ke/F P53OZjZwjW4zA== Message-ID: <26ab770d-4b59-a25a-79ef-e43858e7b67b@collabora.com> Date: Wed, 9 Mar 2022 14:55:36 +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 5/5] drm/virtio: Add memory shrinker Content-Language: en-US To: Rob Clark 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 References: <20220308131725.60607-1-dmitry.osipenko@collabora.com> <20220308131725.60607-6-dmitry.osipenko@collabora.com> From: Dmitry Osipenko In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 04:12, Rob Clark wrote: >> +static unsigned long >> +virtio_gpu_gem_shrinker_count_objects(struct shrinker *shrinker, >> + struct shrink_control *sc) >> +{ >> + struct drm_gem_shmem_object *shmem; >> + struct virtio_gpu_device *vgdev; >> + unsigned long count = 0; >> + bool empty = true; >> + >> + vgdev = container_of(shrinker, struct virtio_gpu_device, >> + vgshrinker.shrinker); >> + >> + if (!mutex_trylock(&vgdev->mm_lock)) >> + return 0; > One bit of advice from previously dealing with shrinker and heavy > memory pressure situations (turns out 4GB chromebooks can be pretty > much under *constant* memory pressure): > > You *really* want to make shrinker->count_objects lockless.. and > minimize the lock contention on shrinker->scan_objects (ie. The > problem is you can end up with shrinking going on on all CPU cores in > parallel, you want to not funnel that thru one lock as much as > possible. > > See in particular: > > 25ed38b3ed26 ("drm/msm: Drop mm_lock in scan loop") > cc8a4d5a1bd8 ("drm/msm: Avoid mutex in shrinker_count()") Thank you, I'll take that into account for v2.