]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
iflib_stop: drain rx tasks to prevent any data races
authorAndriy Gapon <avg@FreeBSD.org>
Fri, 19 Nov 2021 07:56:30 +0000 (09:56 +0200)
committerAndriy Gapon <avg@FreeBSD.org>
Fri, 19 Nov 2021 08:00:38 +0000 (10:00 +0200)
commit1bfdb812c786ac2607a82633f9c84a5d16f54079
treee9e238e2d817b901397be17ee479bb37c79bfa72
parent8502220db5085410dadd9b674b2f54df4815ac23
iflib_stop: drain rx tasks to prevent any data races

iflib_stop modifies iflib data structures that are used by _task_fn_rx,
most prominently the free lists.  So, iflib_stop has to ensure that the
rx task threads are not active.

This should help to fix a crash seen when iflib_if_ioctl (e.g.,
SIOCSIFCAP) is called while there is already traffic flowing.

The crash has been seen on VMWare guests with vmxnet3 driver.

My guess is that on physical hardware the couple of 1ms delays that
iflib_stop has after disabling interrupts are enough for the queued work
to be completed before any iflib state is touched.

But on busy hypervisors the guests might not get enough CPU time to
complete the work, thus there can be a race between the taskqueue
threads and the work done to handle an ioctl, specifically in iflib_stop
and iflib_init_locked.

PR: 259458
Reviewed by: markj
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D32926
sys/net/iflib.c