Skip to content

Commit

Permalink
options: ensure lockmem is set before retrieving probe info
Browse files Browse the repository at this point in the history
The rawtp provider uses trial-and-error BPF program loading to determine
the number of arguments for a raw tracepoint.  That requires the lockmem
option value to be applied before probe info is retrieved.

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
  • Loading branch information
kvanhees committed Jan 3, 2024
1 parent 8d9ae28 commit f59258b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 12 additions & 1 deletion libdtrace/dt_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,13 +1175,24 @@ dtrace_vopen(int version, int flags, int *errp,
int
dtrace_init(dtrace_hdl_t *dtp)
{
int i;
int i;
dtrace_optval_t lockmem = dtp->dt_options[DTRACEOPT_LOCKMEM];

/*
* Initialize the BPF library handling.
*/
dt_dlib_init(dtp);

/*
* Set the locked-memory limit if so directed by the user.
*/
if (lockmem != DTRACEOPT_UNSET) {
struct rlimit rl;

rl.rlim_cur = rl.rlim_max = lockmem;
setrlimit(RLIMIT_MEMLOCK, &rl);
}

/*
* Initialize consume handling.
*/
Expand Down
10 changes: 0 additions & 10 deletions libdtrace/dt_work.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,10 @@ dtrace_go(dtrace_hdl_t *dtp, uint_t cflags)
{
size_t size;
struct epoll_event ev;
dtrace_optval_t lockmem = dtp->dt_options[DTRACEOPT_LOCKMEM];
struct rlimit rl;

if (dtp->dt_active)
return dt_set_errno(dtp, EINVAL);

/*
* Set the locked-memory limit if so directed by the user.
*/
if (lockmem != DTRACEOPT_UNSET) {
rl.rlim_cur = rl.rlim_max = lockmem;
setrlimit(RLIMIT_MEMLOCK, &rl);
}

/* Create the BPF programs. */
if (dt_bpf_make_progs(dtp, cflags) == -1)
return -1;
Expand Down

0 comments on commit f59258b

Please sign in to comment.