lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org>
To: lbj <lbj137@yahoo.com>
Cc: lttng-dev <lttng-dev@lists.lttng.org>, paulmck <paulmck@kernel.org>
Subject: Re: [lttng-dev] QSBR urcu question
Date: Tue, 6 Apr 2021 16:05:54 -0400 (EDT)	[thread overview]
Message-ID: <1546175211.59087.1617739554450.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <13D87E55-7D1B-49B0-9555-656A837ADEB3@yahoo.com>

----- On Apr 5, 2021, at 1:43 PM, lttng-dev lttng-dev@lists.lttng.org wrote:

> Hello all,
> 
> I am using the QSBR flavor of URCU and I have a question: is it ok to call
> rcu_register_thread more than once per thread?

Yes, but you should unregister before registering again.

> Similarly, is it ok to call
> rcu_unregister_thread more than once per thread?

Likewise: you should not have 2 unregistrations back-to-back without a
registration in between.

Note however that frequent registration/unregistration of a thread can lead to
significant performance overhead and lock contention on the rcu_registry_lock,
which is likely something you will want to avoid.

> I am using a library that uses
> a threadpool I have no control over. A thread from its threadpool invokes a
> callback function of mine. Threads may be reused. I would like to call
> rcu_register_thread at the beginning of my callback and rcu_unregister_thread
> at the end. The thread in question may exit or may be reused at some later
> point, I have no control over that. So I want to make sure that periodically
> registering and unregistering the same thread is ok. Thanks for any
> information.

You may want to use the "urcu-bp" flavor instead. It has a slightly higher
overhead than qsbr, but won't require as much fine-tuned integration with the
threadpool runtime.

But if you really want to do an efficient integration of urcu-qsbr with the threadpool
without changing any of the threadpool, here are a few ideas though:

- you could keep a "qsbr_registered" state in a TLS variable owned by your application,
- lazily perform qsbr registration if needed, based on the "qsbr_registered" state,
- put thread "offline" before returning control to the threadpool,
- put thread "online" when entering your code again,
- if the threadpool can call your application before the thread exits, then use that
  to unregister qsbr. Else, you could always use a dummy pthread key to have an application
  destructor called on thread exit, and unregister qsbr that way,

Hoping this help!

Best regards,

Mathieu

> 
> Jeff
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2021-04-06 20:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <13D87E55-7D1B-49B0-9555-656A837ADEB3.ref@yahoo.com>
2021-04-05 17:43 ` [lttng-dev] QSBR urcu question lbj via lttng-dev
2021-04-06 20:05   ` Mathieu Desnoyers via lttng-dev [this message]
2021-04-14  3:19     ` [lttng-dev] QSBR urcu read lock question lbj via lttng-dev
2021-04-15 12:20       ` Mathieu Desnoyers via lttng-dev
2021-04-15 12:41         ` lbj via lttng-dev
2021-04-15 13:04           ` Mathieu Desnoyers via lttng-dev
2021-04-15 14:54             ` lbj via lttng-dev
2021-04-15 16:00               ` Mathieu Desnoyers via lttng-dev
2021-04-15 18:11                 ` lbj via lttng-dev
2021-04-15 19:26                   ` Mathieu Desnoyers via lttng-dev
2021-04-15 20:58                     ` lbj via lttng-dev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1546175211.59087.1617739554450.JavaMail.zimbra@efficios.com \
    --to=lttng-dev@lists.lttng.org \
    --cc=lbj137@yahoo.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).