linux-um archives
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Tiwei Bie <tiwei.btw@antgroup.com>,
	richard@nod.at,  anton.ivanov@cambridgegreys.com
Cc: linux-um@lists.infradead.org
Subject: Re: [PATCH v2 1/4] um: Add pthread-based helper support
Date: Wed, 19 Mar 2025 10:11:18 +0100	[thread overview]
Message-ID: <91bdd4a1200950bf26d3cbe1a42cf1beb913a153.camel@sipsolutions.net> (raw)
In-Reply-To: <20250306150747.2926434-2-tiwei.btw@antgroup.com>

On Thu, 2025-03-06 at 23:07 +0800, Tiwei Bie wrote:
> Introduce a new set of utility functions that can be used to create
> pthread-based helpers. Helper threads created in this way will ensure
> thread safety for errno while sharing the same memory space.

I'm not sure at the moment exactly what the issue is, but with the next
patch, I cannot shut down cleanly.

> +void os_kill_helper_thread(struct os_helper_thread *td)
> +{
> +	pthread_kill(td->handle, SIGKILL);

This ends up killing everything.

I thought maybe it's because all the signals are blocked:

> +int os_run_helper_thread(struct os_helper_thread **td_out,
> +			 void *(*routine)(void *), void *arg)
> +{
> [...]
> +	sigfillset(&sigset);
> +	if (sigprocmask(SIG_SETMASK, &sigset, &oset) < 0) {
> +		err = -errno;
> +		kfree(td);
> +		return err;
> +	}
> +
> +	err = pthread_create(&td->handle, NULL, routine, arg);

but removing SIGKILL from that set doesn't make a difference, and
perhaps this should be using pthread_sigmask(), e.g. if glibc doesn't
retrieve the values from the kernel but uses the ones last set by that
function?

Anyway, the issue is I cannot shut down, I get:

reboot: Power down
Killed

and the terminal isn't cleaned up, i.e. shutdown code isn't run.

Please check :)

johannes


  parent reply	other threads:[~2025-03-19  9:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 15:07 [PATCH v2 0/4] um: Make errno multi-thread safe Tiwei Bie
2025-03-06 15:07 ` [PATCH v2 1/4] um: Add pthread-based helper support Tiwei Bie
2025-03-18 13:06   ` Johannes Berg
2025-03-18 13:16     ` Johannes Berg
2025-03-18 14:55       ` Tiwei Bie
2025-03-25 16:31         ` Benjamin Berg
2025-03-26  6:30           ` Tiwei Bie
2025-03-18 15:00     ` Tiwei Bie
2025-03-19  9:11   ` Johannes Berg [this message]
2025-03-19 12:07     ` Tiwei Bie
2025-03-06 15:07 ` [PATCH v2 2/4] um: ubd: Switch to the pthread-based helper Tiwei Bie
2025-03-06 15:07 ` [PATCH v2 3/4] um: Switch to the pthread-based helper in sigio workaround Tiwei Bie
2025-03-06 15:07 ` [PATCH v2 4/4] um: Prohibit the VM_CLONE flag in run_helper_thread() Tiwei Bie

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=91bdd4a1200950bf26d3cbe1a42cf1beb913a153.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=tiwei.btw@antgroup.com \
    /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