From nobody Sun Feb 8 05:23:22 2026 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 EF2D522F16E for ; Tue, 13 Jan 2026 14:37:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768315057; cv=none; b=h+ncX2qvXFKcZzLVaq2H8rW0qLqgfj6Lu5dH7e7JejEMDTJPwgV15URyFG7tBwDAismE+igbp6sMOBM5PP7XZwpDP2ArrKEpDBNe5irjlBexh9PibmYEv+avTm2vZsUIXYiG4zesFMHqDDyfY65w7EjgpXkxphgpGM7WlW3aAjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768315057; c=relaxed/simple; bh=qSC/zIrS1y8tG/wmYG/wN3xMCvUy2vy2fTkJXDcvMzI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=J0zXyT2XNacuHYGIwMJDRFbwHSNG1yODuGNy+HzKhGnINGYPtcaSMZeM/fyV/zw2sjaVKWg556ExrCekWQ9zmFvoZiwhQDpyQL1QG4XZkHerOgWZjCr2fHNKqAgmrQDpZnvwAwnAXDAUkuu24B7dp99FHiWBMjaimPFU2XaEr70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=B4EH70jF; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="B4EH70jF" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D1gbHp2419350; Tue, 13 Jan 2026 14:37:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=corp-2025-04-25; bh=r3tr5yggJe9ICZ2lJH+sPEW7lRwmW c3XvwmjijrOJqM=; b=B4EH70jF1z4zQvov1+bS8FtMr0ZLF6Q+AvaWgZB5UWbeA FY4fK9gzJIsR29kLaZa3yE8yHG4Eu1uFC1le4Q1/5jyLfF4lruKoHesSsbPtAQWL a1kKuDYY5Nm/v1bWioW838E2MGgdVUVL3M95dZ+/c7aSp09DdmqJZoUr/WlrVW2d R5LSiHTjY4KzJt3rvcPgJBWBXrk8FF95KbUe57OAb/j+fLt71Pas2eoVLKJaMftE sUbUNW1elSMpk+ifmT43fKay+T1hmLLj7zxfRYbkX7XH+Ugq0FzWKM8E15WQJNJz HNM06KjNl+o6FYSB2GIg918YCyiuvEbaqAuMqjb6Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4bkre3uh94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jan 2026 14:37:32 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 60DDA9Gx004186; Tue, 13 Jan 2026 14:37:31 GMT Received: from imran-metabox.au.oracle.com (dhcp-10-191-112-80.vpn.oracle.com [10.191.112.80]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 4bkd7jka4r-1; Tue, 13 Jan 2026 14:37:31 +0000 From: Imran Khan To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org Subject: [PATCH v3] genirq/cpuhotplug: notify about irq affinity change for offlined cpus. Date: Tue, 13 Jan 2026 22:37:27 +0800 Message-Id: <20260113143727.1041265-1-imran.f.khan@oracle.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-13_03,2026-01-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2512120000 definitions=main-2601130122 X-Proofpoint-ORIG-GUID: unPrBqUGxxkNzklgTlVuw2DNN9N-iSkZ X-Authority-Analysis: v=2.4 cv=YKOSCBGx c=1 sm=1 tr=0 ts=696658ac b=1 cx=c_pps a=qoll8+KPOyaMroiJ2sR5sw==:117 a=qoll8+KPOyaMroiJ2sR5sw==:17 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yPCof4ZbAAAA:8 a=xRSqlf7xoV9LckGt0Q4A:9 cc=ntf awl=host:12110 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDEyMyBTYWx0ZWRfX1A6kSjjOqzRx LKV/2xUrPvXG6jV2VufM6Zjm6GVqgKlod32UvafWozi2QftINZuKpNkODGYd9Y6EqoV+loNZySJ mUVnxw0dH90mVwPwhLMJdiiVyV+MkNbUCZJfRfpoCmEPtabDFLcb6HeEosFreHATEBzfgHD8JO7 4c7iIfHtS05gC9TuLhK0bCHdHvrsm1QpcSVVEVx0mAum4fczbkE1NskP7S8ZDHE84VBmp+Xclgl euB9wo2b/M+LWPcJCXiha4ve2JD69QaoqwEq982gCpfpy6ClaXoD/c8+571QG3B6686+u1m5R6L p/KoWmxGvn4OufxDm9QGo1P1SijqmmjBOuqOUAMjaoWOMAtjWSrE0ErKVbV31tNnGWAUqZ0GNjo iFlW45ylCzN3/Wdlvx4EMUVbObmu+xBEniaxlqgcPKftyVX4pXwA48xsnLc+w0vTk/qTwH3EuVq WOZHdzsmh2NPEHe2k8cQep0wNDwBwReEYFtq5B2Y= X-Proofpoint-GUID: unPrBqUGxxkNzklgTlVuw2DNN9N-iSkZ Content-Type: text/plain; charset="utf-8" During cpu offlining the irqs affined to that cpu are moved to other cpu, but this affinity change is not accounted for by irq_desc::affinity_notify (if available). This can leave users, of irq_set_affinity_notifier, with old affinity information. Avoid this by allowing to schedule affinity change notification work for irqs that were affined to the cpu being offlined. Also since irq_set_affinity_locked uses the same logic to schedule affinity change notification work, split out this logic in a dedicated function and use that at both the places. Signed-off-by: Imran Khan --- v2 -> v3: - Address review comments from Thomas - Removed RFC tag v1 -> v2: - Fix compilation error due to missed parenthesis around scoped_guard include/linux/interrupt.h | 2 ++ kernel/irq/cpuhotplug.c | 6 ++++-- kernel/irq/manage.c | 28 ++++++++++++++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 266f2b39213a0..6f93bf524f728 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -383,6 +383,7 @@ irq_create_affinity_masks(unsigned int nvec, struct irq= _affinity *affd); unsigned int irq_calc_affinity_vectors(unsigned int minvec, unsigned int m= axvec, const struct irq_affinity *affd); =20 +extern void schedule_affinity_notify_work(struct irq_desc *desc); #else /* CONFIG_SMP */ =20 static inline int irq_set_affinity(unsigned int irq, const struct cpumask = *m) @@ -445,6 +446,7 @@ irq_calc_affinity_vectors(unsigned int minvec, unsigned= int maxvec, return maxvec; } =20 +static inline void schedule_affinity_notify_work(struct irq_desc *desc) { } #endif /* CONFIG_SMP */ =20 /* diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c index 755346ea98196..c77a3b95fba85 100644 --- a/kernel/irq/cpuhotplug.c +++ b/kernel/irq/cpuhotplug.c @@ -177,9 +177,11 @@ void irq_migrate_all_off_this_cpu(void) bool affinity_broken; =20 desc =3D irq_to_desc(irq); - scoped_guard(raw_spinlock, &desc->lock) + scoped_guard(raw_spinlock, &desc->lock) { affinity_broken =3D migrate_one_irq(desc); - + if (affinity_broken && desc->affinity_notify) + schedule_affinity_notify_work(desc); + } if (affinity_broken) { pr_debug_ratelimited("IRQ %u: no longer affine to CPU%u\n", irq, smp_processor_id()); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 349ae7979da0e..6440a64f65a7b 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -139,6 +139,23 @@ void synchronize_irq(unsigned int irq) } EXPORT_SYMBOL(synchronize_irq); =20 +/** + * schedule_affinity_notify_work - Schedule work to notify + * about irq affinity change. + * @desc: irq descriptor whose affinity changed + * + * Caller needs to hold desc->lock + */ +void schedule_affinity_notify_work(struct irq_desc *desc) +{ + 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); +} +EXPORT_SYMBOL_GPL(schedule_affinity_notify_work); + #ifdef CONFIG_SMP cpumask_var_t irq_default_affinity; =20 @@ -367,14 +384,9 @@ int irq_set_affinity_locked(struct irq_data *data, con= st struct cpumask *mask, irq_copy_pending(desc, mask); } =20 - if (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); - } - } + if (desc->affinity_notify) + schedule_affinity_notify_work(desc); + irqd_set(data, IRQD_AFFINITY_SET); =20 return ret; base-commit: f8f9c1f4d0c7a64600e2ca312dec824a0bc2f1da --=20 2.34.1