On 1/13/26 5:28 AM, Gary Guo wrote:
> On Wed Dec 3, 2025 at 5:58 AM GMT, John Hubbard wrote:
...
>> +pub(crate) struct FbRange(Range<u64>);
>
> How useful do you think this is in general? Would it make sense to have a
> dedicated PhysAddrRange type in kernel crate that provides this feature?
Pretty useful. Yes that sounds like a good move. And I see from Miguel's
reply that Gent Binaku (+CC) has a patch that proposes adding a
PhysAddrRange. I'll go review it in detail.
>
>> +
>> +impl From<Range<u64>> for FbRange {
>> + fn from(range: Range<u64>) -> Self {
>> + Self(range)
>> + }
>> +}
>> +
>> +impl Deref for FbRange {
>> + type Target = Range<u64>;
>> +
>> + fn deref(&self) -> &Self::Target {
>> + &self.0
>> + }
>> +}
>> +
>> +impl fmt::Debug for FbRange {
>> + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
>
> If you want to make this more generic, you can gate the size printing on
> `f.alternate()`. So if people use `{:?}` to print a compact form of
> `FbLayout`,
> they get just the range, and if they use `{:#?}` then they also get the sizes.
>
>> + let size_mb = (self.0.end - self.0.start) >> 20;
>> + f.write_fmt(fmt!(
>> + "{:#x}..{:#x} ({} MB)",
Great idea, that printing choice is extremely nice to have in exactly this
situation.
>
> I would either just use IEC prefix "MiB", or alternatively use the coreutils
> convention and use "M" to represent MiB.
OK.
thanks,
--
John Hubbard