Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\relay.c Create Date:2022-07-28 11:47:04
Last Modify:2020-03-17 19:20:22 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:lay_open - create a new relay channel*@base_filename: base name of files to create, %NULL for buffering only*@parent: dentry of parent directory, %NULL for root directory or buffer*@subbuf_size: size of sub-buffers*@n_subbufs: number of sub-buffers*@cb:

Proto:struct rchan *relay_open(const char *base_filename, struct dentry *parent, size_t subbuf_size, size_t n_subbufs, struct rchan_callbacks *cb, void *private_data)

Type:struct rchan

Parameter:

TypeParameterName
const char *base_filename
struct dentry *parent
size_tsubbuf_size
size_tn_subbufs
struct rchan_callbacks *cb
void *private_data
574  If Not (subbuf_size && n_subbufs) Then Return NULL
576  If subbuf_size > UINT_MAX / n_subbufs Then Return NULL
579  chan = 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).
580  If Not chan Then Return NULL
583  per-cpu channel buffers = alloc_percpu(structrchan_buf * )
584  the version of this struct = Tracks changes to rchan/rchan_buf structs
585  number of sub-buffers per buffer = n_subbufs
586  sub-buffer size = subbuf_size
587  total buffer size allocated = align the pointer to the (next) page boundary (subbuf_size * n_subbufs)
588  parent dentry passed to open = parent
589  for user-defined data = private_data
590  If base_filename Then
591  has a filename associated? = 1
592  Copy a NUL terminated string into a sized buffer
594  setup_callbacks(chan, cb)
595  kref_init - initialize object.*@kref: object in question.
597  mutex_lock( & list of open channels, for cpu hotplug )
598  for_each_online_cpu(i)
599  buf = lay_open_buf - create a new relay channel buffer* used by relay_open() and CPU hotplug.
600  If Not buf Then Go to free_bufs
602  per_cpu_ptr( per-cpu channel buffers , i) = buf
604  list_add - add a new entry*@new: new entry to be added*@head: list head to add it after* Insert a new entry after the specified head.* This is good for implementing stacks.
605  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.
607  Return chan
609  free_bufs :
610  for_each_possible_cpu(i)
611  If buf = per_cpu_ptr( per-cpu channel buffers , i) Then lay_close_buf - close a channel buffer*@buf: channel buffer* Marks the buffer finalized and restores the default callbacks.* The channel buffer and channel buffer data structure are then freed* automatically when the last reference is given up.
615  kref_put - decrement refcount for object.*@kref: object.*@release: pointer to the function that will clean up the object when the* last reference to the object is released.* This pointer is required, and it is not acceptable to pass kfree
616  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.
617  Return NULL