From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792646236; b=FDAiNqIEI2N+d2YkngYtnVLpm4NcViuHUqmCht13HDP6M6MY/NCsb76LTAld/g5C2ImR nixRIlVegjcwIytLpYZ6btnJ0jn4PBxeo5ighyjS8kFsKVyyF9CMth5W9e5GtIkyWUMAR pmwn7ylzNr7sCNRgFHTedtwPUcluET3vxKCdr6u5Or+VLxbry7EoUCP7xITF4f3opr+fx 5whHYL0TYY7PHH2it9Oki1+QkJTlCOx82z1xy/7GJd+vvJqPzwGBFztZ7V+eCmds5zP1S 2zilh+GEsLEITHpkDPT8yrpz+Kxre3wUjbbvWzb+noJbaxJTfHpmltMD1SzxlR6D6tg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792646236; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=H/SXDgdhEaQ9Leps7ngp4tdnFYLEJykx5g1h92ea+nY=; b=jWvNekQ/aj8VX12s9AvhciC+/mcP+HRP96SfJHMnfoRD4qnAAZ2OS7E8C5+gH0C3oSaC fkJqqIwNAxclnqgAOH2u4YSYZWvan3kwcp2wG9XY78NZextPVy9HeMCGhjhWJjASo8uzU UfscxXkfILvYJYOyBD6aSHk6JN0sO6uKz5i+uvg36hPMbw1RhegIJOTPOd06u5iVm1MbA AORjIeAZpPRT1TfenmCsk1Xd9nw11jEeR/TBzjBvFTNDSCT24HBawJWzdUrvtWBC7aZVF 6wtk22oySqkw4tKIqqQJ//bYvTw3yZSbEVWYJ1Vwv0+16lG2Vs/JWZmuU3ihrKFqkaQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=PwoDzxWk; arc=none smtp.remote-ip=209.85.128.44 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF3C606A319 for ; Thu, 22 Oct 2026 05:17:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBF3C606A319 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=PwoDzxWk Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4a2084d62cdso1393155e9.1 for ; Wed, 21 Oct 2026 22:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792646234; x=1793251034; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=H/SXDgdhEaQ9Leps7ngp4tdnFYLEJykx5g1h92ea+nY=; b=PwoDzxWkA70Wmef14Vvpr9c4fHpU4ChmSg7Dc5eGutsiHbtTrYWNl05zc02Gtlv72r 4Zq5Cp5q/leY/52RfvlkHWYrZVWtP80pZpjpJU07hEV0rT/E53N3KO4IWShg7/l5ZzfB poj2nHlLy8FnxKAmRNLKQsThjETb6zYQCRZnWh+D2hQsraNpceIfbDQoN1EdtuazyWtG Xz239Xqggu0HrKDQNYqGFznDgrbku+UIu/jVnKeOMCTNYn8ak5Bg9ETNi333RYgws0vD 8vT7cU2/CuH54hAwzM/b+N0RwJToGTeuGLcM3zg4fHgXkQRw2e7ZuoNShYA6nVFSLNH8 xmQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792646234; x=1793251034; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=H/SXDgdhEaQ9Leps7ngp4tdnFYLEJykx5g1h92ea+nY=; b=DZB/kHwerILSEqPwl941/HGNxQUi/NLcQKn+xh/hVeQ0/jrc9qiyoTDD6TiFBA+dm0 kkVWu1V26AVVRfVcgbo2yiizJrdl1Zkx80o6XUdddQbK+3DIeT0KNYyVMRhqPV6+8GB0 QgJ5aGmZt94lcDHIwB0TCrGnYp6zC0kumuAyIIQII6BdFzxi8AWNZpOLUI7IxvKbFGgE gLGSQjiYGkMhPONAfFEcm5FoEIovDyV3Hxc3QohXSSxgUUqR90hSsJbIbtm/MK8dEsnE 7HqEw3PcNErKPHPAIgmGmK/gozdg3TPODwu0KWuejJlzHJoynYocFHEf/hWvXOAHSrAn OLsg== X-Forwarded-Encrypted: i=1; AKwUvBxVXt+/iWO+YkWJRBQwaGtQOVFcbIylxkEDdctGc6VPg8c9hq2L+dxV1Rk34dL3AxlPB5nRdvH6ZqA=@vger.kernel.org X-Gm-Message-State: AFq9FYIufeEErofkX5G+JlnxkEX/elUO1AgYsN40STHI9mu+EDunsjxx P2eqFlCXG59mNInHhPyO9eobK74JHxPuWZNOUjT6bb+C4oN4CBoUuLiB X-Gm-Gg: AYBFou03x9JOdZqtTikwsVyjsrA3s4XAu7pwX/df1z16AOe6f1YxBOlmNFvi87DHulr xWgEAHYDvSs1+tRuCHnb6XwL5Kd4pR3lMZqC6UzJ9WKwxeHweBy7qC+4ZrHbUfVW/i6pINXNSDD p8VccQPFNwxl29XySvKLBjjqra7uIvVqd+J5sy81RQuIzX0Jja+jQ8fiJtYHOpOLRCU1T5aSGaw phfOTOML05eW7LXeuMDdtH1EzVIaBlXai1diBISdOMX4HPsM+QXwrlzjWSL7LBUAEPrzD5YaEM0 Az6JrQ2i/rzLXhy2WqxEr8fMOnN7ZFmnaiD1rfld6fMUVnVnCkAvbRWNN3MVr63XCB54gja3gjD HAiZYGmLgHtSy8/ef496tz1m9nWaMHPywLf+GTmwsdmjv6yuZwQLyNxOhxXvRN6El1VW2pOUXIZ Y17yGh8tFra0b7GWFhf5Wu3rnT+BedP+1s4nKQAP3NBP1lOYkyU5ScNSIoNhNf0Fiwq7TjHY3rL L6JkYb1dAixIg+m8ajrR4yPVkU2XFCYvIisIbdnYyMfmi2wKM82XS4CaNlFYkmzr9Lmo9y7tfaM sAFBPARqpkVTUwWs1f8gRkQuUiG/8RjoBpn4yNCm4zvjaj68pz3fClwo6iQb9tzOpPjqhI+xllC JlS5x3MsQx2cKPfuGBMVcBl5DaleNN44A41YVDA9cMnJgQ9znLatGyBJha4U= X-Received: by 2002:a05:600c:3513:b0:4a1:cedc:ab49 with SMTP id 5b1f17b1804b1-4a1fdd1e97emr87433205e9.31.1792646233938; Wed, 21 Oct 2026 22:17:13 -0700 (PDT) Received: from localhost.localdomain (dynamic-2a02-3100-ad43-d501-2c28-bb72-120d-420e.310.pool.telefonica.de. [2a02:3100:ad43:d501:2c28:bb72:120d:420e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a1fd0f4427sm90362275e9.3.2026.10.21.22.17.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 21 Oct 2026 22:17:12 -0700 (PDT) From: Karl Mehltretter To: Steven Rostedt , Peter Zijlstra , Thomas Gleixner Cc: Karl Mehltretter , Catalin Marinas , Will Deacon , Mark Rutland , Ingo Molnar , Andy Lutomirski , Frederic Weisbecker , "Paul E . McKenney" , Sebastian Andrzej Siewior , Boqun Feng , Waiman Long , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Hongyan Xia , Jonathan Corbet , Shuah Khan , Randy Dunlap , Andrew Morton , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-arm-kernel@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, linux-doc@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 00/12] entry, tracing: Classify early hardirq entry and return tails Date: Thu, 22 Oct 2026 07:16:42 +0200 Message-Id: <20261022051654.79224-1-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Tracing's transition recursion slot exists because a callback can run after architectural hardirq entry but before generic entry increments preempt_count(). Steve asked whether the count could be updated soon enough to remove that slot. This RFC establishes that entry contract on arm64 and closes a separate recursion window exposed by the same tests. This is a design RFC, not a merge-ready proposal. I am looking for feedback on the entry contract before extending it to other architectures or removing TRACE_CTX_TRANSITION. Clang can outline raw preempt-count updates and __kern_my_cpu_offset() from noinstr entry code. This series applies to a tree with the following two patches added: - Hongyan Xia, "arm64: Always inline raw preempt count updates" https://lore.kernel.org/all/c3a90368dd6c096af9d918e036a27728696fb8a4.1786603168.git.hongyan.xia@transsion.com/ - Will Deacon, "arm64: percpu: Annotate __kern_my_cpu_offset() as '__always_inline'" https://lore.kernel.org/r/20260918161407.2300-12-will@kernel.org Those patches are external prerequisites and are not included in this RFC. Patches 1 through 11 split raw preempt-count updates from generic IRQ bookkeeping. On arm64, ordinary interrupts add HARDIRQ_OFFSET after the pseudo-NMI decision but before instrumentable generic entry work. The remaining accounting still happens in irq_enter_rcu(). The exit side has a similar gap. Function-graph and MTE callbacks can run after the real hardirq state has been removed, and kernel return may schedule before them. The series records ordinary-hardirq provenance and restores a synthetic hardirq classification after the preemption decision. That tail changes only preempt-count and lockdep state. It does not repeat interrupt accounting, RCU, or tick entry. Patch 12 keeps tracing's recursion state inside one preemption-disabled interval. It closes the transition collision reproduced at the IRQ-exit reschedule boundary. TRACE_CTX_TRANSITION remains unchanged because unconverted architecture entry intervals can still run before preempt_count() reflects hardirq context. An x86-64 no-transition control still recorded recursion at system-vector entry and exit and in the deferred hrtimer return tail. The base includes "entry: Account the deferred hrtimer rearm as hardirq context for lockdep" and "softirq: Preserve interrupt context on return from interrupt". The main questions are: - Should generic entry expose separate raw-update and bookkeeping phases? - Are preempt count and lockdep state sufficient for the return tail? - Is arm64 a suitable first user of this contract? - Should the recursion-lifetime fix travel with the entry conversion? Karl Mehltretter (12): sched: Split preempt-count bookkeeping from raw updates lockdep: Use raw access for pinned hardirq state entry: Add the pre-counted ordinary-hardirq entry/exit contract entry: Skip inactive IRQ-return reschedule calls context_tracking: Split IRQ-exit preparation from the EQS transition lockdep: Prepare IRQ-on state from a hardirq return tail entry: Carry ordinary-hardirq provenance through kernel return entry: Classify ordinary hardirq return-tail work as hardirq context arm64: Use the pre-counted hardirq lifecycle docs: entry: Describe the pre-counted hardirq lifecycle locking/selftest: Exercise hardirq return-tail preparation tracing: Pin recursion state for its complete lifetime Documentation/core-api/entry.rst | 75 ++++++++++-- arch/arm64/include/asm/preempt.h | 2 +- arch/arm64/kernel/entry-common.c | 25 ++-- include/linux/context_tracking_irq.h | 32 +++++- include/linux/hardirq.h | 29 +++++ include/linux/interrupt.h | 2 +- include/linux/irq-entry-common.h | 96 ++++++++++++++-- include/linux/irqflags.h | 14 ++- include/linux/preempt.h | 9 ++ include/linux/trace_recursion.h | 14 ++- kernel/context_tracking.c | 78 ++++++++++--- kernel/entry/common.c | 38 +++++- kernel/locking/lockdep.c | 48 +++++--- kernel/sched/core.c | 68 +++++++++-- kernel/softirq.c | 166 +++++++++++++++++++++++---- lib/locking-selftest.c | 53 +++++++++ 16 files changed, 648 insertions(+), 101 deletions(-) base-commit: 779ab5d73a22c798d1273b4aaf50cf5b8d750be9 prerequisite-patch-id: 9c009809614854fbff979d65aad6732757d006d5 prerequisite-patch-id: 764fd197db36a3889548bbc41890dd5b3d902f99 -- 2.39.5 (Apple Git-154)