This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch dj/malloc updated. glibc-2.23-545-g77e65f7


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, dj/malloc has been updated
       via  77e65f7bfe394f5c8e1e92aa02d66839614294cc (commit)
      from  1329743b58bc7fbeb56c0bb75f6ef974bf3b58f6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=77e65f7bfe394f5c8e1e92aa02d66839614294cc

commit 77e65f7bfe394f5c8e1e92aa02d66839614294cc
Author: Carlos O'Donell <carlos@systemhalted.org>
Date:   Wed Jul 6 15:30:36 2016 -0400

    Use __gettid() function for tracing.
    
    Integrate with thread 'tid' cache and use the cached value if
    present, otherwise update the cache. This should be much faster
    than a syscall per trace event.

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 891c644..b795504 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1099,6 +1099,26 @@ volatile size_t __malloc_trace_buffer_head = 0;
 
 static __thread __malloc_trace_buffer_ptr trace_ptr;
 
+static inline pid_t
+__gettid (void)
+{
+  struct pthread *pd = THREAD_SELF;
+  pid_t selftid = THREAD_GETMEM (pd, tid);
+  if (selftid == 0)
+    {
+      /* This system call is not supposed to fail.  */
+#ifdef INTERNAL_SYSCALL
+      INTERNAL_SYSCALL_DECL (err);
+      selftid = INTERNAL_SYSCALL (gettid, err, 0);
+#else
+      selftid = INLINE_SYSCALL (gettid, 0);
+#endif
+      THREAD_SETMEM (pd, tid, selftid);
+    }
+
+  return selftid;
+}
+
 static void
 __mtb_trace_entry (uint32_t type, size_t size, void *ptr1)
 {
@@ -1108,7 +1128,7 @@ __mtb_trace_entry (uint32_t type, size_t size, void *ptr1)
 
   trace_ptr = __malloc_trace_buffer + (head1 % __malloc_trace_buffer_size);
 
-  trace_ptr->thread = syscall(__NR_gettid);
+  trace_ptr->thread = __gettid ();
   trace_ptr->type = type;
   trace_ptr->path_thread_cache = 0;
   trace_ptr->path_cpu_cache = 0;

-----------------------------------------------------------------------

Summary of changes:
 malloc/malloc.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]