All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Dave Martin <Dave.Martin@arm.com>
Cc: Okamoto Takayuki <tokamoto@jp.fujitsu.com>,
	"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu.
Date: Mon, 4 Dec 2017 13:46:57 +0000	[thread overview]
Message-ID: <CAKv+Gu8BzFrc1U7r7iURfZqGKRqpwHJVFM6hvHOX5xghrXojtA@mail.gmail.com> (raw)
In-Reply-To: <1512141582-17474-3-git-send-email-Dave.Martin@arm.com>

On 1 December 2017 at 15:19, Dave Martin <Dave.Martin@arm.com> wrote:
> There is currently some duplicate logic to associate current's
> FPSIMD context with the cpu when loading FPSIMD state into the cpu
> regs.
>
> Subsequent patches will update that logic, so in order to ensure it
> only needs to be done in one place, this patch factors the relevant
> code out into a new function fpsimd_bind_to_cpu().
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 143b3e7..007140b 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -992,6 +992,18 @@ void fpsimd_signal_preserve_current_state(void)
>  }
>
>  /*
> + * Associate current's FPSIMD context with this cpu
> + * Preemption must be disabled when calling this function.
> + */
> +static void fpsimd_bind_to_cpu(void)
> +{
> +       struct fpsimd_state *st = &current->thread.fpsimd_state;
> +
> +       __this_cpu_write(fpsimd_last_state, st);
> +       st->cpu = smp_processor_id();
> +}
> +
> +/*
>   * Load the userland FPSIMD state of 'current' from memory, but only if the
>   * FPSIMD state already held in the registers is /not/ the most recent FPSIMD
>   * state of 'current'
> @@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void)
>         local_bh_disable();
>
>         if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
> -               struct fpsimd_state *st = &current->thread.fpsimd_state;
> -
>                 task_fpsimd_load();
> -               __this_cpu_write(fpsimd_last_state, st);
> -               st->cpu = smp_processor_id();
> +               fpsimd_bind_to_cpu();
>         }
>
>         local_bh_enable();
> @@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
>         }
>         task_fpsimd_load();
>
> -       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
> -               struct fpsimd_state *st = &current->thread.fpsimd_state;
> -
> -               __this_cpu_write(fpsimd_last_state, st);
> -               st->cpu = smp_processor_id();
> -       }
> +       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE))
> +               fpsimd_bind_to_cpu();
>
>         local_bh_enable();
>  }

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

WARNING: multiple messages have this Message-ID (diff)
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu.
Date: Mon, 4 Dec 2017 13:46:57 +0000	[thread overview]
Message-ID: <CAKv+Gu8BzFrc1U7r7iURfZqGKRqpwHJVFM6hvHOX5xghrXojtA@mail.gmail.com> (raw)
In-Reply-To: <1512141582-17474-3-git-send-email-Dave.Martin@arm.com>

On 1 December 2017 at 15:19, Dave Martin <Dave.Martin@arm.com> wrote:
> There is currently some duplicate logic to associate current's
> FPSIMD context with the cpu when loading FPSIMD state into the cpu
> regs.
>
> Subsequent patches will update that logic, so in order to ensure it
> only needs to be done in one place, this patch factors the relevant
> code out into a new function fpsimd_bind_to_cpu().
>
> Signed-off-by: Dave Martin <Dave.Martin@arm.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 143b3e7..007140b 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -992,6 +992,18 @@ void fpsimd_signal_preserve_current_state(void)
>  }
>
>  /*
> + * Associate current's FPSIMD context with this cpu
> + * Preemption must be disabled when calling this function.
> + */
> +static void fpsimd_bind_to_cpu(void)
> +{
> +       struct fpsimd_state *st = &current->thread.fpsimd_state;
> +
> +       __this_cpu_write(fpsimd_last_state, st);
> +       st->cpu = smp_processor_id();
> +}
> +
> +/*
>   * Load the userland FPSIMD state of 'current' from memory, but only if the
>   * FPSIMD state already held in the registers is /not/ the most recent FPSIMD
>   * state of 'current'
> @@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void)
>         local_bh_disable();
>
>         if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
> -               struct fpsimd_state *st = &current->thread.fpsimd_state;
> -
>                 task_fpsimd_load();
> -               __this_cpu_write(fpsimd_last_state, st);
> -               st->cpu = smp_processor_id();
> +               fpsimd_bind_to_cpu();
>         }
>
>         local_bh_enable();
> @@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state)
>         }
>         task_fpsimd_load();
>
> -       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
> -               struct fpsimd_state *st = &current->thread.fpsimd_state;
> -
> -               __this_cpu_write(fpsimd_last_state, st);
> -               st->cpu = smp_processor_id();
> -       }
> +       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE))
> +               fpsimd_bind_to_cpu();
>
>         local_bh_enable();
>  }

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

  reply	other threads:[~2017-12-04 13:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 15:19 [PATCH 0/3] arm64: SVE fixes for v4.15-rc1 Dave Martin
2017-12-01 15:19 ` Dave Martin
2017-12-01 15:19 ` [PATCH 1/3] arm64: KVM: Move CPU ID reg trap setup off the world switch path Dave Martin
2017-12-01 15:19   ` Dave Martin
2017-12-05  9:09   ` Christoffer Dall
2017-12-05  9:09     ` Christoffer Dall
2017-12-05 12:31     ` Dave Martin
2017-12-05 12:31       ` Dave Martin
2017-12-06 10:53       ` Christoffer Dall
2017-12-06 10:53         ` Christoffer Dall
2017-12-06 11:55         ` Dave Martin
2017-12-06 11:55           ` Dave Martin
2017-12-01 15:19 ` [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu Dave Martin
2017-12-01 15:19   ` Dave Martin
2017-12-04 13:46   ` Ard Biesheuvel [this message]
2017-12-04 13:46     ` Ard Biesheuvel
2017-12-01 15:19 ` [PATCH 3/3] arm64/sve: KVM: Avoid dereference of dead task during guest entry Dave Martin
2017-12-01 15:19   ` Dave Martin
2017-12-04 13:53   ` Ard Biesheuvel
2017-12-04 13:53     ` Ard Biesheuvel
2017-12-04 15:36     ` Dave Martin
2017-12-04 15:36       ` Dave Martin
2017-12-05  9:43       ` Christoffer Dall
2017-12-05  9:43         ` Christoffer Dall
2017-12-05 12:40         ` Dave Martin
2017-12-05 12:40           ` Dave Martin
2017-12-06 16:45 [PATCH v2 0/3] arm64: SVE fixes for v4.15-rc2 Dave Martin
2017-12-06 16:45 ` [PATCH 2/3] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu Dave Martin
2017-12-06 16:45   ` Dave Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu8BzFrc1U7r7iURfZqGKRqpwHJVFM6hvHOX5xghrXojtA@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=Dave.Martin@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=tokamoto@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.