函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:ipc\shm.c Create Date:2022-07-27 18:22:28
Last Modify:2020-03-17 22:58:32 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:wseg - Create a new shared memory segment*@ns: namespace*@params: ptr to the structure that contains key, size and shmflg* Called with shm_ids.rwsem held as a writer.

函数原型:static int newseg(struct ipc_namespace *ns, struct ipc_params *params)

返回类型:int

参数:

类型参数名称
struct ipc_namespace *ns
struct ipc_params *params
602  key等于key
603  shmflg等于flg
604  size等于 for shared memories
607  numpages等于sizePAGE_SIZE减1右移PAGE_SHIFT determines the page size
610  acctflag等于0
612  如果size小于min shared seg size (bytes) size大于shm_ctlmax则返回:负EINVAL
615  如果numpages左移PAGE_SHIFT determines the page size 位小于size则返回:负ENOSPC
618  如果shm_totnumpages小于shm_totshm_totnumpages大于shm_ctlall则返回:负ENOSPC
622  shp等于kvmalloc(shp的长度, GFP_KERNEL)
623  如果此条件成立可能性小(为编译器优化)(!shp)则返回:负ENOMEM
626  key等于key
627  mode等于shmflg按位与S_IRWXUGO
628  mlock_user = NULL
630  security = NULL
631  error等于security_shm_alloc( & shm_perm)
632  如果error
633  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
634  返回:error
637  输出格式化串
638  如果shmflg按位与segment will use huge TLB pages
642  hs等于hstate_sizelog((shmflg >> Huge page size encoding when SHM_HUGETLB is specified, and a huge page* size other than the default is desired. See hugetlb_encode.h) & SHM_HUGE_MASK)
643  如果非hs
644  error等于负EINVAL
645  转到:no_file
647  hugesize等于@a is a power of 2 value (size, huge_page_size(hs))
650  如果shmflg按位与don't check for reservations acctflag等于should the VM suppress accounting
652  file等于hugetlb_file_setup(name, hugesize, acctflag, & mlock_user, HUGETLB_SHMFS_INODE, (shmflg >> Huge page size encoding when SHM_HUGETLB is specified, and a huge page* size other than the default is desired. See hugetlb_encode.h) & SHM_HUGE_MASK)
655  否则
660  如果shmflg按位与don't check for reservations sysctl_overcommit_memory不等于OVERCOMMIT_NEVERacctflag等于should the VM suppress accounting
663  file等于shmem_kernel_file_setup - get an unlinked file living in tmpfs which must be* kernel internal. There will be NO LSM permission checks against the* underlying inode. So users of this interface must do LSM checks at a* higher layer
665  error等于错误
666  如果是错误则转到:no_file
669  shm_cprid等于get_pid(task_tgid(当前进程))
670  shm_lprid = NULL
671  shm_atim等于shm_dtim等于0
672  shm_ctim等于ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME* Returns the wall clock seconds since 1970. This replaces the* get_seconds() interface which is not y2038 safe on 32bit systems.
673  shm_segsz等于size
674  shm_nattch等于0
675  shm_file等于file
676  The task created the shm object. NULL if the task is dead. 等于当前进程
679  error等于pc_addid - add an ipc identifier*@ids: ipc identifier set*@new: new ipc permission set*@limit: limit for the number of used ids* Add an entry 'new' to the ipc ids idr
680  如果error小于0则转到:no_id
683  添加链表项
689  Stat data, not accessed from path walking 等于id
691  shm_tot加等于numpages
692  error等于id
694  ipc_unlock_object( & shm_perm)
695  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
696  返回:error
698  no_id :
699  ipc_update_pid( & shm_cprid, NULL)
700  ipc_update_pid( & shm_lprid, NULL)
701  如果is_file_hugepages(file)且mlock_useruser_shm_unlock(size, mlock_user)
703  fput(file)
704  ipc_rcu_putref( & shm_perm, shm_rcu_free)
705  返回:error
706  no_file :
707  Post an RCU callback to be invoked after the end of an RCU grace* period. But since we have but one CPU, that would be after any* quiescent state.
708  返回:error