bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH gnumach] ast: Implement cause_ast_check() by switching cpus


From: Samuel Thibault
Subject: Re: [PATCH gnumach] ast: Implement cause_ast_check() by switching cpus
Date: Sun, 6 Aug 2023 15:56:04 +0200
User-agent: NeoMutt/20170609 (1.8.3)

Damien Zammit, le sam. 05 août 2023 16:16:41 +0000, a ecrit:
> If the current processor is not the one we want to run an ast on,
> we can bind the current thread to the processor we want, and force a
> thread switch to that one, then run the ast_check() on the right cpu.

Err, that's an expensive way of doing it. ast_check() does *not* need to
be executed by this particular thread, it is a per-processor check. So
all we need to do is to send an IPI that makes the other processor call
ast_check(), whatever the context there.

> ---
>  i386/i386/ast_check.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/i386/i386/ast_check.c b/i386/i386/ast_check.c
> index 5121abf1..1b80ea4a 100644
> --- a/i386/i386/ast_check.c
> +++ b/i386/i386/ast_check.c
> @@ -28,12 +28,11 @@
>  
>  /*
>   * Handle signalling ASTs on other processors.
> - *
> - * Initial i386 implementation does nothing.
>   */
>  
>  #include <kern/ast.h>
>  #include <kern/processor.h>
> +#include <kern/thread.h>
>  
>  /*
>   * Initialize for remote invocation of ast_check.
> @@ -47,6 +46,16 @@ void init_ast_check(const processor_t processor)
>   */
>  void cause_ast_check(const processor_t processor)
>  {
> +    thread_t this_thread = current_thread();
> +
> +    if (current_processor() != processor) {
> +        thread_bind(this_thread, processor);
> +        thread_block(thread_no_continuation);
> +    }
> +
> +    ast_check();
> +
> +    thread_bind(this_thread, PROCESSOR_NULL);
>  }
>  
>  #endif       /* NCPUS > 1 */
> -- 
> 2.40.1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]