irq/core for v5.16-rc1
Subsystems (96)
Linus,
please pull the latest irq/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq-core-2021-10-31
up to: 2258a6fc33d5: Merge tag 'irqchip-5.16' into irq/core
Updates for the interrupt subsystem:
Core changes:
- Prevent a potential deadlock when initial priority is assigned to a newly created interrupt thread. A recent change to plug a race between cpuset and __sched_setscheduler() introduced a new lock dependency which is now triggered. Break the lock dependency chain by moving the priority assignment to the thread function.
- A couple of small updates to make the irq core RT safe.
- Confine the irq_cpu_online/offline() API to the only left unfixable user Cavium Octeon so that it does not grow new usage.
- A small documentation update
Driver changes:
- A large cross architecture rework to move irq_enter/exit() into the architecture code to make addressing the NOHZ_FULL/RCU issues simpler.
- The obligatory new irq chip driver for Microchip EIC
- Modularize a few irq chip drivers
- Expand usage of devm_*() helpers throughout the driver code
- The usual small fixes and improvements all over the place
Thanks,
tglx
------------------>
Arnd Bergmann (1):
irqchip: Fix compile-testing without CONFIG_OF
Cai Huoqing (5):
irqchip/irq-mvebu-icu: Make use of the helper function devm_platform_ioremap_resource() irqchip/irq-mvebu-pic: Make use of the helper function devm_platform_ioremap_resource() irqchip/irq-ts4800: Make use of the helper function devm_platform_ioremap_resource() irqchip/stm32: Make use of the helper function devm_platform_ioremap_resource() irqchip/ti-sci-inta: Make use of the helper function devm_platform_ioremap_resource()
Claudiu Beznea (2):
dt-bindings: microchip,eic: Add bindings for the Microchip EIC irqchip/mchp-eic: Add support for the Microchip EIC
Florian Fainelli (13):
irqchip/irq-bcm7038-l1: Remove .irq_cpu_offline() irqchip/irq-bcm7038-l1: Use irq_get_irq_data()
MIPS: BMIPS: Remove use of irq_cpu_offline irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS irqchip/irq-bcm7038-l1: Restrict affinity setting to MIPS irqchip/irq-bcm7038-l1: Switch to IRQCHIP_PLATFORM_DRIVER
genirq: Export irq_gc_{unmask_enable,mask_disable}_reg irqchip/irq-brcmstb-l2: Switch to IRQCHIP_PLATFORM_DRIVER
genirq: Export irq_gc_noop()
irqchip/irq-bcm7120-l2: Switch to IRQCHIP_PLATFORM_DRIVER
arm64: broadcom: Removed forced select of interrupt controllers
ARM: bcm: Removed forced select of interrupt controllers
irqchip: Fix kernel-doc parameter typo for IRQCHIP_DECLARE
Ingo Molnar (1):
genirq: Disable irqfixup/poll on PREEMPT_RT.
Josh Cartwright (1):
genirq: Update irq_set_irqchip_state documentation
Marc Zyngier (5):
irqchip: Provide stronger type checking for IRQCHIP_MATCH/IRQCHIP_DECLARE
MIPS: loongson64: Drop call to irq_cpu_offline() irqchip/mips-gic: Get rid of the reliance on irq_cpu_online()
genirq: Hide irq_cpu_{on,off}line() behind a deprecated option
h8300: Fix linux/irqchip.h include mess
Marian-Cristian Rotariu (1):
dt-bindings: irqchip: renesas-irqc: Document r8a774e1 bindings
Mark Rutland (17):
irq: mips: avoid nested irq_enter()
irq: mips: simplify bcm6345_l1_irq_handle()
irq: mips: stop (ab)using handle_domain_irq()
irq: mips: simplify do_domain_IRQ()
irq: simplify handle_domain_{irq,nmi}()
irq: unexport handle_irq_desc()
irq: add generic_handle_arch_irq()
irq: arc: avoid CONFIG_HANDLE_DOMAIN_IRQ
irq: nds32: avoid CONFIG_HANDLE_DOMAIN_IRQ
irq: add a (temporary) CONFIG_HANDLE_DOMAIN_IRQ_IRQENTRY
irq: arm: perform irqentry in entry code
irq: arm64: perform irqentry in entry code
irq: csky: perform irqentry in entry code
irq: openrisc: perform irqentry in entry code
irq: riscv: perform irqentry in entry code
irq: remove CONFIG_HANDLE_DOMAIN_IRQ_IRQENTRY
irq: remove handle_domain_{irq,nmi}()
Mauro Carvalho Chehab (1):
MAINTAINERS: update arm,vic.yaml reference
Neil Armstrong (2):
irqchip/meson-gpio: Make it possible to build as a module
arm64: meson: remove MESON_IRQ_GPIO selection
Thomas Gleixner (2):
genirq: Move prio assignment into the newly created thread x86/softirq: Disable softirq stacks on PREEMPT_RT
Yang Yingliang (1):
irqchip/mchp-eic: Fix return value check in mchp_eic_init()
Yanteng Si (1):
MIPS: irq: Avoid an unused-variable error
Documentation/core-api/irq/irq-domain.rst | 3 - .../interrupt-controller/microchip,eic.yaml | 73 ++++++ .../interrupt-controller/renesas,irqc.yaml | 1 + MAINTAINERS | 8 +- arch/arc/Kconfig | 1 - arch/arc/kernel/irq.c | 10 +- arch/arm/Kconfig | 1 - arch/arm/kernel/entry-armv.S | 5 +- arch/arm/kernel/irq.c | 14 +- arch/arm/mach-bcm/Kconfig | 4 - arch/arm/mach-imx/avic.c | 2 +- arch/arm/mach-imx/tzic.c | 2 +- arch/arm/mach-omap1/irq.c | 2 +- arch/arm/mach-s3c/irq-s3c24xx.c | 2 +- arch/arm64/Kconfig | 1 - arch/arm64/Kconfig.platforms | 4 - arch/arm64/kernel/entry-common.c | 52 ++-- arch/csky/Kconfig | 1 - arch/csky/kernel/entry.S | 2 +- arch/csky/kernel/irq.c | 5 - arch/h8300/include/asm/irq.h | 2 - arch/h8300/kernel/irq.c | 1 + arch/mips/Kconfig | 2 +- arch/mips/cavium-octeon/octeon-irq.c | 5 +- arch/mips/kernel/irq.c | 8 +- arch/mips/kernel/smp-bmips.c | 3 +- arch/mips/loongson64/smp.c | 1 - arch/nds32/Kconfig | 1 - arch/openrisc/Kconfig | 1 - arch/openrisc/kernel/entry.S | 4 +- arch/openrisc/kernel/irq.c | 5 - arch/riscv/Kconfig | 1 - arch/riscv/kernel/entry.S | 3 +- arch/riscv/kernel/smp.c | 9 +- arch/x86/include/asm/irq_stack.h | 3 + arch/x86/kernel/irq_32.c | 2 + drivers/irqchip/Kconfig | 25 +- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-apple-aic.c | 20 +- drivers/irqchip/irq-armada-370-xp.c | 13 +- drivers/irqchip/irq-aspeed-vic.c | 2 +- drivers/irqchip/irq-ativic32.c | 22 +- drivers/irqchip/irq-atmel-aic.c | 2 +- drivers/irqchip/irq-atmel-aic5.c | 2 +- drivers/irqchip/irq-bcm2835.c | 2 +- drivers/irqchip/irq-bcm2836.c | 2 +- drivers/irqchip/irq-bcm6345-l1.c | 6 +- drivers/irqchip/irq-bcm7038-l1.c | 47 +--- drivers/irqchip/irq-bcm7120-l2.c | 21 +- drivers/irqchip/irq-brcmstb-l2.c | 16 +- drivers/irqchip/irq-clps711x.c | 8 +- drivers/irqchip/irq-csky-apb-intc.c | 2 +- drivers/irqchip/irq-csky-mpintc.c | 4 +- drivers/irqchip/irq-davinci-aintc.c | 2 +- drivers/irqchip/irq-davinci-cp-intc.c | 2 +- drivers/irqchip/irq-digicolor.c | 2 +- drivers/irqchip/irq-dw-apb-ictl.c | 2 +- drivers/irqchip/irq-ftintc010.c | 2 +- drivers/irqchip/irq-gic-v3.c | 4 +- drivers/irqchip/irq-gic.c | 2 +- drivers/irqchip/irq-hip04.c | 2 +- drivers/irqchip/irq-ixp4xx.c | 4 +- drivers/irqchip/irq-lpc32xx.c | 2 +- drivers/irqchip/irq-mchp-eic.c | 280 +++++++++++++++++++++ drivers/irqchip/irq-meson-gpio.c | 15 +- drivers/irqchip/irq-mips-gic.c | 37 ++- drivers/irqchip/irq-mmp.c | 4 +- drivers/irqchip/irq-mvebu-icu.c | 4 +- drivers/irqchip/irq-mvebu-pic.c | 4 +- drivers/irqchip/irq-mxs.c | 2 +- drivers/irqchip/irq-nvic.c | 17 +- drivers/irqchip/irq-omap-intc.c | 2 +- drivers/irqchip/irq-or1k-pic.c | 2 +- drivers/irqchip/irq-orion.c | 4 +- drivers/irqchip/irq-rda-intc.c | 2 +- drivers/irqchip/irq-riscv-intc.c | 2 +- drivers/irqchip/irq-sa11x0.c | 4 +- drivers/irqchip/irq-stm32-exti.c | 4 +- drivers/irqchip/irq-sun4i.c | 2 +- drivers/irqchip/irq-ti-sci-inta.c | 4 +- drivers/irqchip/irq-ts4800.c | 4 +- drivers/irqchip/irq-versatile-fpga.c | 2 +- drivers/irqchip/irq-vic.c | 2 +- drivers/irqchip/irq-vt8500.c | 2 +- drivers/irqchip/irq-wpcm450-aic.c | 2 +- drivers/irqchip/irq-zevio.c | 2 +- include/linux/irq.h | 6 +- include/linux/irqchip.h | 20 +- include/linux/irqdesc.h | 9 +- kernel/irq/Kconfig | 10 +- kernel/irq/chip.c | 2 + kernel/irq/generic-chip.c | 3 + kernel/irq/handle.c | 18 ++ kernel/irq/irqdesc.c | 81 ++---- kernel/irq/manage.c | 6 +- kernel/irq/spurious.c | 8 + 96 files changed, 700 insertions(+), 329 deletions(-) create mode 100644 Documentation/devicetree/bindings/interrupt-controller/microchip,eic.yaml create mode 100644 drivers/irqchip/irq-mchp-eic.c
Documentation/core-api/irq/irq-domain.rst +0 -3
@@ -67,9 +67,6 @@ variety of methods: deprecated - generic_handle_domain_irq() handles an interrupt described by a domain and a hwirq number -- handle_domain_irq() does the same thing for root interrupt - controllers and deals with the set_irq_reg()/irq_enter() sequences - that most architecture requires Note that irq domain lookups must happen in contexts that are compatible with a RCU read-side critical section.
Documentation/devicetree/bindings/interrupt-controller/microchip,eic.yaml new file +73 -0
73 lines not on this page · raw message
Documentation/devicetree/bindings/interrupt-controller/renesas,irqc.yaml +1 -0
@@ -27,6 +27,7 @@ properties: - renesas,intc-ex-r8a774a1 # RZ/G2M - renesas,intc-ex-r8a774b1 # RZ/G2N - renesas,intc-ex-r8a774c0 # RZ/G2E + - renesas,intc-ex-r8a774e1 # RZ/G2H - renesas,intc-ex-r8a7795 # R-Car H3 - renesas,intc-ex-r8a7796 # R-Car M3-W - renesas,intc-ex-r8a77961 # R-Car M3-W+
MAINTAINERS +7 -1
@@ -1551,7 +1551,7 @@ ARM PRIMECELL VIC PL190/PL192 DRIVER M: Linus Walleij <[email protected]> L: [email protected] (moderated for non-subscribers) S: Maintained -F: Documentation/devicetree/bindings/interrupt-controller/arm,vic.txt +F: Documentation/devicetree/bindings/interrupt-controller/arm,vic.yaml F: drivers/irqchip/irq-vic.c ARM SMC WATCHDOG DRIVER
@@ -12254,6 +12254,12 @@ L: [email protected] S: Maintained F: drivers/crypto/atmel-ecc.* +MICROCHIP EIC DRIVER +M: Claudiu Beznea <[email protected]> +L: [email protected] (moderated for non-subscribers) +S: Supported +F: drivers/irqchip/irq-mchp-eic.c + MICROCHIP I2C DRIVER M: Codrin Ciubotariu <[email protected]> L: [email protected]
arch/arc/Kconfig +0 -1
@@ -40,7 +40,6 @@ config ARC select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC select HAVE_PERF_EVENTS - select HANDLE_DOMAIN_IRQ select IRQ_DOMAIN select MODULES_USE_ELF_RELA select OF
arch/arc/kernel/irq.c +9 -1
@@ -6,6 +6,8 @@#include <linux/interrupt.h> #include <linux/irqchip.h> #include <asm/mach_desc.h> + +#include <asm/irq_regs.h> #include <asm/smp.h> /*
@@ -39,5 +41,11 @@ void __init init_IRQ(void)*/ void arch_do_IRQ (unsigned int hwirq,struct pt_regs *regs) { -handle_domain_irq (NULL , hwirq, regs); +struct pt_regs *old_regs; + +irq_enter (); + old_regs =set_irq_regs (regs); +generic_handle_domain_irq (NULL , hwirq); +set_irq_regs (old_regs); +irq_exit (); }
arch/arm/Kconfig +0 -1
@@ -64,7 +64,6 @@ config ARM select GENERIC_PCI_IOMAP select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD - select HANDLE_DOMAIN_IRQ select HARDIRQS_SW_RESEND select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
arch/arm/kernel/entry-armv.S +1 -4
@@ -38,14 +38,11 @@ */ .macro irq_handler #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER - ldr r1, =handle_arch_irq mov r0, sp - badr lr, 9997f - ldr pc, [r1] + bl generic_handle_arch_irq #else arch_irq_handler_default #endif -9997: .endm .macro pabt_helper
arch/arm/kernel/irq.c +8 -6
@@ -63,11 +63,8 @@ int arch_show_interrupts(struct seq_file *p, int prec)*/ void handle_IRQ (unsigned int irq,struct pt_regs *regs) { -struct pt_regs *old_regs =set_irq_regs (regs);struct irq_desc *desc; -irq_enter (); -/* * Some hardware gives randomly wrong interrupts. Rather * than crashing, do something sensible.
@@ -81,9 +78,6 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)handle_irq_desc (desc); elseack_bad_irq (irq ); - -irq_exit (); -set_irq_regs (old_regs); }/*
@@ -92,7 +86,15 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs) asmlinkage void __exception_irq_entryasm_do_IRQ (unsigned int irq,struct pt_regs *regs) { +struct pt_regs *old_regs; + +irq_enter (); + old_regs =set_irq_regs (regs); +handle_IRQ (irq, regs); + +set_irq_regs (old_regs); +irq_exit (); }void __init init_IRQ (void )
arch/arm/mach-bcm/Kconfig +0 -4
@@ -161,7 +161,6 @@ config ARCH_BCM2835 select ARM_TIMER_SP804 select HAVE_ARM_ARCH_TIMER if ARCH_MULTI_V7 select BCM2835_TIMER - select BRCMSTB_L2_IRQ select PINCTRL select PINCTRL_BCM2835 select MFD_CORE
@@ -209,9 +208,6 @@ config ARCH_BRCMSTB select ARM_GIC select ARM_ERRATA_798181 if SMP select HAVE_ARM_ARCH_TIMER - select BCM7038_L1_IRQ - select BRCMSTB_L2_IRQ - select BCM7120_L2_IRQ select ZONE_DMA if ARM_LPAE select SOC_BRCMSTB select SOC_BUS
arch/arm/mach-imx/avic.c +1 -1
@@ -154,7 +154,7 @@ static void __exception_irq_entry avic_handle_irq(struct pt_regs *regs)if (nivector ==0xffff )break ; -handle_domain_irq (domain, nivector, regs); +generic_handle_domain_irq (domain, nivector); }while (1 ); }
arch/arm/mach-imx/tzic.c +1 -1
@@ -134,7 +134,7 @@ static void __exception_irq_entry tzic_handle_irq(struct pt_regs *regs)while (stat) { handled =1 ; irqofs =fls (stat) -1 ; -handle_domain_irq (domain, irqofs + i *32 , regs); +generic_handle_domain_irq (domain, irqofs + i *32 ); stat &= ~(1 << irqofs); } }
arch/arm/mach-omap1/irq.c +1 -1
@@ -165,7 +165,7 @@ asmlinkage void __exception_irq_entry omap1_handle_irq(struct pt_regs *regs) } irq:if (irqnr) -handle_domain_irq (domain, irqnr, regs); +generic_handle_domain_irq (domain, irqnr);else break ; }while (irqnr);
arch/arm/mach-s3c/irq-s3c24xx.c +1 -1
@@ -354,7 +354,7 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,if (!(pnd & (1 << offset))) offset =__ffs (pnd); -handle_domain_irq (intc->domain, intc_offset + offset, regs); +generic_handle_domain_irq (intc->domain, intc_offset + offset);return true; }
arch/arm64/Kconfig +0 -1
@@ -133,7 +133,6 @@ config ARM64 select GENERIC_TIME_VSYSCALL select GENERIC_GETTIMEOFDAY select GENERIC_VDSO_TIME_NS - select HANDLE_DOMAIN_IRQ select HARDIRQS_SW_RESEND select HAVE_MOVE_PMD select HAVE_MOVE_PUD
arch/arm64/Kconfig.platforms +0 -4
@@ -44,7 +44,6 @@ config ARCH_BCM2835 select ARM_AMBA select ARM_GIC select ARM_TIMER_SP804 - select BRCMSTB_L2_IRQ help This enables support for the Broadcom BCM2837 and BCM2711 SoC. These SoCs are used in the Raspberry Pi 3 and 4 devices.
@@ -82,8 +81,6 @@ config ARCH_BITMAIN config ARCH_BRCMSTB bool "Broadcom Set-Top-Box SoCs" select ARCH_HAS_RESET_CONTROLLER - select BCM7038_L1_IRQ - select BRCMSTB_L2_IRQ select GENERIC_IRQ_CHIP select PINCTRL help
@@ -167,7 +164,6 @@ config ARCH_MEDIATEK config ARCH_MESON bool "Amlogic Platforms" select COMMON_CLK - select MESON_IRQ_GPIO help This enables support for the arm64 based Amlogic SoCs such as the s905, S905X/D, S912, A113X/D or S905X/D2
arch/arm64/kernel/entry-common.c +31 -21
96 lines not on this page · raw message
arch/csky/Kconfig +0 -1
@@ -17,7 +17,6 @@ config CSKY select CSKY_APB_INTC select DMA_DIRECT_REMAP select IRQ_DOMAIN - select HANDLE_DOMAIN_IRQ select DW_APB_TIMER_OF select GENERIC_IOREMAP select GENERIC_LIB_ASHLDI3
arch/csky/kernel/entry.S +1 -1
@@ -249,7 +249,7 @@ ENTRY(csky_irq) mov a0, sp - jbsr csky_do_IRQ + jbsr generic_handle_arch_irq jmpi ret_from_exception
arch/csky/kernel/irq.c +0 -5
@@ -15,8 +15,3 @@ void __init init_IRQ(void)setup_smp_ipi ();#endif } - -asmlinkage void __irq_entry csky_do_IRQ(struct pt_regs *regs) -{ -handle_arch_irq (regs); -}
arch/h8300/include/asm/irq.h +0 -2
@@ -2,8 +2,6 @@#ifndef _H8300_IRQ_H_#define _H8300_IRQ_H_ -#include <linux/irqchip.h> -#if defined(CONFIG_CPU_H8300H )#define NR_IRQS 64#define IRQ_CHIP h8300h_irq_chip
arch/h8300/kernel/irq.c +1 -0
@@ -8,6 +8,7 @@#include <linux/init.h> #include <linux/interrupt.h> #include <linux/irq.h> +#include <linux/irqchip.h> #include <linux/irqdomain.h> #include <linux/of_irq.h> #include <asm/traps.h>
arch/mips/Kconfig +1 -1
@@ -47,7 +47,6 @@ config MIPS select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL select GUP_GET_PTE_LOW_HIGH if CPU_MIPS32 && PHYS_ADDR_T_64BIT - select HANDLE_DOMAIN_IRQ select HAVE_ARCH_COMPILER_H select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_KGDB if MIPS_FP_SUPPORT
@@ -1782,6 +1781,7 @@ config CPU_BMIPS select CPU_HAS_PREFETCH select CPU_SUPPORTS_CPUFREQ select MIPS_EXTERNAL_TIMER + select GENERIC_IRQ_MIGRATION if HOTPLUG_CPU help Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors.
arch/mips/cavium-octeon/octeon-irq.c +4 -1
@@ -2609,7 +2609,10 @@ static void octeon_irq_ciu3_ip2(void)else hw = intsn; - ret =handle_domain_irq (domain, hw,NULL ); +irq_enter (); + ret =generic_handle_domain_irq (domain, hw); +irq_exit (); +if (ret <0 ) {union cvmx_ciu3_iscx_w1c isc_w1c;u64 isc_w1c_addr = ciu3_addr +CIU3_ISC_W1C (intsn);
arch/mips/kernel/irq.c +1 -7
@@ -111,15 +111,9 @@ void __irq_entry do_IRQ(unsigned int irq)#ifdef CONFIG_IRQ_DOMAIN void __irq_entry do_domain_IRQ(struct irq_domain *domain, unsigned int hwirq) { -struct irq_desc *desc; -irq_enter ();check_stack_overflow (); - - desc =irq_resolve_mapping (domain, hwirq); -if (likely (desc)) -handle_irq_desc (desc); - +generic_handle_domain_irq (domain, hwirq);irq_exit (); }#endif
arch/mips/kernel/smp-bmips.c +2 -1
@@ -26,6 +26,7 @@#include <linux/bug.h> #include <linux/kernel.h> #include <linux/kexec.h> +#include <linux/irq.h> #include <asm/time.h> #include <asm/processor.h>
@@ -373,7 +374,7 @@ static int bmips_cpu_disable(void)set_cpu_online (cpu, false);calculate_cpu_foreign_map (); -irq_cpu_offline (); +irq_migrate_all_off_this_cpu ();clear_c0_status (IE_IRQ5 );local_flush_tlb_all ();
arch/mips/loongson64/smp.c +0 -1
@@ -550,7 +550,6 @@ static int loongson3_cpu_disable(void)set_cpu_online (cpu, false);calculate_cpu_foreign_map ();local_irq_save (flags); -irq_cpu_offline ();clear_c0_status (ST0_IM );local_irq_restore (flags);local_flush_tlb_all ();
arch/nds32/Kconfig +0 -1
@@ -27,7 +27,6 @@ config NDS32 select GENERIC_LIB_MULDI3 select GENERIC_LIB_UCMPDI2 select GENERIC_TIME_VSYSCALL - select HANDLE_DOMAIN_IRQ select HAVE_ARCH_TRACEHOOK select HAVE_DEBUG_KMEMLEAK select HAVE_EXIT_THREAD
arch/openrisc/Kconfig +0 -1
@@ -13,7 +13,6 @@ config OPENRISC select OF select OF_EARLY_FLATTREE select IRQ_DOMAIN - select HANDLE_DOMAIN_IRQ select GPIOLIB select HAVE_ARCH_TRACEHOOK select SPARSE_IRQ
arch/openrisc/kernel/entry.S +2 -2
@@ -569,8 +569,8 @@ EXCEPTION_ENTRY(_external_irq_handler) #endif CLEAR_LWA_FLAG(r3) l.addi r3,r1,0 - l.movhi r8,hi(do_IRQ) - l.ori r8,r8,lo(do_IRQ) + l.movhi r8,hi(generic_handle_arch_irq) + l.ori r8,r8,lo(generic_handle_arch_irq) l.jalr r8 l.nop l.j _ret_from_intr
arch/openrisc/kernel/irq.c +0 -5
@@ -36,8 +36,3 @@ void __init init_IRQ(void) {irqchip_init (); } - -void __irq_entry do_IRQ(struct pt_regs *regs) -{ -handle_arch_irq (regs); -}
arch/riscv/Kconfig +0 -1
@@ -62,7 +62,6 @@ config RISCV select GENERIC_SCHED_CLOCK select GENERIC_SMP_IDLE_THREAD select GENERIC_TIME_VSYSCALL if MMU && 64BIT - select HANDLE_DOMAIN_IRQ select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
arch/riscv/kernel/entry.S +1 -2
@@ -130,8 +130,7 @@ skip_context_tracking: /* Handle interrupts */ move a0, sp /* pt_regs */ - la a1, handle_arch_irq - REG_L a1, (a1) + la a1, generic_handle_arch_irq jr a1 1: /*
arch/riscv/kernel/smp.c +1 -8
@@ -140,12 +140,9 @@ void arch_irq_work_raise(void)void handle_IPI (struct pt_regs *regs) { -struct pt_regs *old_regs =set_irq_regs (regs);unsigned long *pending_ipis = &ipi_data[smp_processor_id ()].bits;unsigned long *stats = ipi_data[smp_processor_id ()].stats; -irq_enter (); -riscv_clear_ipi ();while (true) {
@@ -156,7 +153,7 @@ void handle_IPI(struct pt_regs *regs) ops =xchg (pending_ipis,0 );if (ops ==0 ) - goto done; +return ;if (ops & (1 <<IPI_RESCHEDULE )) { stats[IPI_RESCHEDULE ]++;
@@ -189,10 +186,6 @@ void handle_IPI(struct pt_regs *regs)/* Order data access and bit testing. */ mb (); } - -done: -irq_exit (); -set_irq_regs (old_regs); }static const char *const ipi_names[] = {
arch/x86/include/asm/irq_stack.h +3 -0
@@ -185,6 +185,7 @@ IRQ_CONSTRAINTS, regs, vector); \ } +#ifndef CONFIG_PREEMPT_RT #define ASM_CALL_SOFTIRQ \ "call %P[__func] \n"
@@ -201,6 +202,8 @@ __this_cpu_write(hardirq_stack_inuse, false); \ } +#endif +#else /* CONFIG_X86_64 */ /* System vector handlers always run on the stack they interrupted. */ #define run_sysvec_on_irqstack_cond (func, regs) \
arch/x86/kernel/irq_32.c +2 -0
@@ -132,6 +132,7 @@ int irq_init_percpu_irqstack(unsigned int cpu)return 0 ; } +#ifndef CONFIG_PREEMPT_RT void do_softirq_own_stack (void ) {struct irq_stack *irqstk;
@@ -148,6 +149,7 @@ void do_softirq_own_stack(void) call_on_stack(__do_softirq, isp); } +#endif void __handle_irq (struct irq_desc *desc,struct pt_regs *regs) {
drivers/irqchip/Kconfig +20 -5
@@ -115,18 +115,24 @@ config BCM6345_L1_IRQ select GENERIC_IRQ_EFFECTIVE_AFF_MASK config BCM7038_L1_IRQ - bool + tristate "Broadcom STB 7038-style L1/L2 interrupt controller driver" + depends on ARCH_BRCMSTB || BMIPS_GENERIC + default ARCH_BRCMSTB || BMIPS_GENERIC select GENERIC_IRQ_CHIP select IRQ_DOMAIN select GENERIC_IRQ_EFFECTIVE_AFF_MASK config BCM7120_L2_IRQ - bool + tristate "Broadcom STB 7120-style L2 interrupt controller driver" + depends on ARCH_BRCMSTB || BMIPS_GENERIC + default ARCH_BRCMSTB || BMIPS_GENERIC select GENERIC_IRQ_CHIP select IRQ_DOMAIN config BRCMSTB_L2_IRQ - bool + tristate "Broadcom STB generic L2 interrupt controller driver" + depends on ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC + default ARCH_BCM2835 || ARCH_BRCMSTB || BMIPS_GENERIC select GENERIC_IRQ_CHIP select IRQ_DOMAIN
@@ -400,8 +406,9 @@ config IRQ_UNIPHIER_AIDET Support for the UniPhier AIDET (ARM Interrupt Detector). config MESON_IRQ_GPIO - bool "Meson GPIO Interrupt Multiplexer" - depends on ARCH_MESON + tristate "Meson GPIO Interrupt Multiplexer" + depends on ARCH_MESON || COMPILE_TEST + default ARCH_MESON select IRQ_DOMAIN_HIERARCHY help Support Meson SoC Family GPIO Interrupt Multiplexer
@@ -602,4 +609,12 @@ config APPLE_AIC Support for the Apple Interrupt Controller found on Apple Silicon SoCs, such as the M1. +config MCHP_EIC + bool "Microchip External Interrupt Controller" + depends on ARCH_AT91 || COMPILE_TEST + select IRQ_DOMAIN + select IRQ_DOMAIN_HIERARCHY + help + Support for Microchip External Interrupt Controller. + endmenu
drivers/irqchip/Makefile +1 -0
@@ -116,3 +116,4 @@ obj-$(CONFIG_MACH_REALTEK_RTL) += irq-realtek-rtl.o obj-$(CONFIG_WPCM450_AIC) += irq-wpcm450-aic.o obj-$(CONFIG_IRQ_IDT3243X) += irq-idt3243x.o obj-$(CONFIG_APPLE_AIC) += irq-apple-aic.o +obj-$(CONFIG_MCHP_EIC) += irq-mchp-eic.o
drivers/irqchip/irq-apple-aic.c +10 -10
@@ -245,7 +245,7 @@ static void __exception_irq_entry aic_handle_irq(struct pt_regs *regs) irq =FIELD_GET (AIC_EVENT_NUM , event);if (type ==AIC_EVENT_TYPE_HW ) -handle_domain_irq (aic_irqc->hw_domain, irq, regs); +generic_handle_domain_irq (aic_irqc->hw_domain, irq);else if (type ==AIC_EVENT_TYPE_IPI && irq ==1 )aic_handle_ipi (regs);else if (event !=0 )
@@ -392,25 +392,25 @@ static void __exception_irq_entry aic_handle_fiq(struct pt_regs *regs) }if (TIMER_FIRING (read_sysreg (cntp_ctl_el0))) -handle_domain_irq (aic_irqc->hw_domain, - aic_irqc->nr_hw +AIC_TMR_EL0_PHYS , regs); +generic_handle_domain_irq (aic_irqc->hw_domain, + aic_irqc->nr_hw +AIC_TMR_EL0_PHYS );if (TIMER_FIRING (read_sysreg (cntv_ctl_el0))) -handle_domain_irq (aic_irqc->hw_domain, - aic_irqc->nr_hw +AIC_TMR_EL0_VIRT , regs); +generic_handle_domain_irq (aic_irqc->hw_domain, + aic_irqc->nr_hw +AIC_TMR_EL0_VIRT );if (is_kernel_in_hyp_mode ()) {uint64_t enabled =read_sysreg_s (SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2 );if ((enabled &VM_TMR_FIQ_ENABLE_P ) &&TIMER_FIRING (read_sysreg_s (SYS_CNTP_CTL_EL02 ))) -handle_domain_irq (aic_irqc->hw_domain, - aic_irqc->nr_hw +AIC_TMR_EL02_PHYS , regs); +generic_handle_domain_irq (aic_irqc->hw_domain, + aic_irqc->nr_hw +AIC_TMR_EL02_PHYS );if ((enabled &VM_TMR_FIQ_ENABLE_V ) &&TIMER_FIRING (read_sysreg_s (SYS_CNTV_CTL_EL02 ))) -handle_domain_irq (aic_irqc->hw_domain, - aic_irqc->nr_hw +AIC_TMR_EL02_VIRT , regs); +generic_handle_domain_irq (aic_irqc->hw_domain, + aic_irqc->nr_hw +AIC_TMR_EL02_VIRT ); } if ((read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & (PMCR0_IMODE | PMCR0_IACT)) ==
@@ -674,7 +674,7 @@ static void aic_handle_ipi(struct pt_regs *regs) firing =atomic_fetch_andnot (enabled,this_cpu_ptr (&aic_vipi_flag)) & enabled;for_each_set_bit (i, &firing,AIC_NR_SWIPI ) -handle_domain_irq (aic_irqc->ipi_domain, i, regs); +generic_handle_domain_irq (aic_irqc->ipi_domain, i);/* * No ordering needed here; at worst this just changes the timing of
drivers/irqchip/irq-armada-370-xp.c +4 -9
@@ -589,12 +589,7 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained) irq = msinr -PCI_MSI_DOORBELL_START ; -if (is_chained) -generic_handle_domain_irq (armada_370_xp_msi_inner_domain, - irq); -else -handle_domain_irq (armada_370_xp_msi_inner_domain, - irq, regs); + generic_handle_domain_irq(armada_370_xp_msi_inner_domain, irq); } }#else
@@ -646,8 +641,8 @@ armada_370_xp_handle_irq(struct pt_regs *regs)break ;if (irqnr >1 ) { -handle_domain_irq (armada_370_xp_mpic_domain, - irqnr, regs); +generic_handle_domain_irq (armada_370_xp_mpic_domain, + irqnr);continue ; }
@@ -666,7 +661,7 @@ armada_370_xp_handle_irq(struct pt_regs *regs) &IPI_DOORBELL_MASK ;for_each_set_bit (ipi, &ipimask,IPI_DOORBELL_END ) - handle_domain_irq(ipi_domain, ipi, regs); + generic_handle_domain_irq(ipi_domain, ipi); }#endif
drivers/irqchip/irq-aspeed-vic.c +1 -1
@@ -100,7 +100,7 @@ static void __exception_irq_entry avic_handle_irq(struct pt_regs *regs)if (stat ==0 )break ; irq +=ffs (stat) -1 ; -handle_domain_irq (vic->dom, irq, regs); +generic_handle_domain_irq (vic->dom, irq); } }
drivers/irqchip/irq-ativic32.c +20 -2
@@ -5,11 +5,14 @@#include <linux/of.h> #include <linux/of_irq.h> #include <linux/of_address.h> +#include <linux/hardirq.h> #include <linux/interrupt.h> #include <linux/irqdomain.h> #include <linux/irqchip.h> #include <nds32_intrinsic.h> +#include <asm/irq_regs.h> +unsigned long wake_mask;static void ativic32_ack_irq (struct irq_data *data)
@@ -103,10 +106,25 @@ static irq_hw_number_t get_intr_src(void) - NDS32_VECTOR_offINTERRUPT; } -asmlinkage void asm_do_IRQ(struct pt_regs *regs) +static void ativic32_handle_irq (struct pt_regs *regs) {irq_hw_number_t hwirq =get_intr_src (); -handle_domain_irq (root_domain, hwirq, regs); +generic_handle_domain_irq (root_domain, hwirq); +} + +/* +* TODO: convert nds32 to GENERIC_IRQ_MULTI_HANDLER so that this entry logic +* can live in arch code. +*/ +asmlinkage void asm_do_IRQ(struct pt_regs *regs) +{ +struct pt_regs *old_regs; + +irq_enter (); + old_regs =set_irq_regs (regs); +ativic32_handle_irq (regs); +set_irq_regs (old_regs); +irq_exit (); }int __init ativic32_init_irq (struct device_node *node,struct device_node *parent)
drivers/irqchip/irq-atmel-aic.c +1 -1
@@ -71,7 +71,7 @@ aic_handle(struct pt_regs *regs)if (!irqstat)irq_reg_writel (gc,0 ,AT91_AIC_EOICR );else -handle_domain_irq (aic_domain, irqnr, regs); +generic_handle_domain_irq (aic_domain, irqnr); }static int aic_retrigger (struct irq_data *d)
drivers/irqchip/irq-atmel-aic5.c +1 -1
@@ -80,7 +80,7 @@ aic5_handle(struct pt_regs *regs)if (!irqstat)irq_reg_writel (bgc,0 ,AT91_AIC5_EOICR );else -handle_domain_irq (aic5_domain, irqnr, regs); +generic_handle_domain_irq (aic5_domain, irqnr); }static void aic5_mask (struct irq_data *d)
drivers/irqchip/irq-bcm2835.c +1 -1
@@ -246,7 +246,7 @@ static void __exception_irq_entry bcm2835_handle_irq(u32 hwirq;while ((hwirq =get_next_armctrl_hwirq ()) != ~0 ) -handle_domain_irq (intc.domain, hwirq, regs); +generic_handle_domain_irq (intc.domain, hwirq); }static void bcm2836_chained_handle_irq (struct irq_desc *desc)
drivers/irqchip/irq-bcm2836.c +1 -1
@@ -143,7 +143,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs)if (stat) {u32 hwirq =ffs (stat) -1 ; -handle_domain_irq (intc.domain, hwirq, regs); +generic_handle_domain_irq (intc.domain, hwirq); } }
drivers/irqchip/irq-bcm6345-l1.c +1 -5
@@ -132,16 +132,12 @@ static void bcm6345_l1_irq_handle(struct irq_desc *desc)int base = idx *IRQS_PER_WORD ;unsigned long pending;irq_hw_number_t hwirq; -unsigned int irq; pending =__raw_readl (cpu->map_base +reg_status (intc, idx)); pending &=__raw_readl (cpu->map_base +reg_enable (intc, idx));for_each_set_bit (hwirq, &pending,IRQS_PER_WORD ) { - irq =irq_linear_revmap (intc->domain, base + hwirq); -if (irq) -do_IRQ (irq); -else +if (generic_handle_domain_irq (intc->domain, base + hwirq))spurious_interrupt (); } }
drivers/irqchip/irq-bcm7038-l1.c +11 -36
99 lines not on this page · raw message
drivers/irqchip/irq-bcm7120-l2.c +15 -6
@@ -220,6 +220,7 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn, {unsigned int clr =IRQ_NOREQUEST |IRQ_NOPROBE |IRQ_NOAUTOEN ;struct bcm7120_l2_intc_data *data; +struct platform_device *pdev;struct irq_chip_generic *gc;struct irq_chip_type *ct;int ret =0 ;
@@ -230,7 +231,13 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,if (!data)return -ENOMEM ; - data->num_parent_irqs =of_irq_count (dn); + pdev =of_find_device_by_node (dn); +if (!pdev) { + ret = -ENODEV ; + goto out_free_data; + } + + data->num_parent_irqs =platform_irq_count (pdev);if (data->num_parent_irqs <=0 ) {pr_err ("invalid number of parent interrupts\n" ); ret = -ENOMEM ;
@@ -329,6 +336,7 @@ static int __init bcm7120_l2_intc_probe(struct device_node *dn,if (data->map_base[idx])iounmap (data->map_base[idx]); } +out_free_data:kfree (data);return ret; }
@@ -347,8 +355,9 @@ static int __init bcm7120_l2_intc_probe_3380(struct device_node *dn, "BCM3380 L2"); } -IRQCHIP_DECLARE (bcm7120_l2_intc,"brcm,bcm7120-l2-intc" , - bcm7120_l2_intc_probe_7120); - -IRQCHIP_DECLARE (bcm3380_l2_intc,"brcm,bcm3380-l2-intc" , - bcm7120_l2_intc_probe_3380); +IRQCHIP_PLATFORM_DRIVER_BEGIN(bcm7120_l2) +IRQCHIP_MATCH("brcm,bcm7120-l2-intc", bcm7120_l2_intc_probe_7120) +IRQCHIP_MATCH("brcm,bcm3380-l2-intc", bcm7120_l2_intc_probe_3380) +IRQCHIP_PLATFORM_DRIVER_END(bcm7120_l2) +MODULE_DESCRIPTION("Broadcom STB 7120-style L2 interrupt controller driver"); +MODULE_LICENSE ("GPL v2" );
drivers/irqchip/irq-brcmstb-l2.c +9 -7
@@ -275,16 +275,18 @@ static int __init brcmstb_l2_edge_intc_of_init(struct device_node *np, {return brcmstb_l2_intc_of_init (np, parent, &l2_edge_intc_init); } -IRQCHIP_DECLARE (brcmstb_l2_intc,"brcm,l2-intc" , brcmstb_l2_edge_intc_of_init); -IRQCHIP_DECLARE (brcmstb_hif_spi_l2_intc,"brcm,hif-spi-l2-intc" , - brcmstb_l2_edge_intc_of_init); -IRQCHIP_DECLARE (brcmstb_upg_aux_aon_l2_intc,"brcm,upg-aux-aon-l2-intc" , - brcmstb_l2_edge_intc_of_init);static int __init brcmstb_l2_lvl_intc_of_init (struct device_node *np,struct device_node *parent) {return brcmstb_l2_intc_of_init (np, parent, &l2_lvl_intc_init); } -IRQCHIP_DECLARE (bcm7271_l2_intc,"brcm,bcm7271-l2-intc" , - brcmstb_l2_lvl_intc_of_init); + +IRQCHIP_PLATFORM_DRIVER_BEGIN(brcmstb_l2) +IRQCHIP_MATCH("brcm,l2-intc", brcmstb_l2_edge_intc_of_init) +IRQCHIP_MATCH("brcm,hif-spi-l2-intc", brcmstb_l2_edge_intc_of_init) +IRQCHIP_MATCH("brcm,upg-aux-aon-l2-intc", brcmstb_l2_edge_intc_of_init) +IRQCHIP_MATCH("brcm,bcm7271-l2-intc", brcmstb_l2_lvl_intc_of_init) +IRQCHIP_PLATFORM_DRIVER_END(brcmstb_l2) +MODULE_DESCRIPTION("Broadcom STB generic L2 interrupt controller"); +MODULE_LICENSE ("GPL v2" );
drivers/irqchip/irq-clps711x.c +4 -4
@@ -77,14 +77,14 @@ static asmlinkage void __exception_irq_entry clps711x_irqh(struct pt_regs *regs) irqstat =readw_relaxed (clps711x_intc->intmr[0 ]) &readw_relaxed (clps711x_intc->intsr[0 ]);if (irqstat) -handle_domain_irq (clps711x_intc->domain, -fls (irqstat) -1 , regs); +generic_handle_domain_irq (clps711x_intc->domain, +fls (irqstat) -1 ); irqstat =readw_relaxed (clps711x_intc->intmr[1 ]) &readw_relaxed (clps711x_intc->intsr[1 ]);if (irqstat) -handle_domain_irq (clps711x_intc->domain, -fls (irqstat) -1 +16 , regs); +generic_handle_domain_irq (clps711x_intc->domain, +fls (irqstat) -1 +16 ); }while (irqstat); }
drivers/irqchip/irq-csky-apb-intc.c +1 -1
@@ -138,7 +138,7 @@ static inline bool handle_irq_perbit(struct pt_regs *regs, u32 hwirq,if (hwirq ==0 )return 0 ; -handle_domain_irq (root_domain, irq_base +__fls (hwirq), regs); +generic_handle_domain_irq (root_domain, irq_base +__fls (hwirq));return 1 ; }
drivers/irqchip/irq-csky-mpintc.c +2 -2
@@ -74,8 +74,8 @@ static void csky_mpintc_handler(struct pt_regs *regs) {void __iomem *reg_base =this_cpu_read (intcl_reg); -handle_domain_irq (root_domain, -readl_relaxed (reg_base +INTCL_RDYIR ), regs); +generic_handle_domain_irq (root_domain, +readl_relaxed (reg_base +INTCL_RDYIR )); }static void csky_mpintc_enable (struct irq_data *d)
drivers/irqchip/irq-davinci-aintc.c +1 -1
@@ -73,7 +73,7 @@ davinci_aintc_handle_irq(struct pt_regs *regs) irqnr >>=2 ; irqnr -=1 ; -handle_domain_irq (davinci_aintc_irq_domain, irqnr, regs); +generic_handle_domain_irq (davinci_aintc_irq_domain, irqnr); }/* ARM Interrupt Controller Initialization */
drivers/irqchip/irq-davinci-cp-intc.c +1 -1
@@ -135,7 +135,7 @@ davinci_cp_intc_handle_irq(struct pt_regs *regs)return ; } -handle_domain_irq (davinci_cp_intc_irq_domain, irqnr, regs); +generic_handle_domain_irq (davinci_cp_intc_irq_domain, irqnr); } static int davinci_cp_intc_host_map(struct irq_domain *h, unsigned int virq,
drivers/irqchip/irq-digicolor.c +1 -1
@@ -50,7 +50,7 @@ static void __exception_irq_entry digicolor_handle_irq(struct pt_regs *regs)return ; } -handle_domain_irq (digicolor_irq_domain, hwirq, regs); +generic_handle_domain_irq (digicolor_irq_domain, hwirq); }while (1 ); }
drivers/irqchip/irq-dw-apb-ictl.c +1 -1
@@ -42,7 +42,7 @@ static void __irq_entry dw_apb_ictl_handle_irq(struct pt_regs *regs)while (stat) {u32 hwirq =ffs (stat) -1 ; -handle_domain_irq (d, hwirq, regs); +generic_handle_domain_irq (d, hwirq); stat &= ~BIT (hwirq); } }
drivers/irqchip/irq-ftintc010.c +1 -1
@@ -134,7 +134,7 @@ asmlinkage void __exception_irq_entry ft010_irqchip_handle_irq(struct pt_regs *rwhile ((status =readl (FT010_IRQ_STATUS (f->base)))) { irq =ffs (status) -1 ; -handle_domain_irq (f->domain, irq, regs); +generic_handle_domain_irq (f->domain, irq); } }
drivers/irqchip/irq-gic-v3.c +2 -2
@@ -660,7 +660,7 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs)* PSR.I will be restored when we ERET to the * interrupted context. */ - err =handle_domain_nmi (gic_data.domain, irqnr, regs); + err =generic_handle_domain_nmi (gic_data.domain, irqnr);if (err)gic_deactivate_unhandled (irqnr);
@@ -728,7 +728,7 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regselse isb (); -if (handle_domain_irq (gic_data.domain, irqnr, regs)) { +if (generic_handle_domain_irq (gic_data.domain, irqnr)) {WARN_ONCE (true,"Unexpected interrupt received!\n" );gic_deactivate_unhandled (irqnr); }
drivers/irqchip/irq-gic.c +1 -1
@@ -369,7 +369,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)this_cpu_write (sgi_intid, irqstat); } -handle_domain_irq (gic->domain, irqnr, regs); +generic_handle_domain_irq (gic->domain, irqnr); }while (1 ); }
drivers/irqchip/irq-hip04.c +1 -1
@@ -206,7 +206,7 @@ static void __exception_irq_entry hip04_handle_irq(struct pt_regs *regs) irqnr = irqstat &GICC_IAR_INT_ID_MASK ;if (irqnr <=HIP04_MAX_IRQS ) -handle_domain_irq (hip04_data.domain, irqnr, regs); +generic_handle_domain_irq (hip04_data.domain, irqnr); }while (irqnr >HIP04_MAX_IRQS ); }
drivers/irqchip/irq-ixp4xx.c +2 -2
@@ -114,7 +114,7 @@ asmlinkage void __exception_irq_entry ixp4xx_handle_irq(struct pt_regs *regs) status =__raw_readl (ixi->irqbase +IXP4XX_ICIP );for_each_set_bit (i, &status,32 ) -handle_domain_irq (ixi->domain, i, regs); +generic_handle_domain_irq (ixi->domain, i);/* * IXP465/IXP435 has an upper IRQ status register
@@ -122,7 +122,7 @@ asmlinkage void __exception_irq_entry ixp4xx_handle_irq(struct pt_regs *regs)if (ixi->is_356) { status =__raw_readl (ixi->irqbase +IXP4XX_ICIP2 );for_each_set_bit (i, &status,32 ) -handle_domain_irq (ixi->domain, i +32 , regs); +generic_handle_domain_irq (ixi->domain, i +32 ); } }
drivers/irqchip/irq-lpc32xx.c +1 -1
@@ -126,7 +126,7 @@ static void __exception_irq_entry lpc32xx_handle_irq(struct pt_regs *regs)while (hwirq) { irq =__ffs (hwirq); hwirq &= ~BIT (irq); -handle_domain_irq (lpc32xx_mic_irqc->domain, irq, regs); +generic_handle_domain_irq (lpc32xx_mic_irqc->domain, irq); } }
drivers/irqchip/irq-mchp-eic.c new file +280 -0
280 lines not on this page · raw message
drivers/irqchip/irq-meson-gpio.c +9 -6
@@ -436,8 +436,7 @@ static const struct irq_domain_ops meson_gpio_irq_domain_ops = { .translate = meson_gpio_irq_domain_translate, }; -static int __init meson_gpio_irq_parse_dt (struct device_node *node, -struct meson_gpio_irq_controller *ctl) +static int meson_gpio_irq_parse_dt (struct device_node *node,struct meson_gpio_irq_controller *ctl) {const struct of_device_id *match;int ret;
@@ -463,8 +462,7 @@ static int __init meson_gpio_irq_parse_dt(struct device_node *node,return 0 ; } -static int __init meson_gpio_irq_of_init (struct device_node *node, -struct device_node *parent) +static int meson_gpio_irq_of_init (struct device_node *node,struct device_node *parent) {struct irq_domain *domain, *parent_domain;struct meson_gpio_irq_controller *ctl;
@@ -521,5 +519,10 @@ static int __init meson_gpio_irq_of_init(struct device_node *node,return ret; } -IRQCHIP_DECLARE (meson_gpio_intc,"amlogic,meson-gpio-intc" , - meson_gpio_irq_of_init); +IRQCHIP_PLATFORM_DRIVER_BEGIN(meson_gpio_intc) +IRQCHIP_MATCH("amlogic,meson-gpio-intc", meson_gpio_irq_of_init) +IRQCHIP_PLATFORM_DRIVER_END(meson_gpio_intc) + +MODULE_AUTHOR("Jerome Brunet <[email protected]>"); +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:meson-gpio-intc" );
drivers/irqchip/irq-mips-gic.c +26 -11
@@ -381,24 +381,35 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d)spin_unlock_irqrestore (&gic_lock, flags); } -static void gic_all_vpes_irq_cpu_online (struct irq_data *d) +static void gic_all_vpes_irq_cpu_online (void ) { -struct gic_all_vpes_chip_data *cd; -unsigned int intr; +static const unsigned int local_intrs[] = { +GIC_LOCAL_INT_TIMER , +GIC_LOCAL_INT_PERFCTR , +GIC_LOCAL_INT_FDC , + }; +unsigned long flags; +int i; - intr =GIC_HWIRQ_TO_LOCAL (d->hwirq); - cd =irq_data_get_irq_chip_data (d); +spin_lock_irqsave (&gic_lock, flags); -write_gic_vl_map (mips_gic_vx_map_reg (intr), cd->map); -if (cd->mask) -write_gic_vl_smask (BIT (intr)); +for (i =0 ; i <ARRAY_SIZE (local_intrs); i++) { +unsigned int intr = local_intrs[i]; +struct gic_all_vpes_chip_data *cd; + + cd = &gic_all_vpes_chip_data[intr]; +write_gic_vl_map (mips_gic_vx_map_reg (intr), cd->map); +if (cd->mask) +write_gic_vl_smask (BIT (intr)); + } + +spin_unlock_irqrestore (&gic_lock, flags); }static struct irq_chip gic_all_vpes_local_irq_controller = { .name ="MIPS GIC Local" , .irq_mask = gic_mask_local_irq_all_vpes, .irq_unmask = gic_unmask_local_irq_all_vpes, - .irq_cpu_online = gic_all_vpes_irq_cpu_online, };static void __gic_irq_dispatch (void )
@@ -477,6 +488,10 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, intr =GIC_HWIRQ_TO_LOCAL (hwirq); map =GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin; +/* +* If adding support for more per-cpu interrupts, keep the the +* array in gic_all_vpes_irq_cpu_online() in sync. +*/ switch (intr) {case GIC_LOCAL_INT_TIMER :/* CONFIG_MIPS_CMP workaround (see __gic_init) */
@@ -663,8 +678,8 @@ static int gic_cpu_startup(unsigned int cpu)/* Clear all local IRQ masks (ie. disable all local interrupts) */ write_gic_vl_rmask (~0 ); -/* Invoke irq_cpu_online callbacks to enable desired interrupts */ -irq_cpu_online (); +/* Enable desired interrupts */ +gic_all_vpes_irq_cpu_online ();return 0 ; }
drivers/irqchip/irq-mmp.c +2 -2
@@ -230,7 +230,7 @@ static void __exception_irq_entry mmp_handle_irq(struct pt_regs *regs)if (!(hwirq &SEL_INT_PENDING ))return ; hwirq &=SEL_INT_NUM_MASK ; -handle_domain_irq (icu_data[0 ].domain, hwirq, regs); +generic_handle_domain_irq (icu_data[0 ].domain, hwirq); } static void __exception_irq_entry mmp2_handle_irq(struct pt_regs *regs)
@@ -241,7 +241,7 @@ static void __exception_irq_entry mmp2_handle_irq(struct pt_regs *regs)if (!(hwirq &SEL_INT_PENDING ))return ; hwirq &=SEL_INT_NUM_MASK ; -handle_domain_irq (icu_data[0 ].domain, hwirq, regs); +generic_handle_domain_irq (icu_data[0 ].domain, hwirq); }/* MMP (ARMv5) */
drivers/irqchip/irq-mvebu-icu.c +1 -3
@@ -347,7 +347,6 @@ builtin_platform_driver(mvebu_icu_subset_driver);static int mvebu_icu_probe (struct platform_device *pdev) {struct mvebu_icu *icu; -struct resource *res;int i; icu = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_icu),
@@ -357,8 +356,7 @@ static int mvebu_icu_probe(struct platform_device *pdev) icu->dev = &pdev->dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - icu->base =devm_ioremap_resource (&pdev->dev, res); + icu->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (icu->base))return PTR_ERR (icu->base);
drivers/irqchip/irq-mvebu-pic.c +1 -3
@@ -121,14 +121,12 @@ static int mvebu_pic_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct mvebu_pic *pic;struct irq_chip *irq_chip; -struct resource *res; pic =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_pic ),GFP_KERNEL );if (!pic)return -ENOMEM ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - pic->base =devm_ioremap_resource (&pdev->dev, res); + pic->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (pic->base))return PTR_ERR (pic->base);
drivers/irqchip/irq-mxs.c +1 -1
@@ -136,7 +136,7 @@ asmlinkage void __exception_irq_entry icoll_handle_irq(struct pt_regs *regs) irqnr =__raw_readl (icoll_priv.stat);__raw_writel (irqnr, icoll_priv.vector); -handle_domain_irq (icoll_domain, irqnr, regs); +generic_handle_domain_irq (icoll_domain, irqnr); } static int icoll_irq_domain_map(struct irq_domain *d, unsigned int virq,
drivers/irqchip/irq-nvic.c +16 -1
@@ -37,10 +37,25 @@static struct irq_domain *nvic_irq_domain; +static void __nvic_handle_irq (irq_hw_number_t hwirq) +{ +generic_handle_domain_irq (nvic_irq_domain, hwirq); +} + +/* +* TODO: restructure the ARMv7M entry logic so that this entry logic can live +* in arch code. +*/ asmlinkage void __exception_irq_entrynvic_handle_irq (irq_hw_number_t hwirq,struct pt_regs *regs) { -handle_domain_irq (nvic_irq_domain, hwirq, regs); +struct pt_regs *old_regs; + +irq_enter (); + old_regs =set_irq_regs (regs); +__nvic_handle_irq (hwirq); +set_irq_regs (old_regs); +irq_exit (); } static int nvic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
drivers/irqchip/irq-omap-intc.c +1 -1
@@ -357,7 +357,7 @@ omap_intc_handle_irq(struct pt_regs *regs) } irqnr &=ACTIVEIRQ_MASK ; -handle_domain_irq (domain, irqnr, regs); +generic_handle_domain_irq (domain, irqnr); } static int __init intc_of_init(struct device_node *node,
drivers/irqchip/irq-or1k-pic.c +1 -1
@@ -116,7 +116,7 @@ static void or1k_pic_handle_irq(struct pt_regs *regs)int irq =-1 ;while ((irq =pic_get_irq (irq +1 )) !=NO_IRQ ) -handle_domain_irq (root_domain, irq, regs); +generic_handle_domain_irq (root_domain, irq); }static int or1k_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw)
drivers/irqchip/irq-orion.c +2 -2
@@ -42,8 +42,8 @@ __exception_irq_entry orion_handle_irq(struct pt_regs *regs) gc->mask_cache;while (stat) {u32 hwirq =__fls (stat); -handle_domain_irq (orion_irq_domain, - gc->irq_base + hwirq, regs); +generic_handle_domain_irq (orion_irq_domain, + gc->irq_base + hwirq); stat &= ~(1 << hwirq); } }
drivers/irqchip/irq-rda-intc.c +1 -1
@@ -53,7 +53,7 @@ static void __exception_irq_entry rda_handle_irq(struct pt_regs *regs)while (stat) { hwirq =__fls (stat); -handle_domain_irq (rda_irq_domain, hwirq, regs); +generic_handle_domain_irq (rda_irq_domain, hwirq); stat &= ~BIT (hwirq); } }
drivers/irqchip/irq-riscv-intc.c +1 -1
@@ -37,7 +37,7 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs)break ;#endif default : -handle_domain_irq (intc_domain, cause, regs); +generic_handle_domain_irq (intc_domain, cause);break ; } }
drivers/irqchip/irq-sa11x0.c +2 -2
@@ -140,8 +140,8 @@ sa1100_handle_irq(struct pt_regs *regs)if (mask ==0 )break ; -handle_domain_irq (sa1100_normal_irqdomain, -ffs (mask) -1 , regs); +generic_handle_domain_irq (sa1100_normal_irqdomain, +ffs (mask) -1 ); }while (1 ); }
drivers/irqchip/irq-stm32-exti.c +1 -3
@@ -850,7 +850,6 @@ static int stm32_exti_probe(struct platform_device *pdev)struct irq_domain *parent_domain, *domain;struct stm32_exti_host_data *host_data;const struct stm32_exti_drv_data *drv_data; -struct resource *res; host_data =devm_kzalloc (dev,sizeof (*host_data),GFP_KERNEL );if (!host_data)
@@ -888,8 +887,7 @@ static int stm32_exti_probe(struct platform_device *pdev)if (!host_data->chips_data)return -ENOMEM ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - host_data->base =devm_ioremap_resource (dev, res); + host_data->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (host_data->base))return PTR_ERR (host_data->base);
drivers/irqchip/irq-sun4i.c +1 -1
@@ -195,7 +195,7 @@ static void __exception_irq_entry sun4i_handle_irq(struct pt_regs *regs)return ;do { -handle_domain_irq (irq_ic_data->irq_domain, hwirq, regs); +generic_handle_domain_irq (irq_ic_data->irq_domain, hwirq); hwirq =readl (irq_ic_data->irq_base +SUN4I_IRQ_VECTOR_REG ) >>2 ; }while (hwirq !=0 );
drivers/irqchip/irq-ti-sci-inta.c +1 -3
@@ -650,7 +650,6 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)struct device_node *parent_node, *node;struct ti_sci_inta_irq_domain *inta;struct device *dev = &pdev->dev; -struct resource *res;int ret; node =dev_of_node (dev);
@@ -694,8 +693,7 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)return PTR_ERR (inta->global_event); } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - inta->base =devm_ioremap_resource (dev, res); + inta->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (inta->base))return PTR_ERR (inta->base);
drivers/irqchip/irq-ts4800.c +1 -3
@@ -93,15 +93,13 @@ static int ts4800_ic_probe(struct platform_device *pdev)struct device_node *node = pdev->dev.of_node;struct ts4800_irq_data *data;struct irq_chip *irq_chip; -struct resource *res;int parent_irq; data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - data->base =devm_ioremap_resource (&pdev->dev, res); + data->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (data->base))return PTR_ERR (data->base);
drivers/irqchip/irq-versatile-fpga.c +1 -1
@@ -105,7 +105,7 @@ static int handle_one_fpga(struct fpga_irq_data *f, struct pt_regs *regs)while ((status =readl (f->base +IRQ_STATUS ))) { irq =ffs (status) -1 ; -handle_domain_irq (f->domain, irq, regs); +generic_handle_domain_irq (f->domain, irq); handled =1 ; }
drivers/irqchip/irq-vic.c +1 -1
@@ -208,7 +208,7 @@ static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)while ((stat =readl_relaxed (vic->base +VIC_IRQ_STATUS ))) { irq =ffs (stat) -1 ; -handle_domain_irq (vic->domain, irq, regs); +generic_handle_domain_irq (vic->domain, irq); handled =1 ; }
drivers/irqchip/irq-vt8500.c +1 -1
@@ -183,7 +183,7 @@ static void __exception_irq_entry vt8500_handle_irq(struct pt_regs *regs)continue ; } -handle_domain_irq (intc[i].domain, irqnr, regs); +generic_handle_domain_irq (intc[i].domain, irqnr); } }
drivers/irqchip/irq-wpcm450-aic.c +1 -1
@@ -69,7 +69,7 @@ static void __exception_irq_entry wpcm450_aic_handle_irq(struct pt_regs *regs)/* Read IPER to signal that nIRQ can be de-asserted */ hwirq =readl (aic->regs +AIC_IPER ) /4 ; -handle_domain_irq (aic->domain, hwirq, regs); +generic_handle_domain_irq (aic->domain, hwirq); }static void wpcm450_aic_eoi (struct irq_data *d)
drivers/irqchip/irq-zevio.c +1 -1
@@ -50,7 +50,7 @@ static void __exception_irq_entry zevio_handle_irq(struct pt_regs *regs)while (readl (zevio_irq_io +IO_STATUS )) { irqnr =readl (zevio_irq_io +IO_CURRENT ); -handle_domain_irq (zevio_irq_domain, irqnr, regs); +generic_handle_domain_irq (zevio_irq_domain, irqnr); } }
include/linux/irq.h +5 -1
@@ -524,9 +524,10 @@ struct irq_chip {void (*irq_bus_lock)(struct irq_data *data);void (*irq_bus_sync_unlock)(struct irq_data *data); +#ifdef CONFIG_DEPRECATED_IRQ_CPU_ONOFFLINE void (*irq_cpu_online)(struct irq_data *data);void (*irq_cpu_offline)(struct irq_data *data); - +#endif void (*irq_suspend)(struct irq_data *data);void (*irq_resume)(struct irq_data *data);void (*irq_pm_shutdown)(struct irq_data *data);
@@ -606,8 +607,10 @@ struct irqaction;extern int setup_percpu_irq (unsigned int irq,struct irqaction *new);extern void remove_percpu_irq (unsigned int irq,struct irqaction *act); +#ifdef CONFIG_DEPRECATED_IRQ_CPU_ONOFFLINE extern void irq_cpu_online (void );extern void irq_cpu_offline (void ); +#endif extern int irq_set_affinity_locked (struct irq_data *data,const struct cpumask *cpumask,bool force);extern int irq_set_vcpu_affinity (unsigned int irq,void *vcpu_info);
@@ -1261,6 +1264,7 @@ int __init set_handle_irq(void (*handle_irq)(struct pt_regs *));* top-level IRQ handler. */ extern void (*handle_arch_irq)(struct pt_regs *)__ro_after_init ; +asmlinkage void generic_handle_arch_irq(struct pt_regs *regs);#else #ifndef set_handle_irq#define set_handle_irq (handle_irq) \
include/linux/irqchip.h +15 -5
@@ -14,8 +14,15 @@#include <linux/acpi.h> #include <linux/module.h> #include <linux/of.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> +/* Undefined on purpose */ +extern of_irq_init_cb_t typecheck_irq_init_cb; + +#define typecheck_irq_init_cb (fn) \ + (__typecheck(typecheck_irq_init_cb, &fn) ? fn : fn) +/* * This macro must be used by the different irqchip drivers to declare * the association between their DT compatible string and their
@@ -23,24 +30,27 @@* * @name: name that must be unique across all IRQCHIP_DECLARE of the * same file. -* @compstr: compatible string of the irqchip driver +* @compat: compatible string of the irqchip driver * @fn: initialization function */ -#define IRQCHIP_DECLARE (name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) +#define IRQCHIP_DECLARE (name, compat, fn) \ + OF_DECLARE_2(irqchip, name, compat, typecheck_irq_init_cb(fn))extern int platform_irqchip_probe (struct platform_device *pdev);#define IRQCHIP_PLATFORM_DRIVER_BEGIN (drv_name) \ static const struct of_device_id drv_name##_irqchip_match_table[] = { -#define IRQCHIP_MATCH (compat, fn) { .compatible = compat, .data = fn }, +#define IRQCHIP_MATCH (compat, fn) { .compatible = compat, \ + .data = typecheck_irq_init_cb(fn), },#define IRQCHIP_PLATFORM_DRIVER_END (drv_name) \ {}, \ }; \ MODULE_DEVICE_TABLE(of, drv_name##_irqchip_match_table); \ -static struct platform_driver drv_name##_driver = { \ - .probe = platform_irqchip_probe, \ +static struct platform_driver drv_name##_driver = { \ + .probe = IS_ENABLED(CONFIG_IRQCHIP) ? \ + platform_irqchip_probe : NULL, \ .driver = { \ .name = #drv_name, \ .owner = THIS_MODULE, \
include/linux/irqdesc.h +1 -8
@@ -168,14 +168,7 @@ int generic_handle_irq(unsigned int irq);* conversion failed. */ int generic_handle_domain_irq (struct irq_domain *domain,unsigned int hwirq); - -#ifdef CONFIG_HANDLE_DOMAIN_IRQ -int handle_domain_irq (struct irq_domain *domain, -unsigned int hwirq,struct pt_regs *regs); - -int handle_domain_nmi (struct irq_domain *domain,unsigned int hwirq, -struct pt_regs *regs); -#endif +int generic_handle_domain_nmi (struct irq_domain *domain,unsigned int hwirq);#endif /* Test to see if a driver has successfully requested an irq */
kernel/irq/Kconfig +7 -3
@@ -97,9 +97,6 @@ config GENERIC_MSI_IRQ_DOMAIN config IRQ_MSI_IOMMU bool -config HANDLE_DOMAIN_IRQ - bool - config IRQ_TIMINGS bool
@@ -144,3 +141,10 @@ config GENERIC_IRQ_MULTI_HANDLER bool help Allow to specify the low level IRQ handler at run time. + +# Cavium Octeon is the last system to use this deprecated option +# Do not even think of enabling this on any new platform +config DEPRECATED_IRQ_CPU_ONOFFLINE + bool + depends on CAVIUM_OCTEON_SOC + default CAVIUM_OCTEON_SOC
kernel/irq/chip.c +2 -0
@@ -1122,6 +1122,7 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) }EXPORT_SYMBOL_GPL (irq_modify_status); +#ifdef CONFIG_DEPRECATED_IRQ_CPU_ONOFFLINE /** * irq_cpu_online - Invoke all irq_cpu_online functions. *
@@ -1181,6 +1182,7 @@ void irq_cpu_offline(void) raw_spin_unlock_irqrestore(&desc->lock, flags); } } +#endif #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
kernel/irq/generic-chip.c +3 -0
@@ -25,6 +25,7 @@ static DEFINE_RAW_SPINLOCK(gc_lock);void irq_gc_noop (struct irq_data *d) { } +EXPORT_SYMBOL_GPL (irq_gc_noop);/** * irq_gc_mask_disable_reg - Mask chip via disable register
@@ -44,6 +45,7 @@ void irq_gc_mask_disable_reg(struct irq_data *d) *ct->mask_cache &= ~mask;irq_gc_unlock (gc); } +EXPORT_SYMBOL_GPL (irq_gc_mask_disable_reg);/** * irq_gc_mask_set_bit - Mask chip via setting bit in mask register
@@ -103,6 +105,7 @@ void irq_gc_unmask_enable_reg(struct irq_data *d) *ct->mask_cache |= mask;irq_gc_unlock (gc); } +EXPORT_SYMBOL_GPL (irq_gc_unmask_enable_reg);/** * irq_gc_ack_set_bit - Ack pending interrupt via setting bit
kernel/irq/handle.c +18 -0
@@ -14,6 +14,8 @@#include <linux/interrupt.h> #include <linux/kernel_stat.h> +#include <asm/irq_regs.h> +#include <trace/events/irq.h> #include "internals.h"
@@ -226,4 +228,20 @@ int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) handle_arch_irq = handle_irq; return 0; } + +/** +* generic_handle_arch_irq - root irq handler for architectures which do no +* entry accounting themselves +* @regs: Register file coming from the low-level handling code +*/ +asmlinkage void noinstr generic_handle_arch_irq(struct pt_regs *regs) +{ +struct pt_regs *old_regs; + +irq_enter (); + old_regs =set_irq_regs (regs); +handle_arch_irq (regs); +set_irq_regs (old_regs); +irq_exit (); +}#endif
kernel/irq/irqdesc.c +17 -64
119 lines not on this page · raw message
kernel/irq/manage.c +3 -3
@@ -1259,6 +1259,8 @@ static int irq_thread(void *data)irqreturn_t (*handler_fn)(struct irq_desc *desc,struct irqaction *action); +sched_set_fifo (current); +if (force_irqthreads () &&test_bit (IRQTF_FORCED_THREAD , &action->thread_flags)) handler_fn = irq_forced_thread_fn;
@@ -1424,8 +1426,6 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)if (IS_ERR (t))return PTR_ERR (t); -sched_set_fifo (t); -/* * We keep the reference to the task struct even if * the thread dies to avoid that the interrupt code
@@ -2827,7 +2827,7 @@ EXPORT_SYMBOL_GPL(irq_get_irqchip_state);* This call sets the internal irqchip state of an interrupt, * depending on the value of @which. * -* This function should be called with preemption disabled if the +* This function should be called with migration disabled if the * interrupt controller has per-cpu registers. */ int irq_set_irqchip_state(unsigned int irq, enum irqchip_irq_state which,
kernel/irq/spurious.c +8 -0
@@ -447,6 +447,10 @@ MODULE_PARM_DESC(noirqdebug, "Disable irq lockup detection when true");static int __init irqfixup_setup (char *str) { +if (IS_ENABLED (CONFIG_PREEMPT_RT )) { +pr_warn ("irqfixup boot option not supported with PREEMPT_RT\n" ); +return 1 ; + } irqfixup =1 ;printk (KERN_WARNING "Misrouted IRQ fixup support enabled.\n" );printk (KERN_WARNING "This may impact system performance.\n" );
@@ -459,6 +463,10 @@ module_param(irqfixup, int, 0644);static int __init irqpoll_setup (char *str) { +if (IS_ENABLED (CONFIG_PREEMPT_RT )) { +pr_warn ("irqpoll boot option not supported with PREEMPT_RT\n" ); +return 1 ; + } irqfixup =2 ;printk (KERN_WARNING "Misrouted IRQ fixup and polling support " "enabled\n" );
[GIT pull] objtool/core for v5.16-rc1
Linus,
please pull the latest objtool/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool-core-2021-10-31
up to: 87c87ecd00c5: bpf,x86: Respect X86_FEATURE_RETPOLINE*
objtool updates:
- Improve retpoline code patching by separating it from alternatives which reduces memory footprint and allows to do better optimizations in the actual runtime patching.
- Add proper retpoline support for x86/BPF
- Address noinstr warnings in x86/kvm, lockdep and paravirtualization code
- Add support to handle pv_opsindirect calls in the noinstr analysis
- Classify symbols upfront and cache the result to avoid redundant str*cmp() invocations.
- Add a CFI hash to reduce memory consumption which also reduces runtime on a allyesconfig by ~50%
- Adjust XEN code to make objtool handling more robust and as a side effect to prevent text fragmentation due to placement of the hypercall page.
Thanks,
tglx
------------------>
Josh Poimboeuf (1):
x86/xen: Move hypercall_page to top of the file
Peter Zijlstra (40):
x86/xen: Mark cpu_bringup_and_idle() as dead_end_function
objtool: Introduce CFI hash
objtool: Handle __sanitize_cov*() tail calls
x86/kvm: Always inline sev_*guest()
x86/kvm: Always inline vmload() / vmsave()
x86: Always inline context_tracking_guest_enter()
x86/kvm: Always inline to_svm()
x86/kvm: Always inline evmcs_write64()
x86: Always inline ip_within_syscall_gap()
x86/sev: Fix noinstr for vc_ghcb_invalidate() locking/lockdep: Avoid RCU-induced noinstr fail x86/paravirt: Mark arch_local_irq_*() __always_inline x86/paravirt: Use PVOP_* for paravirt calls
x86/xen: Make read_cr2() noinstr
x86/xen: Make write_cr2() noinstr
x86/xen: Make get_debugreg() noinstr
x86/xen: Make set_debugreg() noinstr
x86/xen: Make save_fl() noinstr
x86/xen: Make hypercall_page noinstr
x86/xen: Make irq_enable() noinstr
x86/xen: Make irq_disable() noinstr
x86/xen: Mark xen_force_evtchn_callback() noinstr
x86/xen: Rework the xen_{cpu,irq,mmu}_opsarrays
objtool: Support pv_opsindirect calls for noinstr
objtool: Classify symbols
objtool: Explicitly avoid self modifying code in .altinstr_replacement
objtool: Shrink struct instruction
objtool,x86: Replace alternatives with .retpoline_sites x86/retpoline: Remove unused replacement symbols
x86/asm: Fix register order
x86/asm: Fixup odd GEN-for-each-reg.h usage
x86/retpoline: Move the retpoline thunk declarations to nospec-branch.h x86/retpoline: Create a retpoline thunk array x86/alternative: Implement .retpoline_sites support x86/alternative: Handle Jcc __x86_indirect_thunk_\reg x86/alternative: Try inline spectre_v2=retpoline,amd x86/alternative: Add debug prints to apply_retpolines() x86,bugs: Unconditionally allow spectre_v2=retpoline,amd bpf,x86: Simplify computing label offsets
bpf,x86: Respect X86_FEATURE_RETPOLINE*
arch/um/kernel/um_arch.c | 4 + arch/x86/include/asm/GEN-for-each-reg.h | 14 +- arch/x86/include/asm/alternative.h | 1 + arch/x86/include/asm/asm-prototypes.h | 18 - arch/x86/include/asm/nospec-branch.h | 72 +--- arch/x86/include/asm/paravirt.h | 31 +- arch/x86/include/asm/ptrace.h | 2 +- arch/x86/include/asm/xen/hypercall.h | 6 +- arch/x86/kernel/alternative.c | 191 +++++++++- arch/x86/kernel/cpu/bugs.c | 7 - arch/x86/kernel/irqflags.S | 2 + arch/x86/kernel/module.c | 9 +- arch/x86/kernel/paravirt.c | 45 ++- arch/x86/kernel/sev-shared.c | 2 +- arch/x86/kernel/vmlinux.lds.S | 14 + arch/x86/kvm/svm/svm.h | 8 +- arch/x86/kvm/svm/svm_ops.h | 4 +- arch/x86/kvm/vmx/evmcs.h | 4 +- arch/x86/lib/retpoline.S | 56 +-- arch/x86/net/bpf_jit_comp.c | 160 +++----- arch/x86/net/bpf_jit_comp32.c | 22 +- arch/x86/xen/enlighten_pv.c | 70 ++-- arch/x86/xen/irq.c | 31 +- arch/x86/xen/mmu_pv.c | 93 ++--- arch/x86/xen/xen-asm.S | 79 ++-- arch/x86/xen/xen-head.S | 34 +- include/linux/context_tracking.h | 2 +- kernel/locking/lockdep.c | 2 +- lib/Kconfig.debug | 2 +- tools/objtool/arch/x86/decode.c | 180 +++------ tools/objtool/check.c | 646 ++++++++++++++++++++++++-------- tools/objtool/elf.c | 84 ----- tools/objtool/include/objtool/arch.h | 5 +- tools/objtool/include/objtool/cfi.h | 2 + tools/objtool/include/objtool/check.h | 3 +- tools/objtool/include/objtool/elf.h | 9 +- tools/objtool/include/objtool/objtool.h | 9 + tools/objtool/objtool.c | 22 ++ tools/objtool/orc_gen.c | 15 +- tools/objtool/special.c | 8 - 40 files changed, 1157 insertions(+), 811 deletions(-)
arch/um/kernel/um_arch.c +4 -0
@@ -421,6 +421,10 @@ void __init check_bugs(void)os_check_bugs (); } +void apply_retpolines (s32 *start,s32 *end) +{ +} +void apply_alternatives (struct alt_instr *start,struct alt_instr *end) { }
arch/x86/include/asm/GEN-for-each-reg.h +10 -4
@@ -1,11 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* These are in machine order; things rely on that. +*/ #ifdef CONFIG_64BIT GEN(rax) -GEN(rbx) GEN(rcx) GEN(rdx) +GEN(rbx) +GEN(rsp) +GEN(rbp) GEN(rsi) GEN(rdi) -GEN(rbp) GEN(r8) GEN(r9) GEN(r10)
@@ -16,10 +21,11 @@ GEN(r14) GEN(r15) #else GEN(eax) -GEN(ebx) GEN(ecx) GEN(edx) +GEN(ebx) +GEN(esp) +GEN(ebp) GEN(esi) GEN(edi) -GEN(ebp)#endif
arch/x86/include/asm/alternative.h +1 -0
@@ -75,6 +75,7 @@ extern int alternatives_patched;extern void alternative_instructions (void );extern void apply_alternatives (struct alt_instr *start,struct alt_instr *end); +extern void apply_retpolines (s32 *start,s32 *end);struct module ;
arch/x86/include/asm/asm-prototypes.h +0 -18
@@ -17,21 +17,3 @@extern void cmpxchg8b_emu (void );#endif -#ifdef CONFIG_RETPOLINE - -#undef GEN -#define GEN (reg) \ - extern asmlinkage void __x86_indirect_thunk_ ## reg (void); -#include <asm/GEN-for-each-reg.h> - -#undef GEN -#define GEN (reg) \ - extern asmlinkage void __x86_indirect_alt_call_ ## reg (void); -#include <asm/GEN-for-each-reg.h> - -#undef GEN -#define GEN (reg) \ - extern asmlinkage void __x86_indirect_alt_jmp_ ## reg (void); -#include <asm/GEN-for-each-reg.h> - -#endif /* CONFIG_RETPOLINE */
arch/x86/include/asm/nospec-branch.h +13 -59
94 lines not on this page · raw message
arch/x86/include/asm/paravirt.h +17 -14
@@ -52,11 +52,11 @@ void __init paravirt_set_cap(void);/* The paravirtualized I/O functions */ static inline void slow_down_io (void ) { - pv_ops.cpu.io_delay (); +PVOP_VCALL0 (cpu.io_delay);#ifdef REALLY_SLOW_IO - pv_ops.cpu.io_delay (); - pv_ops.cpu.io_delay (); - pv_ops.cpu.io_delay (); +PVOP_VCALL0 (cpu.io_delay); +PVOP_VCALL0 (cpu.io_delay); +PVOP_VCALL0 (cpu.io_delay);#endif }
@@ -113,12 +113,12 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,/* * These special macros can be used to get or set a debugging register */ -static inline unsigned long paravirt_get_debugreg (int reg) +static __always_inline unsigned long paravirt_get_debugreg (int reg) { return PVOP_CALL1(unsigned long, cpu.get_debugreg, reg); }#define get_debugreg (var, reg) var = paravirt_get_debugreg(reg) -static inline void set_debugreg (unsigned long val,int reg) +static __always_inline void set_debugreg(unsigned long val, int reg) {PVOP_VCALL2 (cpu.set_debugreg, reg, val); }
@@ -133,14 +133,14 @@ static inline void write_cr0(unsigned long x)PVOP_VCALL1 (cpu.write_cr0, x); } -static inline unsigned long read_cr2 (void ) +static __always_inline unsigned long read_cr2 (void ) { return PVOP_ALT_CALLEE0(unsigned long, mmu.read_cr2,"mov %%cr2, %%rax;" ,ALT_NOT (X86_FEATURE_XENPV )); } -static inline void write_cr2 (unsigned long x) +static __always_inline void write_cr2(unsigned long x) {PVOP_VCALL1 (mmu.write_cr2, x); }
@@ -653,10 +653,10 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);* functions. */ #define PV_THUNK_NAME (func) "__raw_callee_save_" #func -#define PV_CALLEE_SAVE_REGS_THUNK (func) \ +#define __PV_CALLEE_SAVE_REGS_THUNK (func, section) \ extern typeof(func) __raw_callee_save_##func; \ \ - asm(".pushsection .text;" \ + asm(".pushsection " section ", \"ax\";" \ ".globl " PV_THUNK_NAME(func) ";" \ ".type " PV_THUNK_NAME(func) ", @function;" \ PV_THUNK_NAME(func) ":" \
@@ -669,6 +669,9 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu); ".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \ ".popsection") +#define PV_CALLEE_SAVE_REGS_THUNK (func) \ + __PV_CALLEE_SAVE_REGS_THUNK(func, ".text") +/* Get a reference to a callee-save function */ #define PV_CALLEE_SAVE (func) \ ((struct paravirt_callee_save) { __raw_callee_save_##func })
@@ -678,23 +681,23 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu); ((struct paravirt_callee_save) { func })#ifdef CONFIG_PARAVIRT_XXL -static inline notrace unsigned long arch_local_save_flags (void ) +static __always_inline unsigned long arch_local_save_flags (void ) { return PVOP_ALT_CALLEE0(unsigned long, irq.save_fl, "pushf; pop %%rax;",ALT_NOT (X86_FEATURE_XENPV )); } -static inline notrace void arch_local_irq_disable(void) +static __always_inline void arch_local_irq_disable(void) {PVOP_ALT_VCALLEE0 (irq.irq_disable,"cli;" ,ALT_NOT (X86_FEATURE_XENPV )); } -static inline notrace void arch_local_irq_enable(void) +static __always_inline void arch_local_irq_enable(void) {PVOP_ALT_VCALLEE0 (irq.irq_enable,"sti;" ,ALT_NOT (X86_FEATURE_XENPV )); } -static inline notrace unsigned long arch_local_irq_save (void ) +static __always_inline unsigned long arch_local_irq_save (void ) {unsigned long f;
arch/x86/include/asm/ptrace.h +1 -1
@@ -181,7 +181,7 @@ static inline bool any_64bit_mode(struct pt_regs *regs)#define current_user_stack_pointer () current_pt_regs()->sp#define compat_user_stack_pointer () current_pt_regs()->sp -static inline bool ip_within_syscall_gap (struct pt_regs *regs) +static __always_inline bool ip_within_syscall_gap(struct pt_regs *regs) {bool ret = (regs->ip >= (unsigned long )entry_SYSCALL_64 && regs->ip < (unsigned long )entry_SYSCALL_64_safe_stack);
arch/x86/include/asm/xen/hypercall.h +3 -3
@@ -308,13 +308,13 @@ HYPERVISOR_platform_op(struct xen_platform_op *op)return _hypercall1 (int, platform_op, op); } -static inline int +static __always_inline intHYPERVISOR_set_debugreg (int reg,unsigned long value) {return _hypercall2 (int, set_debugreg, reg, value); } -static inline unsigned long +static __always_inline unsigned long HYPERVISOR_get_debugreg (int reg) { return _hypercall1(unsigned long, get_debugreg, reg);
@@ -358,7 +358,7 @@ HYPERVISOR_event_channel_op(int cmd, void *arg)return _hypercall2 (int, event_channel_op, cmd, arg); } -static inline int +static __always_inline intHYPERVISOR_xen_version (int cmd,void *arg) {return _hypercall2 (int, xen_version, cmd, arg);
arch/x86/kernel/alternative.c +187 -4
233 lines not on this page · raw message
arch/x86/kernel/cpu/bugs.c +0 -7
@@ -882,13 +882,6 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)return SPECTRE_V2_CMD_AUTO ; } -if (cmd ==SPECTRE_V2_CMD_RETPOLINE_AMD && - boot_cpu_data.x86_vendor !=X86_VENDOR_HYGON && - boot_cpu_data.x86_vendor !=X86_VENDOR_AMD ) { -pr_err ("retpoline,amd selected but CPU is not AMD. Switching to AUTO select\n" ); -return SPECTRE_V2_CMD_AUTO ; - } -spec_v2_print_cond (mitigation_options[i].option, mitigation_options[i].secure);return cmd;
arch/x86/kernel/irqflags.S +2 -0
@@ -7,9 +7,11 @@ /* * unsigned long native_save_fl(void) */ +.pushsection .noinstr.text, "ax" SYM_FUNC_START(native_save_fl) pushf pop %_ASM_AX ret SYM_FUNC_END(native_save_fl) +.popsection EXPORT_SYMBOL(native_save_fl)
arch/x86/kernel/module.c +8 -1
@@ -251,7 +251,8 @@ int module_finalize(const Elf_Ehdr *hdr, struct module *me) {const Elf_Shdr *s, *text =NULL , *alt =NULL , *locks =NULL , - *para =NULL , *orc =NULL , *orc_ip =NULL ; + *para =NULL , *orc =NULL , *orc_ip =NULL , + *retpolines =NULL ;char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
@@ -267,8 +268,14 @@ int module_finalize(const Elf_Ehdr *hdr, orc = s;if (!strcmp (".orc_unwind_ip" , secstrings + s->sh_name)) orc_ip = s; +if (!strcmp (".retpoline_sites" , secstrings + s->sh_name)) + retpolines = s; } +if (retpolines) { +void *rseg = (void *)retpolines->sh_addr; +apply_retpolines (rseg, rseg + retpolines->sh_size); + }if (alt) {/* patch .altinstructions */ void *aseg = (void *)alt->sh_addr;
arch/x86/kernel/paravirt.c +36 -9
75 lines not on this page · raw message
arch/x86/kernel/sev-shared.c +1 -1
@@ -64,7 +64,7 @@ static bool sev_es_negotiate_protocol(void) static __always_inline void vc_ghcb_invalidate(struct ghcb *ghcb) { ghcb->save.sw_exit_code =0 ; -memset (ghcb->save.valid_bitmap,0 ,sizeof (ghcb->save.valid_bitmap)); +__builtin_memset (ghcb->save.valid_bitmap,0 ,sizeof (ghcb->save.valid_bitmap)); }static bool vc_decoding_needed (unsigned long exit_code)
arch/x86/kernel/vmlinux.lds.S +14 -0
@@ -272,6 +272,20 @@ SECTIONS __parainstructions_end = .; } +#ifdef CONFIG_RETPOLINE + /* + * List of instructions that call/jmp/jcc to retpoline thunks + * __x86_indirect_thunk_*(). These instructions can be patched along + * with alternatives, after which the section can be freed. + */ + . = ALIGN(8); + .retpoline_sites : AT(ADDR(.retpoline_sites) - LOAD_OFFSET) { + __retpoline_sites = .; + *(.retpoline_sites) + __retpoline_sites_end = .; + } +#endif + /* * struct alt_inst entries. From the header (alternative.h): * "Alternative instructions for different CPU types or capabilities"
arch/x86/kvm/svm/svm.h +4 -4
@@ -218,12 +218,12 @@ DECLARE_PER_CPU(struct svm_cpu_data *, svm_data);void recalc_intercepts (struct vcpu_svm *svm); -static inline struct kvm_svm *to_kvm_svm (struct kvm *kvm) +static __always_inline struct kvm_svm *to_kvm_svm(struct kvm *kvm) { return container_of(kvm, struct kvm_svm, kvm); } -static inline bool sev_guest (struct kvm *kvm) +static __always_inline bool sev_guest(struct kvm *kvm) {#ifdef CONFIG_KVM_AMD_SEV struct kvm_sev_info *sev = &to_kvm_svm (kvm)->sev_info;
@@ -234,7 +234,7 @@ static inline bool sev_guest(struct kvm *kvm)#endif } -static inline bool sev_es_guest (struct kvm *kvm) +static __always_inline bool sev_es_guest(struct kvm *kvm) {#ifdef CONFIG_KVM_AMD_SEV struct kvm_sev_info *sev = &to_kvm_svm (kvm)->sev_info;
@@ -271,7 +271,7 @@ static inline bool vmcb_is_dirty(struct vmcb *vmcb, int bit)return !test_bit (bit, (unsigned long *)&vmcb->control.clean); } -static inline struct vcpu_svm *to_svm (struct kvm_vcpu *vcpu) +static __always_inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu) { return container_of(vcpu, struct vcpu_svm, vcpu); }
arch/x86/kvm/svm/svm_ops.h +2 -2
@@ -56,12 +56,12 @@ static inline void invlpga(unsigned long addr, u32 asid)* VMSAVE, VMLOAD, etc... is still controlled by the effective address size, * hence 'unsigned long' instead of 'hpa_t'. */ -static inline void vmsave (unsigned long pa) +static __always_inline void vmsave(unsigned long pa) {svm_asm1 (vmsave,"a" (pa),"memory" ); } -static inline void vmload (unsigned long pa) +static __always_inline void vmload(unsigned long pa) {svm_asm1 (vmload,"a" (pa),"memory" ); }
arch/x86/kvm/vmx/evmcs.h +2 -2
@@ -93,7 +93,7 @@ static __always_inline int get_evmcs_offset(unsigned long field,return evmcs_field->offset; } -static inline void evmcs_write64 (unsigned long field,u64 value) +static __always_inline void evmcs_write64(unsigned long field, u64 value) {u16 clean_field;int offset =get_evmcs_offset (field, &clean_field);
@@ -183,7 +183,7 @@ static inline void evmcs_load(u64 phys_addr)__init void evmcs_sanitize_exec_ctrls (struct vmcs_config *vmcs_conf);#else /* !IS_ENABLED(CONFIG_HYPERV) */ -static inline void evmcs_write64 (unsigned long field,u64 value) {} +static __always_inline void evmcs_write64(unsigned long field, u64 value) {}static inline void evmcs_write32 (unsigned long field,u32 value) {}static inline void evmcs_write16 (unsigned long field,u16 value) {}static inline u64 evmcs_read64 (unsigned long field) {return 0 ; }
arch/x86/lib/retpoline.S +9 -47
77 lines not on this page · raw message
arch/x86/net/bpf_jit_comp.c +59 -101
272 lines not on this page · raw message
arch/x86/net/bpf_jit_comp32.c +19 -3
@@ -15,6 +15,7 @@#include <asm/cacheflush.h> #include <asm/set_memory.h> #include <asm/nospec-branch.h> +#include <asm/asm-prototypes.h> #include <linux/bpf.h> /*
@@ -1267,6 +1268,21 @@ static void emit_epilogue(u8 **pprog, u32 stack_depth) *pprog = prog; } +static int emit_jmp_edx (u8 **pprog,u8 *ip) +{ +u8 *prog = *pprog; +int cnt =0 ; + +#ifdef CONFIG_RETPOLINE +EMIT1_off32 (0xE9 , (u8 *)__x86_indirect_thunk_edx - (ip +5 )); +#else +EMIT2 (0xFF ,0xE2 ); +#endif + *pprog = prog; + +return cnt; +} +/* * Generate the following code: * ... bpf_tail_call(void *ctx, struct bpf_array *array, u64 index) ...
@@ -1280,7 +1296,7 @@ static void emit_epilogue(u8 **pprog, u32 stack_depth)* goto *(prog->bpf_func + prologue_size); * out: */ -static void emit_bpf_tail_call (u8 **pprog) +static void emit_bpf_tail_call (u8 **pprog,u8 *ip) {u8 *prog = *pprog;int cnt =0 ;
@@ -1362,7 +1378,7 @@ static void emit_bpf_tail_call(u8 **pprog)* eax == ctx (1st arg) * edx == prog->bpf_func + prologue_size */ -RETPOLINE_EDX_BPF_JIT (); + cnt +=emit_jmp_edx (&prog, ip + cnt);if (jmp_label1 ==-1 ) jmp_label1 = cnt;
@@ -2122,7 +2138,7 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,break ; }case BPF_JMP |BPF_TAIL_CALL : -emit_bpf_tail_call (&prog); +emit_bpf_tail_call (&prog, image + addrs[i -1 ]);break ;/* cond jump */
arch/x86/xen/enlighten_pv.c +36 -34
107 lines not on this page · raw message
arch/x86/xen/irq.c +17 -14
@@ -19,12 +19,12 @@* callback mask. We do this in a very simple manner, by making a call * down into Xen. The pending flag will be checked by Xen on return. */ -void xen_force_evtchn_callback (void ) +noinstr void xen_force_evtchn_callback(void) { (void )HYPERVISOR_xen_version (0 ,NULL ); } -asmlinkage __visible unsigned long xen_save_fl(void) +asmlinkage __visible noinstr unsigned long xen_save_fl(void) {struct vcpu_info *vcpu;unsigned long flags;
@@ -40,9 +40,9 @@ asmlinkage __visible unsigned long xen_save_fl(void)*/ return (-flags) &X86_EFLAGS_IF ; } -PV_CALLEE_SAVE_REGS_THUNK (xen_save_fl); +__PV_CALLEE_SAVE_REGS_THUNK (xen_save_fl,".noinstr.text" ); -asmlinkage __visible void xen_irq_disable(void) +asmlinkage __visible noinstr void xen_irq_disable(void) {/* There's a one instruction preempt window here. We need to make sure we're don't switch CPUs between getting the vcpu
@@ -51,9 +51,9 @@ asmlinkage __visible void xen_irq_disable(void)this_cpu_read (xen_vcpu)->evtchn_upcall_mask =1 ;preempt_enable_no_resched (); } -PV_CALLEE_SAVE_REGS_THUNK (xen_irq_disable); +__PV_CALLEE_SAVE_REGS_THUNK (xen_irq_disable,".noinstr.text" ); -asmlinkage __visible void xen_irq_enable(void) +asmlinkage __visible noinstr void xen_irq_enable(void) {struct vcpu_info *vcpu;
@@ -76,7 +76,7 @@ asmlinkage __visible void xen_irq_enable(void)preempt_enable (); } -PV_CALLEE_SAVE_REGS_THUNK (xen_irq_enable); +__PV_CALLEE_SAVE_REGS_THUNK (xen_irq_enable,".noinstr.text" );static void xen_safe_halt (void ) {
@@ -94,17 +94,20 @@ static void xen_halt(void)xen_safe_halt (); } -static const struct pv_irq_ops xen_irq_ops__initconst = { - .save_fl =PV_CALLEE_SAVE (xen_save_fl), - .irq_disable =PV_CALLEE_SAVE (xen_irq_disable), - .irq_enable =PV_CALLEE_SAVE (xen_irq_enable), +static const typeof (pv_ops) xen_irq_ops__initconst = { + .irq = { - .safe_halt = xen_safe_halt, - .halt = xen_halt, + .save_fl =PV_CALLEE_SAVE (xen_save_fl), + .irq_disable =PV_CALLEE_SAVE (xen_irq_disable), + .irq_enable =PV_CALLEE_SAVE (xen_irq_enable), + + .safe_halt = xen_safe_halt, + .halt = xen_halt, + }, };void __init xen_init_irq_ops (void ) { - pv_ops.irq = xen_irq_ops; + pv_ops.irq = xen_irq_ops.irq; x86_init.irqs.intr_init = xen_init_IRQ; }
arch/x86/xen/mmu_pv.c +48 -45
129 lines not on this page · raw message
arch/x86/xen/xen-asm.S +40 -39
103 lines not on this page · raw message
arch/x86/xen/xen-head.S +17 -17
@@ -20,6 +20,23 @@ #include <xen/interface/xen-mca.h> #include <asm/xen/interface.h> +.pushsection .noinstr.text, "ax" + .balign PAGE_SIZE +SYM_CODE_START(hypercall_page) + .rept (PAGE_SIZE / 32) + UNWIND_HINT_FUNC + .skip 31, 0x90 + ret + .endr + +#define HYPERCALL(n) \ + .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \ + .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32 +#include <asm/xen-hypercalls.h> +#undef HYPERCALL +SYM_CODE_END(hypercall_page) +.popsection + #ifdef CONFIG_XEN_PV __INIT SYM_CODE_START(startup_xen)
@@ -64,23 +81,6 @@ SYM_CODE_END(asm_cpu_bringup_and_idle) #endif #endif -.pushsection .text - .balign PAGE_SIZE -SYM_CODE_START(hypercall_page) - .rept (PAGE_SIZE / 32) - UNWIND_HINT_FUNC - .skip 31, 0x90 - ret - .endr - -#define HYPERCALL(n) \ - .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \ - .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32 -#include <asm/xen-hypercalls.h> -#undef HYPERCALL -SYM_CODE_END(hypercall_page) -.popsection - ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
include/linux/context_tracking.h +1 -1
@@ -105,7 +105,7 @@ static inline void user_exit_irqoff(void) { }static inline enum ctx_state exception_enter (void ) {return 0 ; }static inline void exception_exit (enum ctx_state prev_ctx) { }static inline enum ctx_state ct_state (void ) {return CONTEXT_DISABLED ; } -static inline bool context_tracking_guest_enter (void ) {return false; } +static __always_inline bool context_tracking_guest_enter(void) { return false; }static inline void context_tracking_guest_exit (void ) { }#endif /* !CONFIG_CONTEXT_TRACKING */
kernel/locking/lockdep.c +1 -1
@@ -888,7 +888,7 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)if (DEBUG_LOCKS_WARN_ON (!irqs_disabled ()))return NULL ; -hlist_for_each_entry_rcu (class, hash_head, hash_entry) { +hlist_for_each_entry_rcu_notrace (class, hash_head, hash_entry) {if (class->key == key) {/* * Huh! same key, different name? Did someone trample
lib/Kconfig.debug +1 -1
@@ -458,7 +458,7 @@ config STACK_VALIDATION config VMLINUX_VALIDATION bool - depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT + depends on STACK_VALIDATION && DEBUG_ENTRY default y config VMLINUX_MAP
tools/objtool/arch/x86/decode.c +55 -125
233 lines not on this page · raw message
tools/objtool/check.c +495 -151
963 lines not on this page · raw message
tools/objtool/elf.c +0 -84
90 lines not on this page · raw message
tools/objtool/include/objtool/arch.h +3 -2
@@ -69,7 +69,7 @@ struct instruction;void arch_initial_func_cfi_state (struct cfi_init_state *state); -int arch_decode_instruction(const struct elf *elf, const struct section *sec, +int arch_decode_instruction(struct objtool_file *file, const struct section *sec, unsigned long offset, unsigned int maxlen, unsigned int *len, enum insn_type *type, unsigned long *immediate,
@@ -82,8 +82,9 @@ unsigned long arch_jump_destination(struct instruction *insn);unsigned long arch_dest_reloc_offset (int addend);const char *arch_nop_insn (int len); +const char *arch_ret_insn (int len); -int arch_decode_hint_reg (struct instruction *insn,u8 sp_reg); +int arch_decode_hint_reg (u8 sp_reg,int *base);bool arch_is_retpoline (struct symbol *sym);
tools/objtool/include/objtool/cfi.h +2 -0
@@ -7,6 +7,7 @@#define _OBJTOOL_CFI_H#include <arch/cfi_regs.h> +#include <linux/list.h> #define CFI_UNDEFINED -1#define CFI_CFA -2
@@ -24,6 +25,7 @@ struct cfi_init_state { };struct cfi_state { +struct hlist_node hash;/* must be first, cficmp() */ struct cfi_reg regs[CFI_NUM_REGS ];struct cfi_reg vals[CFI_NUM_REGS ];struct cfi_reg cfa;
tools/objtool/include/objtool/check.h +1 -2
@@ -40,7 +40,6 @@ struct instruction {struct list_head list;struct hlist_node hash;struct list_head call_node; -struct list_head mcount_loc_node;struct section *sec;unsigned long offset;unsigned int len;
@@ -60,7 +59,7 @@ struct instruction {struct list_head alts;struct symbol *func;struct list_head stack_ops; -struct cfi_state cfi; +struct cfi_state *cfi; };static inline bool is_static_jump (struct instruction *insn)
tools/objtool/include/objtool/elf.h +6 -3
@@ -54,8 +54,12 @@ struct symbol {unsigned long offset;unsigned int len;struct symbol *pfunc, *cfunc, *alias; -bool uaccess_safe; -bool static_call_tramp; + u8 uaccess_safe : 1; + u8 static_call_tramp : 1; + u8 retpoline_thunk : 1; + u8 fentry : 1; + u8 kcov : 1; +struct list_head pv_target; };struct reloc {
@@ -140,7 +144,6 @@ int elf_write_insn(struct elf *elf, struct section *sec, unsigned long offset, unsigned int len, const char *insn);int elf_write_reloc (struct elf *elf,struct reloc *reloc); -struct symbol *elf_create_undef_symbol (struct elf *elf,const char *name);int elf_write (struct elf *elf);void elf_close (struct elf *elf);
tools/objtool/include/objtool/objtool.h +9 -0
@@ -14,6 +14,11 @@#define __weak __attribute__((weak)) +struct pv_state { +bool clean; +struct list_head targets; +}; +struct objtool_file {struct elf *elf;struct list_head insn_list;
@@ -25,10 +30,14 @@ struct objtool_file {unsigned long jl_short, jl_long;unsigned long jl_nop_short, jl_nop_long; + +struct pv_state *pv_ops; };struct objtool_file *objtool_open_read (const char *_objname); +void objtool_pv_add (struct objtool_file *file,int idx,struct symbol *func); +int check (struct objtool_file *file);int orc_dump (const char *objname);int orc_create (struct objtool_file *file);
tools/objtool/objtool.c +22 -0
@@ -135,6 +135,28 @@ struct objtool_file *objtool_open_read(const char *_objname)return &file; } +void objtool_pv_add (struct objtool_file *f,int idx,struct symbol *func) +{ +if (!noinstr) +return ; + +if (!f->pv_ops) { +WARN ("paravirt confusion" );
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [GIT pull] objtool/core for v5.16-rc1
Quoted 2 lines · Thomas Gleixner
please pull the latest objtool/core branch from:
Hmm. I've pulled this, but I'm not happy about the new warnings it generates with an allmodconfig build:
vmlinux.o: warning: objtool: __do_fast_syscall_32()+0xa: call tostackleak_track_stack() leaves .noinstr.text section
..
do_syscall_64()+0x9: call to stackleak_track_stack ...
do_int80_syscall_32()+0x9: call to stackleak_track_stack ...
exc_general_protection()+0x22: call to stackleak_track_stack ...
fixup_bad_iret()+0x20: call to stackleak_track_stack ...
mce_setup()+0x18: call to memset ...
do_machine_check()+0x27: call to stackleak_track_stack ...
rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter ...
rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit ...
rcu_nmi_enter()+0x36: call to __kasan_check_read ...
.entry.text+0x10e6: call to stackleak_erase ...
.entry.text+0x143: call to stackleak_erase ...
.entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing, but there's a memset in there too, and rcu_dynticks_task_trace_enter/exit and __kasan_check_read..
It may be compiler-dependent, this is with F34 and gcc 11.2.1 20210728.
With my actual normal config (and clang), I don't see any of these, but that's not only a different compiler, it's a much smaller config that has no kasan/stackleak etc.
Linus
Peter Zijlstra
maintainerRe: [GIT pull] objtool/core for v5.16-rc1
Quoted 6 lines · Linus Torvalds
Quoted 2 lines · Thomas Gleixner
please pull the latest objtool/core branch from:
Hmm. I've pulled this, but I'm not happy about the new warnings it generates with an allmodconfig build:
Right, due to fixing the dependency on !PARAVIRT, allyesconfig now does a noinstr validation, and this is the result.
Quoted 4 lines
vmlinux.o: warning: objtool: __do_fast_syscall_32()+0xa: call to
stackleak_track_stack()leaves .noinstr.text section
..mce_setup()+0x18: call to memset ...
Boris was having a poke at the MCE stuff.
Quoted 3 lines
rcu_dynticks_eqs_enter()+0x0: call to rcu_dynticks_task_trace_enter ...
rcu_dynticks_eqs_exit()+0xe: call to rcu_dynticks_task_trace_exit ...
rcu_nmi_enter()+0x36: call to __kasan_check_read ...Fixes for those ^ should be in the rcu tree.
There were also a bunch of Xen ones that should be fixed in the Xen tree, perhaps you've already pulled that.
Quoted 10 lines
do_machine_check()+0x27: call to stackleak_track_stack ... do_syscall_64()+0x9: call to stackleak_track_stack ... do_int80_syscall_32()+0x9: call to stackleak_track_stack ... exc_general_protection()+0x22: call to stackleak_track_stack ... fixup_bad_iret()+0x20: call to stackleak_track_stack ... .entry.text+0x10e6: call to stackleak_erase ... .entry.text+0x143: call to stackleak_erase ... .entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing,
Right, I recently ran into this and hacen't yet had time to look into it. I suspect my normal build box doesn't have the GCC plugin crud enabled or somesuch.
I think the GCC stackleak plugin needs fixing, specifically it needs a function attribute such that it will not emit instrumentation in noinstr functions. I'll go chase down the developer of that thing.
Borislav Petkov
maintainerRe: [GIT pull] objtool/core for v5.16-rc1
Quoted 1 line · Peter Zijlstra
Boris was having a poke at the MCE stuff.
Yeah, on it now that the merge window is open and I finally have some time to do those.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquettePeter Zijlstra
maintainerStackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
In reply to Peter ZijlstraQuoted 13 lines · Peter Zijlstra
Quoted 10 lines · Linus Torvalds
do_machine_check()+0x27: call to stackleak_track_stack ... do_syscall_64()+0x9: call to stackleak_track_stack ... do_int80_syscall_32()+0x9: call to stackleak_track_stack ... exc_general_protection()+0x22: call to stackleak_track_stack ... fixup_bad_iret()+0x20: call to stackleak_track_stack ... .entry.text+0x10e6: call to stackleak_erase ... .entry.text+0x143: call to stackleak_erase ... .entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing,
Quoted 7 lines
Right, I recently ran into this and hacen't yet had time to look into it. I suspect my normal build box doesn't have the GCC plugin crud enabled or somesuch.
I think the GCC stackleak plugin needs fixing, specifically it needs a function attribute such that it will not emit instrumentation in noinstr functions. I'll go chase down the developer of that thing.
Alexander, is there any way to make this plugin grow a function attribute which we can add to noinstr ? There's a strict requirement the compiler doesn't add extra code to noinstr functions these days.
We'll 'soon' be running noinstr C code before switching to kernel page tables even.
Peter Zijlstra
maintainerRe: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
Quoted 22 lines · Peter Zijlstra
Quoted 13 lines · Peter Zijlstra
Quoted 10 lines · Linus Torvalds
do_machine_check()+0x27: call to stackleak_track_stack ... do_syscall_64()+0x9: call to stackleak_track_stack ... do_int80_syscall_32()+0x9: call to stackleak_track_stack ... exc_general_protection()+0x22: call to stackleak_track_stack ... fixup_bad_iret()+0x20: call to stackleak_track_stack ... .entry.text+0x10e6: call to stackleak_erase ... .entry.text+0x143: call to stackleak_erase ... .entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing,
Quoted 7 lines
Right, I recently ran into this and hacen't yet had time to look into it. I suspect my normal build box doesn't have the GCC plugin crud enabled or somesuch.
I think the GCC stackleak plugin needs fixing, specifically it needs a function attribute such that it will not emit instrumentation in noinstr functions. I'll go chase down the developer of that thing.
Quoted 6 lines
Alexander, is there any way to make this plugin grow a function attribute which we can add to noinstr ? There's a strict requirement the compiler doesn't add extra code to noinstr functions these days.
We'll 'soon' be running noinstr C code before switching to kernel page tables even.
Using my pre-release GCC-12 compiler (the only one I have with plugin crud enabled apparently), the below seems to work.
Having the plugin gate on section name seems a lot hacky, but given it's already doing that, one more doesn't hurt.
---
kernel/stackleak.c +1 -2
@@ -48,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,#define skip_erasing () false#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ -asmlinkage void notrace stackleak_erase(void) +asmlinkage noinstr void stackleak_erase(void) {/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */ unsigned long kstack_ptr = current->lowest_stack;
@@ -102,7 +102,6 @@ asmlinkage void notrace stackleak_erase(void)/* Reset the 'lowest_stack' value for the next syscall */ current->lowest_stack =current_top_of_stack () -THREAD_SIZE /64 ; } -NOKPROBE_SYMBOL (stackleak_erase); void __used __no_caller_saved_registers notrace stackleak_track_stack(void) {
scripts/gcc-plugins/stackleak_plugin.c +2 -0
@@ -446,6 +446,8 @@ static bool stackleak_gate(void)return false;if (!strncmp (TREE_STRING_POINTER (section),".meminit.text" ,13 ))return false; +if (!strncmp (TREE_STRING_POINTER (section),".noinstr.text" ,13 )) +return false; }return track_frame_size >=0 ;
Re: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
Quoted 3 lines · Peter Zijlstra
Having the plugin gate on section name seems a lot hacky, but given it's already doing that, one more doesn't hurt.
Looks sane to me.
Some of the other warnings are just odd.
Why is mce_setup() 'noinst'? I'm not seeing any reason for it, but maybe I'm just blind. That one complains about the memcpy() call.
Of course, I suspect memcpy/memset might be better off noinstr anyway, exactly because they can happen for very regular C code (struct assignments etc). But mce_setup() doesn't really seem to have much reason to not be instrumented.
Linus
Borislav Petkov
maintainerRe: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Peter Zijlstra
Having the plugin gate on section name seems a lot hacky, but given it's already doing that, one more doesn't hurt.
Looks sane to me.
Some of the other warnings are just odd.
Quoted 7 lines
Why is
mce_setup()'noinst'? I'm not seeing any reason for it, but maybe I'm just blind. That one complains about thememcpy()call.Of course, I suspect memcpy/memset might be better off noinstr anyway, exactly because they can happen for very regular C code (struct assignments etc). But
mce_setup()doesn't really seem to have much reason to not be instrumented.
That is going away in my local patchset here. The aim is to have the #MC handler be noinstr, ofc, but that thing calls a bunch of other functions and even external ones so it needs careful massaging without destroying the whole house of cards in the process. :-)
I should have something palatable - read: properly split patches - soon.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
In reply to Peter ZijlstraQuoted 34 lines · Peter Zijlstra
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Peter Zijlstra
Quoted 4 lines · Linus Torvalds
do_machine_check()+0x27: call to stackleak_track_stack ... do_syscall_64()+0x9: call to stackleak_track_stack ... do_int80_syscall_32()+0x9: call to stackleak_track_stack ... exc_general_protection()+0x22: call to stackleak_track_stack...
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
fixup_bad_iret()+0x20: call to stackleak_track_stack ... .entry.text+0x10e6: call to stackleak_erase ... .entry.text+0x143: call to stackleak_erase ... .entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing,
Right, I recently ran into this and hacen't yet had time to look
into
Quoted 4 lines
Quoted 4 lines
it. I suspect my normal build box doesn't have the GCC plugin crud enabled or somesuch.
I think the GCC stackleak plugin needs fixing, specifically it
needs a
Quoted 1 line
Quoted 1 line
function attribute such that it will not emit instrumentation in
noinstr
Quoted 4 lines
Quoted 1 line
functions. I'll go chase down the developer of that thing.
Alexander, is there any way to make this plugin grow a function attribute which we can add to noinstr ? There's a strict requirement
the
Quoted 3 lines
compiler doesn't add extra code to noinstr functions these days.
We'll 'soon' be running noinstr C code before switching to kernel
page
Quoted 8 lines
Quoted 1 line
tables even.
Using my pre-release GCC-12 compiler (the only one I have with plugin crud enabled apparently), the below seems to work.
Having the plugin gate on section name seems a lot hacky, but given it's
already doing that, one more doesn't hurt.
Hello Peter!
Yes, this is a correct approach.
But I'm not sure about removing NOKPROBE_SYMBOL and notrace for stackleak_erase. Does the code in noinstr.text disable all those?
Best regards,
Alexander
Quoted 39 lines
---
kernel/stackleak.c +1
-1@@ -48,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,#define skip_erasing () false#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ -asmlinkage void notrace stackleak_erase(void) +asmlinkage noinstr void stackleak_erase(void) {/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
unsigned long kstack_ptr = current->lowest_stack;kernel/stackleak.c +0
-1@@ -102,7 +102,6 @@ asmlinkage void notrace stackleak_erase(void)/* Reset the 'lowest_stack' value for the next syscall */ current->lowest_stack =current_top_of_stack () -THREAD_SIZE /64 ; } -NOKPROBE_SYMBOL (stackleak_erase);void
__used__no_caller_saved_registersnotracestackleak_track_stack(void)
{scripts/gcc-plugins/stackleak_plugin.c +2
-0@@ -446,6 +446,8 @@ static bool stackleak_gate(void)return false;if (!strncmp (TREE_STRING_POINTER (section),".meminit.text" ,13 ))return false; +if (!strncmp (TREE_STRING_POINTER (section),".noinstr.text" ,13 )) +return false; }return track_frame_size >=0 ;
Peter Zijlstra
maintainerRe: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
Quoted 4 lines · Alexander Popov
Yes, this is a correct approach.
But I'm not sure about removing
NOKPROBE_SYMBOLand notrace forstackleak_erase. Does the code in noinstr.text disable all those?
Yes, noinstr implies all those and more. Both kprobe and tracing are a form of instrumentation, and hence noinstr must disallow it.
Re: Stackleak vs noinstr (Was: [GIT pull] objtool/core for v5.16-rc1)
In reply to Peter ZijlstraQuoted 63 lines · Peter Zijlstra
Quoted 22 lines · Peter Zijlstra
Quoted 13 lines · Peter Zijlstra
Quoted 10 lines · Linus Torvalds
do_machine_check()+0x27: call to stackleak_track_stack ... do_syscall_64()+0x9: call to stackleak_track_stack ... do_int80_syscall_32()+0x9: call to stackleak_track_stack ... exc_general_protection()+0x22: call to stackleak_track_stack ... fixup_bad_iret()+0x20: call to stackleak_track_stack ... .entry.text+0x10e6: call to stackleak_erase ... .entry.text+0x143: call to stackleak_erase ... .entry.text+0x17d9: call to stackleak_erase ...most seem to be about the stackleak thing,
Quoted 7 lines
Right, I recently ran into this and hacen't yet had time to look into it. I suspect my normal build box doesn't have the GCC plugin crud enabled or somesuch.
I think the GCC stackleak plugin needs fixing, specifically it needs a function attribute such that it will not emit instrumentation in noinstr functions. I'll go chase down the developer of that thing.
Quoted 6 lines
Alexander, is there any way to make this plugin grow a function attribute which we can add to noinstr ? There's a strict requirement the compiler doesn't add extra code to noinstr functions these days.
We'll 'soon' be running noinstr C code before switching to kernel page tables even.
Using my pre-release GCC-12 compiler (the only one I have with plugin crud enabled apparently), the below seems to work.
Having the plugin gate on section name seems a lot hacky, but given it's already doing that, one more doesn't hurt.
---
kernel/stackleak.c +1
-2@@ -48,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,#define skip_erasing () false#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */ -asmlinkage void notrace stackleak_erase(void) +asmlinkage noinstr void stackleak_erase(void) {/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */ unsigned long kstack_ptr = current->lowest_stack;@@ -102,7 +102,6 @@ asmlinkage void notrace stackleak_erase(void)/* Reset the 'lowest_stack' value for the next syscall */ current->lowest_stack =current_top_of_stack () -THREAD_SIZE /64 ; } -NOKPROBE_SYMBOL (stackleak_erase); void __used __no_caller_saved_registers notrace stackleak_track_stack(void) {scripts/gcc-plugins/stackleak_plugin.c +0
-0
scripts/gcc-plugins/stackleak_plugin.c static bool stackleak_gate(void) · line 453
Quoted 8 lines
scripts/gcc-plugins/stackleak_plugin.c +2
-0@@ -446,6 +446,8 @@ static bool stackleak_gate(void)return false;if (!strncmp (TREE_STRING_POINTER (section),".meminit.text" ,13 ))return false; +if (!strncmp (TREE_STRING_POINTER (section),".noinstr.text" ,13 )) +return false; }return track_frame_size >=0 ;
Did this ever turn into a real patch? I don't see anything in -next for it, so I assume it's still needed.
Signature · 1 line
Kees Cook
Re: [GIT pull] objtool/core for v5.16-rc1
In reply to Thomas GleixnerThe pull request you sent on Mon, 1 Nov 2021 02:16:01 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:16:01 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitobjtool-core-2021-10-31
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/43aa0a195f06101bcb5d8d711bba0dd24b33a1a0
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull] perf/core for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest perf/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf-core-2021-10-31
up to: 2de71ee153ef: perf/x86/intel: Fix ICL/SPR INST_RETIRED.PREC_DIST encodings
perf updates:
core:
- Allow ftrace to instrument parts of the perf core code
- Add a new mem_hops field to perf_mem_data_src which allows to represent intra-node/package or inter-node/off-package details to prepare for next generation systems which have more hieararchy within the node/pacakge level.
tools:
- Update for the new mem_hops field in perf_mem_data_src
arch:
- A set of constraints fixes for the Intel uncore PMU
- The usual set of small fixes and improvements for x86 and PPC
Thanks,
tglx
------------------>
Adrian Hunter (1):
perf/x86: Add new event for AUX output counter index
Kajol Jain (4):
perf: Add comment about current state of PERF_MEM_LVL_* namespace and remove an extra line
perf: Add mem_hops field in perf_mem_data_src structure
tools/perf: Add mem_hops field in perf_mem_data_src structure powerpc/perf: Fix data source encodings for L2.1 and L3.1 accesses
Kan Liang (7):
perf/x86/intel/uncore: Support extra IMC channel on Ice Lake server perf/x86/intel/uncore: Fix invalid unit check perf/x86/intel/uncore: Fix Intel ICX IIO event constraints perf/x86/intel/uncore: Fix Intel SPR CHA event constraints perf/x86/intel/uncore: Fix Intel SPR IIO event constraints perf/x86/intel/uncore: Fix Intel SPR M2PCIE event constraints perf/x86/intel/uncore: Fix Intel SPR M3UPI event constraints
Leo Yan (1):
perf/x86: Add compiler barrier after updating BTS
Song Liu (1):
perf/core: Allow ftrace for functions in kernel/event/core.c
Stephane Eranian (1):
perf/x86/intel: Fix ICL/SPR INST_RETIRED.PREC_DIST encodings
arch/powerpc/perf/isa207-common.c | 26 +++++++++++++++++++----- arch/powerpc/perf/isa207-common.h | 2 ++ arch/x86/events/core.c | 6 ++++++ arch/x86/events/intel/bts.c | 6 ++++++ arch/x86/events/intel/core.c | 21 ++++++++++++++++++-- arch/x86/events/intel/ds.c | 5 +++-- arch/x86/events/intel/uncore_discovery.h | 2 +- arch/x86/events/intel/uncore_snbep.c | 16 +++++++++++++-- arch/x86/events/perf_event.h | 1 + include/linux/perf_event.h | 1 + include/uapi/linux/perf_event.h | 34 +++++++++++++++++++++++++++++--- kernel/events/Makefile | 5 ----- kernel/events/core.c | 30 ++++++++++++++++++++++++++++ tools/include/uapi/linux/perf_event.h | 19 +++++++++++++++--- tools/perf/util/mem-events.c | 20 +++++++++++++++++-- 15 files changed, 169 insertions(+), 25 deletions(-)
arch/powerpc/perf/isa207-common.c +21 -5
@@ -238,11 +238,27 @@ static inline u64 isa207_find_source(u64 idx, u32 sub_idx) ret |=P (SNOOP ,HIT );break ;case 5 : - ret =PH (LVL ,REM_CCE1 ); -if ((sub_idx ==0 ) || (sub_idx ==2 ) || (sub_idx ==4 )) - ret |=P (SNOOP ,HIT ); -else if ((sub_idx ==1 ) || (sub_idx ==3 ) || (sub_idx ==5 )) - ret |=P (SNOOP ,HITM ); +if (cpu_has_feature (CPU_FTR_ARCH_31 )) { + ret =REM |P (HOPS ,0 ); + +if (sub_idx ==0 || sub_idx ==4 ) + ret |=PH (LVL ,L2 ) |LEVEL (L2 ) |P (SNOOP ,HIT ); +else if (sub_idx ==1 || sub_idx ==5 ) + ret |=PH (LVL ,L2 ) |LEVEL (L2 ) |P (SNOOP ,HITM ); +else if (sub_idx ==2 || sub_idx ==6 ) + ret |=PH (LVL ,L3 ) |LEVEL (L3 ) |P (SNOOP ,HIT ); +else if (sub_idx ==3 || sub_idx ==7 ) + ret |=PH (LVL ,L3 ) |LEVEL (L3 ) |P (SNOOP ,HITM ); + }else { +if (sub_idx ==0 ) + ret =PH (LVL ,L2 ) |LEVEL (L2 ) |REM |P (SNOOP ,HIT ) |P (HOPS ,0 ); +else if (sub_idx ==1 ) + ret =PH (LVL ,L2 ) |LEVEL (L2 ) |REM |P (SNOOP ,HITM ) |P (HOPS ,0 ); +else if (sub_idx ==2 || sub_idx ==4 ) + ret =PH (LVL ,L3 ) |LEVEL (L3 ) |REM |P (SNOOP ,HIT ) |P (HOPS ,0 ); +else if (sub_idx ==3 || sub_idx ==5 ) + ret =PH (LVL ,L3 ) |LEVEL (L3 ) |REM |P (SNOOP ,HITM ) |P (HOPS ,0 ); + }break ;case 6 : ret =PH (LVL ,REM_CCE2 );
arch/powerpc/perf/isa207-common.h +2 -0
@@ -273,6 +273,8 @@#define P (a, b) PERF_MEM_S(a, b)#define PH (a, b) (P(LVL, HIT) | P(a, b))#define PM (a, b) (P(LVL, MISS) | P(a, b)) +#define LEVEL (x) P(LVLNUM, x) +#define REM P(REMOTE, REMOTE)int isa207_get_constraint (u64 event,unsigned long *maskp,unsigned long *valp,u64 event_config1); int isa207_compute_mmcr(u64 event[], int n_ev,
arch/x86/events/core.c +6 -0
@@ -66,6 +66,8 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_enable_all, *x86_pmu.enable_all);DEFINE_STATIC_CALL_NULL (x86_pmu_enable, *x86_pmu.enable);DEFINE_STATIC_CALL_NULL (x86_pmu_disable, *x86_pmu.disable); +DEFINE_STATIC_CALL_NULL (x86_pmu_assign, *x86_pmu.assign); +DEFINE_STATIC_CALL_NULL (x86_pmu_add, *x86_pmu.add);DEFINE_STATIC_CALL_NULL (x86_pmu_del, *x86_pmu.del);DEFINE_STATIC_CALL_NULL (x86_pmu_read, *x86_pmu.read);
@@ -1215,6 +1217,8 @@ static inline void x86_assign_hw_event(struct perf_event *event, hwc->last_cpu =smp_processor_id (); hwc->last_tag = ++cpuc->tags[i]; +static_call_cond (x86_pmu_assign)(event, idx); +switch (hwc->idx) {case INTEL_PMC_IDX_FIXED_BTS :case INTEL_PMC_IDX_FIXED_VLBR :
@@ -2005,6 +2009,8 @@ static void x86_pmu_static_call_update(void)static_call_update (x86_pmu_enable, x86_pmu.enable);static_call_update (x86_pmu_disable, x86_pmu.disable); +static_call_update (x86_pmu_assign, x86_pmu.assign); +static_call_update (x86_pmu_add, x86_pmu.add);static_call_update (x86_pmu_del, x86_pmu.del);static_call_update (x86_pmu_read, x86_pmu.read);
arch/x86/events/intel/bts.c +6 -0
@@ -209,6 +209,12 @@ static void bts_update(struct bts_ctx *bts) }else {local_set (&buf->data_size, head); } + +/* +* Since BTS is coherent, just add compiler barrier to ensure +* BTS updating is ordered against bts::handle::event. +*/ +barrier (); } static int
arch/x86/events/intel/core.c +19 -2
@@ -243,7 +243,8 @@ static struct extra_reg intel_skl_extra_regs[] __read_mostly = {static struct event_constraint intel_icl_event_constraints[] = {FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ -FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* old INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x0100 ,0 ),/* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ FIXED_EVENT_CONSTRAINT (0x0400 ,3 ),/* SLOTS */
@@ -287,7 +288,7 @@ static struct extra_reg intel_spr_extra_regs[] __read_mostly = {static struct event_constraint intel_spr_event_constraints[] = {FIXED_EVENT_CONSTRAINT (0x00c0 ,0 ),/* INST_RETIRED.ANY */ -FIXED_EVENT_CONSTRAINT (0x01c0 ,0 ),/* INST_RETIRED.PREC_DIST */ +FIXED_EVENT_CONSTRAINT (0x0100 ,0 ),/* INST_RETIRED.PREC_DIST */ FIXED_EVENT_CONSTRAINT (0x003c ,1 ),/* CPU_CLK_UNHALTED.CORE */ FIXED_EVENT_CONSTRAINT (0x0300 ,2 ),/* CPU_CLK_UNHALTED.REF */ FIXED_EVENT_CONSTRAINT (0x0400 ,3 ),/* SLOTS */
@@ -2402,6 +2403,12 @@ static void intel_pmu_disable_event(struct perf_event *event)intel_pmu_pebs_disable (event); } +static void intel_pmu_assign_event (struct perf_event *event,int idx) +{ +if (is_pebs_pt (event)) +perf_report_aux_output_id (event, idx); +} +static void intel_pmu_del_event (struct perf_event *event) {if (needs_branch_stack (event))
@@ -4494,8 +4501,16 @@ static int intel_pmu_check_period(struct perf_event *event, u64 value)return intel_pmu_has_bts_period (event, value) ? -EINVAL :0 ; } +static void intel_aux_output_init (void ) +{ +/* Refer also intel_pmu_aux_output_match() */ +if (x86_pmu.intel_cap.pebs_output_pt_available) + x86_pmu.assign = intel_pmu_assign_event; +} +static int intel_pmu_aux_output_match (struct perf_event *event) { +/* intel_pmu_assign_event() is needed, refer intel_aux_output_init() */ if (!x86_pmu.intel_cap.pebs_output_pt_available)return 0 ;
@@ -6301,6 +6316,8 @@ __init int intel_pmu_init(void)if (is_hybrid ())intel_pmu_check_hybrid_pmus ((u64 )fixed_mask); +intel_aux_output_init (); +return 0 ; }
arch/x86/events/intel/ds.c +3 -2
@@ -923,7 +923,8 @@ struct event_constraint intel_skl_pebs_event_constraints[] = { };struct event_constraint intel_icl_pebs_event_constraints[] = { -INTEL_FLAGS_UEVENT_CONSTRAINT (0x1c0 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ +INTEL_FLAGS_UEVENT_CONSTRAINT (0x01c0 ,0x100000000ULL ),/* old INST_RETIRED.PREC_DIST */ +INTEL_FLAGS_UEVENT_CONSTRAINT (0x0100 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ INTEL_FLAGS_UEVENT_CONSTRAINT (0x0400 ,0x800000000ULL ),/* SLOTS */ INTEL_PLD_CONSTRAINT (0x1cd ,0xff ),/* MEM_TRANS_RETIRED.LOAD_LATENCY */
@@ -943,7 +944,7 @@ struct event_constraint intel_icl_pebs_event_constraints[] = { };struct event_constraint intel_spr_pebs_event_constraints[] = { -INTEL_FLAGS_UEVENT_CONSTRAINT (0x1c0 ,0x100000000ULL ), +INTEL_FLAGS_UEVENT_CONSTRAINT (0x100 ,0x100000000ULL ),/* INST_RETIRED.PREC_DIST */ INTEL_FLAGS_UEVENT_CONSTRAINT (0x0400 ,0x800000000ULL ),INTEL_FLAGS_EVENT_CONSTRAINT (0xc0 ,0xfe ),
arch/x86/events/intel/uncore_discovery.h +1 -1
@@ -30,7 +30,7 @@#define uncore_discovery_invalid_unit (unit) \ - (!unit.table1 || !unit.ctl || !unit.table3 || \ + (!unit.table1 || !unit.ctl || \ unit.table1 == -1ULL || unit.ctl == -1ULL || \ unit.table3 == -1ULL)
arch/x86/events/intel/uncore_snbep.c +14 -2
@@ -452,7 +452,7 @@#define ICX_M3UPI_PCI_PMON_BOX_CTL 0xa0/* ICX IMC */ -#define ICX_NUMBER_IMC_CHN 2 +#define ICX_NUMBER_IMC_CHN 3#define ICX_IMC_MEM_STRIDE 0x4/* SPR */
@@ -5076,8 +5076,10 @@ static struct event_constraint icx_uncore_iio_constraints[] = {UNCORE_EVENT_CONSTRAINT (0x02 ,0x3 ),UNCORE_EVENT_CONSTRAINT (0x03 ,0x3 ),UNCORE_EVENT_CONSTRAINT (0x83 ,0x3 ), +UNCORE_EVENT_CONSTRAINT (0x88 ,0xc ),UNCORE_EVENT_CONSTRAINT (0xc0 ,0xc ),UNCORE_EVENT_CONSTRAINT (0xc5 ,0xc ), +UNCORE_EVENT_CONSTRAINT (0xd5 ,0xc ), EVENT_CONSTRAINT_END };
@@ -5463,7 +5465,7 @@ static struct intel_uncore_ops icx_uncore_mmio_ops = {static struct intel_uncore_type icx_uncore_imc = { .name ="imc" , .num_counters =4 , - .num_boxes =8 , + .num_boxes =12 , .perf_ctr_bits =48 , .fixed_ctr_bits =48 , .fixed_ctr =SNR_IMC_MMIO_PMON_FIXED_CTR ,
@@ -5647,6 +5649,7 @@ static struct intel_uncore_type spr_uncore_chabox = { .event_mask = SPR_CHA_PMON_EVENT_MASK, .event_mask_ext = SPR_RAW_EVENT_MASK_EXT, .num_shared_regs = 1, + .constraints = skx_uncore_chabox_constraints, .ops = &spr_uncore_chabox_ops, .format_group = &spr_uncore_chabox_format_group, .attr_update = uncore_alias_groups,
@@ -5658,6 +5661,7 @@ static struct intel_uncore_type spr_uncore_iio = { .event_mask_ext = SNR_IIO_PMON_RAW_EVENT_MASK_EXT, .format_group = &snr_uncore_iio_format_group, .attr_update = uncore_alias_groups, + .constraints = icx_uncore_iio_constraints, };static struct attribute *spr_uncore_raw_formats_attr[] = {
@@ -5686,9 +5690,16 @@ static struct intel_uncore_type spr_uncore_irp = { }; +static struct event_constraint spr_uncore_m2pcie_constraints[] = { +UNCORE_EVENT_CONSTRAINT (0x14 ,0x3 ), +UNCORE_EVENT_CONSTRAINT (0x2d ,0x3 ), +EVENT_CONSTRAINT_END +}; +static struct intel_uncore_type spr_uncore_m2pcie = {SPR_UNCORE_COMMON_FORMAT (), .name ="m2pcie" , + .constraints = spr_uncore_m2pcie_constraints, };static struct intel_uncore_type spr_uncore_pcu = {
@@ -5765,6 +5776,7 @@ static struct intel_uncore_type spr_uncore_upi = {static struct intel_uncore_type spr_uncore_m3upi = {SPR_UNCORE_PCI_COMMON_FORMAT (), .name ="m3upi" , + .constraints = icx_uncore_m3upi_constraints, };static struct intel_uncore_type spr_uncore_mdf = {
arch/x86/events/perf_event.h +1 -0
@@ -726,6 +726,7 @@ struct x86_pmu {void (*enable_all)(int added);void (*enable)(struct perf_event *);void (*disable)(struct perf_event *); +void (*assign)(struct perf_event *event,int idx);void (*add)(struct perf_event *);void (*del)(struct perf_event *);void (*read)(struct perf_event *event);
include/linux/perf_event.h +1 -0
@@ -1397,6 +1397,7 @@ perf_event_addr_filters(struct perf_event *event) }extern void perf_event_addr_filters_sync (struct perf_event *event); +extern void perf_report_aux_output_id (struct perf_event *event,u64 hw_id); extern int perf_output_begin(struct perf_output_handle *handle, struct perf_sample_data *data,
include/uapi/linux/perf_event.h +31 -3
@@ -1141,6 +1141,21 @@ enum perf_event_type {*/ PERF_RECORD_TEXT_POKE =20 , +/* +* Data written to the AUX area by hardware due to aux_output, may need +* to be matched to the event by an architecture-specific hardware ID. +* This records the hardware ID, but requires sample_id to provide the +* event ID. e.g. Intel PT uses this record to disambiguate PEBS-via-PT +* records from multiple events. +* +* struct { +* struct perf_event_header header; +* u64 hw_id; +* struct sample_id sample_id; +* }; +*/ +PERF_RECORD_AUX_OUTPUT_HW_ID =21 , + PERF_RECORD_MAX, /* non-ABI */ };
@@ -1210,14 +1225,16 @@ union perf_mem_data_src { mem_remote:1, /* remote */ mem_snoopx:2, /* snoop mode, ext */ mem_blk:3, /* access blocked */ - mem_rsvd:21; + mem_hops:3, /* hop level */ + mem_rsvd:18; }; };#elif defined(__BIG_ENDIAN_BITFIELD)union perf_mem_data_src {__u64 val;struct { -__u64 mem_rsvd:21 , +__u64 mem_rsvd:18 , + mem_hops:3 ,/* hop level */ mem_blk:3 ,/* access blocked */ mem_snoopx:2 ,/* snoop mode, ext */ mem_remote:1, /* remote */
@@ -1241,7 +1258,13 @@ union perf_mem_data_src {#define PERF_MEM_OP_EXEC 0x10/* code (execution) */ #define PERF_MEM_OP_SHIFT 0 -/* memory hierarchy (memory level, hit or miss) */ +/* +* PERF_MEM_LVL_* namespace being depricated to some extent in the +* favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. +* Supporting this namespace inorder to not break defined ABIs. +* +* memory hierarchy (memory level, hit or miss) +*/ #define PERF_MEM_LVL_NA 0x01/* not available */ #define PERF_MEM_LVL_HIT 0x02/* hit level */ #define PERF_MEM_LVL_MISS 0x04/* miss level */
@@ -1307,6 +1330,11 @@ union perf_mem_data_src {#define PERF_MEM_BLK_ADDR 0x04/* address conflict */ #define PERF_MEM_BLK_SHIFT 40 +/* hop level */ +#define PERF_MEM_HOPS_0 0x01/* remote core, same node */ +/* 2-7 available */ +#define PERF_MEM_HOPS_SHIFT 43 +#define PERF_MEM_S (a, s) \ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
kernel/events/Makefile +0 -5
@@ -1,10 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -ifdef CONFIG_FUNCTION_TRACER -CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE) -endif - obj-y := core.o ring_buffer.o callchain.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_UPROBES) += uprobes.o -
kernel/events/core.c +30 -0
@@ -9062,6 +9062,36 @@ static void perf_log_itrace_start(struct perf_event *event)perf_output_end (&handle); } +void perf_report_aux_output_id (struct perf_event *event,u64 hw_id) +{ +struct perf_output_handle handle; +struct perf_sample_data sample; +struct perf_aux_event { +struct perf_event_header header; +u64 hw_id; + } rec; +int ret; + +if (event->parent) + event = event->parent; + + rec.header.type =PERF_RECORD_AUX_OUTPUT_HW_ID ; + rec.header.misc =0 ; + rec.header.size =sizeof (rec); + rec.hw_id = hw_id; + +perf_event_header__init_id (&rec.header, &sample, event); + ret =perf_output_begin (&handle, &sample, event, rec.header.size); + +if (ret) +return ; + +perf_output_put (&handle, rec); +perf_event__output_id_sample (event, &handle, &sample); + +perf_output_end (&handle); +} +static int __perf_event_account_interrupt (struct perf_event *event,int throttle) {
tools/include/uapi/linux/perf_event.h +16 -3
@@ -1210,14 +1210,16 @@ union perf_mem_data_src { mem_remote:1, /* remote */ mem_snoopx:2, /* snoop mode, ext */ mem_blk:3, /* access blocked */ - mem_rsvd:21; + mem_hops:3, /* hop level */ + mem_rsvd:18; }; };#elif defined(__BIG_ENDIAN_BITFIELD)union perf_mem_data_src {__u64 val;struct { -__u64 mem_rsvd:21 , +__u64 mem_rsvd:18 , + mem_hops:3 ,/* hop level */ mem_blk:3 ,/* access blocked */ mem_snoopx:2 ,/* snoop mode, ext */ mem_remote:1, /* remote */
@@ -1241,7 +1243,13 @@ union perf_mem_data_src {#define PERF_MEM_OP_EXEC 0x10/* code (execution) */ #define PERF_MEM_OP_SHIFT 0 -/* memory hierarchy (memory level, hit or miss) */ +/* +* PERF_MEM_LVL_* namespace being depricated to some extent in the +* favour of newer composite PERF_MEM_{LVLNUM_,REMOTE_,SNOOPX_} fields. +* Supporting this namespace inorder to not break defined ABIs. +* +* memory hierarchy (memory level, hit or miss) +*/ #define PERF_MEM_LVL_NA 0x01/* not available */ #define PERF_MEM_LVL_HIT 0x02/* hit level */ #define PERF_MEM_LVL_MISS 0x04/* miss level */
@@ -1307,6 +1315,11 @@ union perf_mem_data_src {#define PERF_MEM_BLK_ADDR 0x04/* address conflict */ #define PERF_MEM_BLK_SHIFT 40 +/* hop level */ +#define PERF_MEM_HOPS_0 0x01/* remote core, same node */ +/* 2-7 available */ +#define PERF_MEM_HOPS_SHIFT 43 +#define PERF_MEM_S (a, s) \ (((__u64)PERF_MEM_##a##_##s) << PERF_MEM_##a##_SHIFT)
tools/perf/util/mem-events.c +18 -2
@@ -301,6 +301,16 @@ static const char * const mem_lvlnum[] = { [PERF_MEM_LVLNUM_NA] = "N/A", }; +static const char *const mem_hops[] = { +"N/A" , +/* +* While printing, 'Remote' will be added to represent +* 'Remote core, same node' accesses as remote field need +* to be set with mem_hops field. +*/ +"core, same node" , +}; +int perf_mem__lvl_scnprintf (char *out,size_t sz,struct mem_info *mem_info) {size_t i, l =0 ;
@@ -320,12 +330,14 @@ int perf_mem__lvl_scnprintf(char *out, size_t sz, struct mem_info *mem_info)/* already taken care of */ m &= ~(PERF_MEM_LVL_HIT |PERF_MEM_LVL_MISS ); -if (mem_info && mem_info->data_src.mem_remote) {strcat (out,"Remote " ); l +=7 ; } +if (mem_info && mem_info->data_src.mem_hops) + l +=scnprintf (out + l, sz - l,"%s " , mem_hops[mem_info->data_src.mem_hops]); + printed =0 ;for (i =0 ; m && i <ARRAY_SIZE (mem_lvl); i++, m >>=1 ) {if (!(m &0x1 ))
@@ -472,8 +484,12 @@ int c2c_decode_stats(struct c2c_stats *stats, struct mem_info *mi)/* * Skylake might report unknown remote level via this * bit, consider it when evaluating remote HITMs. +* +* Incase of power, remote field can also be used to denote cache +* accesses from the another core of same node. Hence, setting +* mrem only when HOPS is zero along with set remote field. */ -bool mrem = data_src->mem_remote; +bool mrem = (data_src->mem_remote && !data_src->mem_hops);int err =0 ;#define HITM_INC (__f) \
Re: [GIT pull] perf/core for v5.16-rc1
The pull request you sent on Mon, 1 Nov 2021 02:16:03 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:16:03 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitperf-core-2021-10-31
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/91e1c99e175ae6bb6be765c6fcd40e869f8f6aee
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull] timers/core for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest timers/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers-core-2021-10-31
up to: a8da61cee95e: Merge tag 'timers-v5.16-rc1' into timers/core
Time, timers and timekeeping updates:
- No core updates
- No new clocksource/event driver
- A large rework of the ARM architected timer driver to prepare for the support of the upcoming ARMv8.6 support
- Fix Kconfig options for Exynos MCT, Samsung PWM and TI DM timers
- Address a namespace collison in the ARC sp804 timer driver
Thanks,
tglx
------------------>
Kees Cook (1):
clocksource/drivers/timer-ti-dm: Select TIMER_OF
Krzysztof Kozlowski (1):
clocksource/drivers/exynosy: Depend on sub-architecture for Exynos MCT and Samsung PWM
Marc Zyngier (12):
clocksource/arm_arch_timer: Add build-time guards for unhandled register accesses clocksource/drivers/arm_arch_timer: Drop CNT*_TVAL read accessors clocksource/drivers/arm_arch_timer: Extend write side of timer register accessors to u64 clocksource/drivers/arm_arch_timer: Move system register timer programming over to CVAL clocksource/drivers/arm_arch_timer: Move drop _tval from erratum function names clocksource/drivers/arm_arch_timer: Fix MMIO base address vs callback ordering issue clocksource/drivers/arm_arch_timer: Move MMIO timer programming over to CVAL clocksource/drivers/arm_arch_timer: Advertise 56bit timer to the core code clocksource/drivers/arm_arch_timer: Work around broken CVAL implementations clocksource/drivers/arm_arch_timer: Remove any trace of the TVAL programming interface clocksource/drivers/arm_arch_timer: Drop unnecessary ISB on CVAL programming clocksource/drivers/arch_arm_timer: Move workaround synchronisation around
Oliver Upton (1):
clocksource/drivers/arm_arch_timer: Fix masking for high freq counters
Randy Dunlap (1):
clocksource/drivers/arc_timer: Eliminate redefined macro error
arch/arm/include/asm/arch_timer.h | 37 +++--- arch/arm64/include/asm/arch_timer.h | 52 ++++---- drivers/clocksource/Kconfig | 3 + drivers/clocksource/arc_timer.c | 6 +- drivers/clocksource/arm_arch_timer.c | 243 +++++++++++++++++++++-------------- include/clocksource/arm_arch_timer.h | 2 +- include/soc/arc/timers.h | 4 +- 7 files changed, 201 insertions(+), 146 deletions(-)
arch/arm/include/asm/arch_timer.h +22 -15
@@ -7,6 +7,7 @@#include <asm/hwcap.h> #include <linux/clocksource.h> #include <linux/init.h> +#include <linux/io-64-nonatomic-lo-hi.h> #include <linux/types.h> #include <clocksource/arm_arch_timer.h>
@@ -24,29 +25,35 @@ int arch_timer_arch_init(void);* the code. At least it does so with a recent GCC (4.6.3). */ static __always_inline -void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u32 val) +void arch_timer_reg_write_cp15(int access, enum arch_timer_reg reg, u64 val) {if (access ==ARCH_TIMER_PHYS_ACCESS ) {switch (reg) {case ARCH_TIMER_REG_CTRL : - asmvolatile ("mcr p15, 0, %0, c14, c2, 1" : :"r" (val)); + asmvolatile ("mcr p15, 0, %0, c14, c2, 1" : :"r" ((u32 )val)); +isb ();break ; -case ARCH_TIMER_REG_TVAL : - asmvolatile ("mcr p15, 0, %0, c14, c2, 0" : :"r" (val)); +case ARCH_TIMER_REG_CVAL : + asmvolatile ("mcrr p15, 2, %Q0, %R0, c14" : :"r" (val));break ; +default : +BUILD_BUG (); } }else if (access ==ARCH_TIMER_VIRT_ACCESS ) {switch (reg) {case ARCH_TIMER_REG_CTRL : - asmvolatile ("mcr p15, 0, %0, c14, c3, 1" : :"r" (val)); + asmvolatile ("mcr p15, 0, %0, c14, c3, 1" : :"r" ((u32 )val)); +isb ();break ; -case ARCH_TIMER_REG_TVAL : - asmvolatile ("mcr p15, 0, %0, c14, c3, 0" : :"r" (val)); +case ARCH_TIMER_REG_CVAL : + asmvolatile ("mcrr p15, 3, %Q0, %R0, c14" : :"r" (val));break ; +default : +BUILD_BUG (); } + }else { +BUILD_BUG (); } - -isb (); } static __always_inline
@@ -59,19 +66,19 @@ u32 arch_timer_reg_read_cp15(int access, enum arch_timer_reg reg)case ARCH_TIMER_REG_CTRL : asmvolatile ("mrc p15, 0, %0, c14, c2, 1" :"=r" (val));break ; -case ARCH_TIMER_REG_TVAL : - asmvolatile ("mrc p15, 0, %0, c14, c2, 0" :"=r" (val)); -break ; +default : +BUILD_BUG (); } }else if (access ==ARCH_TIMER_VIRT_ACCESS ) {switch (reg) {case ARCH_TIMER_REG_CTRL : asmvolatile ("mrc p15, 0, %0, c14, c3, 1" :"=r" (val));break ; -case ARCH_TIMER_REG_TVAL : - asmvolatile ("mrc p15, 0, %0, c14, c3, 0" :"=r" (val)); -break ; +default : +BUILD_BUG (); } + }else { +BUILD_BUG (); }return val;
arch/arm64/include/asm/arch_timer.h +23 -29
127 lines not on this page · raw message
drivers/clocksource/Kconfig +3 -0
@@ -24,6 +24,7 @@ config I8253_LOCK config OMAP_DM_TIMER bool + select TIMER_OF config CLKBLD_I8253 def_bool y if CLKSRC_I8253 || CLKEVT_I8253 || I8253_LOCK
@@ -417,12 +418,14 @@ config ATMEL_TCB_CLKSRC config CLKSRC_EXYNOS_MCT bool "Exynos multi core timer driver" if COMPILE_TEST depends on ARM || ARM64 + depends on ARCH_EXYNOS || COMPILE_TEST help Support for Multi Core Timer controller on Exynos SoCs. config CLKSRC_SAMSUNG_PWM bool "PWM timer driver for Samsung S3C, S5P" if COMPILE_TEST depends on HAS_IOMEM + depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 || COMPILE_TEST help This is a new clocksource driver for the PWM timer found in Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver
drivers/clocksource/arc_timer.c +3 -3
@@ -225,7 +225,7 @@ static int __init arc_cs_setup_timer1(struct device_node *node)write_aux_reg (ARC_REG_TIMER1_LIMIT ,ARC_TIMERN_MAX );write_aux_reg (ARC_REG_TIMER1_CNT ,0 ); -write_aux_reg (ARC_REG_TIMER1_CTRL ,TIMER_CTRL_NH ); +write_aux_reg (ARC_REG_TIMER1_CTRL ,ARC_TIMER_CTRL_NH );sched_clock_register (arc_timer1_clock_read,32 , arc_timer_freq);
@@ -245,7 +245,7 @@ static void arc_timer_event_setup(unsigned int cycles)write_aux_reg (ARC_REG_TIMER0_LIMIT , cycles);write_aux_reg (ARC_REG_TIMER0_CNT ,0 );/* start from 0 */ -write_aux_reg (ARC_REG_TIMER0_CTRL ,TIMER_CTRL_IE |TIMER_CTRL_NH ); +write_aux_reg (ARC_REG_TIMER0_CTRL ,ARC_TIMER_CTRL_IE |ARC_TIMER_CTRL_NH ); }
@@ -294,7 +294,7 @@ static irqreturn_t timer_irq_handler(int irq, void *dev_id)* explicitly clears IP bit * 2. Re-arm interrupt if periodic by writing to IE bit [0] */ -write_aux_reg (ARC_REG_TIMER0_CTRL , irq_reenable |TIMER_CTRL_NH ); +write_aux_reg (ARC_REG_TIMER0_CTRL , irq_reenable |ARC_TIMER_CTRL_NH ); evt->event_handler (evt);
drivers/clocksource/arm_arch_timer.c +147 -96
470 lines not on this page · raw message
include/clocksource/arm_arch_timer.h +1 -1
@@ -24,7 +24,7 @@enum arch_timer_reg {ARCH_TIMER_REG_CTRL , -ARCH_TIMER_REG_TVAL , +ARCH_TIMER_REG_CVAL , };enum arch_timer_ppi_nr {
include/soc/arc/timers.h +2 -2
@@ -17,8 +17,8 @@#define ARC_REG_TIMER1_CNT 0x100/* timer 1 count */ /* CTRL reg bits */ -#define TIMER_CTRL_IE (1 << 0)/* Interrupt when Count reaches limit */ -#define TIMER_CTRL_NH (1 << 1)/* Count only when CPU NOT halted */ +#define ARC_TIMER_CTRL_IE (1 << 0)/* Interrupt when Count reaches limit */ +#define ARC_TIMER_CTRL_NH (1 << 1)/* Count only when CPU NOT halted */ #define ARC_TIMERN_MAX 0xFFFFFFFF
Re: [GIT pull] timers/core for v5.16-rc1
The pull request you sent on Mon, 1 Nov 2021 02:16:06 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:16:06 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gittimers-core-2021-10-31
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/57a315cd7198907326e691cc909df2beebc2420d
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull] sched/core for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest sched/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched-core-2021-11-01
up to: 8ea9183db4ad: sched/fair: Cleanup newidle_balance
Scheduler updates:
- Revert the printk format based wchan() symbol resolution as it can leak the raw value in case that the symbol is not resolvable.
- Make wchan() more robust and work with all kind of unwinders by enforcing that the task stays blocked while unwinding is in progress.
- Prevent sched_fork() from accessing an invalid sched_task_group
- Improve asymmetric packing logic
- Extend scheduler statistics to RT and DL scheduling classes and add statistics for bandwith burst to the SCHED_FAIR class.
- Properly account SCHED_IDLE entities
- Prevent a potential deadlock when initial priority is assigned to a newly created kthread. A recent change to plug a race between cpuset and __sched_setscheduler() introduced a new lock dependency which is now triggered. Break the lock dependency chain by moving the priority assignment to the thread function.
- Fix the idle time reporting in /proc/uptime for NOHZ enabled systems.
- Improve idle balancing in general and especially for NOHZ enabled systems.
- Provide proper interfaces for live patching so it does not have to fiddle with scheduler internals.
- Add cluster aware scheduling support.
- A small set of tweaks for RT (irqwork, wait_task_inactive(), various scheduler options and delaying mmdrop)
- The usual small tweaks and improvements all over the place
Thanks,
tglx
------------------>
Barry Song (1):
sched: Add cluster scheduler level in core and related Kconfig for ARM64
Bharata B Rao (3):
sched/numa: Replace hard-coded number by a define in numa_task_group() sched/numa: Remove the redundant member numa_group::fault_cpus sched/numa: Fix a few comments
Frederic Weisbecker (1):
sched: Provide Kconfig support for default dynamic preempt mode
Huaixin Chang (2):
sched/fair: Add cfs bandwidth burst statistics sched/fair: Add document for burstable CFS bandwidth
Jonathan Cameron (1):
topology: Represent clusters of CPUs within a die
Josh Don (4):
fs/proc/uptime.c: Fix idle time reporting in /proc/uptime
sched: Account number of SCHED_IDLE entities on each cfs_rq
sched: reduce sched slice for SCHED_IDLE entities
sched: adjust sleeper credit for SCHED_IDLE entities
Kees Cook (5):
sched: Fill unconditional hole induced by sched_entity Revert "proc/wchan: use printk format instead of lookup_symbol_name()"
leaking_addresses: Always print a trailing newline
proc: Use task_is_running() for wchan in /proc/$pid/stat
sched: Add wrapper for get_wchan() to keep task blocked
Li Zhijian (1):
kselftests/sched: cleanup the child processes
Peng Wang (1):
sched/core: Remove rq_relock()
Peter Zijlstra (11):
sched/core: Simplify core-wide task selection
sched: Fix DEBUG && !SCHEDSTATS warn
sched: Improve try_invoke_on_locked_down_task() sched,rcu: Rework try_invoke_on_locked_down_task() sched,livepatch: Use task_call_func()
sched: Simplify wake_up_*idle*() sched,livepatch: Use wake_up_if_idle()
sched: Disable -Wunused-but-set-variable
sched: Improve wake_up_all_idle_cpus() take #2 sched,x86: Fix L2 cache mask
x86: Fix __get_wchan() for !STACKTRACE
Qi Zheng (1):
x86: Fix get_wchan() to support the ORC unwinder
Ricardo Neri (6):
x86/sched: Decrease further the priorities of SMT siblings sched/topology: Introduce sched_group::flags
sched/fair: Optimize checking for group_asym_packing sched/fair: Provide update_sg_lb_stats() with sched domain statistics sched/fair: Carve out logic to mark a group for asymmetric packing sched/fair: Consider SMT in ASYM_PACKING load balance
Sebastian Andrzej Siewior (6):
sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD
kthread: Move prio/affinite change into the newly created thread sched/rt: Annotate the RT balancing logic irqwork as IRQ_WORK_HARD_IRQ
irq_work: Allow irq_work_sync() to sleep if irq_work() no IRQ support.
irq_work: Handle some irq_work in a per-CPU thread on PREEMPT_RT
irq_work: Also rcuwait for !IRQ_WORK_HARD_IRQ on PREEMPT_RT
Shaokun Zhang (1):
sched: Make cookie functions static
Thomas Gleixner (5):
sched: Move mmdrop to RCU on RT
sched: Limit the number of task migrations per batch on RT
sched: Disable TTWU_QUEUE on RT
sched: Move kprobes cleanup out of finish_task_switch()
sched: Remove pointless preemption disable in sched_submit_work()
Tim Chen (1):
sched: Add cluster scheduler level for x86
Valentin Schneider (2):
sched/fair: Add NOHZ balancer flag for nohz.next_balance updates sched/fair: Trigger nohz.next_balance updates when a CPU goes NOHZ-idle
Vincent Guittot (6):
sched/fair: Removed useless update of p->recent_used_cpu sched/fair: Account update_blocked_averages in newidle_balance cost sched/fair: Skip update_blocked_averages if we are defering load balance sched/fair: Wait before decaying max_newidle_lb_cost sched/fair: Remove sysctl_sched_migration_cost condition sched/fair: Cleanup newidle_balance
Yafang Shao (8):
sched/fair: Use __schedstat_set() in set_next_entity()
sched: Make struct sched_statistics independent of fair sched class
sched: Make schedstats helpers independent of fair sched class
sched: Introduce task block time in schedstats
sched/rt: Support sched_stat_runtime tracepoint for RT sched class sched/rt: Support schedstats for RT sched class
sched/dl: Support sched_stat_runtime tracepoint for deadline sched class sched/dl: Support schedstats for deadline sched class
Yicong Yang (1):
sched/topology: Remove unused numa_distance in cpu_attach_domain()
YueHaibing (1):
sched: Remove unused inline function __rq_clock_broken()
Zhang Qiao (1):
kernel/sched: Fix sched_fork() access an invalid sched_task_group
Documentation/ABI/stable/sysfs-devices-system-cpu | 15 + Documentation/admin-guide/cgroup-v2.rst | 8 + Documentation/admin-guide/cputopology.rst | 12 +- Documentation/scheduler/sched-bwc.rst | 84 +++- arch/alpha/include/asm/processor.h | 2 +- arch/alpha/kernel/process.c | 5 +- arch/arc/include/asm/processor.h | 2 +- arch/arc/kernel/stacktrace.c | 4 +- arch/arm/include/asm/processor.h | 2 +- arch/arm/kernel/process.c | 4 +- arch/arm64/Kconfig | 9 + arch/arm64/include/asm/processor.h | 2 +- arch/arm64/kernel/process.c | 4 +- arch/arm64/kernel/topology.c | 2 + arch/csky/include/asm/processor.h | 2 +- arch/csky/kernel/stacktrace.c | 5 +- arch/h8300/include/asm/processor.h | 2 +- arch/h8300/kernel/process.c | 5 +- arch/hexagon/include/asm/processor.h | 2 +- arch/hexagon/kernel/process.c | 4 +- arch/ia64/include/asm/processor.h | 2 +- arch/ia64/kernel/process.c | 5 +- arch/m68k/include/asm/processor.h | 2 +- arch/m68k/kernel/process.c | 4 +- arch/microblaze/include/asm/processor.h | 2 +- arch/microblaze/kernel/process.c | 2 +- arch/mips/include/asm/processor.h | 2 +- arch/mips/kernel/process.c | 8 +- arch/nds32/include/asm/processor.h | 2 +- arch/nds32/kernel/process.c | 7 +- arch/nios2/include/asm/processor.h | 2 +- arch/nios2/kernel/process.c | 5 +- arch/openrisc/include/asm/processor.h | 2 +- arch/openrisc/kernel/process.c | 2 +- arch/parisc/include/asm/processor.h | 2 +- arch/parisc/kernel/process.c | 5 +- arch/powerpc/include/asm/processor.h | 2 +- arch/powerpc/kernel/process.c | 9 +- arch/riscv/include/asm/processor.h | 2 +- arch/riscv/kernel/stacktrace.c | 12 +- arch/s390/include/asm/processor.h | 2 +- arch/s390/kernel/process.c | 4 +- arch/sh/include/asm/processor_32.h | 2 +- arch/sh/kernel/process_32.c | 5 +- arch/sparc/include/asm/processor_32.h | 2 +- arch/sparc/include/asm/processor_64.h | 2 +- arch/sparc/kernel/process_32.c | 5 +- arch/sparc/kernel/process_64.c | 5 +- arch/um/include/asm/processor-generic.h | 2 +- arch/um/kernel/process.c | 5 +- arch/x86/Kconfig | 11 + arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/smp.h | 7 + arch/x86/include/asm/topology.h | 3 + arch/x86/kernel/cpu/cacheinfo.c | 1 + arch/x86/kernel/cpu/common.c | 3 + arch/x86/kernel/itmt.c | 2 +- arch/x86/kernel/process.c | 65 +-- arch/x86/kernel/smpboot.c | 44 +- arch/xtensa/include/asm/processor.h | 2 +- arch/xtensa/kernel/process.c | 5 +- drivers/acpi/pptt.c | 67 +++ drivers/base/arch_topology.c | 15 + drivers/base/topology.c | 10 + fs/proc/array.c | 7 +- fs/proc/base.c | 19 +- fs/proc/stat.c | 4 +- fs/proc/uptime.c | 14 +- include/linux/acpi.h | 5 + include/linux/arch_topology.h | 5 + include/linux/irq_work.h | 8 + include/linux/kernel_stat.h | 1 + include/linux/mm_types.h | 4 + include/linux/sched.h | 11 +- include/linux/sched/idle.h | 4 + include/linux/sched/mm.h | 29 ++ include/linux/sched/task.h | 3 +- include/linux/sched/topology.h | 9 +- include/linux/topology.h | 13 + include/linux/wait.h | 3 +- kernel/Kconfig.preempt | 32 +- kernel/exit.c | 2 + kernel/fork.c | 2 +- kernel/irq_work.c | 130 +++++- kernel/kprobes.c | 8 +- kernel/kthread.c | 16 +- kernel/livepatch/transition.c | 95 +++-- kernel/rcu/tasks.h | 12 +- kernel/rcu/tree_stall.h | 8 +- kernel/sched/Makefile | 4 + kernel/sched/core.c | 392 +++++++++-------- kernel/sched/core_sched.c | 9 +- kernel/sched/deadline.c | 99 ++++- kernel/sched/debug.c | 101 +++-- kernel/sched/fair.c | 496 +++++++++++++--------- kernel/sched/features.h | 5 + kernel/sched/rt.c | 130 +++++- kernel/sched/sched.h | 32 +- kernel/sched/stats.c | 104 +++++ kernel/sched/stats.h | 49 +++ kernel/sched/stop_task.c | 4 +- kernel/sched/topology.c | 34 +- kernel/smp.c | 12 +- scripts/leaking_addresses.pl | 3 +- tools/testing/selftests/sched/cs_prctl_test.c | 28 +- 105 files changed, 1682 insertions(+), 789 deletions(-)
Documentation/ABI/stable/sysfs-devices-system-cpu +15 -0
@@ -42,6 +42,12 @@ Description: the CPU core ID of cpuX. Typically it is the hardware platform's architecture and platform dependent. Values: integer +What: /sys/devices/system/cpu/cpuX/topology/cluster_id +Description: the cluster ID of cpuX. Typically it is the hardware platform's + identifier (rather than the kernel's). The actual value is + architecture and platform dependent. +Values: integer + What: /sys/devices/system/cpu/cpuX/topology/book_id Description: the book ID of cpuX. Typically it is the hardware platform's identifier (rather than the kernel's). The actual value is
@@ -85,6 +91,15 @@ Description: human-readable list of CPUs within the same die. The format is like 0-3, 8-11, 14,17. Values: decimal list. +What: /sys/devices/system/cpu/cpuX/topology/cluster_cpus +Description: internal kernel map of CPUs within the same cluster. +Values: hexadecimal bitmask. + +What: /sys/devices/system/cpu/cpuX/topology/cluster_cpus_list +Description: human-readable list of CPUs within the same cluster. + The format is like 0-3, 8-11, 14,17. +Values: decimal list. + What: /sys/devices/system/cpu/cpuX/topology/book_siblings Description: internal kernel map of cpuX's hardware threads within the same book_id. it's only used on s390.
Documentation/admin-guide/cgroup-v2.rst +8 -0
@@ -1016,6 +1016,8 @@ All time durations are in microseconds. - nr_periods - nr_throttled - throttled_usec + - nr_bursts + - burst_usec cpu.weight A read-write single value file which exists on non-root
@@ -1047,6 +1049,12 @@ All time durations are in microseconds. $PERIOD duration. "max" for $MAX indicates no limit. If only one number is written, $MAX is updated. + cpu.max.burst + A read-write single value file which exists on non-root + cgroups. The default is "0". + + The burst in the range [0, $MAX]. + cpu.pressure A read-write nested-keyed file.
Documentation/admin-guide/cputopology.rst +8 -4
@@ -19,11 +19,13 @@ these macros in include/asm-XXX/topology.h:: #define topology_physical_package_id(cpu) #define topology_die_id(cpu) + #define topology_cluster_id(cpu) #define topology_core_id(cpu) #define topology_book_id(cpu) #define topology_drawer_id(cpu) #define topology_sibling_cpumask(cpu) #define topology_core_cpumask(cpu) + #define topology_cluster_cpumask(cpu) #define topology_die_cpumask(cpu) #define topology_book_cpumask(cpu) #define topology_drawer_cpumask(cpu)
@@ -39,10 +41,12 @@ not defined by include/asm-XXX/topology.h: 1) topology_physical_package_id: -1 2) topology_die_id: -1 -3) topology_core_id: 0 -4) topology_sibling_cpumask: just the given CPU -5) topology_core_cpumask: just the given CPU -6) topology_die_cpumask: just the given CPU +3) topology_cluster_id: -1 +4) topology_core_id: 0 +5) topology_sibling_cpumask: just the given CPU +6) topology_core_cpumask: just the given CPU +7) topology_cluster_cpumask: just the given CPU +8) topology_die_cpumask: just the given CPU For architectures that don't support books (CONFIG_SCHED_BOOK) there are no default definitions for topology_book_id() and topology_book_cpumask().
Documentation/scheduler/sched-bwc.rst +75 -9
129 lines not on this page · raw message
arch/alpha/include/asm/processor.h +1 -1
@@ -42,7 +42,7 @@ extern void start_thread(struct pt_regs *, unsigned long, unsigned long);struct task_struct ;extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)
arch/alpha/kernel/process.c +2 -3
@@ -376,12 +376,11 @@ thread_saved_pc(struct task_struct *t) }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {unsigned long schedule_frame;unsigned long pc; -if (!p || p == current ||task_is_running (p)) -return 0 ; +/* * This one depends on the frame size of schedule(). Do a * "disass schedule" in gdb to find the frame size. Also, the
arch/arc/include/asm/processor.h +1 -1
@@ -70,7 +70,7 @@ struct task_struct;extern void start_thread (struct pt_regs * regs,unsigned long pc,unsigned long usp); -extern unsigned int get_wchan (struct task_struct *p); +extern unsigned int __get_wchan (struct task_struct *p);#endif /* !__ASSEMBLY__ */
arch/arc/kernel/stacktrace.c +2 -2
@@ -15,7 +15,7 @@* = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc) * * vineetg: March 2009 -* -Implemented correct versions of thread_saved_pc() and get_wchan() +* -Implemented correct versions of thread_saved_pc() and __get_wchan() * * rajeshwarr: 2008 * -Initial implementation
@@ -248,7 +248,7 @@ void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl)* Of course just returning schedule( ) would be pointless so unwind until * the function is not in schedular code */ -unsigned int get_wchan (struct task_struct *tsk) +unsigned int __get_wchan (struct task_struct *tsk) {return arc_unwind_core (tsk,NULL , __get_first_nonsched,NULL ); }
arch/arm/include/asm/processor.h +1 -1
@@ -84,7 +84,7 @@ struct task_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (p) \ ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
arch/arm/kernel/process.c +1 -3
@@ -276,13 +276,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct stackframe frame;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; frame.fp =thread_saved_fp (p); frame.sp =thread_saved_sp (p);
arch/arm64/Kconfig +9 -0
@@ -989,6 +989,15 @@ config SCHED_MC making when dealing with multi-core CPU chips at a cost of slightly increased overhead in some places. If unsure say N here. +config SCHED_CLUSTER + bool "Cluster scheduler support" + help + Cluster scheduler support improves the CPU scheduler's decision + making when dealing with machines that have clusters of CPUs. + Cluster usually means a couple of CPUs which are placed closely + by sharing mid-level caches, last-level cache tags or internal + busses. + config SCHED_SMT bool "SMT scheduler support" help
arch/arm64/include/asm/processor.h +1 -1
@@ -257,7 +257,7 @@ struct task_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);void update_sctlr_el1 (u64 sctlr);
arch/arm64/kernel/process.c +1 -3
@@ -528,13 +528,11 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,return last; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct stackframe frame;unsigned long stack_page, ret =0 ;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )try_get_task_stack (p);if (!stack_page)
arch/arm64/kernel/topology.c +2 -0
@@ -103,6 +103,8 @@ int __init parse_acpi_topology(void) cpu_topology[cpu].thread_id =-1 ; cpu_topology[cpu].core_id = topology_id; } + topology_id =find_acpi_cpu_topology_cluster (cpu); + cpu_topology[cpu].cluster_id = topology_id; topology_id =find_acpi_cpu_topology_package (cpu); cpu_topology[cpu].package_id = topology_id;
arch/csky/include/asm/processor.h +1 -1
@@ -81,7 +81,7 @@ static inline void release_thread(struct task_struct *dead_task)extern int kernel_thread (int (*fn)(void *),void *arg,unsigned long flags); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->usp)
arch/csky/kernel/stacktrace.c +2 -3
@@ -111,12 +111,11 @@ static bool save_wchan(unsigned long pc, void *arg)return false; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ; -if (likely (task && task != current && !task_is_running (task))) -walk_stackframe (task,NULL , save_wchan, &pc); +walk_stackframe (task,NULL , save_wchan, &pc);return pc; }
arch/h8300/include/asm/processor.h +1 -1
@@ -105,7 +105,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) \ ({ \
arch/h8300/kernel/process.c +1 -4
@@ -128,15 +128,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )p; fp = ((struct pt_regs *)p->thread.ksp)->er6; do {
arch/hexagon/include/asm/processor.h +1 -1
@@ -64,7 +64,7 @@ struct thread_struct {extern void release_thread (struct task_struct *dead_task);/* Get wait channel for task P. */ -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);/* The following stuff is pretty HEXAGON specific. */
arch/hexagon/kernel/process.c +1 -3
@@ -130,13 +130,11 @@ void flush_thread(void)* is an identification of the point at which the scheduler * was invoked by a blocked thread. */ -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )task_stack_page (p); fp = ((struct hexagon_switch_stack *)p->thread.switch_sp)->fp;
arch/ia64/include/asm/processor.h +1 -1
@@ -330,7 +330,7 @@ struct task_struct;#define release_thread (dead_task)/* Get wait channel for task P. */ -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);/* Return instruction pointer of blocked task TSK. */ #define KSTK_EIP (tsk) \
arch/ia64/kernel/process.c +1 -4
@@ -523,15 +523,12 @@ exit_thread (struct task_struct *tsk) }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {struct unw_frame_info info;unsigned long ip;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * Note: p may not be a blocked task (it could be current or * another process running on some other CPU. Rather than
arch/m68k/include/asm/processor.h +1 -1
@@ -150,7 +150,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) \ ({ \
arch/m68k/kernel/process.c +1 -3
@@ -263,13 +263,11 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu) }EXPORT_SYMBOL (dump_fpu); -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; stack_page = (unsigned long )task_stack_page (p); fp = ((struct switch_stack *)p->thread.ksp)->a6;
arch/microblaze/include/asm/processor.h +1 -1
@@ -68,7 +68,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);/* The size allocated for kernel stacks. This _must_ be a power of two! */ # define KERNEL_STACK_SIZE 0x2000
arch/microblaze/kernel/process.c +1 -1
@@ -112,7 +112,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {/* TBD (used by procfs) */ return 0 ;
arch/mips/include/asm/processor.h +1 -1
@@ -369,7 +369,7 @@ static inline void flush_thread(void) { } -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define __KSTK_TOS (tsk) ((unsigned long)task_stack_page(tsk) + \ THREAD_SIZE - 32 - sizeof(struct pt_regs))
arch/mips/kernel/process.c +3 -5
@@ -511,7 +511,7 @@ static int __init frame_info_init(void)/* * Without schedule() frame info, result given by -* thread_saved_pc() and get_wchan() are not reliable. +* thread_saved_pc() and __get_wchan() are not reliable. */ if (schedule_mfi.pc_offset <0 )printk ("Can't analyze schedule() prologue at %p\n" , schedule);
@@ -652,9 +652,9 @@ unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,#endif /* -* get_wchan - a maintenance nightmare^W^Wpain in the ass ... +* __get_wchan - a maintenance nightmare^W^Wpain in the ass ... */ -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ;#ifdef CONFIG_KALLSYMS
@@ -662,8 +662,6 @@ unsigned long get_wchan(struct task_struct *task)unsigned long ra =0 ;#endif -if (!task || task == current ||task_is_running (task)) - goto out;if (!task_stack_page (task)) goto out;
arch/nds32/include/asm/processor.h +1 -1
@@ -83,7 +83,7 @@ extern struct task_struct *last_task_used_math;/* Prepare to copy thread state - unlazy all lazy status */ #define prepare_to_copy (tsk) do { } while (0) -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define cpu_relax () barrier()
arch/nds32/kernel/process.c +1 -6
@@ -233,15 +233,12 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t * fpu)EXPORT_SYMBOL (dump_fpu); -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, lr;unsigned long stack_start, stack_end;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -if (IS_ENABLED (CONFIG_FRAME_POINTER )) { stack_start = (unsigned long )end_of_stack (p); stack_end = (unsigned long )task_stack_page (p) +THREAD_SIZE ;
@@ -258,5 +255,3 @@ unsigned long get_wchan(struct task_struct *p) }return 0 ; } - -EXPORT_SYMBOL (get_wchan);
arch/nios2/include/asm/processor.h +1 -1
@@ -69,7 +69,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (p) \ ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
arch/nios2/kernel/process.c +1 -4
@@ -217,15 +217,12 @@ void dump(struct pt_regs *fp)pr_emerg ("\n\n" ); } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long fp, pc;unsigned long stack_page;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )p; fp = ((struct switch_stack *)p->thread.ksp)->fp;/* ;dgt2 */ do {
arch/openrisc/include/asm/processor.h +1 -1
@@ -73,7 +73,7 @@ struct thread_struct {void start_thread (struct pt_regs *regs,unsigned long nip,unsigned long sp);void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define cpu_relax () barrier()
arch/openrisc/kernel/process.c +1 -1
@@ -263,7 +263,7 @@ void dump_elf_thread(elf_greg_t *dest, struct pt_regs* regs) dest[35 ] =0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {/* TODO */
arch/parisc/include/asm/processor.h +1 -1
@@ -273,7 +273,7 @@ struct mm_struct;/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) ((tsk)->thread.regs.iaoq[0])#define KSTK_ESP (tsk) ((tsk)->thread.regs.gr[30])
arch/parisc/kernel/process.c +1 -4
@@ -240,15 +240,12 @@ copy_thread(unsigned long clone_flags, unsigned long usp, }unsigned long -get_wchan (struct task_struct *p) +__get_wchan (struct task_struct *p) {struct unwind_frame_info info;unsigned long ip;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * These bracket the sleeping functions.. */
arch/powerpc/include/asm/processor.h +1 -1
@@ -300,7 +300,7 @@ struct thread_struct {#define task_pt_regs (tsk) ((tsk)->thread.regs) -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)#define KSTK_ESP (tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
arch/powerpc/kernel/process.c +3 -6
@@ -2111,14 +2111,11 @@ int validate_sp(unsigned long sp, struct task_struct *p,EXPORT_SYMBOL (validate_sp); -static unsigned long __get_wchan (struct task_struct *p) +static unsigned long ___get_wchan (struct task_struct *p) {unsigned long ip, sp;int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - sp = p->thread.ksp;if (!validate_sp (sp, p,STACK_FRAME_OVERHEAD ))return 0 ;
@@ -2137,14 +2134,14 @@ static unsigned long __get_wchan(struct task_struct *p)return 0 ; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long ret;if (!try_get_task_stack (p))return 0 ; - ret =__get_wchan (p); + ret =___get_wchan (p);put_task_stack (p);
arch/riscv/include/asm/processor.h +1 -1
@@ -66,7 +66,7 @@ static inline void release_thread(struct task_struct *dead_task) { } -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);static inline void wait_for_interrupt (void )
arch/riscv/kernel/stacktrace.c +5 -7
@@ -128,16 +128,14 @@ static bool save_wchan(void *arg, unsigned long pc)return true; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc =0 ; -if (likely (task && task != current && !task_is_running (task))) { -if (!try_get_task_stack (task)) -return 0 ; -walk_stackframe (task,NULL , save_wchan, &pc); -put_task_stack (task); - } +if (!try_get_task_stack (task)) +return 0 ; +walk_stackframe (task,NULL , save_wchan, &pc); +put_task_stack (task);return pc; }
arch/s390/include/asm/processor.h +1 -1
@@ -192,7 +192,7 @@ static inline void release_thread(struct task_struct *tsk) { }void guarded_storage_release (struct task_struct *tsk);void gs_load_bc_cb (struct pt_regs *regs); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);#define task_pt_regs (tsk) ((struct pt_regs *) \ (task_stack_page(tsk) + THREAD_SIZE) - 1)#define KSTK_EIP (tsk) (task_pt_regs(tsk)->psw.addr)
arch/s390/kernel/process.c +2 -2
@@ -181,12 +181,12 @@ void execve_tail(void) asmvolatile ("sfpc %0" : :"d" (0 )); } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {struct unwind_state state;unsigned long ip =0 ; -if (!p || p == current ||task_is_running (p) || !task_stack_page (p)) +if (!task_stack_page (p))return 0 ;if (!try_get_task_stack (p))
arch/sh/include/asm/processor_32.h +1 -1
@@ -180,7 +180,7 @@ static inline void show_code(struct pt_regs *regs) }#endif -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->regs[15])
arch/sh/kernel/process_32.c +1 -4
@@ -182,13 +182,10 @@ __switch_to(struct task_struct *prev, struct task_struct *next)return prev; } -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long pc; -if (!p || p == current ||task_is_running (p)) -return 0 ; -/* * The same comment as on the Alpha applies here, too ... */
arch/sparc/include/asm/processor_32.h +1 -1
@@ -89,7 +89,7 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,/* Free all resources held by a thread. */ #define release_thread (tsk) do { } while(0) -unsigned long get_wchan (struct task_struct *); +unsigned long __get_wchan (struct task_struct *);#define task_pt_regs (tsk) ((tsk)->thread.kregs)#define KSTK_EIP (tsk) ((tsk)->thread.kregs->pc)
arch/sparc/include/asm/processor_64.h +1 -1
@@ -183,7 +183,7 @@ do { \/* Free all resources held by a thread. */ #define release_thread (tsk) do { } while (0) -unsigned long get_wchan (struct task_struct *task); +unsigned long __get_wchan (struct task_struct *task);#define task_pt_regs (tsk) (task_thread_info(tsk)->kregs)#define KSTK_EIP (tsk) (task_pt_regs(tsk)->tpc)
arch/sparc/kernel/process_32.c +1 -4
@@ -365,7 +365,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,return 0 ; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc, fp, bias =0 ;unsigned long task_base = (unsigned long ) task;
@@ -373,9 +373,6 @@ unsigned long get_wchan(struct task_struct *task)struct reg_window32 *rw;int count =0 ; -if (!task || task == current ||task_is_running (task)) - goto out; - fp =task_thread_info (task)->ksp + bias; do { /* Bogus frame pointer? */
arch/sparc/kernel/process_64.c +1 -4
@@ -663,7 +663,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)return 0 ; } -unsigned long get_wchan (struct task_struct *task) +unsigned long __get_wchan (struct task_struct *task) {unsigned long pc, fp, bias =0 ;struct thread_info *tp;
@@ -671,9 +671,6 @@ unsigned long get_wchan(struct task_struct *task)unsigned long ret =0 ;int count =0 ; -if (!task || task == current ||task_is_running (task)) - goto out; - tp =task_thread_info (task); bias =STACK_BIAS ; fp =task_thread_info (task)->ksp + bias;
arch/um/include/asm/processor-generic.h +1 -1
@@ -106,6 +106,6 @@ extern struct cpuinfo_um boot_cpu_data;#define cache_line_size () (boot_cpu_data.cache_alignment)#define KSTK_REG (tsk, reg) get_thread_reg(reg, &tsk->thread.switch_buf) -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#endif
arch/um/kernel/process.c +1 -4
@@ -364,14 +364,11 @@ unsigned long arch_align_stack(unsigned long sp) }#endif -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long stack_page, sp, ip;bool seen_sched =0 ; -if ((p ==NULL ) || (p == current) ||task_is_running (p)) -return 0 ; - stack_page = (unsigned long )task_stack_page (p);/* Bail if the process has no kernel stack for some reason */ if (stack_page ==0 )
arch/x86/Kconfig +11 -0
@@ -1001,6 +1001,17 @@ config NR_CPUS This is purely to save memory: each supported CPU adds about 8KB to the kernel image. +config SCHED_CLUSTER + bool "Cluster scheduler support" + depends on SMP + default y + help + Cluster scheduler support improves the CPU scheduler's decision + making when dealing with machines that have clusters of CPUs. + Cluster usually means a couple of CPUs which are placed closely + by sharing mid-level caches, last-level cache tags or internal + busses. + config SCHED_SMT def_bool y if SMP
arch/x86/include/asm/processor.h +1 -1
@@ -589,7 +589,7 @@ static inline void load_sp0(unsigned long sp0)/* Free all resources held by a thread. */ extern void release_thread (struct task_struct *); -unsigned long get_wchan (struct task_struct *p); +unsigned long __get_wchan (struct task_struct *p);/* * Generic CPUID function
arch/x86/include/asm/smp.h +7 -0
@@ -16,7 +16,9 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_die_map);/* cpus sharing the last level cache: */ DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_llc_shared_map); +DECLARE_PER_CPU_READ_MOSTLY (cpumask_var_t, cpu_l2c_shared_map);DECLARE_PER_CPU_READ_MOSTLY (u16, cpu_llc_id); +DECLARE_PER_CPU_READ_MOSTLY (u16, cpu_l2c_id);DECLARE_PER_CPU_READ_MOSTLY (int, cpu_number);static inline struct cpumask *cpu_llc_shared_mask (int cpu)
@@ -24,6 +26,11 @@ static inline struct cpumask *cpu_llc_shared_mask(int cpu)return per_cpu (cpu_llc_shared_map, cpu); } +static inline struct cpumask *cpu_l2c_shared_mask (int cpu) +{ +return per_cpu (cpu_l2c_shared_map, cpu); +} +DECLARE_EARLY_PER_CPU_READ_MOSTLY (u16, x86_cpu_to_apicid);DECLARE_EARLY_PER_CPU_READ_MOSTLY (u32, x86_cpu_to_acpiid);DECLARE_EARLY_PER_CPU_READ_MOSTLY (u16, x86_bios_cpu_apicid);
arch/x86/include/asm/topology.h +3 -0
@@ -103,6 +103,7 @@ static inline void setup_node_to_cpumask_map(void) { }#include <asm-generic/topology.h> extern const struct cpumask *cpu_coregroup_mask (int cpu); +extern const struct cpumask *cpu_clustergroup_mask (int cpu);#define topology_logical_package_id (cpu) (cpu_data(cpu).logical_proc_id)#define topology_physical_package_id (cpu) (cpu_data(cpu).phys_proc_id)
@@ -113,7 +114,9 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);extern unsigned int __max_die_per_package;#ifdef CONFIG_SMP +#define topology_cluster_id (cpu) (per_cpu(cpu_l2c_id, cpu))#define topology_die_cpumask (cpu) (per_cpu(cpu_die_map, cpu)) +#define topology_cluster_cpumask (cpu) (cpu_clustergroup_mask(cpu))#define topology_core_cpumask (cpu) (per_cpu(cpu_core_map, cpu))#define topology_sibling_cpumask (cpu) (per_cpu(cpu_sibling_map, cpu))
arch/x86/kernel/cpu/cacheinfo.c +1 -0
@@ -846,6 +846,7 @@ void init_intel_cacheinfo(struct cpuinfo_x86 *c) l2 = new_l2;#ifdef CONFIG_SMP per_cpu (cpu_llc_id, cpu) = l2_id; +per_cpu (cpu_l2c_id, cpu) = l2_id;#endif }
arch/x86/kernel/cpu/common.c +3 -0
@@ -85,6 +85,9 @@ u16 get_llc_id(unsigned int cpu) }EXPORT_SYMBOL_GPL (get_llc_id); +/* L2 cache ID of each logical CPU */ +DEFINE_PER_CPU_READ_MOSTLY (u16, cpu_l2c_id) =BAD_APICID ; +/* correctly size the local cpu masks */ void __init setup_cpu_local_masks (void ) {
arch/x86/kernel/itmt.c +1 -1
@@ -198,7 +198,7 @@ void sched_set_itmt_core_prio(int prio, int core_cpu)* of the priority chain and only used when * all other high priority cpus are out of capacity. */ - smt_prio = prio * smp_num_siblings / i; + smt_prio = prio * smp_num_siblings / (i * i);per_cpu (sched_core_priority, cpu) = smt_prio; i++; }
arch/x86/kernel/process.c +14 -51
80 lines not on this page · raw message
arch/x86/kernel/smpboot.c +43 -1
111 lines not on this page · raw message
arch/xtensa/include/asm/processor.h +1 -1
@@ -215,7 +215,7 @@ struct mm_struct;/* Free all resources held by a thread. */ #define release_thread (thread) do { } while(0) -extern unsigned long get_wchan (struct task_struct *p); +extern unsigned long __get_wchan (struct task_struct *p);#define KSTK_EIP (tsk) (task_pt_regs(tsk)->pc)#define KSTK_ESP (tsk) (task_pt_regs(tsk)->areg[1])
arch/xtensa/kernel/process.c +1 -4
@@ -298,15 +298,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,* These bracket the sleeping functions.. */ -unsigned long get_wchan (struct task_struct *p) +unsigned long __get_wchan (struct task_struct *p) {unsigned long sp, pc;unsigned long stack_page = (unsigned long )task_stack_page (p);int count =0 ; -if (!p || p == current ||task_is_running (p)) -return 0 ; - sp = p->thread.sp; pc =MAKE_PC_FROM_RA (p->thread.ra, p->thread.sp);
drivers/acpi/pptt.c +67 -0
73 lines not on this page · raw message
drivers/base/arch_topology.c +15 -0
@@ -600,6 +600,11 @@ const struct cpumask *cpu_coregroup_mask(int cpu)return core_mask; } +const struct cpumask *cpu_clustergroup_mask (int cpu) +{ +return &cpu_topology[cpu].cluster_sibling; +} +void update_siblings_masks (unsigned int cpuid) {struct cpu_topology *cpu_topo, *cpuid_topo = &cpu_topology[cpuid];
@@ -617,6 +622,12 @@ void update_siblings_masks(unsigned int cpuid)if (cpuid_topo->package_id != cpu_topo->package_id)continue ; +if (cpuid_topo->cluster_id == cpu_topo->cluster_id && + cpuid_topo->cluster_id !=-1 ) { +cpumask_set_cpu (cpu, &cpuid_topo->cluster_sibling); +cpumask_set_cpu (cpuid, &cpu_topo->cluster_sibling); + } +cpumask_set_cpu (cpuid, &cpu_topo->core_sibling);cpumask_set_cpu (cpu, &cpuid_topo->core_sibling);
@@ -635,6 +646,9 @@ static void clear_cpu_topology(int cpu)cpumask_clear (&cpu_topo->llc_sibling);cpumask_set_cpu (cpu, &cpu_topo->llc_sibling); +cpumask_clear (&cpu_topo->cluster_sibling); +cpumask_set_cpu (cpu, &cpu_topo->cluster_sibling); +cpumask_clear (&cpu_topo->core_sibling);cpumask_set_cpu (cpu, &cpu_topo->core_sibling);cpumask_clear (&cpu_topo->thread_sibling);
@@ -650,6 +664,7 @@ void __init reset_cpu_topology(void) cpu_topo->thread_id =-1 ; cpu_topo->core_id =-1 ; + cpu_topo->cluster_id =-1 ; cpu_topo->package_id =-1 ; cpu_topo->llc_id =-1 ;
drivers/base/topology.c +10 -0
@@ -48,6 +48,9 @@ static DEVICE_ATTR_RO(physical_package_id);define_id_show_func (die_id);static DEVICE_ATTR_RO (die_id); +define_id_show_func (cluster_id); +static DEVICE_ATTR_RO (cluster_id); +define_id_show_func (core_id);static DEVICE_ATTR_RO (core_id);
@@ -63,6 +66,10 @@ define_siblings_read_func(core_siblings, core_cpumask); static BIN_ATTR_RO(core_siblings, 0); static BIN_ATTR_RO(core_siblings_list, 0); +define_siblings_read_func (cluster_cpus, cluster_cpumask); +static BIN_ATTR_RO(cluster_cpus, 0); +static BIN_ATTR_RO(cluster_cpus_list, 0); +define_siblings_read_func (die_cpus, die_cpumask); static BIN_ATTR_RO(die_cpus, 0); static BIN_ATTR_RO(die_cpus_list, 0);
@@ -94,6 +101,8 @@ static struct bin_attribute *bin_attrs[] = { &bin_attr_thread_siblings_list, &bin_attr_core_siblings, &bin_attr_core_siblings_list, + &bin_attr_cluster_cpus, + &bin_attr_cluster_cpus_list, &bin_attr_die_cpus, &bin_attr_die_cpus_list, &bin_attr_package_cpus,
@@ -112,6 +121,7 @@ static struct bin_attribute *bin_attrs[] = {static struct attribute *default_attrs[] = { &dev_attr_physical_package_id.attr, &dev_attr_die_id.attr, + &dev_attr_cluster_id.attr, &dev_attr_core_id.attr, #ifdef CONFIG_SCHED_BOOK &dev_attr_book_id.attr,
fs/proc/array.c +2 -5
@@ -541,7 +541,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, }if (permitted && (!whole || num_threads <2 )) - wchan =get_wchan (task); + wchan = !task_is_running (task);if (!whole) { min_flt = task->min_flt; maj_flt = task->maj_flt;
@@ -606,10 +606,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,* * This works with older implementations of procps as well. */ -if (wchan) -seq_puts (m," 1" ); -else -seq_puts (m," 0" ); +seq_put_decimal_ull (m," " , wchan);seq_put_decimal_ull (m," " ,0 );seq_put_decimal_ull (m," " ,0 );
fs/proc/base.c +11 -8
@@ -67,6 +67,7 @@#include <linux/mm.h> #include <linux/swap.h> #include <linux/rcupdate.h> +#include <linux/kallsyms.h> #include <linux/stacktrace.h> #include <linux/resource.h> #include <linux/module.h>
@@ -386,17 +387,19 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { unsigned long wchan; +char symname[KSYM_NAME_LEN ]; -if (ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) - wchan =get_wchan (task); -else - wchan =0 ; +if (!ptrace_may_access (task,PTRACE_MODE_READ_FSCREDS )) + goto print0; -if (wchan) -seq_printf (m,"%ps" , (void *) wchan); -else -seq_putc (m,'0' ); + wchan =get_wchan (task); +if (wchan && !lookup_symbol_name (wchan, symname)) { +seq_puts (m, symname); +return 0 ; + } +print0: +seq_putc (m,'0' );return 0 ; }#endif /* CONFIG_KALLSYMS */
fs/proc/stat.c +2 -2
@@ -24,7 +24,7 @@#ifdef arch_idle_time -static u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) +u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) {u64 idle;
@@ -46,7 +46,7 @@ static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)#else -static u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) +u64 get_idle_time (struct kernel_cpustat *kcs,int cpu) {u64 idle, idle_usecs =-1ULL ;
fs/proc/uptime.c +9 -5
@@ -12,18 +12,22 @@ static int uptime_proc_show(struct seq_file *m, void *v) {struct timespec64 uptime;struct timespec64 idle; -u64 nsec; +u64 idle_nsec;u32 rem;int i; - nsec =0 ; -for_each_possible_cpu (i) - nsec += (__force u64 )kcpustat_cpu (i).cpustat[CPUTIME_IDLE ]; + idle_nsec =0 ; +for_each_possible_cpu (i) { +struct kernel_cpustat kcs; + +kcpustat_cpu_fetch (&kcs, i); + idle_nsec +=get_idle_time (&kcs, i); + }ktime_get_boottime_ts64 (&uptime);timens_add_boottime (&uptime); - idle.tv_sec =div_u64_rem (nsec,NSEC_PER_SEC , &rem); + idle.tv_sec =div_u64_rem (idle_nsec,NSEC_PER_SEC , &rem); idle.tv_nsec = rem; seq_printf(m, "%lu.%02lu %lu.%02lu\n", (unsigned long) uptime.tv_sec,
include/linux/acpi.h +5 -0
@@ -1353,6 +1353,7 @@ static inline int lpit_read_residency_count_address(u64 *address)#ifdef CONFIG_ACPI_PPTT int acpi_pptt_cpu_is_thread (unsigned int cpu);int find_acpi_cpu_topology (unsigned int cpu,int level); +int find_acpi_cpu_topology_cluster (unsigned int cpu);int find_acpi_cpu_topology_package (unsigned int cpu);int find_acpi_cpu_topology_hetero_id (unsigned int cpu);int find_acpi_cpu_cache_topology (unsigned int cpu,int level);
@@ -1365,6 +1366,10 @@ static inline int find_acpi_cpu_topology(unsigned int cpu, int level) {return -EINVAL ; } +static inline int find_acpi_cpu_topology_cluster (unsigned int cpu) +{ +return -EINVAL ; +}static inline int find_acpi_cpu_topology_package (unsigned int cpu) {return -EINVAL ;
include/linux/arch_topology.h +5 -0
@@ -62,10 +62,12 @@ void topology_set_thermal_pressure(const struct cpumask *cpus,struct cpu_topology {int thread_id;int core_id; +int cluster_id;int package_id;int llc_id;cpumask_t thread_sibling;cpumask_t core_sibling; +cpumask_t cluster_sibling;cpumask_t llc_sibling; };
@@ -73,13 +75,16 @@ struct cpu_topology {extern struct cpu_topology cpu_topology[NR_CPUS ];#define topology_physical_package_id (cpu) (cpu_topology[cpu].package_id) +#define topology_cluster_id (cpu) (cpu_topology[cpu].cluster_id)#define topology_core_id (cpu) (cpu_topology[cpu].core_id)#define topology_core_cpumask (cpu) (&cpu_topology[cpu].core_sibling)#define topology_sibling_cpumask (cpu) (&cpu_topology[cpu].thread_sibling) +#define topology_cluster_cpumask (cpu) (&cpu_topology[cpu].cluster_sibling)#define topology_llc_cpumask (cpu) (&cpu_topology[cpu].llc_sibling)void init_cpu_topology (void );void store_cpu_topology (unsigned int cpuid);const struct cpumask *cpu_coregroup_mask (int cpu); +const struct cpumask *cpu_clustergroup_mask (int cpu);void update_siblings_masks (unsigned int cpu);void remove_cpu_topology (unsigned int cpuid);void reset_cpu_topology (void );
include/linux/irq_work.h +8 -0
@@ -3,6 +3,7 @@#define _LINUX_IRQ_WORK_H#include <linux/smp_types.h> +#include <linux/rcuwait.h> /* * An entry can be in one of four states:
@@ -16,11 +17,13 @@struct irq_work {struct __call_single_node node;void (*func)(struct irq_work *); +struct rcuwait irqwait; };#define __IRQ_WORK_INIT (_func, _flags) (struct irq_work){ \ .node = { .u_flags = (_flags), }, \ .func = (_func), \ + .irqwait = __RCUWAIT_INITIALIZER(irqwait), \ }#define IRQ_WORK_INIT (_func) __IRQ_WORK_INIT(_func, 0)
@@ -46,6 +49,11 @@ static inline bool irq_work_is_busy(struct irq_work *work)return atomic_read (&work->node.a_flags) &IRQ_WORK_BUSY ; } +static inline bool irq_work_is_hard (struct irq_work *work) +{ +return atomic_read (&work->node.a_flags) &IRQ_WORK_HARD_IRQ ; +} +bool irq_work_queue (struct irq_work *work);bool irq_work_queue_on (struct irq_work *work,int cpu);
include/linux/kernel_stat.h +1 -0
@@ -102,6 +102,7 @@ extern void account_system_index_time(struct task_struct *, u64, enum cpu_usage_stat);extern void account_steal_time (u64 );extern void account_idle_time (u64 ); +extern u64 get_idle_time (struct kernel_cpustat *kcs,int cpu);#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE static inline void account_process_tick (struct task_struct *tsk,int user)
include/linux/mm_types.h +4 -0
@@ -12,6 +12,7 @@#include <linux/completion.h> #include <linux/cpumask.h> #include <linux/uprobes.h> +#include <linux/rcupdate.h> #include <linux/page-flags-layout.h> #include <linux/workqueue.h> #include <linux/seqlock.h>
@@ -572,6 +573,9 @@ struct mm_struct {bool tlb_flush_batched;#endif struct uprobes_state uprobes_state; +#ifdef CONFIG_PREEMPT_RT +struct rcu_head delayed_drop; +#endif #ifdef CONFIG_HUGETLB_PAGE atomic_long_t hugetlb_usage;#endif
include/linux/sched.h +7 -4
@@ -503,6 +503,8 @@ struct sched_statistics {u64 block_start;u64 block_max; +s64 sum_block_runtime; +u64 exec_max;u64 slice_max;
@@ -522,7 +524,7 @@ struct sched_statistics {u64 nr_wakeups_passive;u64 nr_wakeups_idle;#endif -}; +}____cacheline_aligned ;struct sched_entity {/* For load-balancing: */
@@ -538,8 +540,6 @@ struct sched_entity {u64 nr_migrations; -struct sched_statistics statistics; -#ifdef CONFIG_FAIR_GROUP_SCHED int depth;struct sched_entity *parent;
@@ -775,10 +775,10 @@ struct task_struct {int normal_prio;unsigned int rt_priority; -const struct sched_class *sched_class;struct sched_entity se;struct sched_rt_entity rt;struct sched_dl_entity dl; +const struct sched_class *sched_class;#ifdef CONFIG_SCHED_CORE struct rb_node core_node;
@@ -803,6 +803,8 @@ struct task_struct {struct uclamp_se uclamp[UCLAMP_CNT ];#endif +struct sched_statistics stats; +#ifdef CONFIG_PREEMPT_NOTIFIERS /* List of struct preempt_notifier: */ struct hlist_head preempt_notifiers;
@@ -2137,6 +2139,7 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)#endif /* CONFIG_SMP */ extern bool sched_task_on_rq (struct task_struct *p); +extern unsigned long get_wchan (struct task_struct *p);/* * In order to reduce various lock holder preemption latencies provide an
include/linux/sched/idle.h +4 -0
@@ -11,7 +11,11 @@ enum cpu_idle_type { CPU_MAX_IDLE_TYPES }; +#ifdef CONFIG_SMP extern void wake_up_if_idle (int cpu); +#else +static inline void wake_up_if_idle (int cpu) { } +#endif /* * Idle thread specific functions to determine the need_resched
include/linux/sched/mm.h +29 -0
@@ -49,6 +49,35 @@ static inline void mmdrop(struct mm_struct *mm)__mmdrop (mm); } +#ifdef CONFIG_PREEMPT_RT +/* +* RCU callback for delayed mm drop. Not strictly RCU, but call_rcu() is +* by far the least expensive way to do that. +*/ +static inline void __mmdrop_delayed (struct rcu_head *rhp) +{ + struct mm_struct *mm = container_of(rhp, struct mm_struct, delayed_drop); + +__mmdrop (mm); +} + +/* +* Invoked from finish_task_switch(). Delegates the heavy lifting on RT +* kernels via RCU. +*/ +static inline void mmdrop_sched (struct mm_struct *mm) +{ +/* Provides a full memory barrier. See mmdrop() */ +if (atomic_dec_and_test (&mm->mm_count)) +call_rcu (&mm->delayed_drop, __mmdrop_delayed); +} +#else +static inline void mmdrop_sched (struct mm_struct *mm) +{ +mmdrop (mm); +} +#endif +/** * mmget() - Pin the address space associated with a &struct mm_struct. * @mm: The address space to pin.
include/linux/sched/task.h +2 -1
@@ -54,7 +54,8 @@ extern asmlinkage void schedule_tail(struct task_struct *prev);extern void init_idle (struct task_struct *idle,int cpu);extern int sched_fork (unsigned long clone_flags,struct task_struct *p); -extern void sched_post_fork (struct task_struct *p); +extern void sched_post_fork (struct task_struct *p, +struct kernel_clone_args *kargs);extern void sched_dead (struct task_struct *p);void __noreturn do_task_dead (void );
include/linux/sched/topology.h +8 -1
@@ -42,6 +42,13 @@ static inline int cpu_smt_flags(void) }#endif +#ifdef CONFIG_SCHED_CLUSTER +static inline int cpu_cluster_flags (void ) +{ +return SD_SHARE_PKG_RESOURCES ; +} +#endif +#ifdef CONFIG_SCHED_MC static inline int cpu_core_flags (void ) {
@@ -98,7 +105,7 @@ struct sched_domain {/* idle_balance() stats */ u64 max_newidle_lb_cost; -unsigned long next_decay_max_lb_cost; +unsigned long last_decay_max_lb_cost;u64 avg_scan_cost;/* select_idle_sibling */
include/linux/topology.h +13 -0
@@ -186,6 +186,9 @@ static inline int cpu_to_mem(int cpu)#ifndef topology_die_id#define topology_die_id (cpu) ((void)(cpu), -1)#endif +#ifndef topology_cluster_id +#define topology_cluster_id (cpu) ((void)(cpu), -1) +#endif #ifndef topology_core_id#define topology_core_id (cpu) ((void)(cpu), 0)#endif
@@ -195,6 +198,9 @@ static inline int cpu_to_mem(int cpu)#ifndef topology_core_cpumask#define topology_core_cpumask (cpu) cpumask_of(cpu)#endif +#ifndef topology_cluster_cpumask +#define topology_cluster_cpumask (cpu) cpumask_of(cpu) +#endif #ifndef topology_die_cpumask#define topology_die_cpumask (cpu) cpumask_of(cpu)#endif
@@ -206,6 +212,13 @@ static inline const struct cpumask *cpu_smt_mask(int cpu) }#endif +#if defined(CONFIG_SCHED_CLUSTER ) && !defined(cpu_cluster_mask) +static inline const struct cpumask *cpu_cluster_mask (int cpu) +{ +return topology_cluster_cpumask (cpu); +} +#endif +static inline const struct cpumask *cpu_cpu_mask (int cpu) {return cpumask_of_node (cpu_to_node (cpu));
include/linux/wait.h +2 -1
@@ -1160,6 +1160,7 @@ int autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, i (wait)->flags =0 ; \ } while (0) -bool try_invoke_on_locked_down_task(struct task_struct *p, bool (*func)(struct task_struct *t, void *arg), void *arg); +typedef int (*task_call_f)(struct task_struct *p, void *arg); +extern int task_call_func (struct task_struct *p,task_call_f func,void *arg);#endif /* _LINUX_WAIT_H */
kernel/Kconfig.preempt +23 -9
@@ -2,10 +2,11 @@ choice prompt "Preemption Model" - default PREEMPT_NONE + default PREEMPT_NONE_BEHAVIOUR -config PREEMPT_NONE +config PREEMPT_NONE_BEHAVIOUR bool "No Forced Preemption (Server)" + select PREEMPT_NONE if !PREEMPT_DYNAMIC help This is the traditional Linux preemption model, geared towards throughput. It will still provide good latencies most of the
@@ -17,9 +18,10 @@ config PREEMPT_NONE raw processing power of the kernel, irrespective of scheduling latencies. -config PREEMPT_VOLUNTARY +config PREEMPT_VOLUNTARY_BEHAVIOUR bool "Voluntary Kernel Preemption (Desktop)" depends on !ARCH_NO_PREEMPT + select PREEMPT_VOLUNTARY if !PREEMPT_DYNAMIC help This option reduces the latency of the kernel by adding more "explicit preemption points" to the kernel code. These new
@@ -35,12 +37,10 @@ config PREEMPT_VOLUNTARY Select this if you are building a kernel for a desktop system. -config PREEMPT +config PREEMPT_BEHAVIOUR bool "Preemptible Kernel (Low-Latency Desktop)" depends on !ARCH_NO_PREEMPT - select PREEMPTION - select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK - select PREEMPT_DYNAMIC if HAVE_PREEMPT_DYNAMIC + select PREEMPT help This option reduces the latency of the kernel by making all kernel code (that is not executing in a critical section)
@@ -58,7 +58,7 @@ config PREEMPT config PREEMPT_RT bool "Fully Preemptible Kernel (Real-Time)" - depends on EXPERT && ARCH_SUPPORTS_RT + depends on EXPERT && ARCH_SUPPORTS_RT && !PREEMPT_DYNAMIC select PREEMPTION help This option turns the kernel into a real-time kernel by replacing
@@ -75,6 +75,17 @@ config PREEMPT_RT endchoice +config PREEMPT_NONE + bool + +config PREEMPT_VOLUNTARY + bool + +config PREEMPT + bool + select PREEMPTION + select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK + config PREEMPT_COUNT bool
@@ -83,7 +94,10 @@ config PREEMPTION select PREEMPT_COUNT config PREEMPT_DYNAMIC - bool + bool "Preemption behaviour defined on boot" + depends on HAVE_PREEMPT_DYNAMIC + select PREEMPT + default y help This option allows to define the preemption model on the kernel command line parameter and thus override the default preemption
kernel/exit.c +2 -0
@@ -64,6 +64,7 @@#include <linux/rcuwait.h> #include <linux/compat.h> #include <linux/io_uring.h> +#include <linux/kprobes.h> #include <linux/uaccess.h> #include <asm/unistd.h>
@@ -168,6 +169,7 @@ static void delayed_put_task_struct(struct rcu_head *rhp) { struct task_struct *tsk = container_of(rhp, struct task_struct, rcu); +kprobe_flush_task (tsk);perf_event_delayed_put (tsk);trace_sched_process_free (tsk);put_task_struct (tsk);
kernel/fork.c +1 -1
@@ -2405,7 +2405,7 @@ static __latent_entropy struct task_struct *copy_process(write_unlock_irq (&tasklist_lock);proc_fork_connector (p); -sched_post_fork (p); +sched_post_fork (p, args);cgroup_post_fork (p, args);perf_event_fork (p);
kernel/irq_work.c +118 -12
196 lines not on this page · raw message
kernel/kprobes.c +4 -4
@@ -1250,10 +1250,10 @@ void kprobe_busy_end(void) }/* -* This function is called from finish_task_switch when task tk becomes dead, -* so that we can recycle any function-return probe instances associated -* with this task. These left over instances represent probed functions -* that have been called but will never return. +* This function is called from delayed_put_task_struct() when a task is +* dead and cleaned up to recycle any function-return probe instances +* associated with this task. These left over instances represent probed +* functions that have been called but will never return. */ void kprobe_flush_task (struct task_struct *tk) {
kernel/kthread.c +8 -8
@@ -270,6 +270,7 @@ EXPORT_SYMBOL_GPL(kthread_parkme);static int kthread (void *_create) { +static const struct sched_param param = { .sched_priority =0 };/* Copy data: it's on kthread's stack */ struct kthread_create_info *create = _create;int (*threadfn)(void *data) = create->threadfn;
@@ -300,6 +301,13 @@ static int kthread(void *_create)init_completion (&self->parked); current->vfork_done = &self->exited; +/* +* The new thread inherited kthreadd's priority and CPU mask. Reset +* back to default in case they have been changed. +*/ +sched_setscheduler_nocheck (current,SCHED_NORMAL , ¶m); +set_cpus_allowed_ptr (current,housekeeping_cpumask (HK_FLAG_KTHREAD )); +/* OK, tell user we're spawned, wait for stop or wakeup */ __set_current_state (TASK_UNINTERRUPTIBLE ); create->result = current;
@@ -397,7 +405,6 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data), } task = create->result;if (!IS_ERR (task)) { -static const struct sched_param param = { .sched_priority =0 };char name[TASK_COMM_LEN ];/*
@@ -406,13 +413,6 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),*/ vsnprintf (name,sizeof (name), namefmt, args);set_task_comm (task, name); -/* -* root may have changed our (kthreadd's) priority or CPU mask. -* The kernel thread should not inherit these properties. -*/ -sched_setscheduler_nocheck (task,SCHED_NORMAL , ¶m); -set_cpus_allowed_ptr (task, -housekeeping_cpumask (HK_FLAG_KTHREAD )); }kfree (create);return task;
kernel/livepatch/transition.c +48 -47
148 lines not on this page · raw message
kernel/rcu/tasks.h +6 -6
@@ -928,7 +928,7 @@ static void trc_read_check_handler(void *t_in) }/* Callback function for scheduler to check locked-down task. */ -static bool trc_inspect_reader (struct task_struct *t,void *arg) +static int trc_inspect_reader (struct task_struct *t,void *arg) {int cpu =task_cpu (t);bool in_qs = false;
@@ -939,7 +939,7 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg)// If no chance of heavyweight readers, do it the hard way. if (!ofl && !IS_ENABLED (CONFIG_TASKS_TRACE_RCU_READ_MB )) -return false; +return -EINVAL ;// If heavyweight readers are enabled on the remote task, // we can inspect its state despite its currently running.
@@ -947,7 +947,7 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg) n_heavy_reader_attempts++;if (!ofl &&// Check for "running" idle tasks on offline CPUs. !rcu_dynticks_zero_in_eqs (cpu, &t->trc_reader_nesting)) -return false;// No quiescent state, do it the hard way. +return -EINVAL ;// No quiescent state, do it the hard way. n_heavy_reader_updates++;if (ofl) n_heavy_reader_ofl_updates++;
@@ -962,7 +962,7 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg) t->trc_reader_checked = true;if (in_qs) -return true;// Already in quiescent state, done!!! +return 0 ;// Already in quiescent state, done!!! // The task is in a read-side critical section, so set up its // state so that it will awaken the grace-period kthread upon exit
@@ -970,7 +970,7 @@ static bool trc_inspect_reader(struct task_struct *t, void *arg)atomic_inc (&trc_n_readers_need_end);// One more to wait on. WARN_ON_ONCE (READ_ONCE (t->trc_reader_special.b.need_qs));WRITE_ONCE (t->trc_reader_special.b.need_qs, true); -return true; +return 0 ; }/* Attempt to extract the state for the specified task. */
@@ -992,7 +992,7 @@ static void trc_wait_for_one_reader(struct task_struct *t,// Attempt to nail down the task for inspection. get_task_struct (t); -if (try_invoke_on_locked_down_task (t, trc_inspect_reader,NULL )) { +if (!task_call_func (t, trc_inspect_reader,NULL )) {put_task_struct (t);return ; }
kernel/rcu/tree_stall.h +4 -4
@@ -240,16 +240,16 @@ struct rcu_stall_chk_rdr {* Report out the state of a not-running task that is stalling the * current RCU grace period. */ -static bool check_slow_task (struct task_struct *t,void *arg) +static int check_slow_task (struct task_struct *t,void *arg) {struct rcu_stall_chk_rdr *rscrp = arg;if (task_curr (t)) -return false;// It is running, so decline to inspect it. +return -EBUSY ;// It is running, so decline to inspect it. rscrp->nesting = t->rcu_read_lock_nesting; rscrp->rs = t->rcu_read_unlock_special; rscrp->on_blkd_list = !list_empty (&t->rcu_node_entry); -return true; +return 0 ; }/*
@@ -283,7 +283,7 @@ static int rcu_print_task_stall(struct rcu_node *rnp, unsigned long flags)raw_spin_unlock_irqrestore_rcu_node (rnp, flags);while (i) { t = ts[--i]; -if (!try_invoke_on_locked_down_task (t, check_slow_task, &rscr)) +if (task_call_func (t, check_slow_task, &rscr))pr_cont (" P%d" , t->pid);else pr_cont(" P%d/%d:%c%c%c%c",
kernel/sched/Makefile +4 -0
@@ -3,6 +3,10 @@ ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_clock.o = $(CC_FLAGS_FTRACE) endif +# The compilers are complaining about unused variables inside an if(0) scope +# block. This is daft, shut them up. +ccflags-y += $(call cc-disable-warning, unused-but-set-variable) + # These files are disabled because they produce non-interesting flaky coverage # that is not a function of syscall inputs. E.g. involuntary context switches. KCOV_INSTRUMENT := n
kernel/sched/core.c +191 -201
615 lines not on this page · raw message
kernel/sched/core_sched.c +5 -4
@@ -11,7 +11,7 @@ struct sched_core_cookie {refcount_t refcnt; }; -unsigned long sched_core_alloc_cookie (void ) +static unsigned long sched_core_alloc_cookie (void ) {struct sched_core_cookie *ck =kmalloc (sizeof (*ck),GFP_KERNEL );if (!ck)
@@ -23,7 +23,7 @@ unsigned long sched_core_alloc_cookie(void)return (unsigned long )ck; } -void sched_core_put_cookie (unsigned long cookie) +static void sched_core_put_cookie (unsigned long cookie) {struct sched_core_cookie *ptr = (void *)cookie;
@@ -33,7 +33,7 @@ void sched_core_put_cookie(unsigned long cookie) } } -unsigned long sched_core_get_cookie (unsigned long cookie) +static unsigned long sched_core_get_cookie (unsigned long cookie) {struct sched_core_cookie *ptr = (void *)cookie;
@@ -53,7 +53,8 @@ unsigned long sched_core_get_cookie(unsigned long cookie)* * Returns: the old cookie */ -unsigned long sched_core_update_cookie (struct task_struct *p,unsigned long cookie) +static unsigned long sched_core_update_cookie (struct task_struct *p, +unsigned long cookie) {unsigned long old_cookie;struct rq_flags rf;
kernel/sched/deadline.c +97 -2
142 lines not on this page · raw message
kernel/sched/debug.c +56 -45
65 lines not on this page · raw message
kernel/sched/fair.c +301 -195
496 lines not on this page · raw message
kernel/sched/rt.c +128 -2
130 lines not on this page · raw message
kernel/sched/stats.c +104 -0
104 lines not on this page · raw message
kernel/sched/stats.h +49 -0
49 lines not on this page · raw message
tools/testing/selftests/sched/cs_prctl_test.c +18 -10
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [GIT pull] sched/core for v5.16-rc1
Quoted 3 lines · Thomas Gleixner
- Make
wchan()more robust and work with all kind of unwinders by enforcing that the task stays blocked while unwinding is in progress.
Ugh. This not-very-important data is protected by a rather core lock.
Is this yet another example of "unwinding is so fragile that it can screw up unless we take a lock that is seriously overkill for a not very important operation"?
Unwinders that need locks because they can do bad things if they are working on unstable data are EVIL and WRONG.
I guess I don't care too much about the pi_lock, and the actual unwinding is hopefully done on tasks that don't care about it, but this smells suspicious to me.
Why is that "stable wchan" so magically important?
Linus
Re: [GIT pull] sched/core for v5.16-rc1
Quoted 3 lines · Linus Torvalds
Unwinders that need locks because they can do bad things if they are working on unstable data are EVIL and WRONG.
Note that this is fundamental: if you can fool an unwider to do something bad just because the data isn't stable, then the unwinder is truly horrendously buggy, and not usable.
It could be a user process doing bad things to the user stack frame from another thread when profiling is enabled.
It could be debug code unwinding without locks for random reasons.
So I really don't like "take a lock for unwinding". It's a pretty bad bug if the lock required.
I have to say, that commit message is pretty bad too. It doesn't actually explain why this is needed. It just talks about the alleged reasons why it should be stable, with no explanation of why that would be an issue, and worth taking a core lock over.
The "Link" in the commit also is entirely useless, pointing back to the emailed submission of the patch, rather than any useful discussion about why the patch happened.
Linus
Peter Zijlstra
maintainerRe: [GIT pull] sched/core for v5.16-rc1
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
Unwinders that need locks because they can do bad things if they are working on unstable data are EVIL and WRONG.
Note that this is fundamental: if you can fool an unwider to do something bad just because the data isn't stable, then the unwinder is truly horrendously buggy, and not usable.
From what I've been led to believe, quite a few of our arch unwinders seem to fall in that category. They're mostly only happy when unwinding self and don't have many guardrails on otherwise.
Quoted 2 lines
It could be a user process doing bad things to the user stack frame from another thread when profiling is enabled.
Most of the unwinders seem to only care about the kernel stack. Not the user stack.
Quoted 4 lines
It could be debug code unwinding without locks for random reasons.
So I really don't like "take a lock for unwinding". It's a pretty bad bug if the lock required.
Fair enough; te x86 unwinder is pretty robust in this regard, but it seems to be one of few :/
Quoted 3 lines
The "Link" in the commit also is entirely useless, pointing back to the emailed submission of the patch, rather than any useful discussion about why the patch happened.
So the initial discussion started here:
https://lkml.kernel.org/r/[email protected]
A later thread that might also be of interest is:
https://lkml.kernel.org/r/[email protected]
Also, an even later thread proposes to push that lock into more stack unwinding functions (anything doing remote unwinds):
https://lkml.kernel.org/r/[email protected]
But it seems to be you're thinking that's fundamentally buggered and people should instead invest in fixing their unwinders already.
Now, as is, this stuff is user exposed through /proc/$pid/{wchan,stack} and as such I think it *can* do with a few extra guardrails in generic code. OTOH, /proc/$pid/stack is root only.
Also, the remote stack-trace code is hooked into bpf (because kitchen-sink) and while I didn't look too hard, I can imagine it could be used to trigger crashes on our less robust architectures if prodded just right.
Should I care about all this from a generic code PoV, or simply let the architectures that got it 'wrong' deal with it?
Mark Rutland
maintainerRe: [GIT pull] sched/core for v5.16-rc1
Quoted 15 lines · Peter Zijlstra
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Linus Torvalds
Unwinders that need locks because they can do bad things if they are working on unstable data are EVIL and WRONG.
Note that this is fundamental: if you can fool an unwider to do something bad just because the data isn't stable, then the unwinder is truly horrendously buggy, and not usable.
From what I've been led to believe, quite a few of our arch unwinders seem to fall in that category. They're mostly only happy when unwinding self and don't have many guardrails on otherwise.
Quoted 5 lines
Quoted 2 lines
It could be a user process doing bad things to the user stack frame from another thread when profiling is enabled.
Most of the unwinders seem to only care about the kernel stack. Not the user stack.
Yup; there are usually separate unwinders for user/kernel, since there are different constaints (and potentially different ABIs for unwinding).
Quoted 7 lines
Quoted 4 lines
It could be debug code unwinding without locks for random reasons.
So I really don't like "take a lock for unwinding". It's a pretty bad bug if the lock required.
Fair enough; te x86 unwinder is pretty robust in this regard, but it seems to be one of few :/
FWIW, the arm64 kernel unwinder also shouldn't blow up (so long as the target stack is pinned via try_get_stack() or similar).
However, depending on how the task reuses the stack, the results can be entirely bogus rather than just stale, since data on the stack can look like a kernel pointer (even if that's fairly unllikely). I'm happy to believe that we don't care aobut that for wchan, but it's not something I'd like to see spread.
Quoted 20 lines
Quoted 3 lines
The "Link" in the commit also is entirely useless, pointing back to the emailed submission of the patch, rather than any useful discussion about why the patch happened.
So the initial discussion started here:
https://lkml.kernel.org/r/[email protected]
A later thread that might also be of interest is:
https://lkml.kernel.org/r/[email protected]
Also, an even later thread proposes to push that lock into more stack unwinding functions (anything doing remote unwinds):
https://lkml.kernel.org/r/[email protected]
But it seems to be you're thinking that's fundamentally buggered and people should instead invest in fixing their unwinders already.
Quoted 8 lines
Now, as is, this stuff is user exposed through
/proc/$pid/{wchan,stack}and as such I think it *can* do with a few extra guardrails in generic code. OTOH,/proc/$pid/stackis root only.Also, the remote stack-trace code is hooked into bpf (because kitchen-sink) and while I didn't look too hard, I can imagine it could be used to trigger crashes on our less robust architectures if prodded just right.
I do worry that remote unwinds from BPF are just silently generating junk, but it's not clear to me what they're actually used for and how much that matters. I don't understand why a remote unwind is necessary at all.
Quoted 2 lines
Should I care about all this from a generic code PoV, or simply let the architectures that got it 'wrong' deal with it?
FWIW I'm happy either way. There are some upcoming improvements to the arm64 unwinder that currently conflict and I need to know whether to wait and rebase or assume that we take those first.
Thanks,
Mark.
Re: [GIT pull] sched/core for v5.16-rc1
In reply to Peter ZijlstraQuoted 6 lines · Peter Zijlstra
Quoted 3 lines
It could be a user process doing bad things to the user stack frame from another thread when profiling is enabled.
Most of the unwinders seem to only care about the kernel stack. Not the user stack.
Note that it very much happens for a kernel stack too.
There the reason isn't some active attack, but simply stack corruption, or - not uncommonly - missing or incomplete debug notes that the unwinder crazily depends on.
If an unwinder isn't robust enough to deal with stack corruption, it damn well should be deleted immediately - it will only cause even *more* problems when some nasty bug happens, and suddenly the unwinder means that you don';t get a proper oops report.
And yes, I feel strongly about this, because we very much used to have that situation on x86 too a long time ago. I spent a year fighting buggy unwinders, and then removed the unbelievable garbage in the end because the maintainer of said thing refused to admit that there was a problem.
So I really think that the solution to "unwinder is not robust" is absolutely not to take more locks. Because that's literally just hiding the much bigger and serious problem.
The fact that the lock in question is a fairly critical one (and needs to use "raw_spin_lock()" and friends) is just another argument against it.
I've obviously pulled this on Monday already, and I'm not going to start reverting those commits unless they cause problems, but I do think they were seriously misguided.
Linus
Peter Zijlstra
maintainerRe: [GIT pull] sched/core for v5.16-rc1
In reply to Linus TorvaldsQuoted 5 lines · Linus Torvalds
Quoted 3 lines · Thomas Gleixner
- Make
wchan()more robust and work with all kind of unwinders by enforcing that the task stays blocked while unwinding is in progress.
Quoted 8 lines
Ugh. This not-very-important data is protected by a rather core lock.
Is this yet another example of "unwinding is so fragile that it can screw up unless we take a lock that is seriously overkill for a not very important operation"?
Unwinders that need locks because they can do bad things if they are working on unstable data are EVIL and WRONG.
Because of that :/ The eventual plan was to implement wchan in core code using the 'regular' stack unwinding functions we have, the diffstats are nice, but the unwinders not so. Also see my other reply.
https://lkml.kernel.org/r/[email protected]
Quoted 3 lines
I guess I don't care too much about the
pi_lock, and the actual unwinding is hopefully done on tasks that don't care about it, but this smells suspicious to me.
You do in fact care about pi_lock. The name is very wrong these days (and I've been very tardy with renaming it because I can't seem to come up with a good name).
It is in fact the core lock involved with regular wakeups. The lock was initially PI only, but it got co-opted into common scheduler use a fair number of years ago. These days it serializes pretty much all per-task scheduling state, not only the pi-chain. So perhaps I should do:
s/pi_lock/sched_lock/ ?
Re: [GIT pull] sched/core for v5.16-rc1
In reply to Thomas GleixnerThe pull request you sent on Mon, 1 Nov 2021 02:16:04 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:16:04 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitsched-core-2021-11-01
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/9a7e0a90a454a7826ecbca055a6ec9271b70c686
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull] x86/apic for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest x86/apic branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-apic-2021-11-01
up to: cc95a07fef06: x86/apic: Reduce cache line misses in __x2apic_send_IPI_mask()
x86/apic related update:
- A single commit which reduces cacheline misses in __x2apic_send_IPI_mask() significantly by converting x86_cpu_to_logical_apicid() to an array instead of using per CPU storage. This reduces the cost for a full broadcast on a dual socket system with 256 CPUs from 33 down to 11 microseconds.
Thanks,
tglx
------------------>
Eric Dumazet (1):
x86/apic: Reduce cache line misses in __x2apic_send_IPI_mask()
arch/x86/kernel/apic/x2apic_cluster.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
arch/x86/kernel/apic/x2apic_cluster.c +21 -6
@@ -15,9 +15,15 @@ struct cluster_mask {struct cpumask mask; }; -static DEFINE_PER_CPU(u32, x86_cpu_to_logical_apicid); +/* +* __x2apic_send_IPI_mask() possibly needs to read +* x86_cpu_to_logical_apicid for all online cpus in a sequential way. +* Using per cpu variable would cost one cache line per cpu. +*/ +static u32 *x86_cpu_to_logical_apicid__read_mostly ; + static DEFINE_PER_CPU(cpumask_var_t, ipi_mask); -static DEFINE_PER_CPU(struct cluster_mask *, cluster_masks); +static DEFINE_PER_CPU_READ_MOSTLY(struct cluster_mask *, cluster_masks);static struct cluster_mask *cluster_hotplug_mask;static int x2apic_acpi_madt_oem_check (char *oem_id,char *oem_table_id)
@@ -27,7 +33,7 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)static void x2apic_send_IPI (int cpu,int vector) { -u32 dest =per_cpu (x86_cpu_to_logical_apicid, cpu); +u32 dest = x86_cpu_to_logical_apicid[cpu];/* x2apic MSRs are special and need a special fence: */ weak_wrmsr_fence ();
@@ -58,7 +64,7 @@ __x2apic_send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest) dest =0 ;for_each_cpu_and (clustercpu, tmpmsk, &cmsk->mask) - dest |=per_cpu (x86_cpu_to_logical_apicid, clustercpu); + dest |= x86_cpu_to_logical_apicid[clustercpu];if (!dest)continue ;
@@ -94,7 +100,7 @@ static void x2apic_send_IPI_all(int vector)static u32 x2apic_calc_apicid (unsigned int cpu) { -return per_cpu (x86_cpu_to_logical_apicid, cpu); +return x86_cpu_to_logical_apicid[cpu]; }static void init_x2apic_ldr (void )
@@ -103,7 +109,7 @@ static void init_x2apic_ldr(void)u32 cluster, apicid =apic_read (APIC_LDR );unsigned int cpu; -this_cpu_write (x86_cpu_to_logical_apicid, apicid); + x86_cpu_to_logical_apicid[smp_processor_id ()] = apicid;if (cmsk) goto update;
@@ -166,12 +172,21 @@ static int x2apic_dead_cpu(unsigned int dead_cpu)static int x2apic_cluster_probe (void ) { +u32 slots; +if (!x2apic_mode)return 0 ; + slots =max_t (u32,L1_CACHE_BYTES /sizeof (u32), nr_cpu_ids); + x86_cpu_to_logical_apicid =kcalloc (slots,sizeof (u32),GFP_KERNEL ); +if (!x86_cpu_to_logical_apicid) +return 0 ; +if (cpuhp_setup_state (CPUHP_X2APIC_PREPARE ,"x86/x2apic:prepare" , x2apic_prepare_cpu, x2apic_dead_cpu) <0 ) {pr_err ("Failed to register X2APIC_PREPARE\n" ); +kfree (x86_cpu_to_logical_apicid); + x86_cpu_to_logical_apicid =NULL ;return 0 ; }init_x2apic_ldr ();
Re: [GIT pull] x86/apic for v5.16-rc1
The pull request you sent on Mon, 1 Nov 2021 02:16:07 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:16:07 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-apic-2021-11-01
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/7d20dd3294b31c11a5f642a3e342174ef8da7c73
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull] locking/core for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest locking/core branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-core-2021-10-31
up to: f98a3dccfcb0: locking: Remove spin_lock_flags() etc
Locking updates:
- Move futex code into kernel/futex/ and split up the kitchen sink into seperate files to make integration of sys_futex_waitv() simpler.
- Add a new sys_futex_waitv() syscall which allows to wait on multiple futexes. The main use case is emulating Windows' WaitForMultipleObjects which allows Wine to improve the performance of Windows Games. Also native Linux games can benefit from this interface as this is a common wait pattern for this kind of applications.
- Add context to ww_mutex_trylock() to provide a path for i915 to rework their eviction code step by step without making lockdep upset until the final steps of rework are completed. It's also useful for regulator and TTM to avoid dropping locks in the non contended path.
- Lockdep and might_sleep() cleanups and improvements
- A few improvements for the RT substitutions.
- The usual small improvements and cleanups.
Thanks,
tglx
------------------>
André Almeida (8):
futex: Implement sys_futex_waitv() futex,x86: Wire up sys_futex_waitv() futex,arm: Wire up sys_futex_waitv()
selftests: futex: Add sys_futex_waitv() test
selftests: futex: Test sys_futex_waitv() timeout
selftests: futex: Test sys_futex_waitv() wouldblock
futex2: Documentation: Document sys_futex_waitv() uAPI
docs: futex: Fix kernel-doc references
Arnd Bergmann (1):
locking: Remove spin_lock_flags() etc
Davidlohr Bueso (1):
locking/rwbase: Optimize rwbase_read_trylock
Maarten Lankhorst (1):
kernel/locking: Add context to ww_mutex_trylock()
Nathan Chancellor (1):
locking/ww-mutex: Fix uninitialized use of ret in test_aa()
Peter Zijlstra (16):
futex: Move to kernel/futex/
futex: Split out syscalls
futex: Rename {,__}{,un}queue_me()
futex: Rename futex_wait_queue_me()
futex: Rename: queue_{,un}lock()
futex: Rename __unqueue_futex()
futex: Rename hash_futex()
futex: Rename: {get,cmpxchg}_futex_value_locked()
futex: Split out PI futex
futex: Rename: hb_waiter_{inc,dec,pending}()
futex: Rename: match_futex()
futex: Rename mark_wake_futex()
futex: Split out requeue
futex: Split out wait/wake
futex: Simplify double_lock_hb()
futex: Fix PREEMPT_RT build
Sebastian Andrzej Siewior (2):
lockdep: Let lock_is_held_type() detect recursive read as read
rtmutex: Check explicit for TASK_RTLOCK_WAIT.
Shaokun Zhang (1):
locking/lockdep: Cleanup the repeated declaration
Thomas Gleixner (9):
sched: Clean up the might_sleep() underscore zoo
sched: Make cond_resched_*lock() variants consistent vs. might_sleep()
sched: Remove preempt_offset argument from __might_sleep()
sched: Cleanup might_sleep() printks
sched: Make might_sleep() output less confusing
sched: Make RCU nest depth distinct in __might_resched()
sched: Make cond_resched_lock() variants RT aware locking/rt: Take RCU nesting into account for __might_resched()
rtmutex: Wake up the waiters lockless while dropping the read lock.
Yanfei Xu (3):
locking/rwsem: Disable preemption for spinning region
locking: Remove rcu_read_{,un}lock() for preempt_{dis,en}able() locking/rwsem: Fix comments about reader optimistic lock stealing conditions
Zhouyi Zhou (1):
lockdep: Improve comments in wait-type checks
Documentation/kernel-hacking/locking.rst | 14 +- .../translations/it_IT/kernel-hacking/locking.rst | 14 +- Documentation/userspace-api/futex2.rst | 86 + Documentation/userspace-api/index.rst | 1 + MAINTAINERS | 3 +- arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 2 + arch/ia64/include/asm/spinlock.h | 23 +- arch/openrisc/include/asm/spinlock.h | 3 - arch/parisc/include/asm/spinlock.h | 15 - arch/powerpc/include/asm/simple_spinlock.h | 21 - arch/s390/include/asm/spinlock.h | 8 - arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + drivers/gpu/drm/drm_modeset_lock.c | 2 +- drivers/regulator/core.c | 2 +- include/linux/debug_locks.h | 2 - include/linux/dma-resv.h | 2 +- include/linux/kernel.h | 13 +- include/linux/lockdep.h | 17 - include/linux/lockdep_types.h | 2 +- include/linux/preempt.h | 5 +- include/linux/rwlock.h | 15 - include/linux/rwlock_api_smp.h | 6 +- include/linux/sched.h | 39 +- include/linux/spinlock.h | 13 - include/linux/spinlock_api_smp.h | 9 - include/linux/spinlock_up.h | 1 - include/linux/syscalls.h | 7 +- include/linux/ww_mutex.h | 15 +- include/uapi/asm-generic/unistd.h | 5 +- include/uapi/linux/futex.h | 25 + kernel/Makefile | 2 +- kernel/futex.c | 4272 -------------------- kernel/futex/Makefile | 3 + kernel/futex/core.c | 1176 ++++++ kernel/futex/futex.h | 299 ++ kernel/futex/pi.c | 1233 ++++++ kernel/futex/requeue.c | 897 ++++ kernel/futex/syscalls.c | 398 ++ kernel/futex/waitwake.c | 708 ++++ kernel/locking/lockdep.c | 4 +- kernel/locking/mutex.c | 63 +- kernel/locking/rtmutex.c | 19 +- kernel/locking/rwbase_rt.c | 11 +- kernel/locking/rwsem.c | 70 +- kernel/locking/spinlock.c | 3 +- kernel/locking/spinlock_rt.c | 17 +- kernel/locking/test-ww_mutex.c | 87 +- kernel/locking/ww_rt_mutex.c | 25 + kernel/rcu/update.c | 4 +- kernel/sched/core.c | 67 +- kernel/sys_ni.c | 3 +- lib/locking-selftest.c | 2 +- mm/memory.c | 2 +- .../testing/selftests/futex/functional/.gitignore | 1 + tools/testing/selftests/futex/functional/Makefile | 3 +- .../futex/functional/futex_wait_timeout.c | 21 +- .../futex/functional/futex_wait_wouldblock.c | 41 +- .../selftests/futex/functional/futex_waitv.c | 237 ++ tools/testing/selftests/futex/functional/run.sh | 3 + tools/testing/selftests/futex/include/futex2test.h | 22 + 63 files changed, 5518 insertions(+), 4550 deletions(-) create mode 100644 Documentation/userspace-api/futex2.rst delete mode 100644 kernel/futex.c create mode 100644 kernel/futex/Makefile create mode 100644 kernel/futex/core.c create mode 100644 kernel/futex/futex.h create mode 100644 kernel/futex/pi.c create mode 100644 kernel/futex/requeue.c create mode 100644 kernel/futex/syscalls.c create mode 100644 kernel/futex/waitwake.c create mode 100644 tools/testing/selftests/futex/functional/futex_waitv.c create mode 100644 tools/testing/selftests/futex/include/futex2test.h
Documentation/kernel-hacking/locking.rst +13 -1
@@ -1352,7 +1352,19 @@ Mutex API reference Futex API reference =================== -.. kernel-doc:: kernel/futex.c +.. kernel-doc:: kernel/futex/core.c + :internal: + +.. kernel-doc:: kernel/futex/futex.h + :internal: + +.. kernel-doc:: kernel/futex/pi.c + :internal: + +.. kernel-doc:: kernel/futex/requeue.c + :internal: + +.. kernel-doc:: kernel/futex/waitwake.c :internal: Further reading
Documentation/translations/it_IT/kernel-hacking/locking.rst +13 -1
@@ -1396,7 +1396,19 @@ Riferimento per l'API dei Mutex Riferimento per l'API dei Futex =============================== -.. kernel-doc:: kernel/futex.c +.. kernel-doc:: kernel/futex/core.c + :internal: + +.. kernel-doc:: kernel/futex/futex.h + :internal: + +.. kernel-doc:: kernel/futex/pi.c + :internal: + +.. kernel-doc:: kernel/futex/requeue.c + :internal: + +.. kernel-doc:: kernel/futex/waitwake.c :internal: Approfondimenti
Documentation/userspace-api/futex2.rst new file +86 -0
86 lines not on this page · raw message
Documentation/userspace-api/index.rst +1 -0
@@ -28,6 +28,7 @@ place where this information is gathered. media/index sysfs-platform_profile vduse + futex2 .. only:: subproject and html
MAINTAINERS +2 -1
@@ -7718,6 +7718,7 @@ M: Ingo Molnar <[email protected]> R: Peter Zijlstra <[email protected]> R: Darren Hart <[email protected]> R: Davidlohr Bueso <[email protected]> +R: André Almeida <[email protected]> L: [email protected] S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
@@ -7725,7 +7726,7 @@ F: Documentation/locking/*futex* F: include/asm-generic/futex.h F: include/linux/futex.h F: include/uapi/linux/futex.h -F: kernel/futex.c +F: kernel/futex/* F: tools/perf/bench/futex* F: tools/testing/selftests/futex/
arch/arm/tools/syscall.tbl +1 -0
@@ -462,3 +462,4 @@ 446 common landlock_restrict_self sys_landlock_restrict_self # 447 reserved for memfd_secret 448 common process_mrelease sys_process_mrelease +449 common futex_waitv sys_futex_waitv
arch/arm64/include/asm/unistd.h +1 -1
@@ -38,7 +38,7 @@#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800) -#define __NR_compat_syscalls 449 +#define __NR_compat_syscalls 450#endif #define __ARCH_WANT_SYS_CLONE
arch/arm64/include/asm/unistd32.h +2 -0
@@ -903,6 +903,8 @@ __SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule) __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self)#define __NR_process_mrelease 448 __SYSCALL(__NR_process_mrelease, sys_process_mrelease) +#define __NR_futex_waitv 449 +__SYSCALL (__NR_futex_waitv, sys_futex_waitv)/* * Please add new compat syscalls above this comment and update
arch/ia64/include/asm/spinlock.h +6 -17
@@ -124,18 +124,13 @@ static __always_inline void arch_spin_unlock(arch_spinlock_t *lock)__ticket_spin_unlock (lock); } -static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock, -unsigned long flags) -{ -arch_spin_lock (lock); -} -#define arch_spin_lock_flags arch_spin_lock_flags -#ifdef ASM_SUPPORTED static __always_inline void -arch_read_lock_flags (arch_rwlock_t *lock,unsigned long flags) +arch_read_lock (arch_rwlock_t *lock) { +unsigned long flags =0 ; + __asm__ __volatile__ ("tbit.nz p6, p0 = %1,%2\n" "br.few 3f\n"
@@ -157,13 +152,8 @@ arch_read_lock_flags(arch_rwlock_t *lock, unsigned long flags) : "p6", "p7", "r2", "memory"); } -#define arch_read_lock_flags arch_read_lock_flags -#define arch_read_lock (lock) arch_read_lock_flags(lock, 0) -#else /* !ASM_SUPPORTED */ -#define arch_read_lock_flags (rw, flags) arch_read_lock(rw) -#define arch_read_lock (rw) \ do { \ arch_rwlock_t *__read_lock_ptr = (rw); \
@@ -186,8 +176,10 @@ do { \#ifdef ASM_SUPPORTED static __always_inline void -arch_write_lock_flags (arch_rwlock_t *lock,unsigned long flags) +arch_write_lock (arch_rwlock_t *lock) { +unsigned long flags =0 ; + __asm__ __volatile__ ("tbit.nz p6, p0 = %1, %2\n" "mov ar.ccv = r0\n"
@@ -210,9 +202,6 @@ arch_write_lock_flags(arch_rwlock_t *lock, unsigned long flags) : "ar.ccv", "p6", "p7", "r2", "r29", "memory"); } -#define arch_write_lock_flags arch_write_lock_flags -#define arch_write_lock (rw) arch_write_lock_flags(rw, 0) -#define arch_write_trylock (rw) \ ({ \ register long result; \
arch/openrisc/include/asm/spinlock.h +0 -3
@@ -19,9 +19,6 @@#include <asm/qrwlock.h> -#define arch_read_lock_flags (lock, flags) arch_read_lock(lock) -#define arch_write_lock_flags (lock, flags) arch_write_lock(lock) -#define arch_spin_relax (lock) cpu_relax()#define arch_read_relax (lock) cpu_relax()#define arch_write_relax (lock) cpu_relax()
arch/parisc/include/asm/spinlock.h +0 -15
@@ -23,21 +23,6 @@ static inline void arch_spin_lock(arch_spinlock_t *x)continue ; } -static inline void arch_spin_lock_flags (arch_spinlock_t *x, -unsigned long flags) -{ -volatile unsigned int *a; - - a =__ldcw_align (x); -while (__ldcw (a) ==0 ) -while (*a ==0 ) -if (flags &PSW_SM_I ) { -local_irq_enable (); -local_irq_disable (); - } -} -#define arch_spin_lock_flags arch_spin_lock_flags -static inline void arch_spin_unlock (arch_spinlock_t *x) {volatile unsigned int *a;
arch/powerpc/include/asm/simple_spinlock.h +0 -21
@@ -123,27 +123,6 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) } } -static inline -void arch_spin_lock_flags (arch_spinlock_t *lock,unsigned long flags) -{ -unsigned long flags_dis; - -while (1 ) { -if (likely (__arch_spin_trylock (lock) ==0 )) -break ; -local_save_flags (flags_dis); -local_irq_restore (flags); -do { -HMT_low (); -if (is_shared_processor ()) -splpar_spin_yield (lock); - }while (unlikely (lock->slock !=0 )); -HMT_medium (); -local_irq_restore (flags_dis); - } -} -#define arch_spin_lock_flags arch_spin_lock_flags -static inline void arch_spin_unlock (arch_spinlock_t *lock) { __asm__ __volatile__("# arch_spin_unlock\n\t"
arch/s390/include/asm/spinlock.h +0 -8
@@ -67,14 +67,6 @@ static inline void arch_spin_lock(arch_spinlock_t *lp)arch_spin_lock_wait (lp); } -static inline void arch_spin_lock_flags (arch_spinlock_t *lp, -unsigned long flags) -{ -if (!arch_spin_trylock_once (lp)) -arch_spin_lock_wait (lp); -} -#define arch_spin_lock_flags arch_spin_lock_flags -static inline int arch_spin_trylock (arch_spinlock_t *lp) {if (!arch_spin_trylock_once (lp))
arch/x86/entry/syscalls/syscall_32.tbl +1 -0
@@ -453,3 +453,4 @@ 446 i386 landlock_restrict_self sys_landlock_restrict_self 447 i386 memfd_secret sys_memfd_secret 448 i386 process_mrelease sys_process_mrelease +449 i386 futex_waitv sys_futex_waitv
arch/x86/entry/syscalls/syscall_64.tbl +1 -0
@@ -370,6 +370,7 @@ 446 common landlock_restrict_self sys_landlock_restrict_self 447 common memfd_secret sys_memfd_secret 448 common process_mrelease sys_process_mrelease +449 common futex_waitv sys_futex_waitv # # Due to a historical design error, certain syscalls are numbered differently
drivers/gpu/drm/drm_modeset_lock.c +1 -1
@@ -248,7 +248,7 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,if (ctx->trylock_only) {lockdep_assert_held (&ctx->ww_ctx); -if (!ww_mutex_trylock (&lock->mutex)) +if (!ww_mutex_trylock (&lock->mutex,NULL ))return -EBUSY ;else return 0 ;
drivers/regulator/core.c +1 -1
@@ -145,7 +145,7 @@ static inline int regulator_lock_nested(struct regulator_dev *rdev,mutex_lock (®ulator_nesting_mutex); -if (ww_ctx || !ww_mutex_trylock (&rdev->mutex)) { +if (!ww_mutex_trylock (&rdev->mutex, ww_ctx)) {if (rdev->mutex_owner == current) rdev->ref_cnt++;else
include/linux/debug_locks.h +0 -2
@@ -47,8 +47,6 @@ extern int debug_locks_off(void);# define locking_selftest () do { } while (0)#endif -struct task_struct ; -#ifdef CONFIG_LOCKDEP extern void debug_show_all_locks (void );extern void debug_show_held_locks (struct task_struct *task);
include/linux/dma-resv.h +1 -1
@@ -173,7 +173,7 @@ static inline int dma_resv_lock_slow_interruptible(struct dma_resv *obj,*/ static inline bool __must_check dma_resv_trylock (struct dma_resv *obj) { -return ww_mutex_trylock (&obj->lock); +return ww_mutex_trylock (&obj->lock,NULL ); }/**
include/linux/kernel.h +6 -7
@@ -111,8 +111,8 @@ static __always_inline void might_resched(void)#endif /* CONFIG_PREEMPT_* */ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP -extern void ___might_sleep (const char *file,int line,int preempt_offset); -extern void __might_sleep (const char *file,int line,int preempt_offset); +extern void __might_resched (const char *file,int line,unsigned int offsets); +extern void __might_sleep (const char *file,int line);extern void __cant_sleep (const char *file,int line,int preempt_offset);extern void __cant_migrate (const char *file,int line);
@@ -129,7 +129,7 @@ extern void __cant_migrate(const char *file, int line);* supposed to. */ # define might_sleep () \ - do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) + do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0)/** * cant_sleep - annotation for functions that cannot sleep *
@@ -168,10 +168,9 @@ extern void __cant_migrate(const char *file, int line);*/ # define non_block_end () WARN_ON(current->non_block_count-- == 0)#else -static inline void ___might_sleep (const char *file,int line, -int preempt_offset) { } -static inline void __might_sleep (const char *file,int line, -int preempt_offset) { } +static inline void __might_resched (const char *file,int line, +unsigned int offsets) { } +static inline void __might_sleep (const char *file,int line) { }# define might_sleep () do { might_resched(); } while (0)# define cant_sleep () do { } while (0)# define cant_migrate () do { } while (0)
include/linux/lockdep.h +0 -17
@@ -481,23 +481,6 @@ do { \#endif /* CONFIG_LOCK_STAT */ -#ifdef CONFIG_LOCKDEP - -/* -* On lockdep we dont want the hand-coded irq-enable of -* _raw_*_lock_flags() code, because lockdep assumes -* that interrupts are not re-enabled during lock-acquire: -*/ -#define LOCK_CONTENDED_FLAGS (_lock, try, lock, lockfl, flags) \ - LOCK_CONTENDED((_lock), (try), (lock)) - -#else /* CONFIG_LOCKDEP */ - -#define LOCK_CONTENDED_FLAGS (_lock, try, lock, lockfl, flags) \ - lockfl((_lock), (flags)) - -#endif /* CONFIG_LOCKDEP */ -#ifdef CONFIG_PROVE_LOCKING extern void print_irqtrace_events (struct task_struct *curr);#else
include/linux/lockdep_types.h +1 -1
@@ -21,7 +21,7 @@ enum lockdep_wait_type { LD_WAIT_SPIN, /* spin loops, raw_spinlock_t etc.. */#ifdef CONFIG_PROVE_RAW_LOCK_NESTING - LD_WAIT_CONFIG, /* CONFIG_PREEMPT_LOCK, spinlock_t etc.. */ + LD_WAIT_CONFIG, /* preemptible in PREEMPT_RT, spinlock_t etc.. */ #else LD_WAIT_CONFIG = LD_WAIT_SPIN,#endif
include/linux/preempt.h +3 -2
@@ -122,9 +122,10 @@* The preempt_count offset after spin_lock() */ #if !defined(CONFIG_PREEMPT_RT ) -#define PREEMPT_LOCK_OFFSET PREEMPT_DISABLE_OFFSET +#define PREEMPT_LOCK_OFFSET PREEMPT_DISABLE_OFFSET#else -#define PREEMPT_LOCK_OFFSET 0 +/* Locks on RT do not disable preemption */ +#define PREEMPT_LOCK_OFFSET 0#endif /*
include/linux/rwlock.h +0 -15
@@ -30,31 +30,16 @@ do { \#ifdef CONFIG_DEBUG_SPINLOCK extern void do_raw_read_lock(rwlock_t *lock) __acquires(lock); -#define do_raw_read_lock_flags (lock, flags) do_raw_read_lock(lock)extern int do_raw_read_trylock (rwlock_t *lock); extern void do_raw_read_unlock(rwlock_t *lock) __releases(lock); extern void do_raw_write_lock(rwlock_t *lock) __acquires(lock); -#define do_raw_write_lock_flags (lock, flags) do_raw_write_lock(lock)extern int do_raw_write_trylock (rwlock_t *lock); extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock);#else - -#ifndef arch_read_lock_flags -# define arch_read_lock_flags (lock, flags) arch_read_lock(lock) -#endif - -#ifndef arch_write_lock_flags -# define arch_write_lock_flags (lock, flags) arch_write_lock(lock) -#endif -# define do_raw_read_lock (rwlock) do {__acquire(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0) -# define do_raw_read_lock_flags (lock, flags) \ - do {__acquire(lock); arch_read_lock_flags(&(lock)->raw_lock, *(flags)); } while (0)# define do_raw_read_trylock (rwlock) arch_read_trylock(&(rwlock)->raw_lock)# define do_raw_read_unlock (rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release(lock); } while (0)# define do_raw_write_lock (rwlock) do {__acquire(lock); arch_write_lock(&(rwlock)->raw_lock); } while (0) -# define do_raw_write_lock_flags (lock, flags) \ - do {__acquire(lock); arch_write_lock_flags(&(lock)->raw_lock, *(flags)); } while (0)# define do_raw_write_trylock (rwlock) arch_write_trylock(&(rwlock)->raw_lock)# define do_raw_write_unlock (rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0)#endif
include/linux/rwlock_api_smp.h +2 -4
@@ -157,8 +157,7 @@ static inline unsigned long __raw_read_lock_irqsave(rwlock_t *lock)local_irq_save (flags);preempt_disable ();rwlock_acquire_read (&lock->dep_map,0 ,0 , _RET_IP_); -LOCK_CONTENDED_FLAGS (lock, do_raw_read_trylock, do_raw_read_lock, - do_raw_read_lock_flags, &flags); +LOCK_CONTENDED (lock, do_raw_read_trylock, do_raw_read_lock);return flags; }
@@ -184,8 +183,7 @@ static inline unsigned long __raw_write_lock_irqsave(rwlock_t *lock)local_irq_save (flags);preempt_disable ();rwlock_acquire (&lock->dep_map,0 ,0 , _RET_IP_); -LOCK_CONTENDED_FLAGS (lock, do_raw_write_trylock, do_raw_write_lock, - do_raw_write_lock_flags, &flags); +LOCK_CONTENDED (lock, do_raw_write_trylock, do_raw_write_lock);return flags; }
include/linux/sched.h +29 -10
@@ -2038,7 +2038,7 @@ static inline int _cond_resched(void) { return 0; }#endif /* !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC) */ #define cond_resched () ({ \ - ___might_sleep(__FILE__, __LINE__, 0); \ + __might_resched(__FILE__, __LINE__, 0); \ _cond_resched(); \ })
@@ -2046,19 +2046,38 @@ extern int __cond_resched_lock(spinlock_t *lock);extern int __cond_resched_rwlock_read (rwlock_t *lock);extern int __cond_resched_rwlock_write (rwlock_t *lock); -#define cond_resched_lock (lock) ({ \ - ___might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET);\ - __cond_resched_lock(lock); \ +#define MIGHT_RESCHED_RCU_SHIFT 8 +#define MIGHT_RESCHED_PREEMPT_MASK ((1U << MIGHT_RESCHED_RCU_SHIFT) - 1) + +#ifndef CONFIG_PREEMPT_RT +/* +* Non RT kernels have an elevated preempt count due to the held lock, +* but are not allowed to be inside a RCU read side critical section +*/ +# define PREEMPT_LOCK_RESCHED_OFFSETS PREEMPT_LOCK_OFFSET +#else +/* +* spin/rw_lock() on RT implies rcu_read_lock(). The might_sleep() check in +* cond_resched*lock() has to take that into account because it checks for +* preempt_count() and rcu_preempt_depth(). +*/ +# define PREEMPT_LOCK_RESCHED_OFFSETS \ + (PREEMPT_LOCK_OFFSET + (1U << MIGHT_RESCHED_RCU_SHIFT)) +#endif + +#define cond_resched_lock (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ + __cond_resched_lock(lock); \ }) -#define cond_resched_rwlock_read (lock) ({ \ - __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \ - __cond_resched_rwlock_read(lock); \ +#define cond_resched_rwlock_read (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ + __cond_resched_rwlock_read(lock); \ }) -#define cond_resched_rwlock_write (lock) ({ \ - __might_sleep(__FILE__, __LINE__, PREEMPT_LOCK_OFFSET); \ - __cond_resched_rwlock_write(lock); \ +#define cond_resched_rwlock_write (lock) ({ \ + __might_resched(__FILE__, __LINE__, PREEMPT_LOCK_RESCHED_OFFSETS); \ + __cond_resched_rwlock_write(lock); \ })static inline void cond_resched_rcu (void )
include/linux/spinlock.h +0 -13
@@ -177,7 +177,6 @@ do { \#ifdef CONFIG_DEBUG_SPINLOCK extern void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock); -#define do_raw_spin_lock_flags (lock, flags) do_raw_spin_lock(lock)extern int do_raw_spin_trylock (raw_spinlock_t *lock); extern void do_raw_spin_unlock(raw_spinlock_t *lock) __releases(lock);#else
@@ -188,18 +187,6 @@ static inline void do_raw_spin_lock(raw_spinlock_t *lock) __acquires(lock)mmiowb_spin_lock (); } -#ifndef arch_spin_lock_flags -#define arch_spin_lock_flags (lock, flags) arch_spin_lock(lock) -#endif - -static inline void -do_raw_spin_lock_flags (raw_spinlock_t *lock,unsigned long *flags)__acquires (lock) -{ -__acquire (lock); -arch_spin_lock_flags (&lock->raw_lock, *flags); -mmiowb_spin_lock (); -} -static inline int do_raw_spin_trylock (raw_spinlock_t *lock) {int ret =arch_spin_trylock (&(lock)->raw_lock);
include/linux/spinlock_api_smp.h +0 -9
@@ -108,16 +108,7 @@ static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock)local_irq_save (flags);preempt_disable ();spin_acquire (&lock->dep_map,0 ,0 , _RET_IP_); -/* -* On lockdep we dont want the hand-coded irq-enable of -* do_raw_spin_lock_flags() code, because lockdep assumes -* that interrupts are not re-enabled during lock-acquire: -*/ -#ifdef CONFIG_LOCKDEP LOCK_CONTENDED (lock, do_raw_spin_trylock, do_raw_spin_lock); -#else -do_raw_spin_lock_flags (lock, &flags); -#endif return flags; }
include/linux/spinlock_up.h +0 -1
@@ -62,7 +62,6 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)#define arch_spin_is_locked (lock) ((void)(lock), 0)/* for sched/core.c and kernel_lock.c: */ # define arch_spin_lock (lock) do { barrier(); (void)(lock); } while (0) -# define arch_spin_lock_flags (lock, flags) do { barrier(); (void)(lock); } while (0)# define arch_spin_unlock (lock) do { barrier(); (void)(lock); } while (0)# define arch_spin_trylock (lock) ({ barrier(); (void)(lock); 1; })#endif /* DEBUG_SPINLOCK */
include/linux/syscalls.h +6 -1
@@ -58,6 +58,7 @@ struct mq_attr;struct compat_stat ;struct old_timeval32 ;struct robust_list_head ; +struct futex_waitv ;struct getcpu_cache ;struct old_linux_dirent ;struct perf_event_attr ;
@@ -610,7 +611,7 @@ asmlinkage long sys_waitid(int which, pid_t pid,asmlinkage long sys_set_tid_address (int __user *tidptr);asmlinkage long sys_unshare (unsigned long unshare_flags); -/* kernel/futex.c */ +/* kernel/futex/syscalls.c */ asmlinkage long sys_futex (u32 __user *uaddr,int op,u32 val,const struct __kernel_timespec __user *utime,u32 __user *uaddr2,u32 val3);
@@ -623,6 +624,10 @@ asmlinkage long sys_get_robust_list(int pid,asmlinkage long sys_set_robust_list (struct robust_list_head __user *head,size_t len); +asmlinkage long sys_futex_waitv (struct futex_waitv *waiters, +unsigned int nr_futexes,unsigned int flags, +struct __kernel_timespec __user *timeout,clockid_t clockid); +/* kernel/hrtimer.c */ asmlinkage long sys_nanosleep (struct __kernel_timespec __user *rqtp,struct __kernel_timespec __user *rmtp);
include/linux/ww_mutex.h +2 -13
@@ -28,12 +28,10 @@#ifndef CONFIG_PREEMPT_RT #define WW_MUTEX_BASE mutex#define ww_mutex_base_init (l,n,k) __mutex_init(l,n,k) -#define ww_mutex_base_trylock (l) mutex_trylock(l)#define ww_mutex_base_is_locked (b) mutex_is_locked((b))#else #define WW_MUTEX_BASE rt_mutex#define ww_mutex_base_init (l,n,k) __rt_mutex_init(l,n,k) -#define ww_mutex_base_trylock (l) rt_mutex_trylock(l)#define ww_mutex_base_is_locked (b) rt_mutex_base_is_locked(&(b)->rtmutex)#endif
@@ -339,17 +337,8 @@ ww_mutex_lock_slow_interruptible(struct ww_mutex *lock,extern void ww_mutex_unlock (struct ww_mutex *lock); -/** -* ww_mutex_trylock - tries to acquire the w/w mutex without acquire context -* @lock: mutex to lock -* -* Trylocks a mutex without acquire context, so no deadlock detection is -* possible. Returns 1 if the mutex has been acquired successfully, 0 otherwise. -*/ -static inline int __must_check ww_mutex_trylock (struct ww_mutex *lock) -{ -return ww_mutex_base_trylock (&lock->base); -} +extern int __must_check ww_mutex_trylock (struct ww_mutex *lock, +struct ww_acquire_ctx *ctx);/*** * ww_mutex_destroy - mark a w/w mutex unusable
include/uapi/asm-generic/unistd.h +4 -1
@@ -880,8 +880,11 @@ __SYSCALL(__NR_memfd_secret, sys_memfd_secret)#define __NR_process_mrelease 448 __SYSCALL(__NR_process_mrelease, sys_process_mrelease) +#define __NR_futex_waitv 449 +__SYSCALL(__NR_futex_waitv, sys_futex_waitv) +#undef __NR_syscalls -#define __NR_syscalls 449 +#define __NR_syscalls 450/* * 32 bit systems traditionally used different
include/uapi/linux/futex.h +25 -0
@@ -43,6 +43,31 @@#define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | \ FUTEX_PRIVATE_FLAG) +/* +* Flags to specify the bit length of the futex word for futex2 syscalls. +* Currently, only 32 is supported. +*/ +#define FUTEX_32 2 + +/* +* Max numbers of elements in a futex_waitv array +*/ +#define FUTEX_WAITV_MAX 128 + +/** +* struct futex_waitv - A waiter for vectorized wait +* @val: Expected value at uaddr +* @uaddr: User address to wait on +* @flags: Flags for this waiter +* @__reserved: Reserved member to preserve data alignment. Should be 0. +*/ +struct futex_waitv { +__u64 val; +__u64 uaddr; +__u32 flags; +__u32 __reserved; +}; +/* * Support for robust futexes: the kernel cleans up held futexes at * thread exit time.
kernel/Makefile +1 -1
@@ -59,7 +59,7 @@ obj-$(CONFIG_FREEZER) += freezer.o obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/ -obj-$(CONFIG_FUTEX) += futex.o +obj-$(CONFIG_FUTEX) += futex/ obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o obj-$(CONFIG_SMP) += smp.o ifneq ($(CONFIG_SMP),y)
kernel/futex.c deleted +0 -4272
2,331 lines not on this page · raw message
kernel/futex/core.c new file +1176 -0
1,176 lines not on this page · raw message
kernel/futex/futex.h new file +299 -0
299 lines not on this page · raw message
kernel/futex/pi.c new file +1233 -0
1,233 lines not on this page · raw message
kernel/futex/requeue.c new file +897 -0
897 lines not on this page · raw message
kernel/futex/syscalls.c new file +398 -0
398 lines not on this page · raw message
kernel/futex/waitwake.c new file +708 -0
708 lines not on this page · raw message
kernel/locking/mutex.c +56 -7
63 lines not on this page · raw message
kernel/locking/rwsem.c +40 -30
70 lines not on this page · raw message
kernel/locking/test-ww_mutex.c +66 -21
87 lines not on this page · raw message
kernel/sched/core.c +43 -24
67 lines not on this page · raw message
tools/testing/selftests/futex/functional/.gitignore +1 -0
Lines of this file are not shown. View the raw message.
tools/testing/selftests/futex/functional/Makefile +2 -1
Lines of this file are not shown. View the raw message.
tools/testing/selftests/futex/functional/futex_wait_timeout.c +20 -1
Lines of this file are not shown. View the raw message.
tools/testing/selftests/futex/functional/futex_wait_wouldblock.c +37 -4
41 lines not on this page · raw message
tools/testing/selftests/futex/functional/futex_waitv.c new file +237 -0
237 lines not on this page · raw message
tools/testing/selftests/futex/functional/run.sh +3 -0
Lines of this file are not shown. View the raw message.
tools/testing/selftests/futex/include/futex2test.h new file +22 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [GIT pull] locking/core for v5.16-rc1
The pull request you sent on Mon, 1 Nov 2021 02:15:59 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:15:59 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitlocking-core-2021-10-31
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/595b28fb0c8949463d8ec1e485f36d17c870ddb2
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
[GIT pull RESEND] x86/fpu for v5.16-rc1
In reply to Thomas GleixnerLinus,
please pull the latest x86/fpu branch from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-fpu-2021-11-01
up to: d7a9590f608d: Documentation/x86: Add documentation for using dynamic XSTATE features
x86/fpu updates:
- Cleanup of extable fixup handling to be more robust, which in turn allows to make the FPU exception fixups more robust as well.
- Change the return code for signal frame related failures from explicit error codes to a boolean fail/success as that's all what the calling code evaluates.
- A large refactoring of the FPU code to prepare for adding AMX support:
- Distangle the public header maze and remove especially the misnomed kitchen sink internal.h which is despite it's name included all over the place.
- Add a proper abstraction for the register buffer storage (struct fpstate) which allows to dynamically size the buffer at runtime by flipping the pointer to the buffer container from the default container which is embedded in task_struct::tread::fpu to a dynamically allocated container with a larger register buffer.
- Convert the code over to the new fpstate mechanism.
- Consolidate the KVM FPU handling by moving the FPU related code into the FPU core which removes the number of exports and avoids adding even more export when AMX has to be supported in KVM. This also removes duplicated code which was of course unnecessary different and incomplete in the KVM copy.
- Simplify the KVM FPU buffer handling by utilizing the new fpstate container and just switching the buffer pointer from the user space buffer to the KVM guest buffer when entering vcpu_run() and flipping it back when leaving the function. This cuts the memory requirements of a vCPU for FPU buffers in half and avoids pointless memory copy operations.
This also solves the so far unresolved problem of adding AMX support because the current FPU buffer handling of KVM inflicted a circular dependency between adding AMX support to the core and to KVM. With the new scheme of switching fpstate AMX support can be added to the core code without affecting KVM.
- Replace various variables with proper data structures so the extra information required for adding dynamically enabled FPU features (AMX) can be added in one place
- Add AMX (Advanved Matrix eXtensions) support (finally):
AMX is a large XSTATE component which is going to be available with Saphire Rapids XEON CPUs. The feature comes with an extra MSR (MSR_XFD) which allows to trap the (first) use of an AMX related instruction, which has two benefits:
1) It allows the kernel to control access to the feature
2) It allows the kernel to dynamically allocate the large register state buffer instead of burdening every task with the the extra 8K or larger state storage.
It would have been great to gain this kind of control already with AVX512.
The support comes with the following infrastructure components:
1) arch_prctl() to
- read the supported features (equivalent to XGETBV(0))
- read the permitted features for a task
- request permission for a dynamically enabled feature
Permission is granted per process, inherited on fork() and cleared on exec(). The permission policy of the kernel is restricted to sigaltstack size validation, but the syscall obviously allows further restrictions via seccomp etc.
2) A stronger sigaltstack size validation for sys_sigaltstack(2) which takes granted permissions and the potentially resulting larger signal frame into account. This mechanism can also be used to enforce factual sigaltstack validation independent of dynamic features to help with finding potential victims of the 2K sigaltstack size constant which is broken since AVX512 support was added.
3) Exception handling for #NM traps to catch first use of a extended feature via a new cause MSR. If the exception was caused by the use of such a feature, the handler checks permission for that feature. If permission has not been granted, the handler sends a SIGILL like the #UD handler would do if the feature would have been disabled in XCR0. If permission has been granted, then a new fpstate which fits the larger buffer requirement is allocated.
In the unlikely case that this allocation fails, the handler sends SIGSEGV to the task. That's not elegant, but unavoidable as the other discussed options of preallocation or full per task permissions come with their own set of horrors for kernel and/or userspace. So this is the lesser of the evils and SIGSEGV caused by unexpected memory allocation failures is not a fundamentally new concept either.
When allocation succeeds, the fpstate properties are filled in to reflect the extended feature set and the resulting sizes, the fpu::fpstate pointer is updated accordingly and the trap is disarmed for this task permanently.
4) Enumeration and size calculations
5) Trap switching via MSR_XFD
The XFD (eXtended Feature Disable) MSR is context switched with the same life time rules as the FPU register state itself. The mechanism is keyed off with a static key which is default disabled so !AMX equipped CPUs have zero overhead. On AMX enabled CPUs the overhead is limited by comparing the tasks XFD value with a per CPU shadow variable to avoid redundant MSR writes. In case of switching from a AMX using task to a non AMX using task or vice versa, the extra MSR write is obviously inevitable.
All other places which need to be aware of the variable feature sets and resulting variable sizes are not affected at all because they retrieve the information (feature set, sizes) unconditonally from the fpstate properties.
6) Enable the new AMX states
Note, this is relatively new code despite the fact that AMX support is in the works for more than a year now.
The big refactoring of the FPU code, which allowed to do a proper integration has been started exactly 3 weeks ago. Refactoring of the existing FPU code and of the original AMX patches took a week and has been subject to extensive review and testing. The only fallout which has not been caught in review and testing right away was restricted to AMX enabled systems, which is completely irrelevant for anyone outside Intel and their early access program. There might be dragons lurking as usual, but so far the fine grained refactoring has held up and eventual yet undetected fallout is bisectable and should be easily addressable before the 5.16 release. Famous last words...
Many thanks to Chang Bae and Dave Hansen for working hard on this and also to the various test teams at Intel who reserved extra capacity to follow the rapid development of this closely which provides the confidence level required to offer this rather large update for inclusion into 5.16-rc1.
Note: There is a minor merge conflict versus ras/core which is sent to you by Borislav (whatever you merge first). A reference resolution is here:
https://tglx.de/~tglx/res-ras-fpu.diff
Thanks,
tglx
------------------>
Anders Roxell (1):
x86/fpu/signal: Fix missed conversion to correct boolean retval in save_xstate_epilog()
Chang S. Bae (18):
x86/fpu/xstate: Provide xstate_calculate_size()
x86/arch_prctl: Add controls for dynamic XSTATE components x86/fpu/signal: Prepare for variable sigframe length
x86/fpu: Reset permission and fpstate on exec()
x86/cpufeatures: Add eXtended Feature Disabling (XFD) feature bit x86/msr-index: Add MSRs for XFD
x86/fpu: Add XFD state to fpstate
x86/fpu: Update XFD state where required
x86/fpu/xstate: Add XFD #NM handler
x86/fpu/xstate: Add fpstate_realloc()/free()
x86/fpu/xstate: Prepare XSAVE feature table for gaps in state component numbers x86/fpu/amx: Define AMX state components and have it used for boot-time checks x86/fpu: Calculate the default sizes independently
x86/fpu: Add XFD handling for dynamic states
x86/fpu/amx: Enable the AMX feature in 64-bit mode selftests/x86/amx: Add test cases for AMX state management selftests/x86/amx: Add context switch test
Documentation/x86: Add documentation for using dynamic XSTATE features
Stephen Rothwell (1):
x86/fpu: Include vmalloc.h for vzalloc()
Thomas Gleixner (90):
x86/extable: Tidy up redundant handler functions
x86/extable: Get rid of redundant macros
x86/mce: Deduplicate exception handling
x86/mce: Get rid of stray semicolons
x86/extable: Rework the exception table mechanics
x86/extable: Provide EX_TYPE_DEFAULT_MCE_SAFE and EX_TYPE_FAULT_MCE_SAFE x86/copy_mc: Use EX_TYPE_DEFAULT_MCE_SAFE for exception fixups x86/fpu: Use EX_TYPE_FAULT_MCE_SAFE for exception fixups x86/extable: Remove EX_TYPE_FAULT from MCE safe fixups x86/fpu/signal: Clarify exception handling in restore_fpregs_from_user() x86/fpu/signal: Move header zeroing out of xsave_to_user_sigframe() x86/fpu/signal: Move xstate clearing out of copy_fpregs_to_sigframe() x86/fpu/signal: Change return type of copy_fpstate_to_sigframe() to boolean x86/fpu/signal: Change return type of copy_fpregs_to_sigframe() helpers to boolean x86/signal: Change return type of restore_sigcontext() to boolean x86/fpu/signal: Change return type of fpu__restore_sig() to boolean x86/fpu/signal: Change return type of __fpu_restore_sig() to boolean x86/fpu/signal: Change return code of check_xstate_in_sigframe() to boolean x86/fpu/signal: Change return code of restore_fpregs_from_user() to boolean x86/fpu: Remove pointless argument from switch_fpu_finish()
x86/fpu: Update stale comments
x86/pkru: Remove useless include
x86/fpu: Restrict xsaves()/xrstors() to independent states
x86/fpu: Cleanup the on_boot_cpu clutter
x86/fpu: Remove pointless memset in fpu_clone()
x86/process: Clone FPU in copy_thread()
x86/fpu: Do not inherit FPU context for kernel and IO worker threads x86/fpu: Cleanup xstate xcomp_bv initialization
x86/fpu/xstate: Provide and use for_each_xfeature()
x86/fpu/xstate: Mark all init only functions __init
x86/fpu: Move KVMs FPU swapping to FPU core
x86/fpu: Replace KVMs home brewed FPU copy from user
x86/fpu: Rework copy_xstate_to_uabi_buf()
x86/fpu: Mark fpu__init_prepare_fx_sw_frame() as __init
x86/fpu: Move context switch and exit to user inlines into sched.h x86/fpu: Clean up CPU feature tests
x86/fpu: Make os_xrstor_booting() private
x86/fpu: Move os_xsave() and os_xrstor() to core
x86/fpu: Move legacy ASM wrappers to core
x86/fpu: Make WARN_ON_FPU() private
x86/fpu: Move fpregs_restore_userregs() to core
x86/fpu: Move mxcsr related code to core
x86/fpu: Move fpstate functions to api.h
x86/fpu: Remove internal.h dependency from fpu/signal.h
x86/sev: Include fpu/xcr.h
x86/fpu: Mop up the internal.h leftovers
x86/fpu: Replace the includes of fpu/internal.h
x86/fpu: Provide a proper function for ex_handler_fprestore() x86/fpu: Replace KVMs home brewed FPU copy to user
x86/fpu: Provide struct fpstate
x86/fpu: Convert fpstate_init() to struct fpstate
x86/fpu: Convert restore_fpregs_from_fpstate() to struct fpstate x86/fpu: Replace KVMs xstate component clearing
x86/KVM: Convert to fpstate
x86/fpu: Convert tracing to fpstate
x86/fpu/regset: Convert to fpstate
x86/fpu/signal: Convert to fpstate
x86/fpu/core: Convert to fpstate
x86/math-emu: Convert to fpstate
x86/fpu: Remove fpu::state
x86/fpu: Do not leak fpstate pointer on fork
x86/process: Move arch_thread_struct_whitelist() out of line x86/fpu: Add size and mask information to fpstate
x86/fpu: Use fpstate::size
x86/fpu/xstate: Use fpstate for os_xsave()
x86/fpu/xstate: Use fpstate for xsave_to_user_sigframe()
x86/fpu: Use fpstate in fpu_copy_kvm_uabi_to_fpstate()
x86/fpu: Use fpstate in __copy_xstate_to_uabi_buf()
x86/fpu/xstate: Use fpstate for copy_uabi_to_xstate() x86/fpu/signal: Use fpstate for size and features
x86/fpu: Provide struct fpu_config
x86/fpu: Cleanup fpu__init_system_xstate_size_legacy() x86/fpu/xstate: Cleanup size calculations
x86/fpu: Move xstate size to fpu_*_cfg
x86/fpu: Move xstate feature masks to fpu_*_cfg
x86/fpu: Mop up xfeatures_mask_uabi()
x86/fpu: Rework restore_regs_from_fpstate()
x86/fpu/xstate: Move remaining xfeature helpers to core
x86/fpu: Prepare for sanitizing KVM FPU code
x86/fpu: Provide infrastructure for KVM FPU cleanup
x86/kvm: Convert FPU handling to a single swap buffer
x86/fpu: Remove old KVM FPU interface
signal: Add an optional check for altstack size
x86/signal: Implement sigaltstack size validation
x86/fpu: Add members to struct fpu to cache permission information x86/fpu: Add fpu_state_config::legacy_features
x86/fpu: Add basic helpers for dynamically enabled features x86/signal: Use fpu::__state_user_size for sigalt stack validation x86/fpu: Prepare fpu_clone() for dynamically enabled features x86/fpu: Add sanity checks for XFD
Documentation/admin-guide/kernel-parameters.txt | 9 + Documentation/x86/index.rst | 1 + Documentation/x86/xstate.rst | 65 ++ arch/Kconfig | 3 + arch/x86/Kconfig | 17 + arch/x86/events/perf_event.h | 1 + arch/x86/ia32/ia32_signal.c | 15 +- arch/x86/include/asm/asm.h | 50 +- arch/x86/include/asm/cpufeatures.h | 2 + arch/x86/include/asm/extable.h | 44 +- arch/x86/include/asm/extable_fixup_types.h | 22 + arch/x86/include/asm/fpu/api.h | 58 +- arch/x86/include/asm/fpu/internal.h | 540 -------------- arch/x86/include/asm/fpu/sched.h | 68 ++ arch/x86/include/asm/fpu/signal.h | 13 +- arch/x86/include/asm/fpu/types.h | 214 +++++- arch/x86/include/asm/fpu/xcr.h | 11 - arch/x86/include/asm/fpu/xstate.h | 90 +-- arch/x86/include/asm/kvm_host.h | 7 +- arch/x86/include/asm/msr-index.h | 2 + arch/x86/include/asm/msr.h | 4 +- arch/x86/include/asm/pkru.h | 2 +- arch/x86/include/asm/processor.h | 9 +- arch/x86/include/asm/proto.h | 2 +- arch/x86/include/asm/segment.h | 2 +- arch/x86/include/asm/trace/fpu.h | 4 +- arch/x86/include/uapi/asm/prctl.h | 4 + arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/cpu/cpuid-deps.c | 2 + arch/x86/kernel/cpu/mce/core.c | 40 +- arch/x86/kernel/cpu/mce/internal.h | 14 +- arch/x86/kernel/cpu/mce/severity.c | 22 +- arch/x86/kernel/fpu/bugs.c | 2 +- arch/x86/kernel/fpu/context.h | 83 +++ arch/x86/kernel/fpu/core.c | 392 +++++++++-- arch/x86/kernel/fpu/init.c | 76 +- arch/x86/kernel/fpu/internal.h | 28 + arch/x86/kernel/fpu/legacy.h | 115 +++ arch/x86/kernel/fpu/regset.c | 36 +- arch/x86/kernel/fpu/signal.c | 285 ++++---- arch/x86/kernel/fpu/xstate.c | 898 +++++++++++++++++++----- arch/x86/kernel/fpu/xstate.h | 278 ++++++++ arch/x86/kernel/process.c | 27 +- arch/x86/kernel/process_32.c | 5 +- arch/x86/kernel/process_64.c | 5 +- arch/x86/kernel/ptrace.c | 2 +- arch/x86/kernel/sev.c | 2 +- arch/x86/kernel/signal.c | 83 ++- arch/x86/kernel/smpboot.c | 2 +- arch/x86/kernel/traps.c | 40 +- arch/x86/kvm/svm/sev.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +- arch/x86/kvm/vmx/vmx.c | 2 +- arch/x86/kvm/x86.c | 258 +------ arch/x86/lib/copy_mc_64.S | 8 +- arch/x86/math-emu/fpu_aux.c | 2 +- arch/x86/math-emu/fpu_entry.c | 6 +- arch/x86/math-emu/fpu_system.h | 2 +- arch/x86/mm/extable.c | 135 ++-- arch/x86/net/bpf_jit_comp.c | 11 +- arch/x86/power/cpu.c | 2 +- include/linux/signal.h | 6 + kernel/signal.c | 35 +- scripts/sorttable.c | 4 +- tools/testing/selftests/x86/Makefile | 2 +- tools/testing/selftests/x86/amx.c | 851 ++++++++++++++++++++++ 67 files changed, 3458 insertions(+), 1575 deletions(-) create mode 100644 Documentation/x86/xstate.rst create mode 100644 arch/x86/include/asm/extable_fixup_types.h create mode 100644 arch/x86/include/asm/fpu/sched.h create mode 100644 arch/x86/kernel/fpu/context.h create mode 100644 arch/x86/kernel/fpu/internal.h create mode 100644 arch/x86/kernel/fpu/legacy.h create mode 100644 arch/x86/kernel/fpu/xstate.h create mode 100644 tools/testing/selftests/x86/amx.c
Documentation/admin-guide/kernel-parameters.txt +9 -0
@@ -5497,6 +5497,15 @@ stifb= [HW] Format: bpp:<bpp1>[:<bpp2>[:<bpp3>...]] + strict_sas_size= + [X86] + Format: <bool> + Enable or disable strict sigaltstack size checks + against the required signal frame size which + depends on the supported FPU features. This can + be used to filter out binaries which have + not yet been made aware of AT_MINSIGSTKSZ. + sunrpc.min_resvport= sunrpc.max_resvport= [NFS,SUNRPC]
Documentation/x86/index.rst +1 -0
@@ -37,3 +37,4 @@ x86-specific Documentation sgx features elf_auxvec + xstate
Documentation/x86/xstate.rst new file +65 -0
65 lines not on this page · raw message
arch/Kconfig +3 -0
@@ -1288,6 +1288,9 @@ config ARCH_HAS_ELFCORE_COMPAT config ARCH_HAS_PARANOID_L1D_FLUSH bool +config DYNAMIC_SIGFRAME + bool + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig"
arch/x86/Kconfig +17 -0
@@ -125,6 +125,7 @@ config X86 select CLOCKSOURCE_VALIDATE_LAST_CYCLE select CLOCKSOURCE_WATCHDOG select DCACHE_WORD_ACCESS + select DYNAMIC_SIGFRAME select EDAC_ATOMIC_SCRUB select EDAC_SUPPORT select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC)
@@ -2388,6 +2389,22 @@ config MODIFY_LDT_SYSCALL Saying 'N' here may make sense for embedded or server kernels. +config STRICT_SIGALTSTACK_SIZE + bool "Enforce strict size checking for sigaltstack" + depends on DYNAMIC_SIGFRAME + help + For historical reasons MINSIGSTKSZ is a constant which became + already too small with AVX512 support. Add a mechanism to + enforce strict checking of the sigaltstack size against the + real size of the FPU frame. This option enables the check + by default. It can also be controlled via the kernel command + line option 'strict_sas_size' independent of this config + switch. Enabling it might break existing applications which + allocate a too small sigaltstack but 'work' because they + never get a signal delivered. + + Say 'N' unless you want to really enforce this check. + source "kernel/livepatch/Kconfig" endmenu
arch/x86/events/perf_event.h +1 -0
@@ -14,6 +14,7 @@#include <linux/perf_event.h> +#include <asm/fpu/xstate.h> #include <asm/intel_ds.h> #include <asm/cpu.h>
arch/x86/ia32/ia32_signal.c +7 -8
@@ -24,7 +24,6 @@#include <linux/syscalls.h> #include <asm/ucontext.h> #include <linux/uaccess.h> -#include <asm/fpu/internal.h> #include <asm/fpu/signal.h> #include <asm/ptrace.h> #include <asm/ia32_unistd.h>
@@ -57,8 +56,8 @@ static inline void reload_segments(struct sigcontext_32 *sc)/* * Do a signal return; undo the signal stack. */ -static int ia32_restore_sigcontext (struct pt_regs *regs, -struct sigcontext_32 __user *usc) +static bool ia32_restore_sigcontext (struct pt_regs *regs, +struct sigcontext_32 __user *usc) {struct sigcontext_32 sc;
@@ -66,7 +65,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs, current->restart_block.fn = do_no_restart_syscall;if (unlikely (copy_from_user (&sc, usc,sizeof (sc)))) -return -EFAULT ; +return false;/* Get only the ia32 registers. */ regs->bx = sc.bx;
@@ -111,7 +110,7 @@ COMPAT_SYSCALL_DEFINE0(sigreturn)set_current_blocked (&set); -if (ia32_restore_sigcontext (regs, &frame->sc)) +if (!ia32_restore_sigcontext (regs, &frame->sc)) goto badframe;return regs->ax;
@@ -135,7 +134,7 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn)set_current_blocked (&set); -if (ia32_restore_sigcontext (regs, &frame->uc.uc_mcontext)) +if (!ia32_restore_sigcontext (regs, &frame->uc.uc_mcontext)) goto badframe;if (compat_restore_altstack (&frame->uc.uc_stack))
@@ -220,8 +219,8 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, sp =fpu__alloc_mathframe (sp,1 , &fx_aligned, &math_size); *fpstate = (struct _fpstate_32 __user *) sp; -if (copy_fpstate_to_sigframe (*fpstate, (void __user *)fx_aligned, - math_size) <0 ) +if (!copy_fpstate_to_sigframe (*fpstate, (void __user *)fx_aligned, + math_size))return (void __user *)-1L ; sp -= frame_size;
arch/x86/include/asm/asm.h +20 -30
81 lines not on this page · raw message
arch/x86/include/asm/cpufeatures.h +2 -0
@@ -277,6 +277,7 @@#define X86_FEATURE_XSAVEC (10*32+ 1)/* XSAVEC instruction */ #define X86_FEATURE_XGETBV1 (10*32+ 2)/* XGETBV with ECX = 1 instruction */ #define X86_FEATURE_XSAVES (10*32+ 3)/* XSAVES/XRSTORS instructions */ +#define X86_FEATURE_XFD (10*32+ 4)/* "" eXtended Feature Disabling */ /* * Extended auxiliary flags: Linux defined - for features scattered in various
@@ -298,6 +299,7 @@/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4)/* AVX VNNI instructions */ #define X86_FEATURE_AVX512_BF16 (12*32+ 5)/* AVX512 BFLOAT16 instructions */ +#define X86_FEATURE_AMX_TILE (18*32+24)/* AMX tile Support */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */
arch/x86/include/asm/extable.h +28 -16
68 lines not on this page · raw message
arch/x86/include/asm/extable_fixup_types.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_EXTABLE_FIXUP_TYPES_H +#define _ASM_X86_EXTABLE_FIXUP_TYPES_H + +#define EX_TYPE_NONE 0 +#define EX_TYPE_DEFAULT 1 +#define EX_TYPE_FAULT 2 +#define EX_TYPE_UACCESS 3 +#define EX_TYPE_COPY 4 +#define EX_TYPE_CLEAR_FS 5 +#define EX_TYPE_FPU_RESTORE 6 +#define EX_TYPE_WRMSR 7 +#define EX_TYPE_RDMSR 8 +#define EX_TYPE_BPF 9 + +#define EX_TYPE_WRMSR_IN_MCE 10 +#define EX_TYPE_RDMSR_IN_MCE 11 + +#define EX_TYPE_DEFAULT_MCE_SAFE 12 +#define EX_TYPE_FAULT_MCE_SAFE 13 + +#endif
arch/x86/include/asm/fpu/api.h +56 -2
75 lines not on this page · raw message
arch/x86/include/asm/fpu/internal.h +0 -540
540 lines not on this page · raw message
arch/x86/include/asm/fpu/sched.h new file +68 -0
68 lines not on this page · raw message
arch/x86/include/asm/fpu/signal.h +12 -1
@@ -5,6 +5,11 @@#ifndef _ASM_X86_FPU_SIGNAL_H#define _ASM_X86_FPU_SIGNAL_H +#include <linux/compat.h> +#include <linux/user.h> + +#include <asm/fpu/types.h> +#ifdef CONFIG_X86_64 # include <uapi/asm/sigcontext.h> # include <asm/user32.h>
@@ -31,6 +36,12 @@ fpu__alloc_mathframe(unsigned long sp, int ia32_frame,unsigned long fpu__get_fpstate_size (void ); -extern void fpu__init_prepare_fx_sw_frame (void ); +extern bool copy_fpstate_to_sigframe (void __user *buf,void __user *fp,int size); +extern void fpu__clear_user_states (struct fpu *fpu); +extern bool fpu__restore_sig (void __user *buf,int ia32_frame); + +extern void restore_fpregs_from_fpstate (struct fpstate *fpstate,u64 mask); + +extern bool copy_fpstate_to_sigframe (void __user *buf,void __user *fp,int size);#endif /* _ASM_X86_FPU_SIGNAL_H */
arch/x86/include/asm/fpu/types.h +206 -8
261 lines not on this page · raw message
arch/x86/include/asm/fpu/xcr.h +0 -11
@@ -2,17 +2,6 @@#ifndef _ASM_X86_FPU_XCR_H#define _ASM_X86_FPU_XCR_H -/* -* MXCSR and XCR definitions: -*/ - -static inline void ldmxcsr (u32 mxcsr) -{ - asmvolatile ("ldmxcsr %0" ::"m" (mxcsr)); -} - -extern unsigned int mxcsr_feature_mask; -#define XCR_XFEATURE_ENABLED_MASK 0x00000000static inline u64 xgetbv (u32 index)
arch/x86/include/asm/fpu/xstate.h +30 -60
127 lines not on this page · raw message
arch/x86/include/asm/kvm_host.h +2 -5
@@ -691,11 +691,10 @@ struct kvm_vcpu_arch {* * Note that while the PKRU state lives inside the fpu registers, * it is switched out separately at VMENTER and VMEXIT time. The -* "guest_fpu" state here contains the guest FPU context, with the +* "guest_fpstate" state here contains the guest FPU context, with the * host PRKU bits. */ -struct fpu *user_fpu; -struct fpu *guest_fpu; +struct fpu_guest guest_fpu;u64 xcr0;u64 guest_supported_xcr0;
@@ -1685,8 +1684,6 @@ void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);int kvm_task_switch (struct kvm_vcpu *vcpu,u16 tss_selector,int idt_index,int reason,bool has_error_code,u32 error_code); -void kvm_free_guest_fpu (struct kvm_vcpu *vcpu); -void kvm_post_set_cr0 (struct kvm_vcpu *vcpu,unsigned long old_cr0,unsigned long cr0);void kvm_post_set_cr4 (struct kvm_vcpu *vcpu,unsigned long old_cr4,unsigned long cr4);int kvm_set_cr0 (struct kvm_vcpu *vcpu,unsigned long cr0);
arch/x86/include/asm/msr-index.h +2 -0
@@ -625,6 +625,8 @@#define MSR_IA32_BNDCFGS_RSVD 0x00000ffc +#define MSR_IA32_XFD 0x000001c4 +#define MSR_IA32_XFD_ERR 0x000001c5#define MSR_IA32_XSS 0x00000da0#define MSR_IA32_APICBASE 0x0000001b
arch/x86/include/asm/msr.h +2 -2
@@ -92,7 +92,7 @@ static __always_inline unsigned long long __rdmsr(unsigned int msr) asm volatile("1: rdmsr\n" "2:\n" - _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe) + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_RDMSR) : EAX_EDX_RET(val, low, high) : "c" (msr));return EAX_EDX_VAL (val, low, high);
@@ -102,7 +102,7 @@ static __always_inline void __wrmsr(unsigned int msr, u32 low, u32 high) { asm volatile("1: wrmsr\n" "2:\n" - _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_unsafe) + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR) : : "c" (msr), "a"(low), "d" (high) : "memory"); }
arch/x86/include/asm/pkru.h +1 -1
@@ -2,7 +2,7 @@#ifndef _ASM_X86_PKRU_H#define _ASM_X86_PKRU_H -#include <asm/fpu/xstate.h> +#include <asm/cpufeature.h> #define PKRU_AD_BIT 0x1#define PKRU_WD_BIT 0x2
arch/x86/include/asm/processor.h +3 -6
@@ -461,9 +461,6 @@ DECLARE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); DECLARE_PER_CPU(struct irq_stack *, softirq_stack_ptr);#endif /* !X86_64 */ -extern unsigned int fpu_kernel_xstate_size; -extern unsigned int fpu_user_xstate_size; -struct perf_event ;struct thread_struct {
@@ -537,12 +534,12 @@ struct thread_struct {*/ }; -/* Whitelist the FPU state from the task_struct for hardened usercopy. */ +extern void fpu_thread_struct_whitelist (unsigned long *offset,unsigned long *size); +static inline void arch_thread_struct_whitelist (unsigned long *offset,unsigned long *size) { - *offset = offsetof(struct thread_struct, fpu.state); - *size = fpu_kernel_xstate_size; +fpu_thread_struct_whitelist (offset, size); } static inline void
arch/x86/include/asm/proto.h +1 -1
@@ -40,6 +40,6 @@ void x86_report_nx(void);extern int reboot_force;long do_arch_prctl_common (struct task_struct *task,int option, -unsigned long cpuid_enabled); +unsigned long arg2);#endif /* _ASM_X86_PROTO_H */
arch/x86/include/asm/segment.h +1 -1
@@ -339,7 +339,7 @@ static inline void __loadsegment_fs(unsigned short value) "1: movw %0, %%fs \n" "2: \n" - _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_clear_fs) + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_CLEAR_FS) : : "rm" (value) : "memory"); }
arch/x86/include/asm/trace/fpu.h +2 -2
@@ -22,8 +22,8 @@ DECLARE_EVENT_CLASS(x86_fpu, __entry->fpu = fpu; __entry->load_fpu =test_thread_flag (TIF_NEED_FPU_LOAD );if (boot_cpu_has (X86_FEATURE_OSXSAVE )) { - __entry->xfeatures = fpu->state.xsave.header.xfeatures; - __entry->xcomp_bv = fpu->state.xsave.header.xcomp_bv; + __entry->xfeatures = fpu->fpstate->regs.xsave.header.xfeatures; + __entry->xcomp_bv = fpu->fpstate->regs.xsave.header.xcomp_bv; } ), TP_printk("x86/fpu: %p load: %d xfeatures: %llx xcomp_bv: %llx",
arch/x86/include/uapi/asm/prctl.h +4 -0
@@ -10,6 +10,10 @@#define ARCH_GET_CPUID 0x1011#define ARCH_SET_CPUID 0x1012 +#define ARCH_GET_XCOMP_SUPP 0x1021 +#define ARCH_GET_XCOMP_PERM 0x1022 +#define ARCH_REQ_XCOMP_PERM 0x1023 +#define ARCH_MAP_VDSO_X32 0x2001#define ARCH_MAP_VDSO_32 0x2002#define ARCH_MAP_VDSO_64 0x2003
arch/x86/kernel/cpu/bugs.c +1 -1
@@ -22,7 +22,7 @@#include <asm/bugs.h> #include <asm/processor.h> #include <asm/processor-flags.h> -#include <asm/fpu/internal.h> +#include <asm/fpu/api.h> #include <asm/msr.h> #include <asm/vmx.h> #include <asm/paravirt.h>
arch/x86/kernel/cpu/common.c +1 -1
@@ -42,7 +42,7 @@#include <asm/setup.h> #include <asm/apic.h> #include <asm/desc.h> -#include <asm/fpu/internal.h> +#include <asm/fpu/api.h> #include <asm/mtrr.h> #include <asm/hwcap2.h> #include <linux/numa.h>
arch/x86/kernel/cpu/cpuid-deps.c +2 -0
@@ -75,6 +75,8 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_SGX_LC, X86_FEATURE_SGX }, { X86_FEATURE_SGX1, X86_FEATURE_SGX }, { X86_FEATURE_SGX2, X86_FEATURE_SGX1 }, + { X86_FEATURE_XFD, X86_FEATURE_XSAVES }, + { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD }, {} };
arch/x86/kernel/cpu/mce/core.c +11 -29
@@ -373,13 +373,16 @@ static int msr_to_offset(u32 msr)return -1 ; } -__visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup, -struct pt_regs *regs,int trapnr, -unsigned long error_code, -unsigned long fault_addr) +void ex_handler_msr_mce (struct pt_regs *regs,bool wrmsr) { -pr_emerg ("MSR access error: RDMSR from 0x%x at rIP: 0x%lx (%pS)\n" , - (unsigned int )regs->cx, regs->ip, (void *)regs->ip); +if (wrmsr) { +pr_emerg ("MSR access error: WRMSR to 0x%x (tried to write 0x%08x%08x) at rIP: 0x%lx (%pS)\n" , + (unsigned int )regs->cx, (unsigned int )regs->dx, (unsigned int )regs->ax, + regs->ip, (void *)regs->ip); + }else { +pr_emerg ("MSR access error: RDMSR from 0x%x at rIP: 0x%lx (%pS)\n" , + (unsigned int )regs->cx, regs->ip, (void *)regs->ip); + }show_stack_regs (regs);
@@ -387,8 +390,6 @@ __visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup,while (true)cpu_relax (); - -return true; }/* MSR access wrappers used for error injection */
@@ -420,32 +421,13 @@ static noinstr u64 mce_rdmsrl(u32 msr)*/ asm volatile("1: rdmsr\n" "2:\n" - _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_fault) + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_RDMSR_IN_MCE) : EAX_EDX_RET(val, low, high) : "c" (msr));return EAX_EDX_VAL (val, low, high); } -__visible bool ex_handler_wrmsr_fault(const struct exception_table_entry *fixup, -struct pt_regs *regs,int trapnr, -unsigned long error_code, -unsigned long fault_addr) -{ -pr_emerg ("MSR access error: WRMSR to 0x%x (tried to write 0x%08x%08x) at rIP: 0x%lx (%pS)\n" , - (unsigned int )regs->cx, (unsigned int )regs->dx, (unsigned int )regs->ax, - regs->ip, (void *)regs->ip); - -show_stack_regs (regs); - -panic ("MCA architectural violation!\n" ); - -while (true) -cpu_relax (); - -return true; -} - static noinstr void mce_wrmsrl(u32 msr, u64 v) {u32 low, high;
@@ -470,7 +452,7 @@ static noinstr void mce_wrmsrl(u32 msr, u64 v)/* See comment in mce_rdmsrl() */ asm volatile("1: wrmsr\n" "2:\n" - _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_fault) + _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR_IN_MCE) : : "c" (msr), "a"(low), "d" (high) : "memory"); }
arch/x86/kernel/cpu/mce/internal.h +2 -12
@@ -61,7 +61,7 @@ static inline void cmci_disable_bank(int bank) { }static inline void intel_init_cmci (void ) { }static inline void intel_init_lmce (void ) { }static inline void intel_clear_lmce (void ) { } -static inline bool intel_filter_mce (struct mce *m) {return false; }; +static inline bool intel_filter_mce (struct mce *m) {return false; }#endif void mce_timer_kick (unsigned long interval);
@@ -183,17 +183,7 @@ extern bool filter_mce(struct mce *m);#ifdef CONFIG_X86_MCE_AMD extern bool amd_filter_mce (struct mce *m);#else -static inline bool amd_filter_mce (struct mce *m) {return false; }; +static inline bool amd_filter_mce (struct mce *m) {return false; }#endif -__visible bool ex_handler_rdmsr_fault(const struct exception_table_entry *fixup, -struct pt_regs *regs,int trapnr, -unsigned long error_code, -unsigned long fault_addr); - -__visible bool ex_handler_wrmsr_fault(const struct exception_table_entry *fixup, -struct pt_regs *regs,int trapnr, -unsigned long error_code, -unsigned long fault_addr); -#endif /* __X86_MCE_INTERNAL_H__ */
arch/x86/kernel/cpu/mce/severity.c +11 -11
@@ -265,25 +265,25 @@ static bool is_copy_from_user(struct pt_regs *regs)*/ static int error_context (struct mce *m,struct pt_regs *regs) { -enum handler_type t; -if ((m->cs &3 ) ==3 )return IN_USER ;if (!mc_recoverable (m->mcgstatus))return IN_KERNEL ; - t =ex_get_fault_handler_type (m->ip); -if (t ==EX_HANDLER_FAULT ) { - m->kflags |=MCE_IN_KERNEL_RECOV ; -return IN_KERNEL_RECOV ; - } -if (t ==EX_HANDLER_UACCESS && regs &&is_copy_from_user (regs)) { - m->kflags |=MCE_IN_KERNEL_RECOV ; +switch (ex_get_fixup_type (m->ip)) { +case EX_TYPE_UACCESS : +case EX_TYPE_COPY : +if (!regs || !is_copy_from_user (regs)) +return IN_KERNEL ; m->kflags |=MCE_IN_KERNEL_COPYIN ; + fallthrough; +case EX_TYPE_FAULT_MCE_SAFE : +case EX_TYPE_DEFAULT_MCE_SAFE : + m->kflags |=MCE_IN_KERNEL_RECOV ;return IN_KERNEL_RECOV ; +default : +return IN_KERNEL ; } - -return IN_KERNEL ; }static int mce_severity_amd_smca (struct mce *m,enum context err_ctx)
arch/x86/kernel/fpu/bugs.c +1 -1
@@ -2,7 +2,7 @@/* * x86 FPU bug checks: */ -#include <asm/fpu/internal.h> +#include <asm/fpu/api.h> /* * Boot time CPU/FPU FDIV bug detection code:
arch/x86/kernel/fpu/context.h new file +83 -0
83 lines not on this page · raw message
arch/x86/kernel/fpu/core.c +315 -77
565 lines not on this page · raw message
arch/x86/kernel/fpu/init.c +34 -42
148 lines not on this page · raw message
arch/x86/kernel/fpu/internal.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __X86_KERNEL_FPU_INTERNAL_H +#define __X86_KERNEL_FPU_INTERNAL_H + +extern struct fpstate init_fpstate; + +/* CPU feature check wrappers */ +static __always_inline __pure bool use_xsave(void) +{ +return cpu_feature_enabled (X86_FEATURE_XSAVE ); +} + +static __always_inline __pure bool use_fxsr(void) +{ +return cpu_feature_enabled (X86_FEATURE_FXSR ); +} + +#ifdef CONFIG_X86_DEBUG_FPU +# define WARN_ON_FPU (x) WARN_ON_ONCE(x) +#else +# define WARN_ON_FPU (x) ({ (void)(x); 0; }) +#endif + +/* Used in init.c */ +extern void fpstate_init_user (struct fpstate *fpstate); +extern void fpstate_reset (struct fpu *fpu); + +#endif
arch/x86/kernel/fpu/legacy.h new file +115 -0
115 lines not on this page · raw message
arch/x86/kernel/fpu/regset.c +20 -16
@@ -5,10 +5,14 @@#include <linux/sched/task_stack.h> #include <linux/vmalloc.h> -#include <asm/fpu/internal.h> +#include <asm/fpu/api.h> #include <asm/fpu/signal.h> #include <asm/fpu/regset.h> -#include <asm/fpu/xstate.h> + +#include "context.h" +#include "internal.h" +#include "legacy.h" +#include "xstate.h" /* * The xstateregs_active() routine is the same as the regset_fpregs_active() routine,
@@ -74,8 +78,8 @@ int xfpregs_get(struct task_struct *target, const struct user_regset *regset,sync_fpstate (fpu);if (!use_xsave ()) { -return membuf_write (&to, &fpu->state.fxsave, -sizeof (fpu->state.fxsave)); +return membuf_write (&to, &fpu->fpstate->regs.fxsave, +sizeof (fpu->fpstate->regs.fxsave)); }copy_xstate_to_uabi_buf (to, target,XSTATE_COPY_FX );
@@ -110,15 +114,15 @@ int xfpregs_set(struct task_struct *target, const struct user_regset *regset,fpu_force_restore (fpu);/* Copy the state */ -memcpy (&fpu->state.fxsave, &newstate,sizeof (newstate)); +memcpy (&fpu->fpstate->regs.fxsave, &newstate,sizeof (newstate));/* Clear xmm8..15 */ -BUILD_BUG_ON (sizeof (fpu->state.fxsave.xmm_space) !=16 *16 ); -memset (&fpu->state.fxsave.xmm_space[8 ],0 ,8 *16 ); +BUILD_BUG_ON (sizeof (fpu->__fpstate.regs.fxsave.xmm_space) !=16 *16 ); +memset (&fpu->fpstate->regs.fxsave.xmm_space[8 ],0 ,8 *16 );/* Mark FP and SSE as in use when XSAVE is enabled */ if (use_xsave ()) - fpu->state.xsave.header.xfeatures |=XFEATURE_MASK_FPSSE ; + fpu->fpstate->regs.xsave.header.xfeatures |=XFEATURE_MASK_FPSSE ;return 0 ; }
@@ -149,7 +153,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,/* * A whole standard-format XSAVE buffer is needed: */ -if (pos !=0 || count != fpu_user_xstate_size) +if (pos !=0 || count != fpu_user_cfg.max_size)return -EFAULT ;if (!kbuf) {
@@ -164,7 +168,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset, }fpu_force_restore (fpu); - ret =copy_uabi_from_kernel_to_xstate (&fpu->state.xsave, kbuf ?: tmpbuf); + ret =copy_uabi_from_kernel_to_xstate (fpu->fpstate, kbuf ?: tmpbuf); out:vfree (tmpbuf);
@@ -283,7 +287,7 @@ static void __convert_from_fxsr(struct user_i387_ia32_struct *env,void convert_from_fxsr (struct user_i387_ia32_struct *env,struct task_struct *tsk) { -__convert_from_fxsr (env, tsk, &tsk->thread.fpu.state.fxsave); +__convert_from_fxsr (env, tsk, &tsk->thread.fpu.fpstate->regs.fxsave); } void convert_to_fxsr(struct fxregs_state *fxsave,
@@ -326,7 +330,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,return fpregs_soft_get (target, regset, to);if (!cpu_feature_enabled (X86_FEATURE_FXSR )) { -return membuf_write (&to, &fpu->state.fsave, +return membuf_write (&to, &fpu->fpstate->regs.fsave,sizeof (struct fregs_state )); }
@@ -337,7 +341,7 @@ int fpregs_get(struct task_struct *target, const struct user_regset *regset,copy_xstate_to_uabi_buf (mb, target,XSTATE_COPY_FP ); fx = &fxsave; }else { - fx = &fpu->state.fxsave; + fx = &fpu->fpstate->regs.fxsave; }__convert_from_fxsr (&env, target, fx);
@@ -366,16 +370,16 @@ int fpregs_set(struct task_struct *target, const struct user_regset *regset,fpu_force_restore (fpu);if (cpu_feature_enabled (X86_FEATURE_FXSR )) -convert_to_fxsr (&fpu->state.fxsave, &env); +convert_to_fxsr (&fpu->fpstate->regs.fxsave, &env);else -memcpy (&fpu->state.fsave, &env,sizeof (env)); +memcpy (&fpu->fpstate->regs.fsave, &env,sizeof (env));/* * Update the header bit in the xsave header, indicating the * presence of FP. */ if (cpu_feature_enabled (X86_FEATURE_XSAVE )) - fpu->state.xsave.header.xfeatures |=XFEATURE_MASK_FP ; + fpu->fpstate->regs.xsave.header.xfeatures |=XFEATURE_MASK_FP ;return 0 ; }
arch/x86/kernel/fpu/signal.c +145 -140
203 lines not on this page · raw message
arch/x86/kernel/fpu/xstate.c +712 -186
898 lines not on this page · raw message
arch/x86/kernel/fpu/xstate.h new file +278 -0
278 lines not on this page · raw message
arch/x86/kernel/signal.c +71 -12
83 lines not on this page · raw message
arch/x86/kvm/x86.c +31 -227
258 lines not on this page · raw message
arch/x86/mm/extable.c +56 -79
135 lines not on this page · raw message
tools/testing/selftests/x86/amx.c new file +851 -0
851 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [GIT pull RESEND] x86/fpu for v5.16-rc1
The pull request you sent on Mon, 1 Nov 2021 02:52:32 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:52:32 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitx86-fpu-2021-11-01
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/8cb1ae19bfae92def42c985417cd6e894ddaa047
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html
The pull request you sent on Mon, 1 Nov 2021 02:15:57 +0100 (CET):
The pull request you sent on Mon, 1 Nov 2021 02:15:57 +0100 (CET):
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitirq-core-2021-10-31
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5a47ebe98e6e5113ea8213d019a794d5851fbd46
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html