From: "Jan Beulich" Subject: [PATCH] x86/cpuidle: clean up hw residencies reading code Date: Tue, 08 Nov 2011 15:38:35 +0000 Message-ID: <4EB95B0B020000780005FA38@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3817C2EB.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" 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. --=__Part3817C2EB.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Fold redundant code and eliminate pointless casts. Signed-off-by: Jan Beulich --- a/xen/arch/x86/acpi/cpu_idle.c +++ b/xen/arch/x86/acpi/cpu_idle.c @@ -99,13 +99,19 @@ struct hw_residencies static void do_get_hw_residencies(void *arg) { struct cpuinfo_x86 *c =3D ¤t_cpu_data; - struct hw_residencies *hw_res =3D (struct hw_residencies *)arg; + struct hw_residencies *hw_res =3D arg; =20 if ( c->x86_vendor !=3D X86_VENDOR_INTEL || c->x86 !=3D 6 ) return; =20 switch ( c->x86_model ) { + /* Sandy bridge */ + case 0x2A: + case 0x2D: + GET_PC2_RES(hw_res->pc2); + GET_CC7_RES(hw_res->cc7); + /* fall through */ /* Nehalem */ case 0x1A: case 0x1E: @@ -120,32 +126,22 @@ static void do_get_hw_residencies(void * GET_CC3_RES(hw_res->cc3); GET_CC6_RES(hw_res->cc6); break; - /* Sandy bridge */ - case 0x2A: - case 0x2D: - GET_PC2_RES(hw_res->pc2); - GET_PC3_RES(hw_res->pc3); - GET_PC6_RES(hw_res->pc6); - GET_PC7_RES(hw_res->pc7); - GET_CC3_RES(hw_res->cc3); - GET_CC6_RES(hw_res->cc6); - GET_CC7_RES(hw_res->cc7); - break; } } =20 static void get_hw_residencies(uint32_t cpu, struct hw_residencies = *hw_res) { + memset(hw_res, 0, sizeof(*hw_res)); + if ( smp_processor_id() =3D=3D cpu ) - do_get_hw_residencies((void *)hw_res); + do_get_hw_residencies(hw_res); else - on_selected_cpus(cpumask_of(cpu), - do_get_hw_residencies, (void *)hw_res, 1); + on_selected_cpus(cpumask_of(cpu), do_get_hw_residencies, hw_res, = 1); } =20 static void print_hw_residencies(uint32_t cpu) { - struct hw_residencies hw_res =3D {0}; + struct hw_residencies hw_res; =20 get_hw_residencies(cpu, &hw_res); =20 @@ -1042,7 +1038,7 @@ int pmstat_get_cx_stat(uint32_t cpuid, s struct acpi_processor_power *power =3D processor_powers[cpuid]; uint64_t usage, res, idle_usage =3D 0, idle_res =3D 0; int i; - struct hw_residencies hw_res =3D {0}; + struct hw_residencies hw_res; =20 if ( power =3D=3D NULL ) { --=__Part3817C2EB.0__= Content-Type: text/plain; name="x86-cpuidle-residencies-cleanup.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-cpuidle-residencies-cleanup.patch" x86/cpuidle: clean up hw residencies reading code=0A=0AFold redundant code = and eliminate pointless casts.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/acpi/cpu_idle.c=0A+++ b/xen/arch/x86/acpi/c= pu_idle.c=0A@@ -99,13 +99,19 @@ struct hw_residencies=0A static void = do_get_hw_residencies(void *arg)=0A {=0A struct cpuinfo_x86 *c =3D = ¤t_cpu_data;=0A- struct hw_residencies *hw_res =3D (struct = hw_residencies *)arg;=0A+ struct hw_residencies *hw_res =3D arg;=0A =0A = if ( c->x86_vendor !=3D X86_VENDOR_INTEL || c->x86 !=3D 6 )=0A = return;=0A =0A switch ( c->x86_model )=0A {=0A+ /* Sandy bridge = */=0A+ case 0x2A:=0A+ case 0x2D:=0A+ GET_PC2_RES(hw_res->pc2);= =0A+ GET_CC7_RES(hw_res->cc7);=0A+ /* fall through */=0A = /* Nehalem */=0A case 0x1A:=0A case 0x1E:=0A@@ -120,32 +126,22 @@ = static void do_get_hw_residencies(void *=0A GET_CC3_RES(hw_res->cc3= );=0A GET_CC6_RES(hw_res->cc6);=0A break;=0A- /* Sandy = bridge */=0A- case 0x2A:=0A- case 0x2D:=0A- GET_PC2_RES(hw_res= ->pc2);=0A- GET_PC3_RES(hw_res->pc3);=0A- GET_PC6_RES(hw_res-= >pc6);=0A- GET_PC7_RES(hw_res->pc7);=0A- GET_CC3_RES(hw_res->= cc3);=0A- GET_CC6_RES(hw_res->cc6);=0A- GET_CC7_RES(hw_res->c= c7);=0A- break;=0A }=0A }=0A =0A static void get_hw_residencies(= uint32_t cpu, struct hw_residencies *hw_res)=0A {=0A+ memset(hw_res, 0, = sizeof(*hw_res));=0A+=0A if ( smp_processor_id() =3D=3D cpu )=0A- = do_get_hw_residencies((void *)hw_res);=0A+ do_get_hw_residencies(h= w_res);=0A else=0A- on_selected_cpus(cpumask_of(cpu),=0A- = do_get_hw_residencies, (void *)hw_res, 1);=0A+ = on_selected_cpus(cpumask_of(cpu), do_get_hw_residencies, hw_res, 1);=0A = }=0A =0A static void print_hw_residencies(uint32_t cpu)=0A {=0A- struct = hw_residencies hw_res =3D {0};=0A+ struct hw_residencies hw_res;=0A =0A = get_hw_residencies(cpu, &hw_res);=0A =0A@@ -1042,7 +1038,7 @@ int = pmstat_get_cx_stat(uint32_t cpuid, s=0A struct acpi_processor_power = *power =3D processor_powers[cpuid];=0A uint64_t usage, res, idle_usage = =3D 0, idle_res =3D 0;=0A int i;=0A- struct hw_residencies hw_res = =3D {0};=0A+ struct hw_residencies hw_res;=0A =0A if ( power =3D=3D = NULL )=0A {=0A --=__Part3817C2EB.0__= 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.xensource.com http://lists.xensource.com/xen-devel --=__Part3817C2EB.0__=--