From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 776E52820C7 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701021; cv=none; b=mc6XZX6psAWjSG0itvWtIWj0DkSNBe3HD2NR5IcUmmfnq9hAEsSqDNObfmA1wEpbIYd4MCDs65qRYQU0OsMLyCzL/1OaHfkbQQxolO96xVKV3ZPGSqKkShsft5TyZKlBJA/nt3BBoFEV7YgeZcE3ifTPjOV2vOy3kFpovNptWok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701021; c=relaxed/simple; bh=62ustbkopVhBdcLoC7hwC9z9bDpnZ7IWCPTGeIvCKP4=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tCDITKBGRTPimll1G4iezmdl6qRWdnh+5irwwNOlUvfS+U7KRrJAaut6o8hrl3m5o3KLutadc/GVXwEpYNU1EKHd8zPbtflyE3Pz/3iKpPguH9NRLaZZHGWATEhxbMZ/hIqVq6Ou2XSr/TTxsIbkAv1v7jiPdcf1GXbnyn4Lm8I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=K0g9fXm+; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="K0g9fXm+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=Ua0dxI0J08PM8zvyZk5eD4nV7fTxFbZ9tXP0wSe2am4=; b=K0g9fXm+B6oxbUqjmInTle4xCS 0g2H7OEfBblBht8ZaLNwDTF5CwJZ9lCes3KvN4LipdYHTqs0swtcl3oHfKB2TOFERkRHtu67VnHpm tzozFMcYkjn/b2nS96AM188ggak4t+eVrO3akJB5q2Ku6Nz5SX17pPnS+zLys3DZfha0oECRO5bu6 0F72BuvN1kx6XoyJO/oWx799a2cM1N4ODlXsoLtbIhLj5wZDe2dKgQe3xg5MAei6cYFbhFZh/kutb C9+uhen+crC4GxOsrQq7IiTFJBZFoWW9ALMM7kApr18pBI8o3id2tlNEzYBwfLzO1FHUWFuywzgO4 mgtE0JzQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeCi-00JQ; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 0117A30050D; Wed, 24 Sep 2025 10:03:32 +0200 (CEST) Message-ID: <20250924080118.425949403@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:49 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 01/12] task_work: Fix NMI race condition References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" __schedule() // disable irqs task_work_add(current, work, TWA_NMI_CURRENT); // current =3D next; // enable irqs task_work_set_notify_irq() test_and_set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); // wrong task! // original task skips task work on its next return to user (or exit!) Fixes: 466e4d801cd4 ("task_work: Add TWA_NMI_CURRENT as an additional notif= y mode.") Reported-by: Josh Poimboeuf Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (Google) --- kernel/task_work.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/kernel/task_work.c +++ b/kernel/task_work.c @@ -9,7 +9,12 @@ static struct callback_head work_exited; #ifdef CONFIG_IRQ_WORK static void task_work_set_notify_irq(struct irq_work *entry) { - test_and_set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); + /* + * no-op IPI + * + * TWA_NMI_CURRENT will already have set the TIF flag, all + * this interrupt does it tickle the return-to-user path. + */ } static DEFINE_PER_CPU(struct irq_work, irq_work_NMI_resume) =3D IRQ_WORK_INIT_HARD(task_work_set_notify_irq); @@ -86,6 +91,7 @@ int task_work_add(struct task_struct *ta break; #ifdef CONFIG_IRQ_WORK case TWA_NMI_CURRENT: + set_tsk_thread_flag(current, TIF_NOTIFY_RESUME); irq_work_queue(this_cpu_ptr(&irq_work_NMI_resume)); break; #endif From nobody Thu Oct 2 01:57:54 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 A0BA726E6FA for ; Wed, 24 Sep 2025 08:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701017; cv=none; b=PrmNAOqfQf0l+dmI/0SiVuQdDK8NDWd75tz2BFfLAankVeiHO0bNS3ifBpPMImnvjNSuZw6Nv/tTckQC+llbkXKNajGuMlu4y8SX5HHdYqTsEfDW/5qx5YuP/gnbqnyMrIa8eO2tjqkldOSN/6+YTMqpAyhnw6svP9sYpbDtnXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701017; c=relaxed/simple; bh=uugCYR/RyKJ2k19QOGAnWn+PMaQlWlHjUIns+kfsIpI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=miH2ixQWB23G5JL6/Uo11zKB2Bk01tA07WqaJy6UwJJnXg8PkprGZ04N8lNsZCBsL3JaV7VB9rFF0wJEygJ5BMO9qHR/GVYcmPsd/n4DiGs8BoQCQHgnXprw+2cadreSdJvbi/lTtY40CftrDAxI3zpE5JGoczztW56onKeKgT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=LTBbQHBa; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LTBbQHBa" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=pxgFIlR99iKm/nP/htLTylf5qVEen9HVPfiXmpXzK2U=; b=LTBbQHBajmiQjw5RZvYIj5FwKY HBXs5IJ69wMbipt/tzIzQet+2tQH4Hx690q8azASZAavzMRqsQIeKyZIMSNOhGnrLfiyz4m5WvVoP mSV49PXmkNZg9qFUU+yNOGwf94t1a2zWioC89RgciRFrlz+hxcNann5MO0QVdDGN9rUKNc4tQbOIN b7SIMTmdQ7m/m0j8VRMn2GhzbiwDY7x1qIJvuXIk679ho5hDJOp7BI4FzGdA9RVspFNfgnfXLU69d UpnjJ0ibMVwi8T9aqwAzd8buyyoTjFx+a7Dsyk8r2WPucF6ROeSAasbQuEjSsaMX0SNDel6jR3uBU orrBoHew==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTN-00000008iAz-1yRB; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 05DFD302D64; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080118.545274393@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:50 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 02/12] unwind: Shorten lines References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" There are some exceptionally long lines that cause ugly wrapping. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Steven Rostedt (Google) --- include/linux/unwind_deferred.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/include/linux/unwind_deferred.h +++ b/include/linux/unwind_deferred.h @@ -8,7 +8,9 @@ =20 struct unwind_work; =20 -typedef void (*unwind_callback_t)(struct unwind_work *work, struct unwind_= stacktrace *trace, u64 cookie); +typedef void (*unwind_callback_t)(struct unwind_work *work, + struct unwind_stacktrace *trace, + u64 cookie); =20 struct unwind_work { struct list_head list; @@ -68,9 +70,17 @@ static __always_inline void unwind_reset static inline void unwind_task_init(struct task_struct *task) {} static inline void unwind_task_free(struct task_struct *task) {} =20 -static inline int unwind_user_faultable(struct unwind_stacktrace *trace) {= return -ENOSYS; } -static inline int unwind_deferred_init(struct unwind_work *work, unwind_ca= llback_t func) { return -ENOSYS; } -static inline int unwind_deferred_request(struct unwind_work *work, u64 *t= imestamp) { return -ENOSYS; } +static inline int unwind_user_faultable(struct unwind_stacktrace *trace) +{ return -ENOSYS; } + +static inline int +unwind_deferred_init(struct unwind_work *work, unwind_callback_t func) +{ return -ENOSYS; } + +static inline int +unwind_deferred_request(struct unwind_work *work, u64 *timestamp) +{ return -ENOSYS; } + static inline void unwind_deferred_cancel(struct unwind_work *work) {} =20 static inline void unwind_deferred_task_exit(struct task_struct *task) {} From nobody Thu Oct 2 01:57:54 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 A0B3923506F for ; Wed, 24 Sep 2025 08:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701017; cv=none; b=f1xAZXEi17PQkOrjNZdPkTvatFoqIQ0lXVp5QZdLTChV/zO2ep8m0o3LsKTbKJi90ItTmtLu/9BikweIyMl1+wd/37GmObJElr2D5K9MJhEsD8a1/hLSne9niRB26ECxaVlQcd0cI7+pyuMc9CSYf6MfDRbW7fNk6DLewLCF6yY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701017; c=relaxed/simple; bh=81G3ehiC2XjLqQUYUmv++p6b+oE6dZ6FqhexIoz5X5E=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=RJP2CG5UrWr+5T7Sg2u9MOMeQpdTvKv2TkpsO9fzlrdHqauf0LhaVVowJPGFrqwwd/BaLZ8Jnnhm3GGlLeDRJb/FTHMoMAts3YzjbpDWoORDdkMtB3VZ5ejsh45Ldyzj+Z/yJnfBkUEjdZbMsIYQZH2KeGPduOtWmDoGqnYPHP8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=LL3km+It; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LL3km+It" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=jPl2PJPpsUjXGW4y5gOPBSspzLqtyrK1u2yYfSklgn8=; b=LL3km+ItppXBmfG7pT/LUWWaY0 i4xVEbILSsJ9XF0Nf6rzku9Iq1RVd3U5uDMcjFNdPl0z7qYxscRnpTWha68oxu3zSwnAoAYH80RMM rEyZnENEmK+sGlAOUBRxrGtqE3VUTtZaLLJE1ojYsLcFOcH0+4vLz1FQJFWY/3b6TxnNHSwPTggVa VmwUb9S6fK9oq6a3tBq1vjrTDazXX3U2vvxepsVPE870dCJ9kUDhYD1Sr7qJNeN0S3NlGsULjC/Lk 0lTkASoxVylJB7BGoXJkvYFDvypZTzXd8AVN48ymoYdZ+3zaWp2M49+EVIPOjYHpXMrBJ6SF5TH0G 1IOev7Zw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTN-00000008iB0-21dT; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 0AA23302D93; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080118.665787071@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:51 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 03/12] unwind: Add required include files References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" To be self sufficient, the file needs to include linux/types.h. This provides things like u32/u64 and struct callback_head. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Steven Rostedt (Google) --- include/linux/unwind_deferred_types.h | 2 ++ 1 file changed, 2 insertions(+) --- a/include/linux/unwind_deferred_types.h +++ b/include/linux/unwind_deferred_types.h @@ -2,6 +2,8 @@ #ifndef _LINUX_UNWIND_USER_DEFERRED_TYPES_H #define _LINUX_UNWIND_USER_DEFERRED_TYPES_H =20 +#include + struct unwind_cache { unsigned long unwind_completed; unsigned int nr_entries; From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 6CBF92820A0 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=VFxxg1qjNoFoxRaRMDSRlwsDFq2LSJXKXTLBkfMQj2/rGn9Y5P2aBTTRutsQ1XcyCoNB2q8ivxkXTLpNQBHlwGcyaqgkdGlP+VOBur/5n22rLmSku4lFjj5u7V+Ae2utgj1b46irBYdVtSB6P9gWRuVy6OVP7VT7gNJvi9MciHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=i6Vw4Ih1S80eP+vqt699mlMmyf72rKFWx2F8Pn2W3RI=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=m91cL+DELmbITcWrwQiagfj8+K1m7r01LBaKbPHeobSUiN0jlUtAfrxA+hQmwi7YRhFDve8lVleJG0L1NPZKfvykRk4SeT8M8O8VHuPvBEPaerhHjoDQE7dwEFlvyCJnPXz+40hGfT6TN6WAYvq9FklIIBltuTog4gaz1DeFTsI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=a4u98U6E; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="a4u98U6E" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=UH3hyurzcrwCnH6P3LZU6oD5I44GKx2Vs+NW8JK3KmI=; b=a4u98U6E7gmPa3Q8dpVoiJG8Tt Oj3qYFZySWEyyULbvu4sCe/slBlVpePEy8wniowlZtyu93l8jIPlEyvnKRudzKC1SHR9UkYcj19a0 gGHXmNnN3lCeBOfAw0jXnDu+xhivREuSGxxwYT/r9dPTFEFoXoct8CbSp6NqP04TDs1hFpzUkZfrs uYMtBukQbgMmDWSqZIn41zwje0URhJjG6vJ0WZdU+FVGalWE8EteMrt8To7gZTiI+zTrHuIJRoMly OariTEBZFsb7dc1zlo+B5Ph5x8ty0gJETiKMOPsM2KnGyrgEL4FEHkU7a6sAYQs6FRvYy4tLChVo5 co0OFmQw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeCo-03ZM; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 111E1302DA9; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080118.777916262@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:52 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 04/12] unwind: Simplify unwind_reset_info() References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" Invert the condition of the first if and make it an early exit to reduce an indent level for the rest fo the function. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (Google) --- include/linux/unwind_deferred.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) --- a/include/linux/unwind_deferred.h +++ b/include/linux/unwind_deferred.h @@ -45,22 +45,22 @@ void unwind_deferred_task_exit(struct ta static __always_inline void unwind_reset_info(void) { struct unwind_task_info *info =3D ¤t->unwind_info; - unsigned long bits; + unsigned long bits =3D info->unwind_mask; =20 /* Was there any unwinding? */ - if (unlikely(info->unwind_mask)) { - bits =3D info->unwind_mask; - do { - /* Is a task_work going to run again before going back */ - if (bits & UNWIND_PENDING) - return; - } while (!try_cmpxchg(&info->unwind_mask, &bits, 0UL)); - current->unwind_info.id.id =3D 0; + if (likely(!bits)) + return; =20 - if (unlikely(info->cache)) { - info->cache->nr_entries =3D 0; - info->cache->unwind_completed =3D 0; - } + do { + /* Is a task_work going to run again before going back */ + if (bits & UNWIND_PENDING) + return; + } while (!try_cmpxchg(&info->unwind_mask, &bits, 0UL)); + current->unwind_info.id.id =3D 0; + + if (unlikely(info->cache)) { + info->cache->nr_entries =3D 0; + info->cache->unwind_completed =3D 0; } } From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 7B5712820D7 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=Ivwui/3AzLjsZYLFUS1QWLQJlRjtgkYyMcMZz/hc9e5j9VUzVzOL1b1GdWEsa0MyQgVnEKuC1jvRhqysWRfgEoEG1aZ/i2QoEby8CZ5QX6wfHJEEyBvpB9iJXJ47dsyxA/1LNinFwGYazv4nt0YhOKr8nuQA2oDL437P73S0Ttk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=DCHKXtICtVbOSz5Xk2gMriv6KBrymPWuwH5XeiwtRyw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XB0euRDMOu6IMIlX+3EYRkYthQ3k2Ms7OUPEaB/q50fc4FJs4QYSgX1n7qkH/dCQZHw2bk/xH4nfYKp7CnWvn/PMzcZK5wE63JGb0eJYQjPqMFvPEsM7yC8WpvCm3tPHantrpepI1f4utGqCjDxs/oXJtF3sNAIZ4jo24U0xPZg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=wA0hlDkt; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="wA0hlDkt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=9heMtrNryMBnT0lE0ZZ/4t8suww3ktzb1k/l4myqmuc=; b=wA0hlDkt4Vvg8JnuDi7R3lNzQj utIpNb9RYaBYCwcIfsko885Glj/VAIEDOvoFo5bSFB32WVjaYznmF2MccsPc3E+KQ0sfict28LYIG VW/WR/EeV2JAN2K5dHK+QzMMnv2hOGnWPtylrv5wmML4jJVnHFZsgrhqN+lzHLdC8NxmrZdOSVqwP 1Z0apbQ1W1D2GVKsEy7+I74pUqb0VzSVZyUA+mQZ3kyzF+CQWnCnfHL2ziCNeFM2joaleR1kORO8U yJoiEHI8QMnNSo1y1HikZHHczigwiE2leFGwuiSWTKm+m6AFEUVYwdLbwGelrkAHN0r7FVbcUGnLN VMF2p3fg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEE-2T9S; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 130D2302DD8; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080118.893367437@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:53 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 05/12] unwind: Add comment to unwind_deferred_task_exit() References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" Explain why unwind_deferred_task_exit() exist and its constraints. Signed-off-by: Peter Zijlstra (Intel) --- kernel/exit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/kernel/exit.c +++ b/kernel/exit.c @@ -934,7 +934,6 @@ void __noreturn do_exit(long code) =20 tsk->exit_code =3D code; taskstats_exit(tsk, group_dead); - unwind_deferred_task_exit(tsk); trace_sched_process_exit(tsk, group_dead); =20 /* @@ -945,6 +944,12 @@ void __noreturn do_exit(long code) * gets woken up by child-exit notifications. */ perf_event_exit_task(tsk); + /* + * PF_EXITING (above) ensures unwind_deferred_request() will no + * longer add new unwinds. While exit_mm() (below) will destroy the + * abaility to do unwinds. + */ + unwind_deferred_task_exit(tsk); =20 exit_mm(); From nobody Thu Oct 2 01:57:54 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8BE543D544 for ; Wed, 24 Sep 2025 08:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701018; cv=none; b=JhfLfF1R2r3iJx76TfMLYkgX7G9N8NbArHb1VrGJi2rwDK5uMy9zzxaVpTKLmOl1Vqc1Zrng5lz3+6m+pIvkRwY9w/LWvcCa8JfHLMk6SnL2ybU/Yxqq1pLRNil7YLf92PJptu8ypND2/QrPIQSPlkqQzomFU/XJCc2JLDzXImc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701018; c=relaxed/simple; bh=Ov2zrF6uYs5dWAepTYDchyC1M2a1bUwpg6VC+Crlgco=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=nDdD09a64iGVpTYvpGfU2L1Ha/1Zx2GPPMOoLaVO6Cvsgyg4l6zu1mOOFcnLFGLFg6uRx7HWM9wnArME0mRfjLJtwr1CSaR76dND1Wrn0tq3OPwQ/20ex1xMsYdWRs6am1S3O+/YPG/SFgp3cIXo8ctW08LPSB9SPEcHLtwUOQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=RaiB78UR; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RaiB78UR" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=hbxVc5Zp1LGC/PA+spY5cB8SwZ/Fdxj7XTfNHEYwPWc=; b=RaiB78URPr5B8Du+qz0ajvJREW RpzTgUhn8IMrMAe8ajLTC+JFQn1rkXtqYnAiIc3uIbLYVXUs/B5O+8lWRajIWE+Er+gnd9yb5TqUV xuZgfS6Q/RBYdjU4JBByQl/jXeuWj8syBpraNsYEoS5MxRzyzXmC7fmU5rlnUPhtj2mjVknt8mf6x SSGE2yxrjrO2wMUNhCxcYxzHnJE+cYA1XysqS7jlF8bDpOWEaT/fnO1Q6gpXpCAH+XWx5jR74GQPZ BnAeq1bDGZryqBv1AeaDIU8bi8AFnFHUZ45NaszArh1aS60UrVnyicwncWwwFWFf8SKcPcTrnOvF0 0Ae7eDAw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-00000008iB7-2RzJ; Wed, 24 Sep 2025 08:03:35 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 181F1302E5F; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.005422353@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:54 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 06/12] unwind: Fix unwind_deferred_request() vs NMI References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" task_work_add(RWA_RESUME) isn't NMI-safe, use TWA_NMI_CURRENT when used from NMI context. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (Google) --- kernel/unwind/deferred.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/kernel/unwind/deferred.c +++ b/kernel/unwind/deferred.c @@ -231,6 +231,7 @@ void unwind_deferred_task_exit(struct ta int unwind_deferred_request(struct unwind_work *work, u64 *cookie) { struct unwind_task_info *info =3D ¤t->unwind_info; + int twa_mode =3D TWA_RESUME; unsigned long old, bits; unsigned long bit; int ret; @@ -246,8 +247,11 @@ int unwind_deferred_request(struct unwin * Trigger a warning to make it obvious that an architecture * is using this in NMI when it should not be. */ - if (WARN_ON_ONCE(!CAN_USE_IN_NMI && in_nmi())) - return -EINVAL; + if (in_nmi()) { + if (WARN_ON_ONCE(!CAN_USE_IN_NMI)) + return -EINVAL; + twa_mode =3D TWA_NMI_CURRENT; + } =20 /* Do not allow cancelled works to request again */ bit =3D READ_ONCE(work->bit); @@ -285,7 +289,7 @@ int unwind_deferred_request(struct unwin } =20 /* The work has been claimed, now schedule it. */ - ret =3D task_work_add(current, &info->work, TWA_RESUME); + ret =3D task_work_add(current, &info->work, twa_mode); =20 if (WARN_ON_ONCE(ret)) WRITE_ONCE(info->unwind_mask, 0); From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 7A0052820D6 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=E/e0M5jzL31bi8TQ0DrrFh1Za6/Ba5kYM1LwGlSOIWhW7ylDUhvJJ7XrU1SH6uw+277/oJmwI2h74hfQ6yyNQxnJn6e1sPHWer8K6iGoT9XqwVsxG5/upH25jB7aEvqX0Q2/JihpmvGG8X3VSnlqZ1zw4R2gcdAQWAxU2ban3Do= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=2ngjv/7OiOtnkuJ7StFHumf5SQS8B4gUssWDdLrExO8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=FuYO2n/5R+Ri38tYc6+1PruZS2HODDzmy64q/YGBP2NV2gKCodzgMXCd3JwLo3QoC1+hSBX0zh+eOK96AdAuUZ5vnYIahKpIqTNsRfi13Cb29DsPD44Dh0iFESnZ/hvfCEccrcw48Nys8/OeV9LoPnOo/eTuQByTiSsXRgcrmiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=oLK71oX/; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="oLK71oX/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=owIgT50kjcdetij22IMm+tbaa5oztYHip42v6jyp2V0=; b=oLK71oX/nDD3PR2TqMehs8KTSk /ND9Dv3KBdqGMgoXs5Ffpr1IXTTjyNi+Cis4o0DDyoubg/AW5oPg0NYZo6OUbcwzGmaWPRHTUtpJq xFsXdYm6/1XuCza1oxf2eU1S93vztFmdbjyJ/UBcQnnlhp01Gtr5MuolFRb8N6NK10fkFQf3zA2PO BUhHQNN/ia3G+OXfY9p6GqQk9YMf9YmgAtyhfW+UCd5/hHrUMwP2ate8QKObYKUq+E+JgM3OWlkEU hh/duxiUY/6zWFNLHDVn5nY+yfgEl41rAb8V7A2eJw/sOCUFbDpcSC1CYE+J4yo5j7eG7P8nM/sbk 5dGohX7w==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEG-2SxF; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 1C994302F79; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.122507632@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:55 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 07/12] unwind: Clarify calling context References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" The get_cookie() function hard relies on IRQs being disabled, but this isn't immediately obvious when reading the function. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Steven Rostedt (Google) --- kernel/unwind/deferred.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/unwind/deferred.c +++ b/kernel/unwind/deferred.c @@ -79,6 +79,8 @@ static u64 get_cookie(struct unwind_task { u32 cnt =3D 1; =20 + lockdep_assert_irqs_disabled(); + if (info->id.cpu) return info->id.id; From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 787082820CE for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=hrE7RlirGP6vd/9t10GWpWsQ9pDeKdwuokKJNrFuWMEuAD1M56/oc2Yaj0lorCXHppkPbNfspfQ/QCzC8I+QwEx14dziOr3DYHFwmhflxuyK4MAykUI/P8WzwdzZdR4RVVbBIEacpEHK18peCjlbTYekyJDAXK9wxKKN13sQl34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=VG77jIrBtuiMeWb+0UyzSJZgzckUa/NXxaBr9lzP4sc=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=GzPGap9xVX3gKrC3Kfm4gTbO8UOXqi6yD+sUAg92lWa7bdg9qYMEm+Dbxb3XfU7h0BPB7So3YX8deL+fIMaiTGiPGsllxWygpdevyUZWB9kZw/wWqIx8bcBLOy01Xv3Z3owdKUZIxIZzFIROpJGkLIuewmMYhZilcPOSSRPub5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=CCLl28k5; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="CCLl28k5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=0du3iXCSqL6lcLgfL4c7Fl9YQ4+y8lzBi1ZnqMrkphg=; b=CCLl28k5+4LZTC9kR0cSKop3PX 34qdCfLnuxRtISBW6Nw/fqCoE1OXhqsiJVKwu2hNLcMiNifcg5vo5cGK78LaANxtGSaCf48uwr5ZI Ga05ut9Tx/ocuh+5kUbB1QC3zyDkY+cbc+IhLmKfQNw0Ttj9FYHGOji9TKjCPqkZXtHxtXPf+DTYn vfH1LN4pEijcn9FR1NGXnS4Xat/pDOp6gbahqSXl63uUouraMLLSMtPP1MHRAHjUhJ1V0DaSkR8/Q ftSrpxqKPYNYQFkgyX1QI8r16M0nmupVCEuItCWTEL/RGWosbRY49yLphmrkE9XFLM62CXSfD07pf ZylPwi4g==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEJ-2UKH; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 216BC303002; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.271671514@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:56 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 08/12] unwind: Simplify unwind_user_faultable() References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Zijlstra (Intel) --- kernel/unwind/deferred.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/kernel/unwind/deferred.c +++ b/kernel/unwind/deferred.c @@ -128,17 +128,15 @@ int unwind_user_faultable(struct unwind_ =20 cache =3D info->cache; trace->entries =3D cache->entries; - - if (cache->nr_entries) { + trace->nr =3D cache->nr_entries; + if (trace->nr) { /* * The user stack has already been previously unwound in this * entry context. Skip the unwind and use the cache. */ - trace->nr =3D cache->nr_entries; return 0; } =20 - trace->nr =3D 0; unwind_user(trace, UNWIND_MAX_ENTRIES); =20 cache->nr_entries =3D trace->nr; From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 6CC642820A9 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=XWgvta5edJn5ktFNpWVpi5tHhTs7gP/ZtMtfbzMMbOJe6gv3cOfkB6Ny6PpFbBO0zT3Lpkraf69KlTtD0khtW+eLxd5I+cOPaAmASUEDMxzhbyvR2pI5lwmtg67nCaCnn6DhBRbTwftuzk+ycJ3HxElP2eCrSam4w21UMJ9eSmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=Dj4FbPOjKoUO9qwih+rRobi26gAuZf8/S5EDW1kka+0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ExaUCx2AyArbVcRf24aL9omP6iz/npXxybIuKfsdAs5oIi4+YPe80KFzGm5qYJTZsXsQQE6tPAr1vVAlvufwaPHQ8bskSorIW4Ymv0+mZamvWpEgyXbioNg6PPBsPz0rQIBfSXnL/0r6IpRpFKe2z52kvOr6pQxWewB0stJEOcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ZZzmNbZ5; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZZzmNbZ5" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=YnHzCz426qXvrptuKmkHrLzo2jAir+fJiymh/WcGuO0=; b=ZZzmNbZ5vEEx2uCOyOop4cBBHH a8PDGT6WEK4GO+o9r6ymYx1kKecmqZieTyvRy4f7uHj1GqfqU4AnJcT6xGdgUZQpcwsyHsEVy8Fy3 JjG7yK6feAzDZvRExAjRkyKFYi+ZXoxQFIatUOzKUDI4i3J0Wke4GNAoozzBlhpOMQ1kYfwGe/wmt uC+wTu3yutIbUYv09PN3+PkpJfTOVzSEE+H0D+ICetjjfdeQGx3TdUuSsdflqd8dMxXsBYafuOzQn GdCPFhNaJ43II2UgB7fhEO3dqjvclD2UKljqZCi1qwiheCivTkzP1DAacmy7AQtiQ9OPBku7F66U/ IEfAUS5w==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEL-2WWv; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 25CDE303005; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.384384486@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:57 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 09/12] unwind: Make unwind_task_info::unwind_mask consistent References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" The unwind_task_info::unwind_mask was manipulated using a mixture of: regular store WRITE_ONCE() try_cmpxchg() set_bit() atomic_long_*() Clean up and make it consistently atomic_long_t. Signed-off-by: Peter Zijlstra (Intel) --- include/linux/unwind_deferred.h | 4 ++-- include/linux/unwind_deferred_types.h | 3 ++- kernel/unwind/deferred.c | 17 +++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) --- a/include/linux/unwind_deferred.h +++ b/include/linux/unwind_deferred.h @@ -46,7 +46,7 @@ void unwind_deferred_task_exit(struct ta static __always_inline void unwind_reset_info(void) { struct unwind_task_info *info =3D ¤t->unwind_info; - unsigned long bits =3D info->unwind_mask; + unsigned long bits =3D atomic_long_read(&info->unwind_mask); =20 /* Was there any unwinding? */ if (likely(!bits)) @@ -56,7 +56,7 @@ static __always_inline void unwind_reset /* Is a task_work going to run again before going back */ if (bits & UNWIND_PENDING) return; - } while (!try_cmpxchg(&info->unwind_mask, &bits, 0UL)); + } while (!atomic_long_try_cmpxchg(&info->unwind_mask, &bits, 0UL)); current->unwind_info.id.id =3D 0; =20 if (unlikely(info->cache)) { --- a/include/linux/unwind_deferred_types.h +++ b/include/linux/unwind_deferred_types.h @@ -3,6 +3,7 @@ #define _LINUX_UNWIND_USER_DEFERRED_TYPES_H =20 #include +#include =20 struct unwind_cache { unsigned long unwind_completed; @@ -32,7 +33,7 @@ union unwind_task_id { }; =20 struct unwind_task_info { - unsigned long unwind_mask; + atomic_long_t unwind_mask; struct unwind_cache *cache; struct callback_head work; union unwind_task_id id; --- a/kernel/unwind/deferred.c +++ b/kernel/unwind/deferred.c @@ -53,7 +53,7 @@ DEFINE_STATIC_SRCU(unwind_srcu); =20 static inline bool unwind_pending(struct unwind_task_info *info) { - return test_bit(UNWIND_PENDING_BIT, &info->unwind_mask); + return atomic_long_read(&info->unwind_mask) & UNWIND_USED; } =20 /* @@ -142,7 +142,7 @@ int unwind_user_faultable(struct unwind_ cache->nr_entries =3D trace->nr; =20 /* Clear nr_entries on way back to user space */ - set_bit(UNWIND_USED_BIT, &info->unwind_mask); + atomic_long_or(UNWIND_USED, &info->unwind_mask); =20 return 0; } @@ -160,7 +160,7 @@ static void process_unwind_deferred(stru =20 /* Clear pending bit but make sure to have the current bits */ bits =3D atomic_long_fetch_andnot(UNWIND_PENDING, - (atomic_long_t *)&info->unwind_mask); + &info->unwind_mask); /* * From here on out, the callback must always be called, even if it's * just an empty trace. @@ -265,7 +265,7 @@ int unwind_deferred_request(struct unwin =20 *cookie =3D get_cookie(info); =20 - old =3D READ_ONCE(info->unwind_mask); + old =3D atomic_long_read(&info->unwind_mask); =20 /* Is this already queued or executed */ if (old & bit) @@ -278,7 +278,7 @@ int unwind_deferred_request(struct unwin * to have a callback. */ bits =3D UNWIND_PENDING | bit; - old =3D atomic_long_fetch_or(bits, (atomic_long_t *)&info->unwind_mask); + old =3D atomic_long_fetch_or(bits, &info->unwind_mask); if (old & bits) { /* * If the work's bit was set, whatever set it had better @@ -292,7 +292,7 @@ int unwind_deferred_request(struct unwin ret =3D task_work_add(current, &info->work, twa_mode); =20 if (WARN_ON_ONCE(ret)) - WRITE_ONCE(info->unwind_mask, 0); + atomic_long_set(&info->unwind_mask, 0); =20 return ret; } @@ -324,7 +324,8 @@ void unwind_deferred_cancel(struct unwin guard(rcu)(); /* Clear this bit from all threads */ for_each_process_thread(g, t) { - clear_bit(bit, &t->unwind_info.unwind_mask); + atomic_long_andnot(UNWIND_USED, + &t->unwind_info.unwind_mask); if (t->unwind_info.cache) clear_bit(bit, &t->unwind_info.cache->unwind_completed); } @@ -354,7 +355,7 @@ void unwind_task_init(struct task_struct =20 memset(info, 0, sizeof(*info)); init_task_work(&info->work, unwind_deferred_task_work); - info->unwind_mask =3D 0; + atomic_long_set(&info->unwind_mask, 0); } =20 void unwind_task_free(struct task_struct *task) From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 75FE12820C6 for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=bL6YbLiPcTZfsCqXy+s6O1UcmXBCedM30ZC5WsDjXVUndnKa1kWevesDFK1lgUhCi7hgH/TqXNquDm9F1rc9DOcHkI2fLjsc1otcFr1Uaz2gpa8jq21IBGo5aXW9j0c8GmiHDHyN6e46GQATcaFEUAC/5jwQCFCJTGwY9v6P+3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=YigqAcV+w42hf+VWmVcy7vItFroM6sD/V4ecsb9NhFo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=DP/pU0UebNlZ4NziJt1mGQKHq1sqNJDz3HlhyAHf5YM5Ghw6RbeGA9SiIJu8SLuXAW8mWDTAjr+53dKU4P+2uLR5hTMxTwY/KA2ORpE7fdZFihIQvv6pJdJZJLQ4e7Kc+bnUFpggefgAaitBR3Y4CDRjSL36kKLR5p+2pIB8Nqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Y0xnflNW; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Y0xnflNW" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=+BxQ8ZbeEQeKLpVX1+kLc7lt/Zs1GYs12EyToR1lv80=; b=Y0xnflNWrSb3yFmTemScuCxx3s t8mmMEq8X6g9NQPuwaBc1x8jdrWFW2TL4dMxOe5pAS5aXP0M3jN4MdmH9O8nfSrFdD435A310rhaj bFOZn9aCHony82Vl7S3CmUjHgI6sa6Ajp9xszCEvixRK7GJ0HhgZKTStnlH0NzgHjlyOtJGjMohyS yZ9+Yo1AoFyMIom00x7EBCXrxRVCYyi+myuUYPySmBgguaEJCSsmqGKr9gUmEU23ZTY8Aoc8+8Dnl TOzYYL8IS+ka/r7+G5AaJGxfZqKmpJvLp7f0k6kMjpcvIzXeqQOAlOtj4sXxtQsOb5FqqW6MCNSiZ PcZA6cKw==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEK-2TIX; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 29E0A303007; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.497867836@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:58 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 10/12] unwind: Simplify unwind_user_next_fp() alignment check References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (Google) --- kernel/unwind/user.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -19,7 +19,6 @@ static int unwind_user_next_fp(struct un { const struct unwind_user_frame *frame =3D &fp_frame; unsigned long cfa, fp, ra; - unsigned int shift; =20 if (frame->use_fp) { if (state->fp < state->sp) @@ -37,8 +36,7 @@ static int unwind_user_next_fp(struct un return -EINVAL; =20 /* Make sure that the address is word aligned */ - shift =3D sizeof(long) =3D=3D 4 ? 2 : 3; - if (cfa & ((1 << shift) - 1)) + if (cfa & (sizeof(long) - 1)) return -EINVAL; =20 /* Find the Return Address (RA) */ From nobody Thu Oct 2 01:57:54 2025 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 8BED4265292 for ; Wed, 24 Sep 2025 08:03:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701018; cv=none; b=G4m22DjTP+AoU7Ei+HTiaB6NAwFg6ekqQ8J+TO9hShf8myZxHHyuVc9yGgw8FjNogCbKUiFatpbZ68wnGSCorcH6vdwE3dT2ws1P5llVgCtjXWwKnGt/PcYh5EdHJj7qBpazHSxVjhnzcsf8gOc5OwTLOE+ON2i1tpKbE8Iz1SA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701018; c=relaxed/simple; bh=PSFacuoLsrD33DwWCB9zYIlIH1F9vW6/njf3D6cjvqw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=oxQ0FNiu3r1BWmllCb7sc5J0PqPWy4L5TtkRbenEqrMvP3fIOD++ZSsgjFRUkJdEPPW1mjwhCIZ8ME6isXd1THNPfMDwWYPPj/qrKDRwwW5vaPEXL8FNIEwF4ptl+vRB8ncnNpqNGvA42wkTo5POTj3rnqyCyLZh0W9XDOPa/UI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=BE8VXE70; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BE8VXE70" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=Us3qc8q+lr4gCCXXPB9CTmjAy8+l/zrT5sp8S8hKBNk=; b=BE8VXE708sf3OPt7/JCXzlBfzy OqmtjER85QCOFmWXEPJHiZ6OTADVmq/fVEc7IaBEXHT4r/R+56J0S5MHUj4ZbdgwSlDuyMdlIJFUo /YCBecunwZoMdvH84Kxp5GDMoPSj5lxsrzdWqA8iEA85jaBB4fMVH51C7lzgd3KU8/Jmj9HTPOrc1 4OgTbuUBVH0YbpQRh8OHA7fJACUQcORxdcTIiVCmN2FGMsG/0FVIsElRU1HAag92G/GA8xKdhCCAr dL+IqjHtwwQUwFXsB9dno2bCYJr7YzEz4MD/GekjB8mD1ZmHznV0s+1b4GmQrxP7mRR0foEWm7Yjd 9qxwjKlQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-00000008iB8-2bFI; Wed, 24 Sep 2025 08:03:35 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 2DF8230300E; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.613695709@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 09:59:59 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org Subject: [PATCH 11/12] unwind: Implement compat fp unwind References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Zijlstra (Intel) --- include/linux/unwind_user_types.h | 1 + kernel/unwind/user.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) --- a/include/linux/unwind_user_types.h +++ b/include/linux/unwind_user_types.h @@ -36,6 +36,7 @@ struct unwind_user_state { unsigned long ip; unsigned long sp; unsigned long fp; + unsigned int ws; enum unwind_user_type current_type; unsigned int available_types; bool done; --- a/kernel/unwind/user.c +++ b/kernel/unwind/user.c @@ -15,6 +15,21 @@ static const struct unwind_user_frame fp #define for_each_user_frame(state) \ for (unwind_user_start(state); !(state)->done; unwind_user_next(state)) =20 +static inline int +get_user_word(unsigned long *word, unsigned long base, int off, int size) +{ + unsigned long __user *addr =3D (void __user *)base + (off * size); +#ifdef CONFIG_COMPAT + if (size =3D=3D sizeof(int)) { + unsigned int data; + int ret =3D get_user(data, (unsigned int __user *)addr); + *word =3D data; + return ret; + } +#endif + return get_user(*word, addr); +} + static int unwind_user_next_fp(struct unwind_user_state *state) { const struct unwind_user_frame *frame =3D &fp_frame; @@ -29,21 +44,21 @@ static int unwind_user_next_fp(struct un } =20 /* Get the Canonical Frame Address (CFA) */ - cfa +=3D frame->cfa_off; + cfa +=3D state->ws * frame->cfa_off; =20 /* stack going in wrong direction? */ if (cfa <=3D state->sp) return -EINVAL; =20 /* Make sure that the address is word aligned */ - if (cfa & (sizeof(long) - 1)) + if (cfa & (state->ws - 1)) return -EINVAL; =20 /* Find the Return Address (RA) */ - if (get_user(ra, (unsigned long *)(cfa + frame->ra_off))) + if (get_user_word(&ra, cfa, frame->ra_off, state->ws)) return -EINVAL; =20 - if (frame->fp_off && get_user(fp, (unsigned long __user *)(cfa + frame->f= p_off))) + if (frame->fp_off && get_user_word(&fp, cfa, frame->fp_off, state->ws)) return -EINVAL; =20 state->ip =3D ra; @@ -100,6 +115,7 @@ static int unwind_user_start(struct unwi state->ip =3D instruction_pointer(regs); state->sp =3D user_stack_pointer(regs); state->fp =3D frame_pointer(regs); + state->ws =3D compat_user_mode(regs) ? sizeof(int) : sizeof(long); =20 return 0; } From nobody Thu Oct 2 01:57:54 2025 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 75F782820BF for ; Wed, 24 Sep 2025 08:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; cv=none; b=Z8mIC6LNa320T6qNMmKPHyRDI98grELsFayBMU1Z3M6GyXw/QTr8FClzPNhzlxTKEaGNsfPnZd6FybxKsMD9D79Nhzl7cmcG0AzeZCETUguLaS5tYiWGwVgxalKd7+8Pc8bcxHkqTg6T+3NDLV+UHdR9oHTUJ/HvPXnDAhnkJvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758701020; c=relaxed/simple; bh=mMYz/jRaxEwW2AvWbm0WouE6h6lhAUYSUz3rEKpsCR8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=gK+TfWeDZ4mKMbcqZz1XF6aczXgnrbIMvLxEe5suEi4bSChOtbmW4vgorObZJgdg2GkoC9yFmk9nwyybfZOzc1zETPEOTfBDnM2iLJ6sNbVZ8noGSO6to0tdXrOc3e18fE5vYofHNOqyUtrPoPqnTFF9Mwp+bkLStKxyzamOLns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=linmzOvp; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="linmzOvp" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=aAwEGCLjQRMZ+6UxkwaJXWq/gpjUiVoYTtJddsNEc+s=; b=linmzOvpJioo68Z0V2+XBSGj9v ixp+ZHp0JrEpxlRZyvlG6M/iXLML32hwKWFY0Lup4Y4tabNj7yi67hYyfHGTcB5w77asvu9WQX2Gx xBVfcsa1oeT5me0BlxmSkT/rXE2hVJ70y40KAYP3jiWM4zyO992D+ffUqsomIUXEBJ4jIEt1hXmu0 aI9zJjMR1c+jLlLddomzlm8wczwijqf+UBbIDjUOJ1vQCWyEpYU4r0VJbUsGzxyIyaSA1LF3lQwVP 2AG3pUbpFhI74xHTB7JZMMCv9WUPkVdklI5xHD3RQDWgA3dYDcf6b3ZH0vZ6dajzI6r3bkkk2CimZ YohumDzg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1v1KTO-0000000BeEM-2YeO; Wed, 24 Sep 2025 08:03:34 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 3268430301A; Wed, 24 Sep 2025 10:03:33 +0200 (CEST) Message-ID: <20250924080119.736377571@infradead.org> User-Agent: quilt/0.68 Date: Wed, 24 Sep 2025 10:00:00 +0200 From: Peter Zijlstra To: jpoimboe@kernel.org, rostedt@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, "Steven Rostedt (Google)" Subject: [PATCH 12/12] unwind_user/x86: Enable frame pointer unwinding on x86 References: <20250924075948.579302904@infradead.org> 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 Content-Type: text/plain; charset="utf-8" From: Josh Poimboeuf Use ARCH_INIT_USER_FP_FRAME to describe how frame pointers are unwound on x86, and enable CONFIG_HAVE_UNWIND_USER_FP accordingly so the unwind_user interfaces can be used. Signed-off-by: Josh Poimboeuf Signed-off-by: Steven Rostedt (Google) Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/Kconfig | 1 + arch/x86/include/asm/ptrace.h | 9 +++++++++ arch/x86/include/asm/unwind_user.h | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 arch/x86/include/asm/unwind_user.h --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -297,6 +297,7 @@ config X86 select HAVE_SYSCALL_TRACEPOINTS select HAVE_UACCESS_VALIDATION if HAVE_OBJTOOL select HAVE_UNSTABLE_SCHED_CLOCK + select HAVE_UNWIND_USER_FP if X86_64 select HAVE_USER_RETURN_NOTIFIER select HAVE_GENERIC_VDSO select VDSO_GETRANDOM if X86_64 --- a/arch/x86/include/asm/ptrace.h +++ b/arch/x86/include/asm/ptrace.h @@ -255,6 +255,15 @@ static inline bool any_64bit_mode(struct #endif } =20 +static inline bool compat_user_mode(struct pt_regs *regs) +{ +#ifdef CONFIG_X86_64 + return !user_64bit_mode(regs); +#else + return false; +#endif +} + #ifdef CONFIG_X86_64 #define current_user_stack_pointer() current_pt_regs()->sp #define compat_user_stack_pointer() current_pt_regs()->sp --- /dev/null +++ b/arch/x86/include/asm/unwind_user.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_UNWIND_USER_H +#define _ASM_X86_UNWIND_USER_H + +#define ARCH_INIT_USER_FP_FRAME \ + .cfa_off =3D 2, \ + .ra_off =3D -1, \ + .fp_off =3D -2, \ + .use_fp =3D true, + +#endif /* _ASM_X86_UNWIND_USER_H */