Commit 5faf6e18 authored by Tvrtko Ursulin's avatar Tvrtko Ursulin Committed by Maxime Ripard

drm: Do not round to megabytes for greater than 1MiB sizes in fdinfo stats

It is better not to lose precision and not revert to 1 MiB size
granularity for every size greater than 1 MiB.

Sizes in KiB should not be so troublesome to read (and in fact machine
parsing is I expect the norm here), they align with other api like
/proc/meminfo, and they allow writing tests for the interface without
having to embed drm.ko implementation knowledge into them. (Like knowing
that minimum buffer size one can use for successful verification has to be
1MiB aligned, and on top account for any pre-existing memory utilisation
outside of driver's control.)

But probably even more importantly I think that it is just better to show
the accurate sizes and not arbitrary lose precision for a little bit of a
stretched use case of eyeballing fdinfo text directly.
Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Adrián Larumbe <adrian.larumbe@collabora.com>
Cc: steven.price@arm.com
Reviewed-by: default avatarSteven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20230927133843.247957-2-tvrtko.ursulin@linux.intel.comSigned-off-by: default avatarMaxime Ripard <mripard@kernel.org>
parent f12af4c4
...@@ -913,7 +913,7 @@ static void print_size(struct drm_printer *p, const char *stat, ...@@ -913,7 +913,7 @@ static void print_size(struct drm_printer *p, const char *stat,
unsigned u; unsigned u;
for (u = 0; u < ARRAY_SIZE(units) - 1; u++) { for (u = 0; u < ARRAY_SIZE(units) - 1; u++) {
if (sz < SZ_1K) if (sz == 0 || !IS_ALIGNED(sz, SZ_1K))
break; break;
sz = div_u64(sz, SZ_1K); sz = div_u64(sz, SZ_1K);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment