From: "Jan Beulich" Subject: [PATCH] x86/cpuidle: publish new states only after fully initializing them Date: Tue, 10 Dec 2013 15:26:29 +0000 Message-ID: <52A740B5020000780010BEC8@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part1A29E2B5.1__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VqPCj-0001ZE-Qz for xen-devel@lists.xenproject.org; Tue, 10 Dec 2013 15:26:34 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Jinsong Liu , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part1A29E2B5.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Since state information coming from Dom0 can arrive at any time, on any CPU, we ought to make sure that a new state is fully initialized before the target CPU might be using it. Once touching that code, also do minor cleanup: A missing (but benign) "break" and some white space adjustments. Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -912,7 +912,7 @@ static void set_cx( acpi_power->cpu, xen_cx->type); return; } - cx =3D &acpi_power->states[acpi_power->count++]; + cx =3D &acpi_power->states[acpi_power->count]; cx->type =3D xen_cx->type; break; } @@ -937,11 +937,14 @@ static void set_cx( break; default: cx->entry_method =3D ACPI_CSTATE_EM_NONE; + break; } =20 - cx->latency =3D xen_cx->latency; - =20 + cx->latency =3D xen_cx->latency; cx->target_residency =3D cx->latency * latency_factor; + + smp_wmb(); + acpi_power->count++; if ( cx->type =3D=3D ACPI_STATE_C1 || cx->type =3D=3D ACPI_STATE_C2 ) acpi_power->safe_state =3D cx; } --=__Part1A29E2B5.1__= Content-Type: text/plain; name="x86-cpuidle-set_cx.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-cpuidle-set_cx.patch" x86/cpuidle: publish new states only after fully initializing them=0A=0ASin= ce state information coming from Dom0 can arrive at any time, on=0Aany = CPU, we ought to make sure that a new state is fully initialized=0Abefore = the target CPU might be using it.=0A=0AOnce touching that code, also do = minor cleanup: A missing (but benign)=0A"break" and some white space = adjustments.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/acpi/cpu_idle.c=0A+++ b/xen/arch/x86/acpi/cpu_idle.c=0A@@ = -912,7 +912,7 @@ static void set_cx(=0A acpi_power->cpu,= xen_cx->type);=0A return;=0A }=0A- cx =3D = &acpi_power->states[acpi_power->count++];=0A+ cx =3D &acpi_power->st= ates[acpi_power->count];=0A cx->type =3D xen_cx->type;=0A = break;=0A }=0A@@ -937,11 +937,14 @@ static void set_cx(=0A = break;=0A default:=0A cx->entry_method =3D ACPI_CSTATE_EM_NONE;= =0A+ break;=0A }=0A =0A- cx->latency =3D xen_cx->latency;=0A= - =0A+ cx->latency =3D xen_cx->latency;=0A cx->target_residency = =3D cx->latency * latency_factor;=0A+=0A+ smp_wmb();=0A+ acpi_power->= count++;=0A if ( cx->type =3D=3D ACPI_STATE_C1 || cx->type =3D=3D = ACPI_STATE_C2 )=0A acpi_power->safe_state =3D cx;=0A }=0A --=__Part1A29E2B5.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part1A29E2B5.1__=--