Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
9de830ae
Commit
9de830ae
authored
Aug 17, 2017
by
4ast
Committed by
GitHub
Aug 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1294 from iovisor/yhs_dev
avoid large map memory allocation in userspace
parents
47305f47
067219b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
src/cc/export/helpers.h
src/cc/export/helpers.h
+6
-6
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+8
-2
No files found.
src/cc/export/helpers.h
View file @
9de830ae
...
...
@@ -50,11 +50,11 @@ struct _name##_table_t { \
void (*call) (void *, int index); \
void (*increment) (_key_type); \
int (*get_stackid) (void *, u64); \
_leaf_type data[_max_entries]
; \
u32 max_entries
; \
int flags; \
}; \
__attribute__((section("
maps
/
" _table_type))) \
struct _name##_table_t _name = { .flags = (_flags) }
struct _name##_table_t _name = { .flags = (_flags)
, .max_entries = (_max_entries)
}
#define BPF_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries) \
BPF_F_TABLE(_table_type, _key_type, _leaf_type, _name, _max_entries, 0)
...
...
@@ -84,10 +84,10 @@ struct _name##_table_t { \
/* map.perf_submit(ctx, data, data_size) */ \
int (*perf_submit) (void *, void *, u32); \
int (*perf_submit_skb) (void *, u32, void *, u32); \
u32
data[0]
; \
u32
max_entries
; \
}; \
__attribute__((section("
maps
/
perf_output
"))) \
struct _name##_table_t _name
struct _name##_table_t _name
= { .max_entries = 0 }
// Table for reading hw perf cpu counters
#define BPF_PERF_ARRAY(_name, _max_entries) \
...
...
@@ -96,10 +96,10 @@ struct _name##_table_t { \
u32 leaf; \
/* counter = map.perf_read(index) */ \
u64 (*perf_read) (int); \
u32
data[_max_entries]
; \
u32
max_entries
; \
}; \
__attribute__((section("
maps
/
perf_array
"))) \
struct _name##_table_t _name
struct _name##_table_t _name
= { .max_entries = (_max_entries) }
#define BPF_HASH1(_name) \
BPF_TABLE("
hash
", u64, u64, _name, 10240)
...
...
src/cc/frontends/clang/b_frontend_action.cc
View file @
9de830ae
...
...
@@ -633,8 +633,14 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
}
table
.
leaf_size
=
sz
;
leaf_type
=
F
->
getType
();
}
else
if
(
F
->
getName
()
==
"data"
)
{
table
.
max_entries
=
sz
/
table
.
leaf_size
;
}
else
if
(
F
->
getName
()
==
"max_entries"
)
{
unsigned
idx
=
F
->
getFieldIndex
();
if
(
auto
I
=
dyn_cast_or_null
<
InitListExpr
>
(
Decl
->
getInit
()))
{
llvm
::
APSInt
res
;
if
(
I
->
getInit
(
idx
)
->
EvaluateAsInt
(
res
,
C
))
{
table
.
max_entries
=
res
.
getExtValue
();
}
}
}
else
if
(
F
->
getName
()
==
"flags"
)
{
unsigned
idx
=
F
->
getFieldIndex
();
if
(
auto
I
=
dyn_cast_or_null
<
InitListExpr
>
(
Decl
->
getInit
()))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment