struct pid
{
refcount_t count;
unsigned int level;
spinlock_t lock;
/* lists of tasks that use this pid */
struct hlist_head tasks[PIDTYPE_MAX];
struct hlist_head inodes;
/* wait queue for pidfd notifications */
wait_queue_head_t wait_pidfd;
struct rcu_head rcu;
struct upid numbers[1];
};
I suspect that part of the reason for this is so that a single struct pid is a valid level-0 pid, without needing a complementary array allocation; initial allocation of the 0-level cache (pid_idr_init() in kernel/pid.c) relies on this:
struct pid
uses a 1-element array:I suspect that part of the reason for this is so that a single
struct pid
is a valid level-0 pid, without needing a complementary array allocation; initial allocation of the 0-level cache (pid_idr_init()
inkernel/pid.c
) relies on this:However the other caches are allocated (
create_pid_cachep
inkernel/pid_namespace.c
) using a manually setup call tokmem_cache_create
:Presumably using the same pattern (with
SLAB_PANIC
added) would be acceptable forpid_cachep
.