All of lore.kernel.org
 help / color / mirror / Atom feed
From: leoy@marvell.com (Leo Yan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1] arm64: fix bug for reloading FPSIMD state after cpu power off
Date: Mon, 1 Sep 2014 09:47:05 +0800	[thread overview]
Message-ID: <5403D019.8030801@marvell.com> (raw)
In-Reply-To: <CC25C839-1C64-4BD0-818B-4DA0CD7EC28B@arm.com>

On 09/01/2014 06:11 AM, Catalin Marinas wrote:
> On 31 Aug 2014, at 06:39, Leo Yan <leoy@marvell.com> wrote:
>> Now arm64 defers reloading FPSIMD state, but this optimization also
>> introduces the bug after cpu resume back from low power mode.
>
> You are right, I can see a bug here.
>
>> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
>> index ad8aebb..4caef93 100644
>> --- a/arch/arm64/kernel/fpsimd.c
>> +++ b/arch/arm64/kernel/fpsimd.c
>> @@ -268,13 +268,9 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
>> {
>> 	switch (cmd) {
>> 	case CPU_PM_ENTER:
>> -		if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
>> -			fpsimd_save_state(&current->thread.fpsimd_state);
>
> That?s needed if we enter a low power state directly from a task with
> a valid mm (user). I?m not sure that?s possible, but just in case.

u are right, in some special cases (such like IKS, etc) a normal thread 
also may call cpu_suspend() function so that it will run here; i will 
commit another patch to reserve this part.

>> +		this_cpu_write(fpsimd_last_state, NULL);
>
> That?s correct. In most cases, we enter low power state from the idle
> thread which does not have an mm, so the CPU_PM_EXIT case wouldn?t set
> a TIF_FOREIGN_FPSTATE, so thread switching would not detect the change.
>
>> 		break;
>> 	case CPU_PM_EXIT:
>> -		if (current->mm)
>> -			set_thread_flag(TIF_FOREIGN_FPSTATE);
>
> See above for why this may still be needed (it case it returns to user
> directly without fpsimd_thread_switch() to detect fpsimd_last_state).

Will reserve this part as well.

Thanks,
Leo Yan

WARNING: multiple messages have this Message-ID (diff)
From: Leo Yan <leoy@marvell.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH v1] arm64: fix bug for reloading FPSIMD state after cpu power off
Date: Mon, 1 Sep 2014 09:47:05 +0800	[thread overview]
Message-ID: <5403D019.8030801@marvell.com> (raw)
In-Reply-To: <CC25C839-1C64-4BD0-818B-4DA0CD7EC28B@arm.com>

On 09/01/2014 06:11 AM, Catalin Marinas wrote:
> On 31 Aug 2014, at 06:39, Leo Yan <leoy@marvell.com> wrote:
>> Now arm64 defers reloading FPSIMD state, but this optimization also
>> introduces the bug after cpu resume back from low power mode.
>
> You are right, I can see a bug here.
>
>> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
>> index ad8aebb..4caef93 100644
>> --- a/arch/arm64/kernel/fpsimd.c
>> +++ b/arch/arm64/kernel/fpsimd.c
>> @@ -268,13 +268,9 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
>> {
>> 	switch (cmd) {
>> 	case CPU_PM_ENTER:
>> -		if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
>> -			fpsimd_save_state(&current->thread.fpsimd_state);
>
> That’s needed if we enter a low power state directly from a task with
> a valid mm (user). I’m not sure that’s possible, but just in case.

u are right, in some special cases (such like IKS, etc) a normal thread 
also may call cpu_suspend() function so that it will run here; i will 
commit another patch to reserve this part.

>> +		this_cpu_write(fpsimd_last_state, NULL);
>
> That’s correct. In most cases, we enter low power state from the idle
> thread which does not have an mm, so the CPU_PM_EXIT case wouldn’t set
> a TIF_FOREIGN_FPSTATE, so thread switching would not detect the change.
>
>> 		break;
>> 	case CPU_PM_EXIT:
>> -		if (current->mm)
>> -			set_thread_flag(TIF_FOREIGN_FPSTATE);
>
> See above for why this may still be needed (it case it returns to user
> directly without fpsimd_thread_switch() to detect fpsimd_last_state).

Will reserve this part as well.

Thanks,
Leo Yan

  reply	other threads:[~2014-09-01  1:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-31  5:39 [PATCH v1] arm64: fix bug for reloading FPSIMD state after cpu power off Leo Yan
2014-08-31  5:39 ` Leo Yan
2014-08-31 22:11 ` Catalin Marinas
2014-08-31 22:11   ` Catalin Marinas
2014-09-01  1:47   ` Leo Yan [this message]
2014-09-01  1:47     ` Leo Yan

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=5403D019.8030801@marvell.com \
    --to=leoy@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.