函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\pid.c Create Date:2022-07-27 10:28:56
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:分配进程句柄

函数原型:struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, size_t set_tid_size)

返回类型:struct pid

参数:

类型参数名称
struct pid_namespace *ns
pid_t *set_tid
size_tset_tid_size
168  retval等于负ENOMEM
178  如果set_tid_size大于进程级别加1则返回:错误号
181  pid等于kmem_cache_alloc(分配pid的slab的地址, GFP_KERNEL)
182  如果非pid则返回:错误号
185  tmp等于ns
186  空间中级别等于进程级别
188 i大于等于0循环
189  tid等于0
191  如果set_tid_size
192  tid等于set_tid[进程级别 - i]
194  retval等于负EINVAL
195  如果tid小于1或tid大于等于pid_max则转到:out_free
201  如果tid不等于1且非子进程回收器则转到:out_free
203  retval等于负EPERM
206  set_tid_size自减
209  dr_preload - preload for idr_alloc()*@gfp_mask: allocation mask to use for preloading* Preallocate memory to use for the next call to idr_alloc(). This function* returns with preemption disabled. It will be enabled by idr_preload_end().
210  spin_lock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
212  如果tid
219  如果nr恒等于负ENOSPCnr等于负EEXIST
221  否则
222  pid_min等于1
237  spin_unlock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
238  dr_preload_end - end preload section started with idr_preload()* Each idr_preload() should be matched with an invocation of this* function. See idr_preload() for details.
240  如果nr小于0则
241  retval等于如果nr恒等于负ENOSPC则负EAGAIN否则nr
242  转到:out_free
245  进程号等于nr
246  进程所处空间等于tmp
247  tmp等于父进程空间
250  如果此条件成立可能性小(为编译器优化)(是资源回收器)则
251  如果pid_ns_prepare_proc(ns)则转到:out_free
255  get_pid_ns(ns)
256  _set - set a refcount's value*@r: the refcount*@n: value to which the refcount will be set
257 type小于最大进程循环INIT_HLIST_HEAD( & 进程属性列[type])
260  init_waitqueue_head( & wait queue for pidfd notifications )
262  upid等于进程空间进程级别
263  spin_lock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
264  如果非pid_allocated按位与PIDNS_ADDING的值则转到:out_unlock
266 upid大于等于进程空间循环
268  dr_replace() - replace pointer for given ID
269  pid_allocated自加
271  spin_unlock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
273  返回:pid
275  out_unlock :
276  spin_unlock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
277  put_pid_ns(ns)
279  out_free :
280  spin_lock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
281 i先自加小于等于进程级别循环
282  upid等于进程空间i
283  删除释放idr
287  如果pid_allocated恒等于PIDNS_ADDINGdr_set_cursor - Set the current position of the cyclic allocator*@idr: idr handle*@val: new position* The next call to idr_alloc_cyclic() will return @val if it is free* (otherwise the search will start from this position).
290  spin_unlock_irq( & Note: disable interrupts while the pidmap_lock is held as an* interrupt might come in and do read_lock(&tasklist_lock))
292  释放一个对象
293  返回:错误号
调用者
名称描述
copy_process创建进程