Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\pid.c Create Date:2022-07-28 09:28:37
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:alloc_pid

Proto:struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, size_t set_tid_size)

Type:struct pid

Parameter:

TypeParameterName
struct pid_namespace *ns
pid_t *set_tid
size_tset_tid_size
168  retval = -ENOMEM
178  If set_tid_size > level + 1 Then Return ERR_PTR( - EINVAL)
181  pid = kmem_cache_alloc(pid_cachep, GFP_KERNEL)
182  If Not pid Then Return ERR_PTR(retval)
185  tmp = ns
186  level = level
188  When i >= 0 cycle
189  tid = 0
191  If set_tid_size Then
192  tid = set_tid[level - i]
194  retval = -EINVAL
195  If tid < 1 || tid >= pid_max Then Go to out_free
201  If tid != 1 && Not child_reaper Then Go to 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  If tid Then
219  If nr == -ENOSPC Then nr = -EEXIST
221  Else
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  If nr < 0 Then
241  retval = If nr == -ENOSPC Then -EAGAIN Else nr
242  Go to out_free
245  nr = nr
246  ns = tmp
247  tmp = parent
250  If Value for the false possibility is greater at compile time(s_child_reaper returns true if the pid is the init process* of the current namespace. As this one could be checked before* pid_ns->child_reaper is assigned in copy_process, we check* with the pid number.) Then
251  If pid_ns_prepare_proc(ns) Then Go to 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  When type < PIDTYPE_MAX cycle INIT_HLIST_HEAD( & lists of tasks that use this pid [type])
260  init_waitqueue_head( & wait queue for pidfd notifications )
262  upid = numbers + level
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  If Not (pid_allocated & PIDNS_ADDING) Then Go to out_unlock
266  When upid >= numbers cycle
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  Return 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  When ++i <= level cycle
282  upid = numbers + i
283  dr_remove() - Remove an ID from the IDR
287  If pid_allocated == PIDNS_ADDING Then dr_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  Deallocate an object
293  Return ERR_PTR(retval)