Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • kernel
  • bpf
  • stackmap.c
Find file BlameHistoryPermalink
  • Namhyung Kim's avatar
    bpf: Adjust BPF stack helper functions to accommodate skip > 0 · ee2a0988
    Namhyung Kim authored Mar 14, 2022
    Let's say that the caller has storage for num_elem stack frames.  Then,
    the BPF stack helper functions walk the stack for only num_elem frames.
    This means that if skip > 0, one keeps only 'num_elem - skip' frames.
    
    This is because it sets init_nr in the perf_callchain_entry to the end
    of the buffer to save num_elem entries only.  I believe it was because
    the perf callchain code unwound the stack frames until it reached the
    global max size (sysctl_perf_event_max_stack).
    
    However it now has perf_callchain_entry_ctx.max_stack to limit the
    iteration locally.  This simplifies the code to handle init_nr in the
    BPF callstack entries and removes the confusion with the perf_event's
    __PERF_SAMPLE_CALLCHAIN_EARLY which sets init_nr to 0.
    
    Also change the comment on bpf_get_stack() in the header file to be
    more explicit what the return value means.
    
    Fixes: c195651e
    
     ("bpf: add bpf_get_stack helper")
    Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarYonghong Song <yhs@fb.com>
    Link: https://lore.kernel.org/bpf/30a7b5d5-6726-1cc2-eaee-8da2828a9a9c@oracle.com
    Link: https://lore.kernel.org/bpf/20220314182042.71025-1-namhyung@kernel.org
    
    
    
    Based-on-patch-by: default avatarEugene Loh <eugene.loh@oracle.com>
    ee2a0988
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7