Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__perf_output_begin

Proto:static __always_inline int __perf_output_begin(struct perf_output_handle *handle, struct perf_event *event, unsigned int size, bool backward)

Type:int

Parameter:

TypeParameterName
struct perf_output_handle *handle
struct perf_event *event
unsigned intsize
boolbackward
156  struct{struct perf_event_header header;u64 id;u64 lost;}lost_event
162  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
166  If parent Then event = parent
169  rb = fetch RCU-protected pointer for dereferencing(rb)
170  If Value for the false possibility is greater at compile time(!rb) Then Go to out
173  If Value for the false possibility is greater at compile time( can write into ring buffer ) Then
174  If nr of data pages Then local_inc( & nr records lost )
176  Go to out
179  rb = rb
180  event = event
182  have_lost = local_read( & nr records lost )
183  If Value for the false possibility is greater at compile time(have_lost) Then
184  size += size of lost_event
185  If sample_id_all Then size += id_header_size
189  We need to ensure a later event_id doesn't publish a head when a former* event isn't done writing. However since we need to deal with NMIs we* cannot fully serialize things.* We only publish the head (and generate a wakeup) when the outer-most
191  Do
192  tail = READ_ONCE(user-space written tail )
193  offset = head = local_read( & write position )
194  If Not can overwrite itself Then
213  If Not backward Then head += size
215  Else head -= size
217  When local_cmpxchg( & write position , offset, head) != offset cycle
219  If backward Then
220  offset = head
221  head = -head
229  If Value for the false possibility is greater at compile time(head - local_read( & wakeup stamp ) > wakeup watermark ) Then local_add( wakeup watermark , & wakeup stamp )
232  page_shift = PAGE_SHIFT determines the page size + page_order(rb)
234  page = offset >> page_shift & nr of data pages - 1
235  offset &= (1UL << page_shift) - 1
236  addr = data_pages[page] + offset
237  size = (1UL << page_shift) - offset
239  If Value for the false possibility is greater at compile time(have_lost) Then
242  size = size of lost_event
243  type = PERF_RECORD_LOST
244  misc = 0
245  id = id
246  lost = Always has a lock prefix ( & nr records lost , 0)
248  perf_event_header__init_id( & header, & sample_data, event)
250  perf_output_put(handle, lost_event)
251  perf_event__output_id_sample(event, handle, & sample_data)
254  Return 0
256  fail :
257  local_inc( & nr records lost )
258  perf_output_put_handle(handle)
259  out :
260  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
262  Return -ENOSPC
Caller
NameDescribe
perf_output_begin_forward
perf_output_begin_backward
perf_output_begin