Skip to content

Detect process exit through the chardev's ->release instead of the sched_process_exit probe #1610

Open

Description

@Koichi98

Process death is currently detected by a sched_process_exit probe filtered on is_agnocast_pid() (agnocast_kmod/agnocast_internal.c:239-248), a hand-built substitute for what a chardev ->release gives for free, and it costs an atomic read plus an RCU hash lookup on every process exit on the machine, agnocast-related or not. Driving cleanup from ->release on /dev/agnocast instead (the fops has only .unlocked_ioctl today, agnocast_kmod/agnocast_init.c:19-22) would delete the probe and the filter, and would remove the pid-reuse reasoning that every pid-keyed table in the module currently carries; the ring buffer and worker kthread stay, with ->release replacing the probe as what feeds them.

The blocker is that the file's lifetime is not the process's: agnocast_fd is opened without O_CLOEXEC (src/agnocastlib/src/agnocast.cpp:533) and every daemon child reuses the inherited descriptor rather than reopening (:180, :208, :297), so one struct file is shared by the application and all three of its daemons — a naive .release would never fire for an application process while its unlink daemon, which lives as long as the IPC namespace, still holds it. Making the file per-process (O_CLOEXEC plus a reopen in each child) is therefore a prerequisite.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions