Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Strange (or at least interesting) printf() behavior!
On Mon, Jan 03, 2011 at 06:22:39PM +0000, David Laight wrote:
> On Mon, Jan 03, 2011 at 06:43:39PM +0100, Nicolas Joly wrote:
> >
> > Program terminated with signal 6, Aborted.
> > #0 0x00007f7ffd8e7dea in _lwp_kill () from /usr/lib/libc.so.12
> > (gdb) bt
> > #0 0x00007f7ffd8e7dea in _lwp_kill () from /usr/lib/libc.so.12
> > #1 0x00007f7ffd8e775e in abort () at
> > /local/src/NetBSD/src/lib/libc/stdlib/abort.c:74
> > #2 0x0000000000400b58 in sigalrm_action (signo=14, info=0x7f7fffffc640,
> > ptr=0x7f7fffffc6c0) at xx.c:23
> > #3 <signal handler called>
> > #4 0x00007f7ffd898f6e in arena_bin_run_size_calc (bin=0x7f7ffdff7110,
> > min_run_size=<value optimized out>)
> > at /local/src/NetBSD/src/lib/libc/stdlib/jemalloc.c:2200
> > #5 0x00007f7ffd89a4d1 in arenas_extend (ind=0) at
> > /local/src/NetBSD/src/lib/libc/stdlib/jemalloc.c:2631
> > #6 0x00007f7ffd89a9b4 in malloc_init_hard () at
> > /local/src/NetBSD/src/lib/libc/stdlib/jemalloc.c:3655
> > #7 0x00007f7ffd89bd35 in malloc (size=4096) at
> > /local/src/NetBSD/src/lib/libc/stdlib/jemalloc.c:3313
>
> That looks like the same place as the CTRL+C that gdb caught.
>
> line 2200 of jmalloc is part of this test.
> } while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL
> && max_ovrhd > RUN_MAX_OVRHD_RELAX / ((float)(bin->reg_size << 3))
> && ((float)(try_reg0_offset)) / ((float)(try_run_size)) > max_ovrhd);
>
> So I guess it might be looping forever.
> Maybe because of some unwanted FP state ??
>
> (Actually that test can surely be revamped to avoid FP divisions??)
Here it is ... patch for test/review. Got it from FreeBSD :
revision 1.154
date: 2007/12/18 05:27:57; author: jasone; state: Exp; lines: +47 -42
Use fixed point integer math instead of floating point math when
calculating run sizes. Use of the floating point unit was a potential
pessimization to context switching for applications that do not otherwise
use floating point math. [1]
Reformat cpp macro-related comments to improve consistency.
Submitted by: das
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
Index: stdlib/jemalloc.c
===================================================================
RCS file: /cvsroot/src/lib/libc/stdlib/jemalloc.c,v
retrieving revision 1.21
diff -u -p -r1.21 jemalloc.c
--- stdlib/jemalloc.c 4 Mar 2010 22:48:31 -0000 1.21
+++ stdlib/jemalloc.c 3 Jan 2011 19:33:10 -0000
@@ -319,20 +319,25 @@ __strerror_r(int e, char *s, size_t l)
#define SMALL_MAX_DEFAULT (1 << SMALL_MAX_2POW_DEFAULT)
/*
- * Maximum desired run header overhead. Runs are sized as small as possible
- * such that this setting is still honored, without violating other
constraints.
- * The goal is to make runs as small as possible without exceeding a per run
- * external fragmentation threshold.
+ * RUN_MAX_OVRHD indicates maximum desired run header overhead. Runs are sized
+ * as small as possible such that this setting is still honored, without
+ * violating other constraints. The goal is to make runs as small as possible
+ * without exceeding a per run external fragmentation threshold.
*
- * Note that it is possible to set this low enough that it cannot be honored
- * for some/all object sizes, since there is one bit of header overhead per
- * object (plus a constant). In such cases, this constraint is relaxed.
+ * We use binary fixed point math for overhead computations, where the binary
+ * point is implicitly RUN_BFP bits to the left.
*
- * RUN_MAX_OVRHD_RELAX specifies the maximum number of bits per region of
- * overhead for which RUN_MAX_OVRHD is relaxed.
+ * Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be
+ * honored for some/all object sizes, since there is one bit of header overhead
+ * per object (plus a constant). This constraint is relaxed (ignored) for runs
+ * that are so small that the per-region overhead is greater than:
+ *
+ * (RUN_MAX_OVRHD / (reg_size << (3+RUN_BFP))
*/
-#define RUN_MAX_OVRHD 0.015
-#define RUN_MAX_OVRHD_RELAX 1.5
+#define RUN_BFP 12
+/* \/ Implicit binary fixed point. */
+#define RUN_MAX_OVRHD 0x0000003dU
+#define RUN_MAX_OVRHD_RELAX 0x00001800U
/* Put a cap on small object run size. This overrides RUN_MAX_OVRHD. */
#define RUN_MAX_SMALL_2POW 15
@@ -2143,7 +2148,6 @@ arena_bin_run_size_calc(arena_bin_t *bin
size_t try_run_size, good_run_size;
unsigned good_nregs, good_mask_nelms, good_reg0_offset;
unsigned try_nregs, try_mask_nelms, try_reg0_offset;
- float max_ovrhd = RUN_MAX_OVRHD;
assert(min_run_size >= pagesize);
assert(min_run_size <= arena_maxclass);
@@ -2161,7 +2165,7 @@ arena_bin_run_size_calc(arena_bin_t *bin
*/
try_run_size = min_run_size;
try_nregs = (unsigned)(((try_run_size - sizeof(arena_run_t)) /
- bin->reg_size) + 1); /* Counter-act the first line of the loop. */
+ bin->reg_size) + 1); /* Counter-act try_nregs-- in loop. */
do {
try_nregs--;
try_mask_nelms = (try_nregs >> (SIZEOF_INT_2POW + 3)) +
@@ -2195,9 +2199,8 @@ arena_bin_run_size_calc(arena_bin_t *bin
} while (sizeof(arena_run_t) + (sizeof(unsigned) *
(try_mask_nelms - 1)) > try_reg0_offset);
} while (try_run_size <= arena_maxclass && try_run_size <= RUN_MAX_SMALL
- && max_ovrhd > RUN_MAX_OVRHD_RELAX / ((float)(bin->reg_size << 3))
- && ((float)(try_reg0_offset)) / ((float)(try_run_size)) >
- max_ovrhd);
+ && RUN_MAX_OVRHD * (bin->reg_size << 3) > RUN_MAX_OVRHD_RELAX
+ && (try_reg0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size);
assert(sizeof(arena_run_t) + (sizeof(unsigned) * (good_mask_nelms - 1))
<= good_reg0_offset);
Home |
Main Index |
Thread Index |
Old Index