diff mbox series

[11/13] nptl: Simplify resetting the in-flight stack in __reclaim_stacks

Message ID ca4a63acda644d583ed3769e4d1f4f833fb3ce5d.1620323953.git.fweimer@redhat.com
State Committed
Commit 652c7c6fe7a08643b8e98f085d422f4e43ec47b4
Headers show
Series Linux: Move most stack management out of libpthread | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer May 6, 2021, 6:11 p.m. UTC
stack_list_del overwrites the in-flight stack variable.
---
 nptl/allocatestack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Carlos O'Donell May 9, 2021, 9:42 p.m. UTC | #1
On 5/6/21 2:11 PM, Florian Weimer via Libc-alpha wrote:
> stack_list_del overwrites the in-flight stack variable.

LGTM. Hard to tell if I want to call this is a bug fix or a cleanup
that just happens naturally as part of the refactoring :-)

Tested on x86_64 and i686 without regression.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  nptl/allocatestack.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
> index 12cd1058d4..076cffd35b 100644
> --- a/nptl/allocatestack.c
> +++ b/nptl/allocatestack.c
> @@ -799,6 +799,8 @@ __reclaim_stacks (void)
>  	  elem->next->prev = elem->prev;
>  	  elem->prev->next = elem->next;
>  	}
> +
> +      GL (dl_in_flight_stack) = 0;
>      }
>  
>    /* Mark all stacks except the still running one as free.  */
> @@ -842,7 +844,7 @@ __reclaim_stacks (void)
>    /* Remove the entry for the current thread to from the cache list
>       and add it to the list of running threads.  Which of the two
>       lists is decided by the user_stack flag.  */
> -  stack_list_del (&self->list);
> +  list_del (&self->list);
>  
>    /* Re-initialize the lists for all the threads.  */
>    INIT_LIST_HEAD (&GL (dl_stack_used));
> @@ -856,8 +858,6 @@ __reclaim_stacks (void)
>    /* There is one thread running.  */
>    __nptl_nthreads = 1;
>  
> -  GL (dl_in_flight_stack) = 0;
> -
>    /* Initialize locks.  */
>    GL (dl_stack_cache_lock) = LLL_LOCK_INITIALIZER;
>    __default_pthread_attr_lock = LLL_LOCK_INITIALIZER;
>
diff mbox series

Patch

diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 12cd1058d4..076cffd35b 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -799,6 +799,8 @@  __reclaim_stacks (void)
 	  elem->next->prev = elem->prev;
 	  elem->prev->next = elem->next;
 	}
+
+      GL (dl_in_flight_stack) = 0;
     }
 
   /* Mark all stacks except the still running one as free.  */
@@ -842,7 +844,7 @@  __reclaim_stacks (void)
   /* Remove the entry for the current thread to from the cache list
      and add it to the list of running threads.  Which of the two
      lists is decided by the user_stack flag.  */
-  stack_list_del (&self->list);
+  list_del (&self->list);
 
   /* Re-initialize the lists for all the threads.  */
   INIT_LIST_HEAD (&GL (dl_stack_used));
@@ -856,8 +858,6 @@  __reclaim_stacks (void)
   /* There is one thread running.  */
   __nptl_nthreads = 1;
 
-  GL (dl_in_flight_stack) = 0;
-
   /* Initialize locks.  */
   GL (dl_stack_cache_lock) = LLL_LOCK_INITIALIZER;
   __default_pthread_attr_lock = LLL_LOCK_INITIALIZER;