[ltt-dev] (forw) [chris.meyers.fsu at gmail.com: Re: ltt channel thread safe?]
Mathieu Desnoyers
compudj at krystal.dyndns.org
Fri Aug 27 13:01:58 EDT 2010
* Fu Juntang(David) (juntang.fu at windriver.com) wrote:
> Hi,Mathieu:
> has the issue any update?
>
> please see my test case and the trace logs(in the attachment), from
> the trace log,we can see we can only see the trace datas from cpu_0:
> ust.myevent: 18161.506516049
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 2 }
> ust.myevent: 18163.506594856
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 3 }
> ust.myevent: 18165.506667869
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 5 }
> ust.myevent: 18167.506735881
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 7 }
> ust.myevent: 18169.506818732
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 8 }
> ust.myevent: 18171.506903062
> (/home/Large_Space/Part_B/LogStore/LTTngLog_wrlinux-4.0/UST/UST_Logs/multi-thread/david-desktop-20100811163524864824113/11520_5504068123890634635/ust_0), 0, 0, , , 0, 0x0, MODE_UNKNOWN { firstthread = 10 }
> End trace set
>
> we missed the trace logs:
> trace_mark(ust, myevent, "secondthread %d", number);
Oh, you created two events with same channel and same name, but with a
different first parameter name. This should be forbidden. UST should
take care of checking for these duplicate markers with non-matching
parameters.
libust marker.c is checking for this, as it should:
static int set_marker(struct marker_entry *entry, struct marker *elem,
int active)
{
int ret = 0;
WARN_ON(strcmp(entry->name, elem->name) != 0);
if (entry->format) {
if (strcmp(entry->format, elem->format) != 0) {
DBG("Format mismatch for probe %s (%s), marker (%s)",
entry->name,
entry->format,
elem->format);
return -EPERM;
}
} else {
Pierre-Marc, why it this only showing the warning if UST_DEBUG is
defined ? This should always spit out the warning.
Thanks,
Mathieu
>
> thanks
>
> --Juntang Fu(David)
>
> On Fri, 2010-08-13 at 08:24 -0400, Mathieu Desnoyers wrote:
> > * Fu Juntang(David) (juntang.fu at windriver.com) wrote:
> > > Hi,Mathieu:
> > > Please see my answer inline:
> > >
> > > On Thu, 2010-08-12 at 09:40 -0400, Mathieu Desnoyers wrote:
> > > > * Fu Juntang(David) (juntang.fu at windriver.com) wrote:
> > > > > Hi,Mathieu:
> > > > > I have found another UST bug in this multi-thread functions:
> > > > > in my SMP host(2 cpu cores),I have found that UST can only collect one
> > > > > thread trace logs running one core(CPU_1),but can not collect the
> > > > > other thread trace logs running another core(CPU_0),is this a known
> > > > > bug?
> > > > > if you need my debug logs, I can attach it to you.
> > > >
> > [...]
> > > > Can you try putting a printf in
> > > >
> > > > ust/libust/buffer.c: get_n_cpus() to see how many CPUs the library
> > > > detects ?
> > > >
> > > yes,sure, the output says that it detects 2 cpus
> > >
> > > > What does your usttrace directory looks like ? (the subdir containing
> > > > the ust and metadata files... with ls -al)
> > > >
> > > total 24
> > > drwxr-xr-x 2 david david 4096 2010-08-13 15:30 .
> > > drwxr-xr-x 3 david david 4096 2010-08-13 15:30 ..
> > > -rw------- 1 david david 4096 2010-08-13 15:30 metadata_0
> > > -rw------- 1 david david 4096 2010-08-13 15:30 metadata_1
> > > -rw------- 1 david david 4096 2010-08-13 15:30 ust_0
> > > -rw------- 1 david david 4096 2010-08-13 15:30 ust_1
> > >
> >
> > It all looks fine so far. Note that the Linux scheduler can decide to
> > schedule your 2 threads on the same CPU. How do you detect that there is
> > a "problem": is it that events you are writing from a specific thread
> > are missing or that you expect events on CPU 1 and don't have any ?
> >
> > The latter case could be normal.
> >
> > Thanks,
> >
> > Mathieu
> >
>
> #include<stdio.h>
> #include<pthread.h>
> #include<sys/time.h>
> #include<string.h>
>
> #include <ust/marker.h>
>
> #define _GNU_SOURCE
> #include <utmpx.h>
>
> #define MAX 10
>
> pthread_t thread[2];
> pthread_mutex_t mut;
>
> int number=0,i;
>
> void thread1()
> {
> int cpu;
>
> cpu = sched_getcpu();
> printf("thread1:I'm thread 1 and cpu is: %d\n", cpu);
> for(i=0;i<MAX;i++)
> {
> pthread_mutex_lock(&mut);
> number++;
> trace_mark(ust, myevent, "firstthread %d", number);
> pthread_mutex_unlock(&mut);
> //trace_mark(ust, myevent, "firstthread %d", number);
> sleep(2);
> }
> pthread_exit(NULL);
> }
> void *thread2()
> {
> int cpu ;
>
> cpu = sched_getcpu();
> printf("thread2:I'm thread2 and cpu is:%d\n", cpu);
> for(i=0;i<MAX;i++)
> {
> pthread_mutex_lock(&mut);
> number++;
> trace_mark(ust, myevent, "secondthread %d", number);
> pthread_mutex_unlock(&mut);
> //trace_mark(ust, myevent, "secondthread %d", number);
> sleep(3);
> }
> pthread_exit(NULL);
> }
> void thread_create(void)
> {
> int temp;
> memset(&thread,0,sizeof(thread));
>
> if((temp=pthread_create(&thread[0],NULL,thread1,NULL))!=0)
> printf("thread 1 create failed!\n");
> else
> if((temp=pthread_create(&thread[1],NULL,thread2,NULL))!=0)
> printf("thead 2 created failed!\n");
> }
> void thread_wait(void)
> {
> if(thread[0]!=0)
> {
> pthread_join(thread[0],NULL);
> }
> if(thread[1]!=0)
> {
> pthread_join(thread[1],NULL);
> }
> }
> int main()
> {
> pthread_mutex_init(&mut,NULL);
> thread_create();
> thread_wait();
> return 0;
> }
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list