# 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-8.1.0-nolibc/s390-linux/bin/s390-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/s390-linux/bin/s390-linux-ld --version # < git log --format=%s --max-count=1 472e5b056f000a778abb41f1e443de58eb259783 # < make -s -j 8 ARCH=s390 O=/kisskb/build/linus_s390-allmodconfig_s390x-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/s390-linux/bin/s390-linux- allmodconfig # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_SAMPLES=n # < make -s -j 8 ARCH=s390 O=/kisskb/build/linus_s390-allmodconfig_s390x-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/s390-linux/bin/s390-linux- help # make -s -j 8 ARCH=s390 O=/kisskb/build/linus_s390-allmodconfig_s390x-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/s390-linux/bin/s390-linux- olddefconfig # make -s -j 8 ARCH=s390 O=/kisskb/build/linus_s390-allmodconfig_s390x-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/s390-linux/bin/s390-linux- /kisskb/src/drivers/gpu/drm/rockchip/cdn-dp-core.c:1124:12: warning: 'cdn_dp_resume' defined but not used [-Wunused-function] static int cdn_dp_resume(struct device *dev) ^~~~~~~~~~~~~ In file included from /kisskb/src/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:41: /kisskb/src/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c: In function 'mvpp2_setup_bm_pool': /kisskb/src/drivers/net/ethernet/marvell/mvpp2/mvpp2.h:647:2: warning: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551584' to '-32' [-Woverflow] ((total_size) - MVPP2_SKB_HEADROOM - MVPP2_SKB_SHINFO_SIZE) ^ /kisskb/src/drivers/net/ethernet/marvell/mvpp2/mvpp2.h:714:33: note: in expansion of macro 'MVPP2_RX_MAX_PKT_SIZE' #define MVPP2_BM_SHORT_PKT_SIZE MVPP2_RX_MAX_PKT_SIZE(MVPP2_BM_SHORT_FRAME_SIZE) ^~~~~~~~~~~~~~~~~~~~~ /kisskb/src/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:652:41: note: in expansion of macro 'MVPP2_BM_SHORT_PKT_SIZE' mvpp2_pools[MVPP2_BM_SHORT].pkt_size = MVPP2_BM_SHORT_PKT_SIZE; ^~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/drivers/input/joystick/analog.c:160:2: warning: #warning Precise timer not defined for this architecture. [-Wcpp] #warning Precise timer not defined for this architecture. ^~~~~~~ /kisskb/src/drivers/staging/media/tegra-vde/vde.c:916:12: warning: 'tegra_vde_runtime_suspend' defined but not used [-Wunused-function] static int tegra_vde_runtime_suspend(struct device *dev) ^~~~~~~~~~~~~~~~~~~~~~~~~ Completed OK # rm -rf /kisskb/build/linus_s390-allmodconfig_s390x-gcc8 # Build took: 0:31:26.685960