Re: [PATCH v2 4/5] x86/topo: Fix SNC topology mess
From: Peter Zijlstra
Date: Tue Mar 03 2026 - 09:52:15 EST
On Tue, Mar 03, 2026 at 12:59:46PM +0100, Ingo Molnar wrote:
>
> * Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> > +static u32 slit_cluster_package(int N)
> > +{
> > + int u = topology_num_nodes_per_package();
> > + u32 pkg_id = ~0;
> > +
> > + for (int n = 0; n < u; n++) {
> > + const struct cpumask *cpus = cpumask_of_node(N + n);
> > + int cpu;
> > +
> > + for_each_cpu(cpu, cpus) {
> > + u32 id = topology_logical_package_id(cpu);
> > + if (pkg_id == ~0)
> > + pkg_id = id;
>
> Nit: newline after the 'id' local variable definition.
>
> > + /*
> > + * Off-trace cluster.
> > + *
> > + * Notably average out the symmetric pair of off-trace clusters to
> > + * ensure the resulting SLIT table is symmetric.
> > + */
> > + x = i - (i % u);
> > + y = j - (j % u);
>
> AFAICS that's an open-coded rounddown() from <linux/math.h>:
>
> x = rounddown(i, u);
> y = rounddown(j, u);
>
> right?
Yeah, but I can never remember those 'helpers'. That is, if I have to
spend time looking for them, they're a net negative to me.
Same reason I'm most likely to write: (x + d - 1) / d, rather than,
uhmmm, /me goes find.. DIV_ROUND_UP(). And while I did actually use
that in this series, that's only because it was already in use at the
exact spot I made a change, so I didn't have to go looking.
So sure, I can do the rounddown() thing, but really, its longer than the
thing they replace and less clear, so where's the win?