# 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-4.9.4-nolibc/s390-linux/bin/s390-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/s390-linux/bin/s390-linux-ld --version # < git log --format=%s --max-count=1 fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c # < make -s -j 48 ARCH=s390 O=/kisskb/build/linus_s390-defconfig_s390x-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/s390-linux/bin/s390-linux- defconfig # < make -s -j 48 ARCH=s390 O=/kisskb/build/linus_s390-defconfig_s390x-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/s390-linux/bin/s390-linux- help # make -s -j 48 ARCH=s390 O=/kisskb/build/linus_s390-defconfig_s390x-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/s390-linux/bin/s390-linux- olddefconfig # make -s -j 48 ARCH=s390 O=/kisskb/build/linus_s390-defconfig_s390x-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/s390-linux/bin/s390-linux- /kisskb/src/security/landlock/ruleset.c: In function 'insert_rule': /kisskb/src/security/landlock/ruleset.c:196:34: warning: passing argument 2 of 'create_rule' from incompatible pointer type new_rule = create_rule(object, &this->layers, this->num_layers, ^ /kisskb/src/security/landlock/ruleset.c:69:30: note: expected 'const struct landlock_layer (* const)[]' but argument is of type 'struct landlock_layer (*)[]' static struct landlock_rule *create_rule( ^ /kisskb/src/security/landlock/ruleset.c: In function 'landlock_insert_rule': /kisskb/src/security/landlock/ruleset.c:240:38: warning: passing argument 3 of 'insert_rule' from incompatible pointer type return insert_rule(ruleset, object, &layers, ARRAY_SIZE(layers)); ^ /kisskb/src/security/landlock/ruleset.c:144:12: note: expected 'const struct landlock_layer (* const)[]' but argument is of type 'struct landlock_layer (*)[1]' static int insert_rule(struct landlock_ruleset *const ruleset, ^ /kisskb/src/security/landlock/ruleset.c: In function 'merge_ruleset': /kisskb/src/security/landlock/ruleset.c:300:47: warning: passing argument 3 of 'insert_rule' from incompatible pointer type err = insert_rule(dst, walker_rule->object, &layers, ^ /kisskb/src/security/landlock/ruleset.c:144:12: note: expected 'const struct landlock_layer (* const)[]' but argument is of type 'struct landlock_layer (*)[1]' static int insert_rule(struct landlock_ruleset *const ruleset, ^ /kisskb/src/security/landlock/ruleset.c: In function 'inherit_ruleset': /kisskb/src/security/landlock/ruleset.c:330:5: warning: passing argument 3 of 'insert_rule' from incompatible pointer type &walker_rule->layers, walker_rule->num_layers); ^ /kisskb/src/security/landlock/ruleset.c:144:12: note: expected 'const struct landlock_layer (* const)[]' but argument is of type 'struct landlock_layer (*)[]' static int insert_rule(struct landlock_ruleset *const ruleset, ^ /kisskb/src/net/sched/sch_frag.c: In function 'sch_fragment': /kisskb/src/net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] struct rtable sch_frag_rt = { 0 }; ^ /kisskb/src/net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] /kisskb/src/fs/btrfs/tree-checker.c: In function 'check_root_item': /kisskb/src/fs/btrfs/tree-checker.c:1071:9: warning: missing braces around initializer [-Wmissing-braces] struct btrfs_root_item ri = { 0 }; ^ /kisskb/src/fs/btrfs/tree-checker.c:1071:9: warning: (near initialization for 'ri.inode') [-Wmissing-braces] /kisskb/src/fs/cifs/connect.c: In function 'cifs_mount': /kisskb/src/fs/cifs/connect.c:3466:2: warning: missing braces around initializer [-Wmissing-braces] uuid_t mount_id = {0}; ^ /kisskb/src/fs/cifs/connect.c:3466:2: warning: (near initialization for 'mount_id.b') [-Wmissing-braces] /kisskb/src/net/openvswitch/actions.c: In function 'ovs_fragment': /kisskb/src/net/openvswitch/actions.c:831:10: warning: missing braces around initializer [-Wmissing-braces] struct rtable ovs_rt = { 0 }; ^ /kisskb/src/net/openvswitch/actions.c:831:10: warning: (near initialization for 'ovs_rt.dst') [-Wmissing-braces] Completed OK # rm -rf /kisskb/build/linus_s390-defconfig_s390x-gcc4.9 # Build took: 0:04:01.739119