<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><hr id="zwchr"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"草木秀" <39017736@qq.com><br><b>To: </b>"mathieu.desnoyers" <mathieu.desnoyers@efficios.com><br><b>Sent: </b>Friday, November 15, 2013 11:37:11 AM<br><b>Subject: </b>how does ust tracer map share lttng buffer<br><div><br></div><div>Hi,Mathieu</div><div><br></div><div>   After lttng sub-command enable-event is issued at first time, lttng-consumerd will be informed by lttng-sessiond to open and mmap share memory regions .Then lttng-sessiond get all shmfds from lttng-consumerd.But how does ust tracer map to these share memory regions?</div><div><br></div><div>  AFAIK,lttng-sessiond will call 
do_consumer_create_channel()  ,then send_channel_uid_to_ust(). What's confused me is in send_channel_uid_to_ust(),lttng-sessiond dup() one shmfd , then ust_consumer_send_stream_to_ust() to ust tracer, then close the shmfd and loop all shmfds. So all duped fds are the same fd-number (say A)and send to ust tracer through ust_consumer_send_stream_to_ust()->ustctl_send_stream_to_ust()->ustctl_send_stream()->ustcomm_send_fds_unix_sock()(unix socket is $HOME/.lttng/lttng-ust-sock-5).Why does it send the same fds to ust tracer?</div><div>  At ust tracer side,it calls handle_message()->ustcomm_recv_stream_from_sessiond() and mmap every received fd to share memory region.However,every received fd is different from A.So I must miss something anywhere.How does ust tracer map share lttng buffer?</div></blockquote><div><br></div><div>In lttng-sessiond, we send file descriptors for each posix SHM associated to every per-cpu buffer to the application over unix socket. So it's more or less : receive FD from consumer, send FD over unix socket to UST, close FD (we loop on this). Indeed, from a sessiond point of view, this will typically use the same FD number, but it's really associated with a different posix SHM each time. David can probably answer your question in more detail.<br></div><div><br></div><div>Thanks,<br></div><div><br></div><div>Mathieu<br></div><div><br></div><div><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div><br></div><div>PS:code is from lttng-2.3.0 .</div><div><br></div><div>Thanks</div><div>MuXiu.Cao</div><div><br></div></blockquote><div><br><br></div><div><br></div><div>-- <br></div><div><span name="x"></span>Mathieu Desnoyers<br>EfficiOS Inc.<br>http://www.efficios.com<span name="x"></span><br></div></div></body></html>