Skip to contentSkip to conversation

how does ust tracer map share lttng buffer

DISCUSSION Mathieu Desnoyers 2 participants 2 messages Nov 15, 2013 – Nov 16, 2013 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

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

Quoted 12 lines

From: "草木秀" <[email protected]>
To: "mathieu.desnoyers" <[email protected]>
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?

Quoted 14 lines

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

Quoted 4 lines

PS:code is from lttng-2.3.0 .

Thanks
MuXiu.Cao

Signature · 3 lines
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 4 lines · 草木秀
Quoted 1 line

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

Quoted 41 lines

Thanks
MuXiu.Cao

From: "草木秀" <[email protected]>
To: "mathieu.desnoyers" <[email protected]>
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

Quoted 17 lines

PS:code is from lttng-2.3.0 .

Thanks
MuXiu.Cao

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev