Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp438428rdb; Thu, 5 Oct 2023 10:06:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEg3yUTP8SjL/ZpeqrUFwZKjPHSVCE5ugluab7R+xrugWH5j6dvM18q9lkHZJ3CK/fKCOGV X-Received: by 2002:a05:6a20:8f09:b0:129:d944:2e65 with SMTP id b9-20020a056a208f0900b00129d9442e65mr7038008pzk.13.1696525582450; Thu, 05 Oct 2023 10:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525582; cv=none; d=google.com; s=arc-20160816; b=WeBnRQEkxmgYDO8Yqyqs3zf3FjIlPIEGGf/RiTkefLSlHFsJ9gdlqYeX9uSs5vQQ8J N+Er38kz6OpU6iSh4tgEvc7nf1To7BB+FpPA+e8BxDXmVGdV2trBl8QNLJvFFBq/+VCX PTiboGVtTR/rXzQERGCsir6NTjVHYyeAY+lM+vJDHUSbKGP3sglMrBlyoSe2pn0zKeZv S+ql5cw6X41M3nXHGrNxDpeGXNSZZWEPf8MjpT5ZW0zmoMdcPNqgJ8Ks/17z678/aPS9 f7jS1hPywKndNCA+6Xjs0p6Xx/9Vx+itLJEDfd46/ICuioOQ627JqPrMVDnvhsasfoGE M6gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ayKSFBBzzYVWPPMmemDYllzhSncPxlqMw6+93w40Th0=; fh=spFblIJQT4eADR1RsxWEdnrlx7ABR2LLC2kzUTZ3o+M=; b=wejrl6mscDo53G0z3qwd4OPCKBz1Z/O6zeNsPlngvxHRZE0PvFImA8ITI/ABFOnK3d gKQI1E+6NLujidh4kjNhx0sDdmTOziq8hNkyMDYJM4GbMgEPhp8nTgPZ5xZ8p+RCqMr3 izp/UshjgdGTK+zw0SpBJEDRuX/8S5GUjv+ehJgtyrU8KX15MwKTaxrOlQPEjBOLYtkg Ks23Q7+PrSgT6PniB9NrsOcDSXsLdFbGlqeYFx21q7RgYRmv+BUE0lf3TCdhqXKYco6N fshOErXHgNkn8rU2HKOAwjoCdMuGUqnycLFVM0B9kJhHC6lvjUapOjKfzkUIrIo5IrcG j9UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iIRdY2zj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id f3-20020a056a00228300b00690b8833ccbsi1829846pfe.270.2023.10.05.10.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iIRdY2zj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7291180BEF10; Fri, 29 Sep 2023 11:17:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233786AbjI2SQk (ORCPT + 99 others); Fri, 29 Sep 2023 14:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233051AbjI2SQf (ORCPT ); Fri, 29 Sep 2023 14:16:35 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A6F1A4; Fri, 29 Sep 2023 11:16:31 -0700 (PDT) Received: from localhost.localdomain (unknown [IPv6:2a02:8010:65b5:0:1ac0:4dff:feee:236a]) (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: alarumbe) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4EB986607347; Fri, 29 Sep 2023 19:16:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1696011390; bh=oQRC2/7kakFVXnxc/dlMxlyz1zqib0bHYDtG5iDdAHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iIRdY2zj8T9sL8uHfyesDgY45cvFOQzztvdf8mEkeZCMCqMG2aiKe+RuDhpooKUMb 1/nNGJBQN38yP/RLpdqIWXM4ngFj4850YCTEl0JwmOeoi+87il8wBXEttXi00Gplgn vxvLVMo0qIoVLklHWeaIVBYJD4UTFypTJt2ey7iJCVvto9lbecGHIbHrPbmK/elbYH sHtlVteqSpnqVV/7dvj6Yn3S5SuoqGHsZUDS1W0yVafvDKIioL6NB+u7QIL1YxulEr dAx4umxU4K9K4v1+zicThspOBMq+yhTep4lRLJnXT4GowJub1MLyEt0AZ7Nad2ZeeS XSScA1DepKBMQ== From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, marijn.suijten@somainline.org, robh@kernel.org, steven.price@arm.com Cc: adrian.larumbe@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, healych@amazon.com, kernel@collabora.com, tvrtko.ursulin@linux.intel.com, boris.brezillon@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v8 3/5] drm/panfrost: Add fdinfo support for memory stats Date: Fri, 29 Sep 2023 19:14:29 +0100 Message-ID: <20230929181616.2769345-4-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230929181616.2769345-1-adrian.larumbe@collabora.com> References: <20230929181616.2769345-1-adrian.larumbe@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 11:17:27 -0700 (PDT) A new DRM GEM object function is added so that drm_show_memory_stats can provide more accurate memory usage numbers. Ideally, in panfrost_gem_status, the BO's purgeable flag would be checked after locking the driver's shrinker mutex, but drm_show_memory_stats takes over the drm file's object handle database spinlock, so there's potential for a race condition here. Signed-off-by: Adrián Larumbe Reviewed-by: Boris Brezillon Reviewed-by: Steven Price Reviewed-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++ drivers/gpu/drm/panfrost/panfrost_gem.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 97e5bc4a82c8..b834777b409b 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -568,6 +568,8 @@ static void panfrost_show_fdinfo(struct drm_printer *p, struct drm_file *file) struct panfrost_device *pfdev = dev->dev_private; panfrost_gpu_show_fdinfo(pfdev, file->driver_priv, p); + + drm_show_memory_stats(p, file); } static const struct file_operations panfrost_drm_driver_fops = { diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c index 3c812fbd126f..de238b71b321 100644 --- a/drivers/gpu/drm/panfrost/panfrost_gem.c +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c @@ -195,6 +195,20 @@ static int panfrost_gem_pin(struct drm_gem_object *obj) return drm_gem_shmem_pin(&bo->base); } +static enum drm_gem_object_status panfrost_gem_status(struct drm_gem_object *obj) +{ + struct panfrost_gem_object *bo = to_panfrost_bo(obj); + enum drm_gem_object_status res = 0; + + if (bo->base.pages) + res |= DRM_GEM_OBJECT_RESIDENT; + + if (bo->base.madv == PANFROST_MADV_DONTNEED) + res |= DRM_GEM_OBJECT_PURGEABLE; + + return res; +} + static const struct drm_gem_object_funcs panfrost_gem_funcs = { .free = panfrost_gem_free_object, .open = panfrost_gem_open, @@ -206,6 +220,7 @@ static const struct drm_gem_object_funcs panfrost_gem_funcs = { .vmap = drm_gem_shmem_object_vmap, .vunmap = drm_gem_shmem_object_vunmap, .mmap = drm_gem_shmem_object_mmap, + .status = panfrost_gem_status, .vm_ops = &drm_gem_shmem_vm_ops, }; -- 2.42.0