Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:mempool_resize - resize an existing memory pool*@pool: pointer to the memory pool which was allocated via* mempool_create().*@new_min_nr: the new minimum number of elements guaranteed to be* allocated for this pool.* This function shrinks/grows the pool

Proto:int mempool_resize(mempool_t *pool, int new_min_nr)

Type:int

Parameter:

TypeParameterName
mempool_t *pool
intnew_min_nr
305  BUG_ON(new_min_nr <= 0)
306  might_sleep()
308  spin_lock_irqsave( & lock, flags)
309  If new_min_nr <= nr of elements at *elements Then
316  nr of elements at *elements = new_min_nr
317  Go to out_unlock
319  spin_unlock_irqrestore( & lock, flags)
322  new_elements = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
324  If Not new_elements Then Return -ENOMEM
327  spin_lock_irqsave( & lock, flags)
328  If Value for the false possibility is greater at compile time(new_min_nr <= nr of elements at *elements ) Then
330  spin_unlock_irqrestore( & lock, flags)
331  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
332  Go to out
334  memcpy(new_elements, elements, Current nr of elements at *elements * size of new_elements )
336  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
337  elements = new_elements
338  nr of elements at *elements = new_min_nr
340  When Current nr of elements at *elements < nr of elements at *elements cycle
341  spin_unlock_irqrestore( & lock, flags)
342  element = alloc(GFP_KERNEL, pool_data)
343  If Not element Then Go to out
345  spin_lock_irqsave( & lock, flags)
348  Else
351  Go to out
354  out_unlock :
355  spin_unlock_irqrestore( & lock, flags)
356  out :
357  Return 0