Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:kmem_cache_create_usercopy - Create a cache with a region suitable* for copying to userspace*@name: A string which is used in /proc/slabinfo to identify this cache.*@size: The size of objects to be created in this cache.

Proto:struct kmem_cache *kmem_cache_create_usercopy(const char *name, unsigned int size, unsigned int align, slab_flags_t flags, unsigned int useroffset, unsigned int usersize, void (*ctor)(void *))

Type:struct kmem_cache

Parameter:

TypeParameterName
const char *name
unsigned intsize
unsigned intalign
slab_flags_tflags
unsigned intuseroffset
unsigned intusersize
void (*ctor
460  struct kmem_cache * s = NULL
464  get_online_cpus()
465  get_online_mems()
466  memcg_get_cache_ids()
468  mutex_lock( & slab_mutex)
470  err = kmem_cache_sanity_check(name, size)
471  If err Then
472  Go to out_unlock
476  If flags & ~Common flags permitted for kmem_cache_create Then
477  err = -EINVAL
478  Go to out_unlock
487  flags &= Common flags available with current configuration
490  If WARN_ON(!usersize && useroffset) || WARN_ON(size < usersize || size - usersize < useroffset) Then usersize = useroffset = 0
494  If Not usersize Then s = __kmem_cache_alias(name, size, align, flags, ctor)
496  If s Then Go to out_unlock
499  cache_name = kstrdup_const - conditionally duplicate an existing const string*@s: the string to duplicate*@gfp: the GFP mask used in the kmalloc() call when allocating memory* Note: Strings allocated by kstrdup_const should be freed by kfree_const.
500  If Not cache_name Then
501  err = -ENOMEM
502  Go to out_unlock
505  s = create_cache(cache_name, size, Figure out what the alignment of the objects will be given a set of* flags, a user specified alignment and the size of the objects., flags, useroffset, usersize, ctor, NULL, NULL)
508  If IS_ERR(s) Then
509  err = PTR_ERR(s)
510  kfree_const - conditionally free memory*@x: pointer to the memory* Function calls kfree only if @x is not in .rodata section.
513  out_unlock :
514  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
516  memcg_put_cache_ids()
517  put_online_mems()
518  put_online_cpus()
520  If err Then
521  If flags & Panic if kmem_cache_create() fails Then panic - halt the system*@fmt: The text string to print* Display a message, then perform cleanups.* This function never returns.
524  Else
525  pr_warn("kmem_cache_create(%s) failed with error %d\n", name, err)
527  dump_stack()
529  Return NULL
531  Return s
Caller
NameDescribe
proc_caches_init
uts_ns_init
kmem_cache_createkmem_cache_create - Create a cache.*@name: A string which is used in /proc/slabinfo to identify this cache.*@size: The size of objects to be created in this cache.*@align: The required alignment for the objects.*@flags: SLAB flags