All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v6 0/3] Threads support in proc connector
@ 2024-10-23 16:20 Anjali Kulkarni
  2024-10-23 16:20 ` [PATCH net-next v6 1/3] connector/cn_proc: Add hash table for threads Anjali Kulkarni
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anjali Kulkarni @ 2024-10-23 16:20 UTC (permalink / raw)
  To: davem, Liam.Howlett
  Cc: edumazet, kuba, pabeni, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, rostedt, bsegall, mgorman,
	vschneid, jiri, linux-kernel, netdev, akpm, brendan.higgins,
	davidgow, rmoar, johannes.berg, mic, gnoack, jk, kunit-dev, 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().

v5->v6 changes:
- As suggested by Simon Horman, fixed style issues (some old) by running
  ./scripts/checkpatch.pl --strict --max-line-length=80
- Removed inline functions as suggested by Simon Horman
- Added "depends on" in Kconfig.debug as suggested by Stanislav Fomichev
- Removed warning while compilation with kernel space headers as
  suggested by Simon Horman
- Removed "comm" field, will send separate patch for this.
- Added kunit configs in tools/testing/kunit/configs/all_tests.config
  with it's dependencies.

v4->v5 changes:
- Handled comment by Stanislav Fomichev to fix a print format error.
- Made thread.c completely automated by starting proc_filter program
  from within threads.c.
- Changed name CONFIG_CN_HASH_KUNIT_TEST to CN_HASH_KUNIT_TEST in
  Kconfig.debug and changed display text.

v3->v4 changes:
- Reduce size of exit.log by removing unnecessary text.

v2->v3 changes:
- Handled comment by Liam Howlett to set hdev to NULL and add comment on
  it.
- Handled comment by Liam Howlett to combine functions for deleting+get
  and deleting into one in cn_hash.c
- Handled comment by Liam Howlett to remove extern in the functions
  defined in cn_hash_test.h
- Some nits by Liam Howlett fixed.
- Handled comment by Liam Howlett to make threads test automated.
  proc_filter.c creates exit.log, which is read by thread.c and checks
  the values reported.
- Added "comm" field to struct proc_event, to copy the task's name to
  the packet to allow further filtering by packets.

v1->v2 changes:
- Handled comment by Peter Zijlstra to remove locking for PF_EXIT_NOTIFY
  task->flags.
- Added error handling in thread.c

v->v1 changes:
- Handled comment by Simon Horman to remove unused err in cn_proc.c
- Handled comment by Simon Horman to make adata and key_display static
  in cn_hash_test.c

Anjali Kulkarni (3):
  connector/cn_proc: Add hash table for threads
  connector/cn_proc: Kunit tests for threads hash table
  connector/cn_proc: Selftest for threads

 drivers/connector/Makefile                    |   2 +-
 drivers/connector/cn_hash.c                   | 216 ++++++++++++++++
 drivers/connector/cn_proc.c                   |  81 ++++--
 drivers/connector/connector.c                 |  88 ++++++-
 include/linux/connector.h                     |  62 ++++-
 include/linux/sched.h                         |   2 +-
 include/uapi/linux/cn_proc.h                  |   4 +-
 lib/Kconfig.debug                             |  19 ++
 lib/Makefile                                  |   1 +
 lib/cn_hash_test.c                            | 169 +++++++++++++
 lib/cn_hash_test.h                            |  10 +
 tools/testing/kunit/configs/all_tests.config  |   5 +
 tools/testing/selftests/connector/Makefile    |  25 ++
 .../testing/selftests/connector/proc_filter.c |  63 +++--
 tools/testing/selftests/connector/thread.c    | 238 ++++++++++++++++++
 .../selftests/connector/thread_filter.c       |  96 +++++++
 16 files changed, 1027 insertions(+), 54 deletions(-)
 create mode 100644 drivers/connector/cn_hash.c
 create mode 100644 lib/cn_hash_test.c
 create mode 100644 lib/cn_hash_test.h
 create mode 100644 tools/testing/selftests/connector/thread.c
 create mode 100644 tools/testing/selftests/connector/thread_filter.c

-- 
2.46.0


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

end of thread, other threads:[~2024-10-31  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 16:20 [PATCH net-next v6 0/3] Threads support in proc connector Anjali Kulkarni
2024-10-23 16:20 ` [PATCH net-next v6 1/3] connector/cn_proc: Add hash table for threads Anjali Kulkarni
2024-10-31  0:57   ` Jakub Kicinski
2024-10-23 16:20 ` [PATCH net-next v6 2/3] connector/cn_proc: Kunit tests for threads hash table Anjali Kulkarni
2024-10-23 16:20 ` [PATCH net-next v6 3/3] connector/cn_proc: Selftest for threads Anjali Kulkarni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.