linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Preeti U Murthy <preeti@linux.vnet.ibm.com>
To: "Shreyas B. Prabhu" <shreyas@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org,
	Michael Ellerman <mpe@ellerman.id.au>,
	"benh@kernel.crashing.org" <benh@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior
Date: Tue, 14 Apr 2015 13:57:10 +0530	[thread overview]
Message-ID: <552CCF5E.5040201@linux.vnet.ibm.com> (raw)
In-Reply-To: <1428976613-13007-4-git-send-email-shreyas@linux.vnet.ibm.com>

Hi Shreyas,

On 04/14/2015 07:26 AM, Shreyas B. Prabhu wrote:
> +	 * fastsleep_workaround_state = WORKAROUND_APPLYONCE implies
> +	 * fastsleep workaround needs to be left in 'applied' state on all
> +	 * the cores. Do this by-
> +	 * 1. Patching out the call to 'undo' workaround in fastsleep exit path
> +	 * 2. Sending ipi to all the cores which have atleast one online thread
> +	 * 3. Patching out the call to 'apply' workaround in fastsleep entry
> +	 * path
> +	 * There is no need to send ipi to cores which have all threads
> +	 * offlined, as last thread of the core entering fastsleep or deeper
> +	 * state would have applied workaround.
> +	 */
> +	err = patch_instruction(
> +		(unsigned int *)pnv_fastsleep_workaround_at_exit,
> +		PPC_INST_NOP);
> +	if (err) {
> +		pr_err("fastsleep_workaround_state change failed while patching pnv_fastsleep_workaround_at_exit");
> +		goto fail;
> +	}
> +
> +	primary_thread_mask = cpu_online_cores_map();
> +	on_each_cpu_mask(&primary_thread_mask,
> +				pnv_fastsleep_workaround_apply,
> +				&err, 1);
> +	if (err) {
> +		pr_err("fastsleep_workaround_state change failed while running pnv_fastsleep_workaround_apply");
> +		goto fail;
> +	}
> +
> +	err = patch_instruction(
> +		(unsigned int *)pnv_fastsleep_workaround_at_entry,
> +		PPC_INST_NOP);
> +	if (err) {
> +		pr_err("fastsleep_workaround_state change failed while patching pnv_fastsleep_workaround_at_entry");
> +		goto fail;
> +	}

A point that bothers me here is if we can potentially race with cpu
hotplug ? If cpuX and its siblings are offline and it was interrupted to
come online:

cpuX                                     cpuY
Interrupted to come online
Undo workaround

                                Nop the fastsleep_workaround_exit path
                                IPI online cores: apply workaround once

Set yourself in the online mask
                                Nop the fastsleep_workaround_entry path


This results in cpuX undoing the workaround on its core, never to set it
back again.

So should we protect the region between the beginning and end of
patching instructions with get_online_cpus() and put_online_cpus() ?

Regards
Preeti U Murthy

  parent reply	other threads:[~2015-04-14  8:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  1:56 [PATCH v4 0/3] powerpc: powernv: Fastsleep workaround behavior Shreyas B. Prabhu
2015-04-14  1:56 ` [PATCH v4 1/3] powerpc: Fix cpu_online_cores_map to return only online threads mask Shreyas B. Prabhu
2015-04-14  1:56 ` [PATCH v4 2/3] powerpc/powernv: Move cpuidle related code from setup.c to new file Shreyas B. Prabhu
2015-04-14  5:07   ` Preeti U Murthy
2015-04-14  1:56 ` [PATCH v4 3/3] powerpc/powernv: Introduce sysfs control for fastsleep workaround behavior Shreyas B. Prabhu
2015-04-14  5:59   ` Preeti U Murthy
2015-04-14  8:10     ` Shreyas B Prabhu
2015-04-14  8:31       ` Preeti U Murthy
2015-04-14  8:27   ` Preeti U Murthy [this message]
2015-04-15  6:05     ` Shreyas B Prabhu

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=552CCF5E.5040201@linux.vnet.ibm.com \
    --to=preeti@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=shreyas@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).