]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
New Option --avg-transtab-entry-size=<number> can be used to tune
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 15 Mar 2015 12:24:19 +0000 (12:24 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 15 Mar 2015 12:24:19 +0000 (12:24 +0000)
  the size of the translation table sectors, either to gain memory
  or to avoid too many retranslations.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15016

NEWS
coregrind/m_main.c
coregrind/m_transtab.c
coregrind/pub_core_options.h
coregrind/pub_core_transtab.h
docs/xml/manual-core.xml
none/tests/cmdline1.stdout.exp
none/tests/cmdline2.stdout.exp

diff --git a/NEWS b/NEWS
index 4a57638e2a854c0531c1c3be9f4dc6a5def38239..1e29c4efb6ad880cde5da69572c310b449ede401 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,10 @@ Release 3.11.0 is under development, not yet released.
   Useful to reduce memory use or increase the stack size if Valgrind
   segfaults due to stack exhausted.
 
+* New Option --avg-transtab-entry-size=<number> can be used to tune
+  the size of the translation table sectors, either to gain memory
+  or to avoid too many retranslations.
+
 * Valgrind can be built with Intel's ICC compiler. The required
   compiler version is 14.0 or later.
 
index a1de69c7c724be4f5e98144ca91af2ebd6ade1c5..0f902f1335ad5c66d0664099c3a5cc70b7a33bbb 100644 (file)
@@ -194,6 +194,8 @@ static void usage_NORETURN ( Bool debug_help )
 "           program counters in max <number> frames) [0]\n"
 "    --num-transtab-sectors=<number> size of translated code cache [%d]\n"
 "           more sectors may increase performance, but use more memory.\n"
+"    --avg-transtab-entry-size=<number> avg size in bytes of a translated\n"
+"           basic block [0, meaning use tool provided default]\n"
 "    --aspace-minaddr=0xPP     avoid mapping memory below 0xPP [guessed]\n"
 "    --valgrind-stacksize=<number> size of valgrind (host) thread's stack\n"
 "                               (in bytes) ["
@@ -694,6 +696,9 @@ void main_process_cmd_line_options ( /*OUT*/Bool* logging_to_fd,
       else if VG_BINT_CLO(arg, "--num-transtab-sectors",
                                VG_(clo_num_transtab_sectors),
                                MIN_N_SECTORS, MAX_N_SECTORS) {}
+      else if VG_BINT_CLO(arg, "--avg-transtab-entry-size",
+                               VG_(clo_avg_transtab_entry_size),
+                               50, 5000) {}
       else if VG_BINT_CLO(arg, "--merge-recursive-frames",
                                VG_(clo_merge_recursive_frames), 0,
                                VG_DEEPEST_BACKTRACE) {}
index b3d136b14f514208f1865186c5a648a235de359c..f28c3f338bffe6fbf0ab84d250cf9efa8b669383 100644 (file)
@@ -59,6 +59,10 @@ UInt VG_(clo_num_transtab_sectors) = N_SECTORS_DEFAULT;
    Will be set by VG_(init_tt_tc) to VG_(clo_num_transtab_sectors). */
 static UInt n_sectors = 0;
 
+/* Average size of a transtab code entry. 0 means to use the tool
+   provided default. */
+UInt VG_(clo_avg_transtab_entry_size) = 0;
+
 /*------------------ CONSTANTS ------------------*/
 /* Number of TC entries in each sector.  This needs to be a prime
    number to work properly, it must be <= 65535 (so that a TT index
@@ -2223,7 +2227,10 @@ void VG_(init_tt_tc) ( void )
                    "(startup of code management)\n");
 
    /* Figure out how big each tc area should be.  */
-   avg_codeszQ   = (VG_(details).avg_translation_sizeB + 7) / 8;
+   if (VG_(clo_avg_transtab_entry_size) == 0)
+      avg_codeszQ   = (VG_(details).avg_translation_sizeB + 7) / 8;
+   else
+      avg_codeszQ   = (VG_(clo_avg_transtab_entry_size) + 7) / 8;
    tc_sector_szQ = N_TTES_PER_SECTOR_USABLE * (1 + avg_codeszQ);
 
    /* Ensure the calculated value is not way crazy. */
@@ -2253,6 +2260,13 @@ void VG_(init_tt_tc) ( void )
 
    if (VG_(clo_verbosity) > 2 || VG_(clo_stats)
        || VG_(debugLog_getLevel) () >= 2) {
+      VG_(message)(Vg_DebugMsg,
+         "TT/TC: cache: %s--avg-transtab-entry-size=%d, " 
+         "%stool provided default %d\n",
+         VG_(clo_avg_transtab_entry_size) == 0 ? "ignoring " : "using ",
+         VG_(clo_avg_transtab_entry_size),
+         VG_(clo_avg_transtab_entry_size) == 0 ? "using " : "ignoring ",
+         VG_(details).avg_translation_sizeB);
       VG_(message)(Vg_DebugMsg,
          "TT/TC: cache: %d sectors of %d bytes each = %d total\n", 
           n_sectors, 8 * tc_sector_szQ,
index 60c79e13949a770782a3da5abd062281c93414e7..53ccfc0cc95af803d47d900ef8480a5ad10f487a 100644 (file)
@@ -310,6 +310,10 @@ extern Int VG_(clo_merge_recursive_frames);
 /* Max number of sectors that will be used by the translation code cache. */
 extern UInt VG_(clo_num_transtab_sectors);
 
+/* Average size of a transtab code entry. 0 means to use the tool
+   provided default. */
+extern UInt VG_(clo_avg_transtab_entry_size);
+
 /* Only client requested fixed mapping can be done below 
    VG_(clo_aspacem_minAddr). */
 extern Addr VG_(clo_aspacem_minAddr);
index 67fd9d82f477158e3fcee4a2739755a61889696b..2fd8612f6f3635003a925d6a032a21ebec155fc3 100644 (file)
@@ -56,7 +56,8 @@ extern __attribute__((aligned(16)))
 #define TRANSTAB_BOGUS_GUEST_ADDR ((Addr)1)
 
 
-/* Initialises the TC, using VG_(clo_num_transtab_sectors).
+/* Initialises the TC, using VG_(clo_num_transtab_sectors)
+   and VG_(clo_avg_transtab_entry_size).
    VG_(clo_num_transtab_sectors) must be >= MIN_N_SECTORS
    and <= MAX_N_SECTORS. */
 extern void VG_(init_tt_tc)       ( void );
index 21a994ef5179b455030950e835563eda35b9943f..5437bd536833379ae1ce6cadec33c7e4477fa6e5 100644 (file)
@@ -2208,7 +2208,7 @@ need to use them.</para>
     </term>
     <listitem>
       <para>Valgrind translates and instruments your program's machine
-      code in small fragments. The translations are stored in a
+      code in small fragments (basic blocks). The translations are stored in a
       translation cache that is divided into a number of sections
       (sectors). If the cache is full, the sector containing the
       oldest translations is emptied and reused. If these old
@@ -2219,6 +2219,7 @@ need to use them.</para>
       performance by reducing the number of re-translations needed.
       Sectors are allocated on demand.  Once allocated, a sector can
       never be freed, and occupies considerable space, depending on the tool
+      and the value of <option>--avg-transtab-entry-size</option>
       (about 40 MB per sector for Memcheck).  Use the
       option <option>--stats=yes</option> to obtain precise
       information about the memory used by a sector and the allocation
@@ -2226,6 +2227,28 @@ need to use them.</para>
    </listitem>
   </varlistentry>
 
+  <varlistentry id="opt.avg-transtab-entry-size" xreflabel="--avg-transtab-entry-size">
+    <term>
+      <option><![CDATA[--avg-transtab-entry-size=<number> [default: 0,
+      meaning use tool provided default] ]]></option>
+    </term>
+    <listitem>
+      <para>Average size of translated basic block. This average size
+      is used to dimension the size of a sector.
+      Each tool provides a default value to be used.
+      If this default value is too small, the translation sectors
+      will become full too quickly. If this default value is too big,
+      a significant part of the translation sector memory will be unused.
+      Note that the average size of a basic block translation depends
+      on the tool, and might depend on tool options. For example,
+      the memcheck option <option>--track-origins=yes</option>
+      increases the size of the basic block translations.
+      Use <option>--avg-transtab-entry-size</option> to tune the size of the
+      sectors, either to gain memory or to avoid too many retranslations.
+      </para>
+   </listitem>
+  </varlistentry>
+
   <varlistentry id="opt.aspace-minaddr" xreflabel="----aspace-minaddr">
     <term>
       <option><![CDATA[--aspace-minaddr=<address> [default: depends
index 385f77360caaea7bbe81a7b1e72911f1e17d8a20..564a2e0fcbf8ce80c006cb1e5de5237196d08a2a 100644 (file)
@@ -107,6 +107,8 @@ usage: valgrind [options] prog-and-args
            program counters in max <number> frames) [0]
     --num-transtab-sectors=<number> size of translated code cache [16]
            more sectors may increase performance, but use more memory.
+    --avg-transtab-entry-size=<number> avg size in bytes of a translated
+           basic block [0, meaning use tool provided default]
     --aspace-minaddr=0xPP     avoid mapping memory below 0xPP [guessed]
     --valgrind-stacksize=<number> size of valgrind (host) thread's stack
                                (in bytes) [1048576]
index 9dbac3105575ae4986b58d3e5ed2b6eb45522fdf..4efc4239301062fa97dbe2ceba27ac2377635ebf 100644 (file)
@@ -107,6 +107,8 @@ usage: valgrind [options] prog-and-args
            program counters in max <number> frames) [0]
     --num-transtab-sectors=<number> size of translated code cache [16]
            more sectors may increase performance, but use more memory.
+    --avg-transtab-entry-size=<number> avg size in bytes of a translated
+           basic block [0, meaning use tool provided default]
     --aspace-minaddr=0xPP     avoid mapping memory below 0xPP [guessed]
     --valgrind-stacksize=<number> size of valgrind (host) thread's stack
                                (in bytes) [1048576]