Adjust descriptor locking to tell the kqueue subsystem that our descriptor is
already locked. The reason to do this is to avoid two lock+unlock operations in a row. We need the lock here to serialize access to bd_pid for stats collection purposes. Drop the locks all together on detach, as they will be picked up by knlist_remove. This should fix a failed locking assertion when kqueue is being used with bpf descriptors. Discussed with: jmg
This commit is contained in:
parent
814fe9e98e
commit
4b19419ee7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160087
@ -1152,7 +1152,7 @@ bpfkqfilter(struct cdev *dev, struct knote *kn)
|
||||
d->bd_pid = curthread->td_proc->p_pid;
|
||||
kn->kn_fop = &bpfread_filtops;
|
||||
kn->kn_hook = d;
|
||||
knlist_add(&d->bd_sel.si_note, kn, 0);
|
||||
knlist_add(&d->bd_sel.si_note, kn, 1);
|
||||
BPFD_UNLOCK(d);
|
||||
|
||||
return (0);
|
||||
@ -1163,9 +1163,7 @@ filt_bpfdetach(struct knote *kn)
|
||||
{
|
||||
struct bpf_d *d = (struct bpf_d *)kn->kn_hook;
|
||||
|
||||
BPFD_LOCK(d);
|
||||
knlist_remove(&d->bd_sel.si_note, kn, 0);
|
||||
BPFD_UNLOCK(d);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user