Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • L linux-sp
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • linux-arm
  • linux-sp
  • Repository
Switch branch/tag
  • linux-sp
  • net
  • core
  • bpf_sk_storage.c
Find file BlameHistoryPermalink
  • Martin KaFai Lau's avatar
    bpf: Improve bucket_log calculation logic · 88d6f130
    Martin KaFai Lau authored Feb 07, 2020
    It was reported that the max_t, ilog2, and roundup_pow_of_two macros have
    exponential effects on the number of states in the sparse checker.
    
    This patch breaks them up by calculating the "nbuckets" first so that the
    "bucket_log" only needs to take ilog2().
    
    In addition, Linus mentioned:
    
      Patch looks good, but I'd like to point out that it's not just sparse.
    
      You can see it with a simple
    
        make net/core/bpf_sk_storage.i
        grep 'smap->bucket_log = ' net/core/bpf_sk_storage.i | wc
    
      and see the end result:
    
          1  365071 2686974
    
      That's one line (the assignment line) that is 2,686,974 characters in
      length.
    
      Now, sparse does happen to react particularly badly to that (I didn't
      look to why, but I suspect it's just that evaluating all the types
      that don't actually ever end up getting used ends up being much more
      expensive than it should be), but I bet it's not good for gcc either.
    
    Fixes: 6ac99e8f
    
     ("bpf: Introduce bpf sk local storage")
    Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
    Reported-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
    Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: default avatarLuc Van Oostenryck <luc.vanoostenryck@gmail.com>
    Link: https://lore.kernel.org/bpf/20200207081810.3918919-1-kafai@fb.com
    88d6f130