Skip to content

Commit

Permalink
x86: bpf_jit_comp: can call module_free() from any context
Browse files Browse the repository at this point in the history
It looks like we can call module_free()/vfree() from softirq context,
so no longer need a wrapper and a work_struct.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed May 18, 2013
1 parent b4236da commit 650c849
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions arch/x86/net/bpf_jit_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,7 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
break;
}
if (proglen == oldproglen) {
image = module_alloc(max_t(unsigned int,
proglen,
sizeof(struct work_struct)));
image = module_alloc(proglen);
if (!image)
goto out;
}
Expand All @@ -738,20 +736,8 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
return;
}

static void jit_free_defer(struct work_struct *arg)
{
module_free(NULL, arg);
}

/* run from softirq, we must use a work_struct to call
* module_free() from process context
*/
void bpf_jit_free(struct sk_filter *fp)
{
if (fp->bpf_func != sk_run_filter) {
struct work_struct *work = (struct work_struct *)fp->bpf_func;

INIT_WORK(work, jit_free_defer);
schedule_work(work);
}
if (fp->bpf_func != sk_run_filter)
module_free(NULL, fp->bpf_func);
}

0 comments on commit 650c849

Please sign in to comment.