Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Allocate an array of spinlocks to be accessed by a hash. Two arguments* indicate the number of elements to allocate in the array. max_size* gives the maximum number of elements to allocate. cpu_mult gives* the number of locks per CPU to allocate

Proto:int __alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *locks_mask, size_t max_size, unsigned int cpu_mult, gfp_t gfp, const char *name, struct lock_class_key *key)

Type:int

Parameter:

TypeParameterName
spinlock_t **locks
unsigned int *locks_mask
size_tmax_size
unsigned intcpu_mult
gfp_tgfp
const char *name
struct lock_class_key *key
18  spinlock_t * tlocks = NULL
23  nr_pcpus = num_possible_cpus()
26  If cpu_mult Then
27  nr_pcpus = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedint, nr_pcpus, 64UL)
28  size = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(unsignedint, nr_pcpus * cpu_mult, max_size)
29  Else
30  size = max_size
33  If sizeof(spinlock_t) != 0 Then
34  tlocks = kvmalloc_array(size, sizeof(spinlock_t), gfp)
35  If Not tlocks Then Return -ENOMEM
37  When i < size cycle
43  locks = tlocks
44  locks_mask = size - 1
46  Return 0