lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <201007221611.o6MGBnmW029378@hs20-bc2-1.build.redhat.com>
Date:	Thu, 22 Jul 2010 12:11:49 -0400
From:	Ulrich Drepper <drepper@...hat.com>
To:	a.p.zijlstra@...llo.nl, acme@...hat.com, davem@...emloft.net,
	imunsie@...ibm.com, linux-kernel@...r.kernel.org,
	mhiramat@...hat.com, mingo@...e.hu, paulus@...ba.org
Subject: Small perf optimization

Before this bad practice of using arrays of string pointers to constant
strings further spreads let's fix it.  With this change not only is the
entire data associated with the arrays read-only, it also replaces a
memory lookup with a trivial arithmetic operation.  The result is
a smaller and faster binary.


Signed-off-by: Ulrich Drepper <drepper@...hat.com>


diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c
index 0ab8848..17f193e 100644
--- a/tools/perf/arch/sparc/util/dwarf-regs.c
+++ b/tools/perf/arch/sparc/util/dwarf-regs.c
@@ -14,7 +14,7 @@
 
 #define SPARC_MAX_REGS	96
 
-const char *sparc_regs_table[SPARC_MAX_REGS] = {
+static const char sparc_regs_table[SPARC_MAX_REGS][5] = {
 	"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
 	"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7",
 	"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
diff --git a/tools/perf/arch/x86/util/dwarf-regs.c b/tools/perf/arch/x86/util/dwarf-regs.c
index a794d30..fe5ef0f 100644
--- a/tools/perf/arch/x86/util/dwarf-regs.c
+++ b/tools/perf/arch/x86/util/dwarf-regs.c
@@ -28,7 +28,7 @@
  */
 
 #define X86_32_MAX_REGS 8
-const char *x86_32_regs_table[X86_32_MAX_REGS] = {
+static const char x86_32_regs_table[X86_32_MAX_REGS][7] = {
 	"%ax",
 	"%cx",
 	"%dx",
@@ -40,7 +40,7 @@ const char *x86_32_regs_table[X86_32_MAX_REGS] = {
 };
 
 #define X86_64_MAX_REGS 16
-const char *x86_64_regs_table[X86_64_MAX_REGS] = {
+static const char x86_64_regs_table[X86_64_MAX_REGS][5] = {
 	"%ax",
 	"%dx",
 	"%cx",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ