Skip to contentSkip to conversation

Fix: cache the result of getpid() internally

PATCH New Michael Jeanson 2 participants 2 messages Mar 2, 2018 – Mar 5, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Fix: cache the result of getpid() internally

On Linux we called getpid() directly on each tracepoint and relied on the glibc pid cache. However, in glibc 2.25, released on 2017-02-05, the pid cache was removed which results in a getpid syscall on each event when the vpid context is enabled.

Remove the Linux specific case and use our internal cache all the time.

---
 liblttng-ust/lttng-context-vpid.c | 12 ------------
 1 file changed, 12 deletions(-)
liblttng-ust/lttng-context-vpid.c +0 -12
index 5e5ed14..53fb314 100644
@@ -27,17 +27,6 @@
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.h>
 
-#ifdef __linux__
-static inline
-pid_t wrapper_getpid(void)
-{
-	return getpid();
-}
-
-void lttng_context_vpid_reset(void)
-{
-}
-#else
 /*
  * We cache the result to ensure we don't trigger a system call for
  * each event.
@@ -60,7 +49,6 @@ void lttng_context_vpid_reset(void)
 {
 	cached_vpid = 0;
 }
-#endif
 
 static
 size_t vpid_get_size(struct lttng_ctx_field *field, size_t offset)
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#2 lore raw

Re: [PATCH lttng-ust 1/2] Fix: reset cached vpid context on fork

In reply to a message not in the archive

Both patches merged into master, 2.10, 2.9, thanks!

Mathieu

Quoted 23 lines · ----- On Mar 2, 2018, at 5:36 PM, Michael Jeanson [email protected] wrote:

We currently reset the cached vtid on fork but not the vpid. This is not a problem on Linux because we don't cache the vpid internally but call getpid() directly and rely on the glibc pid cache.

---
liblttng-ust/lttng-ust-comm.c | 1 +

1 file changed, 1 insertion(+)
liblttng-ust/lttng-ust-comm.c +1 -1
index 4391446..d4add1c 100644
@@ -2011,6 +2011,7 @@ void ust_after_fork_child(sigset_t *restore_sigset)
 {
 	if (URCU_TLS(lttng_ust_nest_count))
 		return;
+	lttng_context_vpid_reset();
 	lttng_context_vtid_reset();
 	DBG("process %d", getpid());
 	/* Release urcu mutexes */
--

2.7.4

Signature · 7 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev