Re: LTTng + dynamick tick

Mathieu Desnoyers <[email protected]>
Newsgroups gmane.linux.kernel.tracing
Message-ID <20061005170928.GB11149@Krystal>
Hi Thomas,

* Thomas Gleixner ([email protected]) wrote:
> > So, over all, I think we could switch to hrtimers for architectures which lack
> > proper synchronized TSC support, but with the seqlock tweaks I just mentioned.
> 
> These tweaks are horrible without having seen them.
> 

They look like :
static inline u32 ltt_get_timestamp32(void)
{
        unsigned long seq;
        unsigned long try = 5;
        u32 ret;

        do {
                seq = read_seqbegin(&xtime_lock);
                ret = (jiffies << LTTNG_LOGICAL_SHIFT)
                        | (atomic_add_return(1, &lttng_logical_clock));
        } while(read_seqretry(&xtime_lock, seq) && (--try) > 0);

        if(try == 0)
                return 0;
        else
                return ret;
}

> The only way you can deadlock is when you are inside a section which
> holds xtime_lock. So in your locking path all you need is:
> 
> 	if (!is_writelocked_seqlock(&xtime_lock))
> 		now = ktime_get();
> 	else
> 		now = (ktime_t) {.tv64 = 0 };
> 
> and in seqlock.h
> 
> static inline int is_writelocked_seqlock(struct seqlock *sl)
> {
> 	return spin_is_locked(&sl->lock);
> }
> 
> You may get some false positives, but this should not matter much.
> 

The problem with your approach is that there will be a lot of false positives
on SMP systems. The problem of NMI nested over a write lock is rare and we
should not create false positives by the way we handle it.

The other way around would be to rework the xtime and wall_to_monotonic values
so they would use a pointer to an array and make the update atomic (a preempt
disable is needed for the reader). I have done such tricks in ltt-heartbeat.c.
It would have to be investigated to see if it could be applied to get rid of
the seqlock.

Mathieu


OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.