connector/cn_proc: Performance improvements
authorAnjali Kulkarni <anjali.k.kulkarni@oracle.com>
Wed, 19 Jul 2023 20:18:19 +0000 (13:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 23 Jul 2023 10:34:22 +0000 (11:34 +0100)
commit743acf351bae1ff7ff4aaadd6a406d4d6091d90b
tree5f25faf64e85567493ed13529c490c4253742271
parent2aa1f7a1f47ce8dac7593af605aaa859b3cf3bb1
connector/cn_proc: Performance improvements

This patch adds the capability to filter messages sent by the proc
connector on the event type supplied in the message from the client
to the connector. The client can register to listen for an event type
given in struct proc_input.

This event based filteting will greatly enhance performance - handling
8K exits takes about 70ms, whereas 8K-forks + 8K-exits takes about 150ms
& handling 8K-forks + 8K-exits + 8K-execs takes 200ms. There are currently
9 different types of events, and we need to listen to all of them. Also,
measuring the time using pidfds for monitoring 8K process exits took
much longer - 200ms, as compared to 70ms using only exit notifications of
proc connector.

We also add a new event type - PROC_EVENT_NONZERO_EXIT, which is
only sent by kernel to a listening application when any process exiting,
has a non-zero exit status. This will help the clients like Oracle DB,
where a monitoring process wants notfications for non-zero process exits
so it can cleanup after them.

This kind of a new event could also be useful to other applications like
Google's lmkd daemon, which needs a killed process's exit notification.

The patch takes care that existing clients using old mechanism of not
sending the event type work without any changes.

cn_filter function checks to see if the event type being notified via
proc connector matches the event type requested by client, before
sending(matches) or dropping(does not match) a packet.

Signed-off-by: Anjali Kulkarni <anjali.k.kulkarni@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/connector/cn_proc.c
include/uapi/linux/cn_proc.h