# git rev-parse -q --verify 472e5b056f000a778abb41f1e443de58eb259783^{commit} 472e5b056f000a778abb41f1e443de58eb259783 already have revision, skipping fetch # git checkout -q -f -B kisskb 472e5b056f000a778abb41f1e443de58eb259783 # git clean -qxdf # < git log -1 # commit 472e5b056f000a778abb41f1e443de58eb259783 # Author: Linus Torvalds # Date: Thu Oct 1 19:14:36 2020 -0700 # # pipe: remove pipe_wait() and fix wakeup race with splice # # The pipe splice code still used the old model of waiting for pipe IO by # using a non-specific "pipe_wait()" that waited for any pipe event to # happen, which depended on all pipe IO being entirely serialized by the # pipe lock. So by checking the state you were waiting for, and then # adding yourself to the wait queue before dropping the lock, you were # guaranteed to see all the wakeups. # # Strictly speaking, the actual wakeups were not done under the lock, but # the pipe_wait() model still worked, because since the waiter held the # lock when checking whether it should sleep, it would always see the # current state, and the wakeup was always done after updating the state. # # However, commit 0ddad21d3e99 ("pipe: use exclusive waits when reading or # writing") split the single wait-queue into two, and in the process also # made the "wait for event" code wait for _two_ wait queues, and that then # showed a race with the wakers that were not serialized by the pipe lock. # # It's only splice that used that "pipe_wait()" model, so the problem # wasn't obvious, but Josef Bacik reports: # # "I hit a hang with fstest btrfs/187, which does a btrfs send into # /dev/null. This works by creating a pipe, the write side is given to # the kernel to write into, and the read side is handed to a thread that # splices into a file, in this case /dev/null. # # The box that was hung had the write side stuck here [pipe_write] and # the read side stuck here [splice_from_pipe_next -> pipe_wait]. # # [ more details about pipe_wait() scenario ] # # The problem is we're doing the prepare_to_wait, which sets our state # each time, however we can be woken up either with reads or writes. In # the case above we race with the WRITER waking us up, and re-set our # state to INTERRUPTIBLE, and thus never break out of schedule" # # Josef had a patch that avoided the issue in pipe_wait() by just making # it set the state only once, but the deeper problem is that pipe_wait() # depends on a level of synchonization by the pipe mutex that it really # shouldn't. And the whole "wait for any pipe state change" model really # isn't very good to begin with. # # So rather than trying to work around things in pipe_wait(), remove that # legacy model of "wait for arbitrary pipe event" entirely, and actually # create functions that wait for the pipe actually being readable or # writable, and can do so without depending on the pipe lock serializing # everything. # # Fixes: 0ddad21d3e99 ("pipe: use exclusive waits when reading or writing") # Link: https://lore.kernel.org/linux-fsdevel/bfa88b5ad6f069b2b679316b9e495a970130416c.1601567868.git.josef@toxicpanda.com/ # Reported-by: Josef Bacik # Reviewed-and-tested-by: Josef Bacik # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc --version # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld --version # < git log --format=%s --max-count=1 472e5b056f000a778abb41f1e443de58eb259783 # < make -s -j 8 ARCH=arm O=/kisskb/build/linus_rpc_defconfig_arm-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- rpc_defconfig # < make -s -j 8 ARCH=arm O=/kisskb/build/linus_rpc_defconfig_arm-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- help # make -s -j 8 ARCH=arm O=/kisskb/build/linus_rpc_defconfig_arm-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- olddefconfig # make -s -j 8 ARCH=arm O=/kisskb/build/linus_rpc_defconfig_arm-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- /kisskb/src/drivers/tty/vt/vt_ioctl.c: In function 'vt_ioctl': /kisskb/src/drivers/tty/vt/vt_ioctl.c:1058:1: internal compiler error: Max. number of generated reload insns per insn is achieved (90) } ^ Please submit a full bug report, with preprocessed source if appropriate. See for instructions. make[4]: *** [/kisskb/src/scripts/Makefile.build:283: drivers/tty/vt/vt_ioctl.o] Error 1 make[3]: *** [/kisskb/src/scripts/Makefile.build:500: drivers/tty/vt] Error 2 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/kisskb/src/scripts/Makefile.build:500: drivers/tty] Error 2 make[1]: *** [/kisskb/src/Makefile:1784: drivers] Error 2 make[1]: *** Waiting for unfinished jobs.... /kisskb/src/fs/fat/dir.c: In function 'fat_ioctl_filldir': /kisskb/src/fs/fat/dir.c:759:43: internal compiler error: Max. number of generated reload insns per insn is achieved (90) FAT_IOCTL_FILLDIR_FUNC(fat_ioctl_filldir, __fat_dirent) ^ /kisskb/src/fs/fat/dir.c:714:9: note: in definition of macro 'FAT_IOCTL_FILLDIR_FUNC' struct dirent_type __user *d2 = d1 + 1; \ ^ Please submit a full bug report, with preprocessed source if appropriate. See for instructions. make[3]: *** [/kisskb/src/scripts/Makefile.build:283: fs/fat/dir.o] Error 1 make[2]: *** [/kisskb/src/scripts/Makefile.build:500: fs/fat] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [/kisskb/src/Makefile:1784: fs] Error 2 make: *** [Makefile:185: __sub-make] Error 2 Command 'make -s -j 8 ARCH=arm O=/kisskb/build/linus_rpc_defconfig_arm-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi- ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus_rpc_defconfig_arm-gcc4.9 # Build took: 0:00:51.156561