Function Report

Linux Kernel (v4.4)

Source File:kernel\pid.c Create Date:2016-01-14 10:36:27
Last Modify:2016-01-11 07:01:32 Copyright©Brick
home page Tree
Annotate the kernelChinese

Function Name:alloc_pid

Function:struct pid * alloc_pid(struct pid_namespace *ns)

Return Type:struct pid *

Parameter:

Type Parameter NameRemarks
struct pid_namespace * ns

Function description:

304  retval = -Out of memory
306  pid = kmem_cache_alloc(pid_cachep, GFP_KERNEL)
307  If !pid then Returning ERR_PTR(retval)
310  tmp = ns
311  level = level
312  For of i >= 0
313  alloc_pidmap(tmp)
314  If IS_ERR_VALUE then
316  Go to out_free
319  Try to keep pid_chain in the same cacheline as nr for find_vpid = result of alloc_pidmap(tmp)
320  is used to get the id of the struct pid, as it is seen in particular namespace. Later the struct pid is found with find_pid_ns() using the int nr and struct pid_namespace*ns. = tmp
321  tmp = parent
324  If Value for the false possibility is greater at compile time then
325  If pid_ns_prepare_proc(ns) then Go to out_free
329  get_pid_ns(ns)
330  set atomic variable
331  For of type < PIDTYPE_MAX, INIT_HLIST_HEAD
334  is used to get the id of the struct pid, as it is seen in particular namespace. Later the struct pid is found with find_pid_ns() using the int nr and struct pid_namespace*ns. = numbers + level
335  spin_lock_irq( &Note: disable interrupts while the pidmap_lock is held as an interrupt might come in and do read_lock(&tasklist_lock).)
336  If !(nr_hashed & PIDNS_HASH_ADDING) then Go to out_unlock
338  For of is used to get the id of the struct pid, as it is seen in particular namespace. Later the struct pid is found with find_pid_ns() using the int nr and struct pid_namespace*ns. >= numbers
340  adds the specified element to the specified hlist
341  nr_hashed++
343  spin_unlock_irq( &Note: disable interrupts while the pidmap_lock is held as an interrupt might come in and do read_lock(&tasklist_lock).)
345  Returning pid
347  out_unlock
348  spin_unlock_irq( &Note: disable interrupts while the pidmap_lock is held as an interrupt might come in and do read_lock(&tasklist_lock).)
349  put_pid_ns(ns)
351  out_free
352  While ++i <= level , free_pidmap(numbers + i)
355  kmem_cache_free(pid_cachep, pid)
356  Returning ERR_PTR(retval)
Caller
Function NameFunction description
copy_processCreate a new process