Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
4a888de1
Unverified
Commit
4a888de1
authored
Jan 30, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: use bpf log when logging at trace level
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
25a8b256
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+16
-7
No files found.
src/lxc/cgroups/cgroup2_devices.c
View file @
4a888de1
...
...
@@ -27,6 +27,7 @@
lxc_log_define
(
cgroup2_devices
,
cgroup
);
#define BPF_LOG_BUF_SIZE (1 << 23)
/* 8MB */
#ifndef BPF_LOG_LEVEL1
#define BPF_LOG_LEVEL1 1
#endif
...
...
@@ -321,17 +322,25 @@ int bpf_program_finalize(struct bpf_program *prog)
return
bpf_program_add_instructions
(
prog
,
ins
,
ARRAY_SIZE
(
ins
));
}
static
int
bpf_program_load_kernel
(
struct
bpf_program
*
prog
,
char
*
log_buf
,
__u32
log_size
,
__u32
log_level
)
static
int
bpf_program_load_kernel
(
struct
bpf_program
*
prog
)
{
__do_free
char
*
log_buf
=
NULL
;
__u32
log_level
=
0
,
log_size
=
0
;
union
bpf_attr
*
attr
;
if
((
log_size
!=
0
&&
!
log_buf
)
||
(
log_size
==
0
&&
log_buf
))
return
ret_errno
(
EINVAL
);
if
(
prog
->
kernel_fd
>=
0
)
return
0
;
if
(
lxc_log_get_level
()
<=
LXC_LOG_LEVEL_TRACE
)
{
log_buf
=
zalloc
(
BPF_LOG_BUF_SIZE
);
if
(
!
log_buf
)
{
WARN
(
"Failed to allocate bpf log buffer"
);
}
else
{
log_level
=
BPF_LOG_LEVEL
;
log_size
=
BPF_LOG_BUF_SIZE
;
}
}
attr
=
&
(
union
bpf_attr
){
.
prog_type
=
prog
->
prog_type
,
.
insns
=
PTR_TO_UINT64
(
prog
->
instructions
),
...
...
@@ -376,7 +385,7 @@ int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
return
true
;
}
ret
=
bpf_program_load_kernel
(
prog
,
NULL
,
0
,
0
);
ret
=
bpf_program_load_kernel
(
prog
);
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
ret
,
"Failed to load bpf program"
);
...
...
@@ -543,7 +552,7 @@ bool bpf_devices_cgroup_supported(void)
if
(
ret
<
0
)
return
log_trace
(
false
,
"Failed to add new instructions to bpf device cgroup program"
);
ret
=
bpf_program_load_kernel
(
prog
,
NULL
,
0
,
0
);
ret
=
bpf_program_load_kernel
(
prog
);
if
(
ret
<
0
)
return
log_trace
(
false
,
"Failed to load new bpf device cgroup program"
);
...
...
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