Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] how does ust tracer map share lttng buffer
       [not found] <tencent_4B722D17200DC9B17B45EFF3@qq.com>
@ 2013-11-15 17:06 ` Mathieu Desnoyers
       [not found]   ` <tencent_778EC52B229ABB7013AB0416@qq.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Desnoyers @ 2013-11-15 17:06 UTC (permalink / raw)


----- Original Message -----

> From: "???" <39017736@qq.com>
> To: "mathieu.desnoyers" <mathieu.desnoyers at efficios.com>
> Sent: Friday, November 15, 2013 11:37:11 AM
> Subject: how does ust tracer map share lttng buffer

> Hi,Mathieu

> 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?

> 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?
> 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?

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. 

Thanks, 

Mathieu 

> PS:code is from lttng-2.3.0 .

> Thanks
> MuXiu.Cao

-- 
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131115/3b598b1c/attachment.html>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [lttng-dev] 回复: how does ust tracer map share lttng buffer
       [not found]   ` <tencent_778EC52B229ABB7013AB0416@qq.com>
@ 2013-11-16 13:42     ` David Goulet
  0 siblings, 0 replies; 2+ messages in thread
From: David Goulet @ 2013-11-16 13:42 UTC (permalink / raw)


On 16 Nov (07:18:45), ??? wrote:
> >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.
> 
> 
>   Yes,what confused me the most is that sessiond sends the same FD number to UST every time,but UST receives the different FD number each time and can map it to the right per-cpu share buffer sucessfully.

Yes, in per UID buffers, for every application using UST we send the FD
corresponding to the already allocated buffer (being per UID).

Please note that sending a FD through a Unix socket dups it so basically
UST receives that, access the shared memory buffer and can then operate
correctly.

Cheers!
David

> 
> 
> Thanks
> MuXiu.Cao
> 
> 
> 
> 
> 
> From: "???" <39017736@qq.com>
> To: "mathieu.desnoyers" <mathieu.desnoyers at efficios.com>
> Sent: Friday, November 15, 2013 11:37:11 AM
> Subject: how does ust tracer map share lttng buffer
> 
> 
> Hi,Mathieu
> 
> 
>    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?
> 
> 
>   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?
>   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?
> 
> 
> 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.
> 
> 
> 
> Thanks,
> 
> 
> 
> Mathieu
> 
> 
> 
> 
> 
> 
> 
> PS:code is from lttng-2.3.0 .
> 
> 
> Thanks
> MuXiu.Cao
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> Mathieu Desnoyers
> EfficiOS Inc.
> http://www.efficios.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: Digital signature
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20131116/afbf97a4/attachment.pgp>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-16 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_4B722D17200DC9B17B45EFF3@qq.com>
2013-11-15 17:06 ` [lttng-dev] how does ust tracer map share lttng buffer Mathieu Desnoyers
     [not found]   ` <tencent_778EC52B229ABB7013AB0416@qq.com>
2013-11-16 13:42     ` [lttng-dev] 回复: " David Goulet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox