# 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/fe-x86-64-core-i7-2017.05/bin/x86_64-linux-gcc --version # < /opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux-ld --version # < git log --format=%s --max-count=1 fe67f4dd8daa252eb9aa7acb61555f3cc3c1ce4c # < make -s -j 120 ARCH=um O=/kisskb/build/linus_um-allyesconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 allyesconfig # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_KCOV=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_GCC_PLUGIN_CYC_COMPLEXITY=n # Added to kconfig CONFIG_GCC_PLUGIN_SANCOV=n # Added to kconfig CONFIG_GCC_PLUGIN_LATENT_ENTROPY=n # Added to kconfig CONFIG_GCC_PLUGIN_STRUCTLEAK=n # Added to kconfig CONFIG_GCC_PLUGIN_RANDSTRUCT=n # Added to kconfig CONFIG_UML_NET=n # Added to kconfig CONFIG_UML_NET_ETHERTAP=n # Added to kconfig CONFIG_UML_NET_TUNTAP=n # Added to kconfig CONFIG_UML_NET_SLIP=n # Added to kconfig CONFIG_UML_NET_DAEMON=n # Added to kconfig CONFIG_UML_NET_VDE=n # Added to kconfig CONFIG_UML_NET_MCAST=n # Added to kconfig CONFIG_UML_NET_PCAP=n # Added to kconfig CONFIG_UML_NET_SLIRP=n # Added to kconfig CONFIG_GCOV_KERNEL=n # Added to kconfig CONFIG_DEBUG_INFO_BTF=n # Added to kconfig CONFIG_BPF_PRELOAD=n # < make -s -j 120 ARCH=um O=/kisskb/build/linus_um-allyesconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 help # make -s -j 120 ARCH=um O=/kisskb/build/linus_um-allyesconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 olddefconfig .config:11819:warning: override: reassigning to symbol GCC_PLUGIN_SANCOV .config:11822:warning: override: reassigning to symbol GCC_PLUGIN_RANDSTRUCT .config:11824:warning: override: reassigning to symbol UML_NET_ETHERTAP .config:11826:warning: override: reassigning to symbol UML_NET_SLIP .config:11829:warning: override: reassigning to symbol UML_NET_MCAST .config:11831:warning: override: reassigning to symbol UML_NET_SLIRP # make -s -j 120 ARCH=um O=/kisskb/build/linus_um-allyesconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 /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/drivers/pci/controller/vmd.c:116:21: error: field 'sysdata' has incomplete type struct pci_sysdata sysdata; ^ /kisskb/src/drivers/pci/controller/vmd.c: In function 'vmd_compose_msi_msg': /kisskb/src/drivers/pci/controller/vmd.c:150:20: error: 'X86_MSI_BASE_ADDRESS_HIGH' undeclared (first use in this function) msg->address_hi = X86_MSI_BASE_ADDRESS_HIGH; ^ /kisskb/src/drivers/pci/controller/vmd.c:150:20: note: each undeclared identifier is reported only once for each function it appears in /kisskb/src/drivers/pci/controller/vmd.c:151:19: error: 'arch_msi_msg_addr_lo_t {aka struct arch_msi_msg_addr_lo}' has no member named 'base_address' msg->arch_addr_lo.base_address = X86_MSI_BASE_ADDRESS_LOW; ^ /kisskb/src/drivers/pci/controller/vmd.c:151:35: error: 'X86_MSI_BASE_ADDRESS_LOW' undeclared (first use in this function) msg->arch_addr_lo.base_address = X86_MSI_BASE_ADDRESS_LOW; ^ /kisskb/src/drivers/pci/controller/vmd.c:152:19: error: 'arch_msi_msg_addr_lo_t {aka struct arch_msi_msg_addr_lo}' has no member named 'destid_0_7' msg->arch_addr_lo.destid_0_7 = index_from_irqs(vmd, irq); ^ /kisskb/src/drivers/pci/controller/vmd.c: In function 'vmd_enable_domain': /kisskb/src/drivers/pci/controller/vmd.c:700:4: error: dereferencing pointer to incomplete type 'struct pci_sysdata' sd->vmd_dev = vmd->dev; ^ /kisskb/src/drivers/pci/controller/vmd.c: In function 'vmd_from_bus': /kisskb/src/drivers/pci/controller/vmd.c:127:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: some warnings being treated as errors make[4]: *** [/kisskb/src/scripts/Makefile.build:271: drivers/pci/controller/vmd.o] Error 1 make[4]: *** Waiting for unfinished jobs.... make[3]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/pci/controller] Error 2 make[2]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/pci] Error 2 make[2]: *** Waiting for unfinished jobs.... /kisskb/src/drivers/dma/ioat/dca.c: In function 'dca_enabled_in_bios': /kisskb/src/drivers/dma/ioat/dca.c:64:18: error: implicit declaration of function 'cpuid_eax' [-Werror=implicit-function-declaration] cpuid_level_9 = cpuid_eax(9); ^ /kisskb/src/drivers/dma/ioat/dca.c: In function 'system_has_dca_enabled': /kisskb/src/drivers/dma/ioat/dca.c:74:6: error: implicit declaration of function 'boot_cpu_has' [-Werror=implicit-function-declaration] if (boot_cpu_has(X86_FEATURE_DCA)) ^ /kisskb/src/drivers/dma/ioat/dca.c: In function 'ioat_dca_get_tag': /kisskb/src/drivers/dma/ioat/dca.c:17:31: error: implicit declaration of function 'cpuid_ebx' [-Werror=implicit-function-declaration] #define cpu_physical_id(cpu) (cpuid_ebx(1) >> 24) ^ /kisskb/src/drivers/dma/ioat/dca.c:185:12: note: in expansion of macro 'cpu_physical_id' apic_id = cpu_physical_id(cpu); ^ cc1: some warnings being treated as errors make[4]: *** [/kisskb/src/scripts/Makefile.build:271: drivers/dma/ioat/dca.o] Error 1 make[4]: *** Waiting for unfinished jobs.... In file included from /kisskb/src/drivers/dma/idxd/init.c:24:0: /kisskb/src/drivers/dma/idxd/perfmon.h: In function 'event_to_pmu': /kisskb/src/drivers/dma/idxd/perfmon.h:24:13: error: 'struct perf_event' has no member named 'pmu' pmu = event->pmu; ^ /kisskb/src/drivers/dma/idxd/perfmon.h: In function 'event_to_idxd': /kisskb/src/drivers/dma/idxd/perfmon.h:35:13: error: 'struct perf_event' has no member named 'pmu' pmu = event->pmu; ^ /kisskb/src/drivers/dma/idxd/init.c: In function 'idxd_init_module': /kisskb/src/drivers/dma/idxd/init.c:815:7: error: implicit declaration of function 'cpu_feature_enabled' [-Werror=implicit-function-declaration] if (!cpu_feature_enabled(X86_FEATURE_MOVDIR64B)) { ^ cc1: some warnings being treated as errors make[4]: *** [/kisskb/src/scripts/Makefile.build:271: drivers/dma/idxd/init.o] Error 1 make[3]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/dma/idxd] Error 2 make[3]: *** Waiting for unfinished jobs.... make[3]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/dma/ioat] Error 2 /kisskb/src/drivers/video/fbdev/riva/fbdev.c: In function 'rivafb_probe': /kisskb/src/drivers/video/fbdev/riva/fbdev.c:2059:11: warning: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] iounmap(default_par->riva.PRAMIN); ^ In file included from /kisskb/src/arch/um/include/asm/io.h:7:0, from /kisskb/src/include/linux/io.h:13, from /kisskb/src/include/linux/irq.h:20, from /kisskb/src/include/asm-generic/hardirq.h:17, from /kisskb/src/arch/um/include/asm/hardirq.h:5, from /kisskb/src/include/linux/hardirq.h:11, from /kisskb/src/include/linux/interrupt.h:11, from /kisskb/src/include/linux/trace_recursion.h:5, from /kisskb/src/include/linux/ftrace.h:10, from /kisskb/src/include/linux/kprobes.h:29, from /kisskb/src/include/linux/kgdb.h:19, from /kisskb/src/include/linux/fb.h:5, from /kisskb/src/drivers/video/fbdev/riva/fbdev.c:39: /kisskb/src/include/asm-generic/logic_io.h:36:17: note: expected 'void *' but argument is of type 'volatile U032 * {aka volatile unsigned int *}' #define iounmap iounmap ^ /kisskb/src/include/asm-generic/logic_io.h:37:6: note: in expansion of macro 'iounmap' void iounmap(void __iomem *addr); ^ /kisskb/src/drivers/video/fbdev/riva/fbdev.c: In function 'rivafb_remove': /kisskb/src/drivers/video/fbdev/riva/fbdev.c:2092:11: warning: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] iounmap(par->riva.PRAMIN); ^ In file included from /kisskb/src/arch/um/include/asm/io.h:7:0, from /kisskb/src/include/linux/io.h:13, from /kisskb/src/include/linux/irq.h:20, from /kisskb/src/include/asm-generic/hardirq.h:17, from /kisskb/src/arch/um/include/asm/hardirq.h:5, from /kisskb/src/include/linux/hardirq.h:11, from /kisskb/src/include/linux/interrupt.h:11, from /kisskb/src/include/linux/trace_recursion.h:5, from /kisskb/src/include/linux/ftrace.h:10, from /kisskb/src/include/linux/kprobes.h:29, from /kisskb/src/include/linux/kgdb.h:19, from /kisskb/src/include/linux/fb.h:5, from /kisskb/src/drivers/video/fbdev/riva/fbdev.c:39: /kisskb/src/include/asm-generic/logic_io.h:36:17: note: expected 'void *' but argument is of type 'volatile U032 * {aka volatile unsigned int *}' #define iounmap iounmap ^ /kisskb/src/include/asm-generic/logic_io.h:37:6: note: in expansion of macro 'iounmap' void iounmap(void __iomem *addr); ^ make[2]: *** [/kisskb/src/scripts/Makefile.build:514: drivers/dma] Error 2 /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c: In function 'nvidiafb_probe': /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c:1414:10: warning: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] iounmap(par->REGS); ^ In file included from /kisskb/src/arch/um/include/asm/io.h:7:0, from /kisskb/src/include/linux/io.h:13, from /kisskb/src/include/linux/irq.h:20, from /kisskb/src/include/asm-generic/hardirq.h:17, from /kisskb/src/arch/um/include/asm/hardirq.h:5, from /kisskb/src/include/linux/hardirq.h:11, from /kisskb/src/include/linux/interrupt.h:11, from /kisskb/src/include/linux/trace_recursion.h:5, from /kisskb/src/include/linux/ftrace.h:10, from /kisskb/src/include/linux/kprobes.h:29, from /kisskb/src/include/linux/kgdb.h:19, from /kisskb/src/include/linux/fb.h:5, from /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c:19: /kisskb/src/include/asm-generic/logic_io.h:36:17: note: expected 'void *' but argument is of type 'volatile u32 * {aka volatile unsigned int *}' #define iounmap iounmap ^ /kisskb/src/include/asm-generic/logic_io.h:37:6: note: in expansion of macro 'iounmap' void iounmap(void __iomem *addr); ^ /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c: In function 'nvidiafb_remove': /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c:1439:10: warning: passing argument 1 of 'iounmap' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] iounmap(par->REGS); ^ In file included from /kisskb/src/arch/um/include/asm/io.h:7:0, from /kisskb/src/include/linux/io.h:13, from /kisskb/src/include/linux/irq.h:20, from /kisskb/src/include/asm-generic/hardirq.h:17, from /kisskb/src/arch/um/include/asm/hardirq.h:5, from /kisskb/src/include/linux/hardirq.h:11, from /kisskb/src/include/linux/interrupt.h:11, from /kisskb/src/include/linux/trace_recursion.h:5, from /kisskb/src/include/linux/ftrace.h:10, from /kisskb/src/include/linux/kprobes.h:29, from /kisskb/src/include/linux/kgdb.h:19, from /kisskb/src/include/linux/fb.h:5, from /kisskb/src/drivers/video/fbdev/nvidia/nvidia.c:19: /kisskb/src/include/asm-generic/logic_io.h:36:17: note: expected 'void *' but argument is of type 'volatile u32 * {aka volatile unsigned int *}' #define iounmap iounmap ^ /kisskb/src/include/asm-generic/logic_io.h:37:6: note: in expansion of macro 'iounmap' void iounmap(void __iomem *addr); ^ make[1]: *** [/kisskb/src/Makefile:1851: drivers] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:220: __sub-make] Error 2 Command 'make -s -j 120 ARCH=um O=/kisskb/build/linus_um-allyesconfig_um-x86_64 CROSS_COMPILE=/opt/cross/kisskb/fe-x86-64-core-i7-2017.05/bin/x86_64-linux- SUBARCH=x86_64 ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus_um-allyesconfig_um-x86_64 # Build took: 0:02:42.266860