Index | Thread | Search

From:
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject:
Re: pass proc to sleep_signal_check()
To:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Cc:
tech@openbsd.org
Date:
Tue, 23 Jul 2024 22:08:08 +0200

Download raw body.

Thread
> Date: Tue, 23 Jul 2024 10:31:04 +0200
> From: Claudio Jeker <cjeker@diehard.n-r-g.com>
> 
> sleep_finish() already pulls in curproc and caches it in p. So just pass
> that to sleep_signal_check() and save one extra curproc call.

Not sure if this really matters; accessing curproc should be fast.
But I think it makes the code slightly better, so

ok kettenis@

> Index: kern_synch.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_synch.c,v
> diff -u -p -r1.205 kern_synch.c
> --- kern_synch.c	3 Jun 2024 12:48:25 -0000	1.205
> +++ kern_synch.c	23 Jul 2024 08:29:39 -0000
> @@ -62,7 +62,7 @@
>  #include <sys/ktrace.h>
>  #endif
>  
> -int	sleep_signal_check(void);
> +int	sleep_signal_check(struct proc *);
>  int	thrsleep(struct proc *, struct sys___thrsleep_args *);
>  int	thrsleep_unlock(void *);
>  
> @@ -385,7 +385,7 @@ sleep_finish(int timo, int do_sleep)
>  		 * we must be ready for sleep when sleep_signal_check() is
>  		 * called.
>  		 */
> -		if ((error = sleep_signal_check()) != 0) {
> +		if ((error = sleep_signal_check(p)) != 0) {
>  			catch = 0;
>  			do_sleep = 0;
>  		}
> @@ -438,7 +438,7 @@ sleep_finish(int timo, int do_sleep)
>  
>  	/* Check if thread was woken up because of a unwind or signal */
>  	if (catch != 0)
> -		error = sleep_signal_check();
> +		error = sleep_signal_check(p);
>  
>  	/* Signal errors are higher priority than timeouts. */
>  	if (error == 0 && error1 != 0)
> @@ -451,9 +451,8 @@ sleep_finish(int timo, int do_sleep)
>   * Check and handle signals and suspensions around a sleep cycle.
>   */
>  int
> -sleep_signal_check(void)
> +sleep_signal_check(struct proc *p)
>  {
> -	struct proc *p = curproc;
>  	struct sigctx ctx;
>  	int err, sig;
>  
> 
>