From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D749D38A9AE for ; Tue, 13 Jan 2026 09:24:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768296260; cv=none; b=aHoijkm2HihdMwu3DgrUH1gq9TTjKkT8tUHUybNQLBvWVLTaurmAZFvxS0oU7yzNvBJUS2ia4OmawivHgy6OdSZD2qmEKMAdlx/3qqjQlTWphuViGLW3SdhXmFkk2cO8qtPc6aFxbkC1soJ6SE+Rsh6A4ILnanfst2LDVoalal0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768296260; c=relaxed/simple; bh=sqWk4ZnbgY3G0hicts4OU5aWqD3cOdsaWPp8afMMbTI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=S2LTo0LRaOL5vuYqaF5gxZf+3gDHvwFz3vW8abyodu/bqSEGz1nZSJX2Ql0bj89m7aa/rcbekoyBRRMqP8kNpQU/bPTlB0w63+WEC7Z1XwDQpgL1pSPhajzu/S2JHxpZuEuJYzR8EjEfW3GHRinAWGo4uoUq5r0YhVjs7DYBqFY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X3gHf2FG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X3gHf2FG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE286C116C6; Tue, 13 Jan 2026 09:24:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768296260; bh=sqWk4ZnbgY3G0hicts4OU5aWqD3cOdsaWPp8afMMbTI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=X3gHf2FGr2ZsaYka/lkK+oB/DPDaD3UQHHekUb4mU9biGsVK0Y8VYWzWUt6Ut/0Hc vvWQKMoJUSMJl+ccJj5Za2sHI7Oo24kZkMPssnh/J4ifOcXkt5RBGWf8zEYDxscZRv OUtTP5W/DykwqXVs3Id2n8wlN8KSqLdHqDenH1odVLcq8SeWpnFTIKOAd0cFk26Q4+ YOXlXgnGJ2g7fro7z0PiKyGFRliTq+datwUmn1im/XmHdKWvbFnf21NXQ6Vpr2L0Z7 /Gjcb/xphLbSn07ZtKiC2CUMyy8YISJcttDBJkk+GgS6Nz8w7CvVazl70UPMmyxHO/ J+UTopg0MMQ4w== From: Thomas Gleixner To: Imran Khan Cc: linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2] genirq/cpuhotpug: notify of irq affinity change for offlined cpu. In-Reply-To: <20260102165308.76290-1-imran.f.khan@oracle.com> References: <20260102165308.76290-1-imran.f.khan@oracle.com> Date: Tue, 13 Jan 2026 10:24:16 +0100 Message-ID: <871pjtg91b.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Sat, Jan 03 2026 at 00:53, Imran Khan wrote: > During cpu offlining the irqs with broken_affinity are affined > to other CPU but this affinity change is not accounted for by > desc::affinity_notify (if available). > This can leave users of irq_set_affinity_notifier, with old > affinity information. > > Signed-off-by: Imran Khan > --- > v1 -> v2: > - Fix compilation error due to missed parenthesis around scoped_guard > > kernel/irq/cpuhotplug.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c > index 755346ea98196..30153be1a4cca 100644 > --- a/kernel/irq/cpuhotplug.c > +++ b/kernel/irq/cpuhotplug.c > @@ -177,9 +177,17 @@ void irq_migrate_all_off_this_cpu(void) > bool affinity_broken; > > desc = irq_to_desc(irq); > - scoped_guard(raw_spinlock, &desc->lock) > + scoped_guard(raw_spinlock_irqsave, &desc->lock) { > affinity_broken = migrate_one_irq(desc); > - > + if (affinity_broken && desc->affinity_notify) { > + kref_get(&desc->affinity_notify->kref); > + if (!schedule_work(&desc->affinity_notify->work)) { > + /* Work was already scheduled, drop our extra ref */ > + kref_put(&desc->affinity_notify->kref, > + desc->affinity_notify->release); > + } > + } No, we are not doing random copy&pasta. Split out the functionality into a function and use it both here and in irq_set_affinity_locked(). Thanks, tglx