# git rev-parse -q --verify fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c^{commit} fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c already have revision, skipping fetch # git checkout -q -f -B kisskb fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c # git clean -qxdf # < git log -1 # commit fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c # Author: Linus Torvalds # Date: Tue Aug 24 10:39:25 2021 -0700 # # pipe: do FASYNC notifications for every pipe IO, not just state changes # # It turns out that the SIGIO/FASYNC situation is almost exactly the same # as the EPOLLET case was: user space really wants to be notified after # every operation. # # Now, in a perfect world it should be sufficient to only notify user # space on "state transitions" when the IO state changes (ie when a pipe # goes from unreadable to readable, or from unwritable to writable). User # space should then do as much as possible - fully emptying the buffer or # what not - and we'll notify it again the next time the state changes. # # But as with EPOLLET, we have at least one case (stress-ng) where the # kernel sent SIGIO due to the pipe being marked for asynchronous # notification, but the user space signal handler then didn't actually # necessarily read it all before returning (it read more than what was # written, but since there could be multiple writes, it could leave data # pending). # # The user space code then expected to get another SIGIO for subsequent # writes - even though the pipe had been readable the whole time - and # would only then read more. # # This is arguably a user space bug - and Colin King already fixed the # stress-ng code in question - but the kernel regression rules are clear: # it doesn't matter if kernel people think that user space did something # silly and wrong. What matters is that it used to work. # # So if user space depends on specific historical kernel behavior, it's a # regression when that behavior changes. It's on us: we were silly to # have that non-optimal historical behavior, and our old kernel behavior # was what user space was tested against. # # Because of how the FASYNC notification was tied to wakeup behavior, this # was first broken by commits f467a6a66419 and 1b6b26ae7053 ("pipe: fix # and clarify pipe read/write wakeup logic"), but at the time it seems # nobody noticed. Probably because the stress-ng problem case ends up # being timing-dependent too. # # It was then unwittingly fixed by commit 3a34b13a88ca ("pipe: make pipe # writes always wake up readers") only to be broken again when by commit # 3b844826b6c6 ("pipe: avoid unnecessary EPOLLET wakeups under normal # loads"). # # And at that point the kernel test robot noticed the performance # refression in the stress-ng.sigio.ops_per_sec case. So the "Fixes" tag # below is somewhat ad hoc, but it matches when the issue was noticed. # # Fix it for good (knock wood) by simply making the kill_fasync() case # separate from the wakeup case. FASYNC is quite rare, and we clearly # shouldn't even try to use the "avoid unnecessary wakeups" logic for it. # # Link: https://lore.kernel.org/lkml/20210824151337.GC27667@xsang-OptiPlex-9020/ # Fixes: 3b844826b6c6 ("pipe: avoid unnecessary EPOLLET wakeups under normal loads") # Reported-by: kernel test robot # Tested-by: Oliver Sang # Cc: Eric Biederman # Cc: Colin Ian King # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ld --version # < git log --format=%s --max-count=1 fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c # < make -s -j 32 ARCH=arm64 O=/kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- allmodconfig # < make -s -j 32 ARCH=arm64 O=/kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- help # make -s -j 32 ARCH=arm64 O=/kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- olddefconfig # make -s -j 32 ARCH=arm64 O=/kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- /kisskb/src/kernel/trace/trace_osnoise.c: In function 'start_kthread': /kisskb/src/kernel/trace/trace_osnoise.c:1515:8: warning: 'main' is usually a function [-Wmain] void *main = osnoise_main; ^~~~ /kisskb/src/lib/test_scanf.c: In function 'numbers_list_field_width_val_width': /kisskb/src/lib/test_scanf.c:530:1: warning: the frame size of 2512 bytes is larger than 2048 bytes [-Wframe-larger-than=] } ^ /kisskb/src/lib/test_scanf.c: In function 'numbers_list_field_width_typemax': /kisskb/src/lib/test_scanf.c:488:1: warning: the frame size of 3008 bytes is larger than 2048 bytes [-Wframe-larger-than=] } ^ /kisskb/src/lib/test_scanf.c: In function 'numbers_list': /kisskb/src/lib/test_scanf.c:437:1: warning: the frame size of 2512 bytes is larger than 2048 bytes [-Wframe-larger-than=] } ^ In file included from /kisskb/src/include/linux/byteorder/little_endian.h:5, from /kisskb/src/arch/arm64/include/uapi/asm/byteorder.h:23, from /kisskb/src/include/asm-generic/bitops/le.h:7, from /kisskb/src/arch/arm64/include/asm/bitops.h:29, from /kisskb/src/include/linux/bitops.h:32, from /kisskb/src/include/linux/of.h:15, from /kisskb/src/include/linux/irqdomain.h:35, from /kisskb/src/include/linux/acpi.h:13, from /kisskb/src/drivers/infiniband/hw/hns/hns_roce_hw_v2.c:33: In function 'modify_qp_init_to_rtr', inlined from 'hns_roce_v2_set_abs_fields' at /kisskb/src/drivers/infiniband/hw/hns/hns_roce_hw_v2.c:4798:9, inlined from 'hns_roce_v2_modify_qp' at /kisskb/src/drivers/infiniband/hw/hns/hns_roce_hw_v2.c:5001:8: /kisskb/src/include/linux/compiler_types.h:328:38: error: call to '__compiletime_assert_1854' declared with attribute error: FIELD_PREP: value too large for the field _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ /kisskb/src/include/uapi/linux/byteorder/little_endian.h:33:51: note: in definition of macro '__cpu_to_le32' #define __cpu_to_le32(x) ((__force __le32)(__u32)(x)) ^ /kisskb/src/include/linux/compiler_types.h:316:2: note: in expansion of macro '__compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^~~~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ ^~~~~~~~~~~~~~~~ /kisskb/src/include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK' __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \ ^~~~~~~~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_common.h:91:52: note: in expansion of macro 'FIELD_PREP' *((__le32 *)ptr + (field_h) / 32) |= cpu_to_le32(FIELD_PREP( \ ^~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_common.h:95:39: note: in expansion of macro '_hr_reg_write' #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val) ^~~~~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_hw_v2.c:4422:2: note: in expansion of macro 'hr_reg_write' hr_reg_write(context, QPC_LP_PKTN_INI, lp_pktn_ini); ^~~~~~~~~~~~ /kisskb/src/include/linux/compiler_types.h:328:38: error: call to '__compiletime_assert_1861' declared with attribute error: FIELD_PREP: value too large for the field _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ /kisskb/src/include/uapi/linux/byteorder/little_endian.h:33:51: note: in definition of macro '__cpu_to_le32' #define __cpu_to_le32(x) ((__force __le32)(__u32)(x)) ^ /kisskb/src/include/linux/compiler_types.h:316:2: note: in expansion of macro '__compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^~~~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/compiler_types.h:328:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ /kisskb/src/include/linux/bitfield.h:49:3: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \ ^~~~~~~~~~~~~~~~ /kisskb/src/include/linux/bitfield.h:94:3: note: in expansion of macro '__BF_FIELD_CHECK' __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \ ^~~~~~~~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_common.h:91:52: note: in expansion of macro 'FIELD_PREP' *((__le32 *)ptr + (field_h) / 32) |= cpu_to_le32(FIELD_PREP( \ ^~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_common.h:95:39: note: in expansion of macro '_hr_reg_write' #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val) ^~~~~~~~~~~~~ /kisskb/src/drivers/infiniband/hw/hns/hns_roce_hw_v2.c:4426:2: note: in expansion of macro 'hr_reg_write' hr_reg_write(context, QPC_ACK_REQ_FREQ, lp_pktn_ini); ^~~~~~~~~~~~ make[5]: *** [/kisskb/src/scripts/Makefile.build:271: drivers/infiniband/hw/hns/hns_roce_hw_v2.o] Error 1 make[4]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/infiniband/hw/hns] Error 2 make[3]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/infiniband/hw] Error 2 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/infiniband] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [/kisskb/src/Makefile:1851: drivers] Error 2 make: *** [Makefile:220: __sub-make] Error 2 Command 'make -s -j 32 ARCH=arm64 O=/kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus_arm64-allmodconfig_arm64-gcc8 # Build took: 0:15:49.366008