Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\ring_buffer.c Create Date:2022-07-28 11:53:41
Last Modify:2020-03-17 19:30:04 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:__ring_buffer_alloc - allocate a new ring_buffer*@size: the size in bytes per cpu that is needed.*@flags: attributes to set for the ring buffer.* Currently the only flag that is available is the RB_FL_OVERWRITE* flag

Proto:struct ring_buffer *__ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *key)

Type:struct ring_buffer

Parameter:

TypeParameterName
unsigned longsize
unsignedflags
struct lock_class_key *key
1387  buffer = 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).
1389  If Not buffer Then Return NULL
1392  If Not zalloc_cpumask_var( & cpumask, GFP_KERNEL) Then Go to fail_free_buffer
1395  nr_pages = DIV_ROUND_UP(size, BUF_PAGE_SIZE)
1396  flags = flags
1397  clock = race_clock_local(): the simplest and least coherent tracing clock.* Useful for tracing that does not cross to other CPUs nor* does it go through idle events.
1398  reader_lock_key = key
1400  init_irq_work( & work, _wake_up_waiters - wake up tasks waiting for ring buffer input* Schedules a delayed work to wake up any task that is blocked on the* ring buffer waiters queue.)
1401  init_waitqueue_head( & waiters)
1404  If nr_pages < 2 Then nr_pages = 2
1407  cpus = Setup number of possible processor ids
1409  bsize = size of * * Setup number of possible processor ids
1410  buffers = 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).
1412  If Not buffers Then Go to fail_free_cpumask
1415  cpu = These macros fold the SMP functionality into a single CPU system()
1416  pumask_set_cpu - set a cpu in a cpumask*@cpu: cpu number (< nr_cpu_ids)*@dstp: the cpumask pointer
1417  buffers[cpu] = rb_allocate_cpu_buffer(buffer, nr_pages, cpu)
1418  If Not buffers[cpu] Then Go to fail_free_buffers
1421  ret = puhp_state_add_instance - Add an instance for a state and invoke startup* callback.*@state: The state for which the instance is installed*@node: The node for this individual state.* Installs the instance for the @state and invokes the startup callback on
1422  If ret < 0 Then Go to fail_free_buffers
1425  mutex_init - initialize the mutex*@mutex: the mutex to be initialized* Initialize the mutex to unlocked state.* It is not allowed to initialize an already locked mutex.( & mutex)
1427  Return buffer
1429  fail_free_buffers :
1430  for_each_buffer_cpu(buffer, cpu)
1431  If buffers[cpu] Then rb_free_cpu_buffer(buffers[cpu])
1434  kfree(buffers)
1436  fail_free_cpumask :
1437  free_cpumask_var(cpumask)
1439  fail_free_buffer :
1440  kfree(buffer)
1441  Return NULL