mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Naman Jain <namjain@linux.microsoft.com>
Cc: Thomas Gleixner <tglx@kernel.org>,
	Tianyou Li <tianyou.li@intel.com>,
	Wangyang Guo <wangyang.guo@intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	linux-kernel@vger.kernel.org, Long Li <longli@microsoft.com>,
	Ming Lei <tom.leiming@gmail.com>, Ming Lei <ming.lei@redhat.com>
Subject: Re: [PATCH] lib/group_cpus: rotate extra groups to avoid IRQ stacking
Date: Sun, 26 Apr 2026 13:52:46 -0700	[thread overview]
Message-ID: <20260426135246.0a52d9f4e04fd84a304b2339@linux-foundation.org> (raw)
In-Reply-To: <20260324075352.2326972-1-namjain@linux.microsoft.com>

On Tue, 24 Mar 2026 07:53:52 +0000 Naman Jain <namjain@linux.microsoft.com> wrote:

> When multiple devices call group_cpus_evenly() with the same number of
> groups, the cluster-aware path in __try_group_cluster_cpus() assigns
> extra groups to the same set of clusters every time, producing identical
> affinity masks for every caller. CPUs in clusters that receive two
> groups (and thus get single-CPU dedicated masks) end up handling
> interrupts from ALL devices, creating an IRQ imbalance.
> 
> For example, on a 96-CPU / 2-NUMA-node system with 24 clusters of
> 2 CPUs each and 6 NVMe disks each requesting 62 vectors:
> alloc_groups_to_nodes() distributes 31 groups across 24 clusters,
> giving 7 clusters 2 groups (single-CPU mask = dedicated) and 17
> clusters 1 group (2-CPU mask = shared). Because the assignment is
> deterministic, all 6 disks produce the same mapping and the same 14
> CPUs each accumulate 6 dedicated IRQs -- roughly twice the interrupt
> load of other CPUs -- causing up to 11% per-disk throughput degradation
> on IRQ-heavy CPUs.
> 
> Fix this by introducing a per-caller rotation offset via a static
> atomic counter. After alloc_groups_to_nodes() determines each
> cluster's group count, collect the extras (groups above the per-cluster
> minimum), then redistribute them starting from a rotated position with
> a stride of ncluster/extras so that successive callers scatter their
> extra groups across different clusters. A capacity check
> (cpumask_weight_and) ensures no cluster is assigned more groups than it
> has CPUs, with a fallback loop for any extras that could not be placed
> in the strided pass.
> 
> For systems without cluster topology, the same rotation is applied in
> assign_cpus_to_groups() at the per-group level: the modular expression
> (v + spread_offset) % nv->ngroups selects which groups receive the
> extra CPU, replacing the previous sequential decrement.

Thanks.  AI review asked a couple of questions.

	https://sashiko.dev/#/patchset/20260324075352.2326972-1-namjain@linux.microsoft.com


group_cpus.c is difficult.  It's tricky code and few people seem to be
familiar with it - I certainly don't feel competent to review changes.

The original author (Ming Lei) is still around, but wasn't cc'ed on
this change.  Let me add.  (I'm seeing two Ming Lei's - apologies if
they aren't the same person ;))


  reply	other threads:[~2026-04-26 20:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  7:53 Naman Jain
2026-04-26 20:52 ` Andrew Morton [this message]
2026-04-27  8:45   ` Naman Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260426135246.0a52d9f4e04fd84a304b2339@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=ming.lei@redhat.com \
    --cc=namjain@linux.microsoft.com \
    --cc=tglx@kernel.org \
    --cc=tianyou.li@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=tom.leiming@gmail.com \
    --cc=wangyang.guo@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®