Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:da_alloc_range() - Allocate an unused ID.*@ida: IDA handle.*@min: Lowest ID to allocate.*@max: Highest ID to allocate.*@gfp: Memory allocation flags.* Allocate an ID between @min and @max, inclusive. The allocated ID will

Proto:int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max, gfp_t gfp)

Type:int

Parameter:

TypeParameterName
struct ida *ida
unsigned intmin
unsigned intmax
gfp_tgfp
382  XA_STATE() - Declare an XArray operation state.*@name: Name of this operation state (usually xas).*@array: Array to operate on.*@index: Initial index of interest.* Declare and initialise an xa_state on the stack.(xas, & xa, min / IDA_BITMAP_BITS)
383  bit = min % IDA_BITMAP_BITS
385  struct ida_bitmap * bitmap, * alloc = NULL
387  If min < 0 Then Return -ENOSPC
390  If max < 0 Then max = INT_MAX
393  retry :
394  xas_lock_irqsave( & xas, flags)
395  :
396  bitmap = xas_find_marked() - Find the next marked entry in the XArray.*@xas: XArray operation state.*@max: Highest index to return.*@mark: Mark number to search for.* If the @xas has not yet been walked to an entry, return the marked entry
397  If xa_index > min / IDA_BITMAP_BITS Then bit = 0
399  If xa_index * IDA_BITMAP_BITS + bit > max Then Go to nospc
402  If xa_is_value() - Determine if an entry is a value.*@entry: XArray entry.* Context: Any context.* Return: True if the entry is a value, false if it is a pointer. Then
403  tmp = xa_to_value() - Get value stored in an XArray entry.*@entry: XArray entry.* Context: Any context.* Return: The value stored in the XArray entry.
407  If xa_index * IDA_BITMAP_BITS + bit > max Then Go to nospc
410  tmp |= 1UL << bit
412  Go to out
415  bitmap = alloc
416  If Not bitmap Then bitmap = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
418  If Not bitmap Then Go to alloc
420  bitmap[0] = tmp
421  xas_store() - Store this entry in the XArray
423  bitmap[0] = 0
424  Go to out
428  If bitmap Then
429  bit = d_next_zero_bit - find the next cleared bit in a memory region*@addr: The address to base the search on*@offset: The bitnumber to start searching at*@size: The bitmap size in bits* Returns the bit number of the next zero bit
430  If xa_index * IDA_BITMAP_BITS + bit > max Then Go to nospc
432  If bit == IDA_BITMAP_BITS Then Go to next
435  __set_bit - Set a bit in memory*@nr: the bit to set*@addr: the address to start counting from* Unlike set_bit(), this function is non-atomic. If it is called on the same* region of memory concurrently, the effect may be that only one operation* succeeds.
436  If bitmap_full(bitmap, IDA_BITMAP_BITS) Then xas_clear_mark() - Clears the mark on this entry and its parents.*@xas: XArray operation state.*@mark: Mark number.* Clears the specified mark on this entry, and walks back to the head* attempting to clear it on all the ancestor entries. Does nothing if
438  Else
441  Else
442  bitmap = alloc
445  If Not bitmap Then Go to alloc
449  xas_store() - Store this entry in the XArray
451  out :
452  xas_unlock_irqrestore( & xas, flags)
453  If xas_nomem() - Allocate memory if needed.*@xas: XArray operation state.*@gfp: Memory allocation flags.* If we need to add new nodes to the XArray, we try to allocate memory* with GFP_NOWAIT while holding the lock, which will usually succeed. Then
454  xa_index = min / IDA_BITMAP_BITS
455  bit = min % IDA_BITMAP_BITS
456  Go to retry
458  If bitmap != alloc Then kfree(alloc)
460  If xas_error() - Return an errno stored in the xa_state.*@xas: XArray operation state.* Return: 0 if no error has been noted. A negative errno if one has. Then Return xas_error() - Return an errno stored in the xa_state.*@xas: XArray operation state.* Return: 0 if no error has been noted. A negative errno if one has.
462  Return xa_index * IDA_BITMAP_BITS + bit
463  alloc :
464  xas_unlock_irqrestore( & xas, flags)
465  alloc = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
466  If Not alloc Then Return -ENOMEM
468  xas_set() - Set up XArray operation state for a different index
469  bit = min % IDA_BITMAP_BITS
470  Go to retry
471  nospc :
472  xas_unlock_irqrestore( & xas, flags)
473  Return -ENOSPC
Caller
NameDescribe
objagg_obj_root_id_alloc
ida_allocda_alloc() - Allocate an unused ID.*@ida: IDA handle.*@gfp: Memory allocation flags.* Allocate an ID between 0 and %INT_MAX, inclusive.* Context: Any context.* Return: The allocated ID, or %-ENOMEM if memory could not be allocated,
ida_alloc_minda_alloc_min() - Allocate an unused ID
ida_alloc_maxda_alloc_max() - Allocate an unused ID