Re: [RFC PATCH 25/31] x86/resctrl: Introduce region-based MBA write implementation on MMIO space

From: Chen, Yu C

Date: Wed Aug 05 2026 - 02:36:33 EST


On 8/5/2026 5:13 AM, Luck, Tony wrote:
+ for (i = m->low; i < m->high; i++) {
+ closid_idx = (region / 4) * 64 + i;
+ addr = d->base[mmio_type] + closid_idx * 8;
+
+ /* The cached value retains the reserved bits to be preserved. */
+ val = d->marc_buf[closid_idx];
+ if (!val)
+ val = readq(addr);
+
+ if (WARN_ON_ONCE(!val))
+ return;
+
+ val &= ~(0x1ffULL << region_offset_bits);
+ val |= (u64)(hw_dom->ctrl_val[i] & 0x1ff) << region_offset_bits;
+ d->marc_buf[closid_idx] = val;
+ writeq(val, addr);
+ }
}

There are lots of opinions about bit fields. I'm a fan for h/w registers
accessed in architecture specific code.
I think the version below is easier to read than all the inline masks and
shifts.


Got it, learned a lot, I will revise it in this direction.

thanks,
Chenyu