[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hurd-bug
Subject:    Re: [PATCH 1/5 gnumach] sched_prim.c: Split bound processor case into two
From:       Samuel Thibault <samuel.thibault () gnu ! org>
Date:       2023-08-22 21:20:45
Message-ID: 20230822212045.f2nkv3lygu7mzjor () begin
[Download RAW message or body]

What improvement do we actually get here? Only avoiding locking the
processor? That does not seems to me worth making the code yet longer.

Samuel

Damien Zammit, le mer. 16 août 2023 01:48:55 +0000, a ecrit:
> ---
>  kern/sched_prim.c | 32 ++++++++++++++++++++++++++------
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/kern/sched_prim.c b/kern/sched_prim.c
> index be34e7dd..d69e4990 100644
> --- a/kern/sched_prim.c
> +++ b/kern/sched_prim.c
> @@ -1325,12 +1325,33 @@ void thread_setrun(
>  	}
>  	else {
>  	    /*
> -	     *	Bound, can only run on bound processor.  Have to lock
> -	     *  processor here because it may not be the current one.
> +	     *	Bound, can only run on bound processor.
> +	     *	Check two cases, bound is current or not.
>  	     */
> -	    if (processor->state == PROCESSOR_IDLE) {
> +#if	MACH_HOST
> +	    pset = processor->processor_set;
> +#else
> +	    pset = &default_pset;
> +#endif	/* MACH_HOST */
> +	    if (processor == current_processor()) {
> +		if (processor->state == PROCESSOR_IDLE) {
> +		    simple_lock(&pset->idle_lock);
> +		    if (processor->state == PROCESSOR_IDLE) {
> +		        queue_remove(&pset->idle_queue, processor,
> +		    		     processor_t, processor_queue);
> +		        pset->idle_count--;
> +		        processor->next_thread = th;
> +			processor->state = PROCESSOR_DISPATCHING;
> +		        simple_unlock(&pset->idle_lock);
> +		    	/* Interrupt self */
> +			cause_ast_check(processor);
> +			return;
> +		    }
> +		    simple_unlock(&pset->idle_lock);
> +		}
> +	    }
> +	    else {
>  		processor_lock(processor);
> -		pset = processor->processor_set;
>  		simple_lock(&pset->idle_lock);
>  		if (processor->state == PROCESSOR_IDLE) {
>  		    queue_remove(&pset->idle_queue, processor,
> @@ -1340,8 +1361,7 @@ void thread_setrun(
>  		    processor->state = PROCESSOR_DISPATCHING;
>  		    simple_unlock(&pset->idle_lock);
>  		    processor_unlock(processor);
> -		    if (processor != current_processor())
> -			cause_ast_check(processor);
> +		    cause_ast_check(processor);
>  		    return;
>  		}
>  		simple_unlock(&pset->idle_lock);
> -- 
> 2.40.1
> 
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic