函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\ring_buffer.c Create Date:2022-07-27 15:02:56
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:__perf_output_begin

函数原型:static __always_inline int __perf_output_begin(struct perf_output_handle *handle, struct perf_event *event, unsigned int size, bool backward)

返回类型:int

参数:

类型参数名称
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  如果parentevent等于parent
169  rb等于cu_dereference() - fetch RCU-protected pointer for dereferencing*@p: The pointer to read, prior to dereferencing* This is a simple wrapper around rcu_dereference_check().(rb)
170  如果此条件成立可能性小(为编译器优化)(!rb)则转到:out
173  如果此条件成立可能性小(为编译器优化)( can write into ring buffer )则
174  如果 nr of data pages local_inc( & nr records lost )
176  转到:out
179  rb等于rb
180  event等于event
182  have_lost等于local_read( & nr records lost )
183  如果此条件成立可能性小(为编译器优化)(have_lost)则
184  size加等于lost_event的长度
185  如果sample_id_allsize加等于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  循环
192  tail等于READ_ONCE(user-space written tail )
193  offset等于head等于local_read( & write position )
194  如果非 can overwrite itself
213  如果非backwardhead加等于size
215  否则head减等于size
217 local_cmpxchg( & write position , offset, head)不等于offset循环
219  如果backward
220  offset等于head
221  head等于负head
229  如果此条件成立可能性小(为编译器优化)(head - local_read( & wakeup stamp ) > wakeup watermark )则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  如果此条件成立可能性小(为编译器优化)(have_lost)则
242  size等于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  返回: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  返回:负ENOSPC
调用者
名称描述
perf_output_begin_forward
perf_output_begin_backward
perf_output_begin