Re: [PATCH net-next v2 1/3] connector/cn_proc: Add hash table for threads

From: Anjali Kulkarni
Date: Tue Oct 15 2024 - 23:02:26 EST



[..snip..]

>> +void cn_hash_free_elem(struct uexit_pid_hnode *elem);
>> +int cn_hash_add_elem(struct cn_hash_dev *hdev, __u32 uexit_code, pid_t pid);
>> +int cn_hash_del_elem(struct cn_hash_dev *hdev, pid_t pid);
>> +__u32 cn_hash_del_get_exval(struct cn_hash_dev *hdev, pid_t pid);
>> +__u32 cn_hash_get_exval(struct cn_hash_dev *hdev, pid_t pid);
>> +
>
> Why are these here twice? Am I missing something?
>

Do you mean to say cn_hash_del_elem() and cn_hash_del_get_exval() ?
I can combine those 2 to both delete and get the exit value.
The cn_hash_get_exval() has to be separate, as it only gets the exit code.

> It also seems like a lot of these can be static inline and removed
> completely from the header as they are not used externally.
>
>> +bool cn_table_empty(void);
>> +bool cn_hash_table_empty(struct cn_hash_dev *hdev);
>> +
>> #endif /* __CONNECTOR_H */
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index e6ee4258169a..a2339ae6208b 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -1673,7 +1673,7 @@ extern struct pid *cad_pid;
>> #define PF_USED_MATH 0x00002000 /* If unset the fpu must be initialized before use */
>> #define PF_USER_WORKER 0x00004000 /* Kernel thread cloned from userspace thread */
>> #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */
>> -#define PF__HOLE__00010000 0x00010000
>> +#define PF_EXIT_NOTIFY 0x00010000 /* This thread has sent an exit value to be sent as a notification to listening processes */
>> #define PF_KSWAPD 0x00020000 /* I am kswapd */
>> #define PF_MEMALLOC_NOFS 0x00040000 /* All allocations inherit GFP_NOFS. See memalloc_nfs_save() */
>> #define PF_MEMALLOC_NOIO 0x00080000 /* All allocations inherit GFP_NOIO. See memalloc_noio_save() */
>> diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h
>> index 18e3745b86cd..2b12a24e4651 100644
>> --- a/include/uapi/linux/cn_proc.h
>> +++ b/include/uapi/linux/cn_proc.h
>> @@ -27,7 +27,8 @@
>> */
>> enum proc_cn_mcast_op {
>> PROC_CN_MCAST_LISTEN = 1,
>> - PROC_CN_MCAST_IGNORE = 2
>> + PROC_CN_MCAST_IGNORE = 2,
>> + PROC_CN_MCAST_NOTIFY = 3
>> };
>>
>> #define PROC_EVENT_ALL (PROC_EVENT_FORK | PROC_EVENT_EXEC | PROC_EVENT_UID | \
>> @@ -65,6 +66,7 @@ enum proc_cn_event {
>> struct proc_input {
>> enum proc_cn_mcast_op mcast_op;
>> enum proc_cn_event event_type;
>> + __u32 uexit_code;
>> };
>>
>> static inline enum proc_cn_event valid_event(enum proc_cn_event ev_type)
>> --
>> 2.46.0