Re: [patch 01/15] Kernel Tracepoints

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mathieu Desnoyers
Date: Tuesday, July 15, 2008 - 6:25 am

* Peter Zijlstra (peterz@infradead.org) wrote:

Hi Peter,

Thanks for the review,


Yes, given that I started from the marker code as a base, I did not
re-explain everything that wasn't changed from those. I guess it's good
to give more details about this though. I'll address this.


Thanks, let's looks at them,


Yes, I though there would be an optimization to do here, I'll use your
proposal. This code snippet is especially important since it will
generate instructions near every tracepoint side. Saving a few bytes
becomes important.

Given that (tp)->funcs references an array of function pointers and that
it can be NULL, the if (funcs) test must still be there and we must use

#define __DO_TRACE(tp, proto, args)					\
	do {								\
		void *func;						\
									\
		preempt_disable();					\
		if ((tp)->funcs) {					\
			func = rcu_dereference((tp)->funcs);		\
			for (; func; func++) {				\
				((void(*)(proto))(func))(args);		\
			}						\
		}							\
		preempt_enable();					\
	} while (0)


The resulting assembly is a bit more dense than my previous
implementation, which is good :

On x86_64 :

 820:   bf 01 00 00 00          mov    $0x1,%edi
 825:   e8 00 00 00 00          callq  82a <thread_return+0x136>
 82a:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 831 <thread_retur
n+0x13d>
 831:   48 85 c0                test   %rax,%rax
 834:   74 22                   je     858 <thread_return+0x164>
 836:   48 8b 18                mov    (%rax),%rbx
 839:   48 85 db                test   %rbx,%rbx
 83c:   74 1a                   je     858 <thread_return+0x164>
 83e:   66 90                   xchg   %ax,%ax
 840:   48 8b 95 68 ff ff ff    mov    -0x98(%rbp),%rdx
 847:   48 8b b5 60 ff ff ff    mov    -0xa0(%rbp),%rsi
 84e:   4c 89 e7                mov    %r12,%rdi
 851:   ff d3                   callq  *%rbx
 853:   48 ff c3                inc    %rbx
 856:   75 e8                   jne    840 <thread_return+0x14c>
 858:   bf 01 00 00 00          mov    $0x1,%edi
 85d:   e8 00 00 00 00          callq  862 <thread_return+0x16e>
 862:

For 66 bytes (a 2 arguments tracepoint). Note that these bytes are
outside of the critical path in an unlikely branch. The branch test
bytes have been discussed thoroughly in the "Immediate Values" work,
which can be seen as an optimisation to be integrated later.

The current branch code added to the critical path is, on x86_64 :

 5ff:   b8 00 00 00 00          mov    $0x0,%eax
 604:   85 c0                   test   %eax,%eax
 606:   0f 85 14 02 00 00       jne    820 <thread_return+0x12c>

The immediate values can make this smaller by using a 2-bytes movb
instructions to populate eax, which would save 3 bytes of cache-hot
cachelines.


Addition and removal of tracepoints is synchronized by RCU using the
scheduler (and preempt_disable) as guarantees to find a quiescent state
(this is really RCU "classic"). The update side uses rcu_barrier_sched()
with call_rcu_sched() and the read/execute side uses
"preempt_disable()/preempt_enable()".



Yes, it does. We make sure the previous array containing probes, which
has been scheduled for deletion by the rcu callback, is indeed freed
before we proceed to the next update. It therefore limits the rate of
modification of a single tracepoint to one update per RCU period. The
objective here is to permit fast batch add/removal of probes on
_different_ tracepoints.

This use of "synchronize_sched()" can be changed for call_rcu_sched() in
linux-next, I'll fix this.



good point.


Yes.


Good point. I'll then remove the wmb, and change the
smp_read_barrier_depends for a rcu_dereference in __DO_TRACE. It will
make things clearer.

The comments becomes :

        /*
         * rcu_assign_pointer has a smp_wmb() which makes sure that the new
         * probe callbacks array is consistent before setting a pointer to it.
         * This array is referenced by __DO_TRACE from
         * include/linux/tracepoints.h. A matching rcu_dereference() is used.
         */

I'll release a new version including those changes shortly,

Thanks,

Mathieu


-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Wed Jul 9, 7:59 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 12:50 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 6:25 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 6:59 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 7:03 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 7:27 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 7:42 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 7:46 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 8:13 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 8:22 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 8:31 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 8:50 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 9:08 am)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 9:25 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 9:26 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 9:51 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 10:50 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 11:22 am)
Re: [patch 01/15] Kernel Tracepoints, Steven Rostedt, (Tue Jul 15, 11:33 am)
Re: [patch 01/15] Kernel Tracepoints, Masami Hiramatsu, (Tue Jul 15, 11:52 am)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 12:02 pm)
Re: [patch 01/15] Kernel Tracepoints, Mathieu Desnoyers, (Tue Jul 15, 12:08 pm)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Tue Jul 15, 12:52 pm)
Re: [patch 01/15] Kernel Tracepoints, Paul E. McKenney, (Fri Aug 1, 2:10 pm)
Re: [patch 01/15] Kernel Tracepoints, Paul E. McKenney, (Fri Aug 1, 2:10 pm)
Re: [patch 01/15] Kernel Tracepoints, Paul E. McKenney, (Fri Aug 1, 2:10 pm)
Re: [patch 01/15] Kernel Tracepoints, Paul E. McKenney, (Fri Aug 1, 2:10 pm)
Re: [patch 01/15] Kernel Tracepoints, Peter Zijlstra, (Fri Aug 1, 5:03 pm)
Re: [patch 01/15] Kernel Tracepoints, Paul E. McKenney, (Fri Aug 1, 5:17 pm)