Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2695915rdb; Fri, 22 Sep 2023 06:12:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6OlsGbYSvM9APPT7toRBoy20qYM0vGYEqLoe7qVv4pw0u23rjJqmCznFMnEniUBaXevQb X-Received: by 2002:a17:90a:7b88:b0:268:38a7:842e with SMTP id z8-20020a17090a7b8800b0026838a7842emr7924050pjc.2.1695388370170; Fri, 22 Sep 2023 06:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695388370; cv=none; d=google.com; s=arc-20160816; b=yHOdUDz9kTnhRcVF1+ntvsgSk1tKx3O2Mt9oPPu1i5ARIz0yelIUOHVerDPlFwS1rP Y57NG9/it9wtIk268TFt8uf5zOQoHPkwyrXh+qbSJJ7CYB8Q4b4LoIT2B8pc+6p/4jLb FnU64xZd4gcsykP9hPC67jf58adoIhouxK1TzTDDtFHk8AiTYMpfWbPiTXc0pAh+Fu94 i8RXJm/GKZ6NT7+XUrl6uoxQb1/ZlZvOC3FE/U3mhlWfY7Rn/OKT52HJdyIMVEhyury5 HgweK5vIc4dKHwBVGE1X3LyUCbZIPuv2mhCKOBcMcKgfzDiUTeuHASpymWnj7NAVpsxS r+1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9ipZUWIya4Ay9zWVHpjN3v1HFUrhNPxHTz7joJg0d7Y=; fh=u1fRHtClMjp4METtLhCud7j5a/3Jm/lOaA4CXK/G9wM=; b=RlLCdy2Z1zO6dN4vTKdwL2GLVCSNYRaOG8LoXOpTGV41/WqiGht7NpxX2IxDb86kOx 7Zce+T0DNyzxWHQcIhnd0vREWGJebDSXLG9iKZuBmqmI7V5sNY+WwTidl2jpnwDFhB2f IIk8a+hIL33gSP2x+BoHE+ZMvnZ5KkNcZgwQ/kLIzXq/J8Big71iIhTGem6MiYQ7o5SM CKVuX3t2lG8KUMe0uRIyyF7RLdbmhBkiLYzmTt/g4Jmc30b1MHWoTSxmqVu2zYi9bjph gMsnkAIT+8zRbXgMsWWbe9yGiF0ST/aJHqhTYCqQjTCIeMvZwqgse1HZRing3tATzT/f gryw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dJ6zNgz1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ch6-20020a17090af40600b0026800178358si3794130pjb.144.2023.09.22.06.12.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dJ6zNgz1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 71F97840FE04; Fri, 22 Sep 2023 04:02:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233341AbjIVLCC (ORCPT + 99 others); Fri, 22 Sep 2023 07:02:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjIVLCA (ORCPT ); Fri, 22 Sep 2023 07:02:00 -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 ACEA4AC; Fri, 22 Sep 2023 04:01:54 -0700 (PDT) Received: from localhost (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 ECDHE (P-256) 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 4003F6607298; Fri, 22 Sep 2023 12:01:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695380513; bh=DH0CgaoapBhQcnFaMJV2Rkn3poFia6kb9FUwld5Yr2E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dJ6zNgz1saDEIBBf1GHZ23CbSGegBUGIrVNb+i9AEu7qR7jYz7IFXRRwOXFkniNu1 6W2QvGETHn3Hg4eV1rtjcfRLwntU5BFH9z16vwMG+INRFoLhmsK/hyd038lOzee5MG AN5V2N/xLwAz9WcUkPcDs6BjqK6OhUIl4L7Oiv8GEkueYje3z+Q9DexAffumG3TVZw AhdiIfJS9WhrfHrzWBCT03jT0+u2Kj7Rjw6R8BqH5Q/t+b9YaeI+e9gBQBq8NqVkU0 LT3OV+n/GPDdwshll/UEVl7U9WRMwpbWzK0dG0oxPb9ao1Z+1dfAzXG49BGOpBPbUh /+nO2CcbzXwbg== Date: Fri, 22 Sep 2023 12:01:51 +0100 From: =?utf-8?Q?Adri=C3=A1n?= Larumbe To: Tvrtko Ursulin Cc: 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, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, healych@amazon.com, Boris Brezillon , kernel@collabora.com, freedreno@lists.freedesktop.org Subject: Re: [PATCH v6 6/6] drm/drm-file: Show finer-grained BO sizes in drm_show_memory_stats Message-ID: <3l4prybv2bhyd5s3s7vkfo3k42cjndl2db53sntduqeuwjquld@tfop5o5p6gez> References: <20230919233556.1458793-1-adrian.larumbe@collabora.com> <20230919233556.1458793-7-adrian.larumbe@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 04:02:09 -0700 (PDT) On 20.09.2023 16:32, Tvrtko Ursulin wrote: > >On 20/09/2023 00:34, Adrián Larumbe wrote: >> The current implementation will try to pick the highest available size >> display unit as soon as the BO size exceeds that of the previous >> multiplier. That can lead to loss of precision in contexts of low memory >> usage. >> >> The new selection criteria try to preserve precision, whilst also >> increasing the display unit selection threshold to render more accurate >> values. >> >> Signed-off-by: Adrián Larumbe >> Reviewed-by: Boris Brezillon >> Reviewed-by: Steven Price >> --- >> drivers/gpu/drm/drm_file.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c >> index 762965e3d503..34cfa128ffe5 100644 >> --- a/drivers/gpu/drm/drm_file.c >> +++ b/drivers/gpu/drm/drm_file.c >> @@ -872,6 +872,8 @@ void drm_send_event(struct drm_device *dev, struct drm_pending_event *e) >> } >> EXPORT_SYMBOL(drm_send_event); >> +#define UPPER_UNIT_THRESHOLD 100 >> + >> static void print_size(struct drm_printer *p, const char *stat, >> const char *region, u64 sz) >> { >> @@ -879,7 +881,8 @@ static void print_size(struct drm_printer *p, const char *stat, >> unsigned u; >> for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { >> - if (sz < SZ_1K) >> + if ((sz & (SZ_1K - 1)) && > >IS_ALIGNED worth it at all? This could look better, yeah. >> + sz < UPPER_UNIT_THRESHOLD * SZ_1K) >> break; > >Excuse me for a late comment (I was away). I did not get what what is special >about a ~10% threshold? Sounds to me just going with the lower unit, when size >is not aligned to the higher one, would be better than sometimes >precision-sometimes-not. We had a bit of a debate over this in previous revisions of the patch. It all began when a Panfrost user complained that for relatively small BOs, they were losing precision in the fdinfo file because the sum of the sizes of all BOs for a drm file was in the order of MiBs, but not big enough to warrant losing accuracy when plotting them on nvtop or gputop. At first I thought of letting drivers pick their own preferred unit, but this would lead to inconsistency in the units presented in the fdinfo file across different DRM devices. Rob then suggested imposing a unit multiple threshold, while Boris made the suggestion of checking for unit size alignment to lessen precision loss. In the end Rob thought that minding both constraints was a good solution of compromise. The unit threshold was picked sort of arbitrarily, and suggested by Rob himself. The point of having it is avoiding huge number representations for BO size tallies that aren't aligned to the next unit, and also because BO size sums are scaled when plotting them on a Y axis, so complete accuracy isn't a requirement. >Regards, > >Tvrtko > >> sz = div_u64(sz, SZ_1K); >> } Adrian Larumbe