Skip to contentSkip to conversation

Thread safety of cobalt syslog/syslogv call

DISCUSSION François Legal 2 participants 6 messages Jul 1, 2024 – Jul 2, 2024

lore
Share & tools
lore
#0 lore raw

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Thanks

François

#1 lore raw
Quoted 4 lines · François Legal

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Can you be more precise in what you do? And which parts of lib/cobalt/printf.c you consider problematic /wrt thread safety, the printout to syslog or the wrapper functions themselves?

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#2 lore raw
Quoted 12 lines · Jan Kiszka
Quoted 4 lines · François Legal

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Can you be more precise in what you do? And which parts of lib/cobalt/printf.c you consider problematic /wrt thread safety, the printout to syslog or the wrapper functions themselves?

Jan

I have a set of threads that would each send to syslof under certain conditions. In my syslog, I can see a bunch of truncated log entries. I'd first though that maybe RT_PRINT_DEFAULT_BUFFER & RT_PRINT_DEFAULT_BUFFERS_COUNT would be too small in my application, but increasing those values did not make any differences. I ended up looking at the code and got to vprint_to_buffer that should be called when I want to send an entry to syslog in my RT threads, and was wondering (I believe it is not) whether or not this function was thread safe.
Am I getting something wrong ?

François

Quoted 4 lines

--
Siemens AG, Technology
Linux Expert Center

#3 lore raw
Quoted 12 lines · François Legal
Quoted 10 lines · Jan Kiszka
Quoted 4 lines · François Legal

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Can you be more precise in what you do? And which parts of lib/cobalt/printf.c you consider problematic /wrt thread safety, the printout to syslog or the wrapper functions themselves?

Quoted 6 lines
Quoted 2 lines

Jan

I have a set of threads that would each send to syslof under certain conditions. In my syslog, I can see a bunch of truncated log entries. I'd first though that maybe RT_PRINT_DEFAULT_BUFFER & RT_PRINT_DEFAULT_BUFFERS_COUNT would be too small in my application, but increasing those values did not make any differences. I ended up looking at the code and got to vprint_to_buffer that should be called when I want to send an entry to syslog in my RT threads, and was wondering (I believe it is not) whether or not this function was thread safe.
Am I getting something wrong ?

You application is supposed to call rt_syslog (& Co.) or regular syslog when wrapped to map that on the RT version (analogously to other cobalt services). Internally, those are mapped on vprint_to_buffer, true, and that is supposed to be thread-safe - it operates on per-thread data structures and lock-free in a single-producer/single-consumer relationship with the printer thread.

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center
#4 lore raw
Quoted 20 lines · Jan Kiszka
Quoted 12 lines · François Legal
Quoted 10 lines · Jan Kiszka
Quoted 4 lines · François Legal

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Can you be more precise in what you do? And which parts of lib/cobalt/printf.c you consider problematic /wrt thread safety, the printout to syslog or the wrapper functions themselves?

Quoted 6 lines
Quoted 2 lines

Jan

I have a set of threads that would each send to syslof under certain conditions. In my syslog, I can see a bunch of truncated log entries. I'd first though that maybe RT_PRINT_DEFAULT_BUFFER & RT_PRINT_DEFAULT_BUFFERS_COUNT would be too small in my application, but increasing those values did not make any differences. I ended up looking at the code and got to vprint_to_buffer that should be called when I want to send an entry to syslog in my RT threads, and was wondering (I believe it is not) whether or not this function was thread safe.
Am I getting something wrong ?

Quoted 7 lines

You application is supposed to call rt_syslog (& Co.) or regular syslog when wrapped to map that on the RT version (analogously to other cobalt services). Internally, those are mapped on vprint_to_buffer, true, and that is supposed to be thread-safe - it operates on per-thread data structures and lock-free in a single-producer/single-consumer relationship with the printer thread.

Thanks for the clarification. I misread the pthread_getspecific manual !
So if I understand correctly, my truncated log problem should only be a matter of how large the vprint_to_buffer buffer is, as my non RT log never seem to get truncated. I'll take a look into that.
This code is built in libcobalt, so that the only piece I need to rebuild to enlarge these buffers ? Correct ?

Thanks

François

Quoted 6 lines

Jan

--
Siemens AG, Technology
Linux Expert Center

#5 lore raw
Quoted 30 lines · François Legal
Quoted 20 lines · Jan Kiszka
Quoted 12 lines · François Legal
Quoted 10 lines · Jan Kiszka
Quoted 4 lines · François Legal

Hello,

I was wondering whether or not the syslog/vsyslog calls in cobalt runtime libs are thread safe. I observer strange behaviour in my logs under heavy log load.

Can you be more precise in what you do? And which parts of lib/cobalt/printf.c you consider problematic /wrt thread safety, the printout to syslog or the wrapper functions themselves?

Quoted 6 lines
Quoted 2 lines

Jan

I have a set of threads that would each send to syslof under certain conditions. In my syslog, I can see a bunch of truncated log entries. I'd first though that maybe RT_PRINT_DEFAULT_BUFFER & RT_PRINT_DEFAULT_BUFFERS_COUNT would be too small in my application, but increasing those values did not make any differences. I ended up looking at the code and got to vprint_to_buffer that should be called when I want to send an entry to syslog in my RT threads, and was wondering (I believe it is not) whether or not this function was thread safe.
Am I getting something wrong ?

Quoted 7 lines

You application is supposed to call rt_syslog (& Co.) or regular syslog when wrapped to map that on the RT version (analogously to other cobalt services). Internally, those are mapped on vprint_to_buffer, true, and that is supposed to be thread-safe - it operates on per-thread data structures and lock-free in a single-producer/single-consumer relationship with the printer thread.

Quoted 5 lines

Thanks for the clarification. I misread the pthread_getspecific manual !
So if I understand correctly, my truncated log problem should only be a matter of how large the vprint_to_buffer buffer is, as my non RT log never seem to get truncated. I'll take a look into that.
This code is built in libcobalt, so that the only piece I need to rebuild to enlarge these buffers ? Correct ?

You can just call rt_print_init() (rather than relying on implicit initialization) and provide a different buffer size along it.

And if that works, feel free to contribute inline documentation for that function - you had no real fair chance to find that interface :)

Jan

Signature · 2 lines
Siemens AG, Technology
Linux Expert Center