netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] Threads extension for process connector
@ 2024-09-20  0:09 Anjali Kulkarni
  2024-09-20  0:09 ` [PATCH net-next 1/2] connector/cn_proc: Handle threads for proc connector Anjali Kulkarni
  2024-09-20  0:09 ` [PATCH net-next 2/2] connector/cn_proc: Selftest for threads case Anjali Kulkarni
  0 siblings, 2 replies; 8+ messages in thread
From: Anjali Kulkarni @ 2024-09-20  0:09 UTC (permalink / raw)
  To: davem, Liam.Howlett
  Cc: edumazet, kuba, pabeni, oleg, akpm, axboe, brauner, mhocko,
	alexjlzheng, willy, michael.christie, linux-kernel, netdev, shuah,
	linux-kselftest, anjali.k.kulkarni, peili.io

Recently we committed a fix to allow processes to receive notifications for
non-zero exits via the process connector module. Commit is a4c9a56e6a2c.

However, for threads, when it does a pthread_exit(&exit_status) call, the
kernel is not aware of the exit status with which pthread_exit is called.
It is sent by child thread to the parent process, if it is waiting in
pthread_join(). Hence, for a thread exiting abnormally, kernel cannot
send notifications to any listening processes.

The exception to this is if the thread is sent a signal which it has not
handled, and dies along with it's process as a result; for eg. SIGSEGV or
SIGKILL. In this case, kernel is aware of the non-zero exit and sends a
notification for it.

For our use case, we cannot have parent wait in pthread_join, one of the
main reasons for this being that we do not want to track normal
pthread_exit(), which could be a very large number. We only want to be
notified of any abnormal exits. Hence, threads are created with
pthread_attr_t set to PTHREAD_CREATE_DETACHED.

To fix this problem, we add a new type PROC_CN_MCAST_NOTIFY to proc connector
API, which allows a thread to send it's exit status to kernel either when
it needs to call pthread_exit() with non-zero value to indicate some
error or from signal handler before pthread_exit().

Anjali Kulkarni (2):
  connector/cn_proc: Handle threads for proc connector
  connector/cn_proc: Selftest for threads case

 drivers/connector/cn_proc.c                   | 11 ++-
 include/linux/cn_proc.h                       |  5 +-
 include/uapi/linux/cn_proc.h                  |  4 +-
 kernel/exit.c                                 |  5 +-
 tools/testing/selftests/connector/Makefile    | 23 ++++-
 .../testing/selftests/connector/proc_filter.c |  5 +
 tools/testing/selftests/connector/thread.c    | 87 +++++++++++++++++
 .../selftests/connector/thread_filter.c       | 93 +++++++++++++++++++
 8 files changed, 226 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/connector/thread.c
 create mode 100644 tools/testing/selftests/connector/thread_filter.c

-- 
2.45.2


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

end of thread, other threads:[~2024-09-22  1:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-20  0:09 [PATCH net-next 0/2] Threads extension for process connector Anjali Kulkarni
2024-09-20  0:09 ` [PATCH net-next 1/2] connector/cn_proc: Handle threads for proc connector Anjali Kulkarni
2024-09-20 11:00   ` Oleg Nesterov
2024-09-20 15:42     ` Anjali Kulkarni
2024-09-20 18:44       ` Oleg Nesterov
2024-09-20 19:39         ` Anjali Kulkarni
2024-09-20  0:09 ` [PATCH net-next 2/2] connector/cn_proc: Selftest for threads case Anjali Kulkarni
2024-09-22  1:23   ` kernel test robot

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).