From: DJ Delorie Date: Fri, 22 Jul 2016 05:23:10 +0000 (-0400) Subject: More 32-bit fixes. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a738e7f526e8c4f063176e79df9393355a91685;p=thirdparty%2Fglibc.git More 32-bit fixes. Various fixes to handle traces and workloads bigger than 2 Gb. --- diff --git a/malloc/trace2wl.cc b/malloc/trace2wl.cc index e1e8bb684b2..d6774026c55 100644 --- a/malloc/trace2wl.cc +++ b/malloc/trace2wl.cc @@ -36,8 +36,8 @@ struct Buffer { BufferBlock *first_buffer; BufferBlock *last_buffer; - int count_total; - int count_last; + size_t count_total; + size_t count_last; Buffer(); void add (char x); @@ -121,10 +121,10 @@ PerThreadMap per_thread; struct PerAddr { PerThread *owner; void *ptr; - int idx; + size_t idx; int valid; const char *reason; - int reason_idx; + size_t reason_idx; __malloc_trace_buffer_s *inverted; PerAddr(void *_ptr) : owner(0), ptr(_ptr), valid(0), reason("not seen"), inverted(NULL) {}; }; @@ -187,7 +187,7 @@ int fixed_inversions = 0; static void process_one_trace_record (__malloc_trace_buffer_s *r) { - int i = r - trace_records; + size_t i = r - trace_records; // Quick-skip for NULs at EOF if (r->type == __MTB_TYPE_UNUSED) @@ -233,11 +233,10 @@ process_one_trace_record (__malloc_trace_buffer_s *r) { if (pa2->inverted) { - printf ("%d: pointer %p alloc'd again? (possible multi-level inversion) size %d %d:%s\n", - i, pa2->ptr, (int)r->size, pa2->reason_idx, pa2->reason); - exit (1); + printf ("%ld: pointer %p alloc'd again? (possible multi-level inversion) size %ld %ld:%s\n", + i, pa2->ptr, (long int)r->size, pa2->reason_idx, pa2->reason); + // exit (1); } - printf("inversion for type %d\n", r->type); pa2->inverted = r; fixed_inversions ++; pending_inversions ++; @@ -289,7 +288,7 @@ process_one_trace_record (__malloc_trace_buffer_s *r) } else { - printf("%d: invalid pointer %p passed to free: %d:%s\n", i, pa1->ptr, pa1->reason_idx, pa1->reason); + printf("%ld: invalid pointer %p passed to free: %ld:%s\n", i, pa1->ptr, pa1->reason_idx, pa1->reason); } break; @@ -322,7 +321,7 @@ process_one_trace_record (__malloc_trace_buffer_s *r) case __MTB_TYPE_MEMALIGN: acq_ptr (thread, pa2); if (pa2 && pa2->valid) - printf ("%d: pointer %p memalign'd again? %d:%s\n", i, pa2->ptr, pa2->reason_idx, pa2->reason); + printf ("%ld: pointer %p memalign'd again? %ld:%s\n", i, pa2->ptr, pa2->reason_idx, pa2->reason); thread->add (C_MEMALIGN); thread->add_int (pa2 ? pa2->idx : 0); thread->add_int (r->size2); @@ -336,7 +335,7 @@ process_one_trace_record (__malloc_trace_buffer_s *r) break; case __MTB_TYPE_POSIX_MEMALIGN: - printf ("%d: Unsupported posix_memalign call.\n", i); + printf ("%ld: Unsupported posix_memalign call.\n", i); exit (1); break; @@ -398,12 +397,12 @@ main(int argc, char **argv) per_addr[0] = NULL; - for (unsigned int i = 0; i < num_trace_records; i++) + for (unsigned long i = 0; i < num_trace_records; i++) process_one_trace_record (trace_records + i); int n_threads = per_thread.size(); PerThread *threads[n_threads]; - int thread_off[n_threads]; + size_t thread_off[n_threads]; int i = 0; PerThreadMap::iterator iter; @@ -416,19 +415,19 @@ main(int argc, char **argv) threads[i++] = iter->second; iter->second->add(C_DONE); if(verbose) - printf("thread: %d bytes\n", iter->second->workload.count_total); + printf("thread: %ld bytes\n", (long)iter->second->workload.count_total); } /* The location of each thread's workload depends on the size of the startup block, but the size of the startup block depends on the size of the thread's location encoding. So, we loop until it stabilizes. */ - int old_len = 1; - int new_len = 2; + size_t old_len = 1; + size_t new_len = 2; Buffer main_loop; while (old_len != new_len) { - int off = new_len; + size_t off = new_len; int i; old_len = new_len; @@ -467,7 +466,7 @@ main(int argc, char **argv) for (i=0; iworkload.write (wl_fd); } diff --git a/malloc/trace_run.c b/malloc/trace_run.c index 91331e49469..fc9cbbdd40b 100644 --- a/malloc/trace_run.c +++ b/malloc/trace_run.c @@ -1,3 +1,4 @@ +#define _LARGEFILE64_SOURCE #include #include #include @@ -186,7 +187,7 @@ io_init (IOPerThreadType *io, size_t file_offset, int incr) io->incr = incr; pthread_mutex_lock (&io_mutex); - lseek (io_fd, io->buf_base, SEEK_SET); + lseek64 (io_fd, io->buf_base, SEEK_SET); // short read OK, the eof is just to prevent runaways from bad data. if (read (io_fd, io->buf, incr) < 0) io->saw_eof = 1; @@ -278,12 +279,14 @@ thread_common (void *my_data_v) ticks_t my_realloc_time = 0, my_realloc_count = 0; ticks_t my_free_time = 0, my_free_count = 0; ticks_t stime, etime; + int thread_idx = io - thread_io; #ifdef MDEBUG volatile void *tmp; #endif while (1) { + unsigned char this_op = io_peek (io); if (io->saw_eof) myabort(); dprintf("op %p:%ld is %d\n", (void *)thrc, io_pos (io), io_peek (io)); @@ -483,6 +486,8 @@ thread_common (void *my_data_v) break; default: + printf("op %d - unsupported, thread %d addr %lu\n", + this_op, thread_idx, (long unsigned int)io_pos (io)); myabort(); } } @@ -611,7 +616,7 @@ main(int argc, char **argv) idx = get_int (&main_io); io_init (& thread_io[thread_idx], idx, guessed_io_size); pthread_create (&thread_ids[thread_idx], NULL, thread_common, thread_io + thread_idx); - dprintf("Starting thread %lld at offset %d %x\n", (long long)thread_ids[thread_idx], (int)idx, (unsigned int)idx); + dprintf("Starting thread %lld at offset %lu %lx\n", (long long)thread_ids[thread_idx], (unsigned long)idx, (unsigned long)idx); thread_idx ++; break; case C_DONE: