[PATCH 08/12] unwind: Simplify unwind_user_faultable()

Peter Zijlstra posted 12 patches 1 week ago
[PATCH 08/12] unwind: Simplify unwind_user_faultable()
Posted by Peter Zijlstra 1 week ago

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 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_
 
 	cache = info->cache;
 	trace->entries = cache->entries;
-
-	if (cache->nr_entries) {
+	trace->nr = 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 = cache->nr_entries;
 		return 0;
 	}
 
-	trace->nr = 0;
 	unwind_user(trace, UNWIND_MAX_ENTRIES);
 
 	cache->nr_entries = trace->nr;
Re: [PATCH 08/12] unwind: Simplify unwind_user_faultable()
Posted by Steven Rostedt 10 hours ago
On Wed, 24 Sep 2025 09:59:56 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  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_
>  
>  	cache = info->cache;
>  	trace->entries = cache->entries;
> -
> -	if (cache->nr_entries) {
> +	trace->nr = 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 = cache->nr_entries;
>  		return 0;
>  	}

Could we turn the above into:

	/*
	 * If the user stack has already been previously unwound in this
	 * entry context.  Skip the unwind and use the cache.
	 */
	if (trace->nr)
		return 0;

So we could remove the squiggly brackets?

-- Steve



>  
> -	trace->nr = 0;
>  	unwind_user(trace, UNWIND_MAX_ENTRIES);
>  
>  	cache->nr_entries = trace->nr;
>