lttng-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [lttng-dev] URCU background threads vs signalfd
@ 2022-09-22  9:15 Eric Wong via lttng-dev
  2022-09-23 15:57 ` Mathieu Desnoyers via lttng-dev
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Wong via lttng-dev @ 2022-09-22  9:15 UTC (permalink / raw)
  To: lttng-dev

Hello, I'm using urcu-bp + rculfhash + call_rcu to implement
malloc instrumentation (via LD_PRELOAD) on an existing
single-threaded Perl codebase which uses Linux signalfd.

signalfd depends on signals being blocked in all threads
of the process, otherwise threads with unblocked signals
can receive them and starve the signalfd.

While some threads in URCU do block signals (e.g. workqueue
worker for rculfhash), the call_rcu thread and rculfhash
partition_resize_helper threads do not...

Should all threads URCU creates block signals (aside from SIGRCU)?

There might be other places, too, I haven't looked too closely...

Anyways, I'm currently relying on this workaround to ensure
initial calls to call_rcu and cds_lfht_resize are run with
signals blocked:

/* error-checking omitted for brevity */
__attribute__((constructor)) static void my_ctor(void)
{
	sigset_t set, old;
	struct foo_hdr *h;

	sigfillset(&set);
	pthread_sigmask(SIG_SETMASK, &set, &old);

	g_tbl = cds_lfht_new(8192, 1, 0, CDS_LFHT_AUTO_RESIZE, 0);

	h = malloc(sizeof(struct foo_hdr)));
	if (h) /* force call_rcu to start background thread */
		call_rcu(&h->as.dead, free_foo_hdr_rcu);

	/* start more background threads before unblocking signals */
	cds_lfht_resize(g_tbl, 16384);

	pthread_sigmask(SIG_SETMASK, &old, NULL);
}

But I suspect it's better to ensure signals are blocked in all
URCU-created threads...

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

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

end of thread, other threads:[~2022-09-26 20:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-22  9:15 [lttng-dev] URCU background threads vs signalfd Eric Wong via lttng-dev
2022-09-23 15:57 ` Mathieu Desnoyers via lttng-dev
2022-09-23 17:55   ` Eric Wong via lttng-dev
2022-09-23 18:24     ` Mathieu Desnoyers via lttng-dev
2022-09-23 22:05       ` Eric Wong via lttng-dev
2022-09-26 12:51         ` Mathieu Desnoyers via lttng-dev
2022-09-26 19:58           ` Eric Wong via lttng-dev
2022-09-26 20:12             ` Mathieu Desnoyers via lttng-dev

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