aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalvatore Bonaccorso <carnil@debian.org>2019-12-18 18:06:31 +0100
committerSalvatore Bonaccorso <carnil@debian.org>2019-12-18 22:50:21 +0100
commit102987a83771aa994821d4d982d06faa64c789e4 (patch)
tree3e5ab5206886ec297a1a97ce80f504d75468ed2f
parent479cb120ecb2b3f2c4d929a7b57860248d6f79bd (diff)
downloadkernel_replicant_linux-102987a83771aa994821d4d982d06faa64c789e4.tar.gz
kernel_replicant_linux-102987a83771aa994821d4d982d06faa64c789e4.tar.bz2
kernel_replicant_linux-102987a83771aa994821d4d982d06faa64c789e4.zip
[rt] Update to 5.4.3-rt1 and re-enable
Adjust for context changes due to backport of e66b39af00f4 ("workqueue: Fix pwq ref leak in rescuer_thread()") and def98c84b6cd ("workqueue: Fix spurious sanity check failures in destroy_workqueue()") in 5.4.4.
-rw-r--r--debian/changelog3
-rw-r--r--debian/config/defines2
-rw-r--r--debian/patches-rt/0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch16
-rw-r--r--debian/patches-rt/0001-cgroup-Remove-css_rstat_flush.patch117
-rw-r--r--debian/patches-rt/0001-hrtimer-Use-READ_ONCE-to-access-timer-base-in-hrimer.patch33
-rw-r--r--debian/patches-rt/0001-jbd2-Simplify-journal_unmap_buffer.patch58
-rw-r--r--debian/patches-rt/0001-mm-page_alloc-Split-drain_local_pages.patch57
-rw-r--r--debian/patches-rt/0001-printk-rb-add-printk-ring-buffer-documentation.patch2
-rw-r--r--debian/patches-rt/0001-workqueue-Don-t-assume-that-the-callback-has-interru.patch36
-rw-r--r--debian/patches-rt/0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch22
-rw-r--r--debian/patches-rt/0002-cgroup-Consolidate-users-of-cgroup_rstat_lock.patch69
-rw-r--r--debian/patches-rt/0002-hrtimer-Don-t-grab-the-expiry-lock-for-non-soft-hrti.patch31
-rw-r--r--debian/patches-rt/0002-jbd2-Remove-jbd_trylock_bh_state.patch31
-rw-r--r--debian/patches-rt/0002-mm-swap-Add-static-key-dependent-pagevec-locking.patch419
-rw-r--r--debian/patches-rt/0002-printk-rb-add-prb-locking-functions.patch4
-rw-r--r--debian/patches-rt/0002-sched-swait-Add-swait_event_lock_irq.patch (renamed from debian/patches-rt/sched-swait-Add-swait_event_lock_irq.patch)7
-rw-r--r--debian/patches-rt/0003-cgroup-Remove-may_sleep-from-cgroup_rstat_flush_lock.patch56
-rw-r--r--debian/patches-rt/0003-hrtimer-Prevent-using-hrtimer_grab_expiry_lock-on-mi.patch34
-rw-r--r--debian/patches-rt/0003-jbd2-Move-dropping-of-jh-reference-out-of-un-re-fili.patch151
-rw-r--r--debian/patches-rt/0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch114
-rw-r--r--debian/patches-rt/0003-mm-swap-Access-struct-pagevec-remotely.patch137
-rw-r--r--debian/patches-rt/0003-printk-rb-define-ring-buffer-struct-and-initializer.patch2
-rw-r--r--debian/patches-rt/0003-workqueue-Use-swait-for-wq_manager_wait.patch54
-rw-r--r--debian/patches-rt/0004-cgroup-Acquire-cgroup_rstat_lock-with-enabled-interr.patch72
-rw-r--r--debian/patches-rt/0004-jbd2-Drop-unnecessary-branch-from-jbd2_journal_forge.patch28
-rw-r--r--debian/patches-rt/0004-mm-SLUB-delay-giving-back-empty-slubs-to-IRQ-enabled.patch38
-rw-r--r--debian/patches-rt/0004-mm-swap-Enable-use_pvec_lock-nohz_full-dependent.patch57
-rw-r--r--debian/patches-rt/0004-printk-rb-add-writer-interface.patch2
-rw-r--r--debian/patches-rt/0004-workqueue-Convert-the-locks-to-raw-type.patch (renamed from debian/patches-rt/workqueue-Convert-the-locks-to-raw-type.patch)200
-rw-r--r--debian/patches-rt/0005-jbd2-Don-t-call-__bforget-unnecessarily.patch59
-rw-r--r--debian/patches-rt/0005-printk-rb-add-basic-non-blocking-reading-interface.patch2
-rw-r--r--debian/patches-rt/0006-jbd2-Make-state-lock-a-spinlock.patch676
-rw-r--r--debian/patches-rt/0006-printk-rb-add-blocking-reader-support.patch2
-rw-r--r--debian/patches-rt/0007-jbd2-Free-journal-head-outside-of-locked-region.patch89
-rw-r--r--debian/patches-rt/0007-printk-rb-add-functionality-required-by-printk.patch2
-rw-r--r--debian/patches-rt/0008-printk-add-ring-buffer-and-kthread.patch10
-rw-r--r--debian/patches-rt/0009-printk-remove-exclusive-console-hack.patch16
-rw-r--r--debian/patches-rt/0010-printk-redirect-emit-store-to-new-ringbuffer.patch18
-rw-r--r--debian/patches-rt/0011-printk_safe-remove-printk-safe-code.patch20
-rw-r--r--debian/patches-rt/0012-printk-minimize-console-locking-implementation.patch14
-rw-r--r--debian/patches-rt/0013-printk-track-seq-per-console.patch12
-rw-r--r--debian/patches-rt/0014-printk-do-boot_delay_msec-inside-printk_delay.patch8
-rw-r--r--debian/patches-rt/0015-printk-print-history-for-new-consoles.patch6
-rw-r--r--debian/patches-rt/0016-printk-implement-CON_PRINTBUFFER.patch14
-rw-r--r--debian/patches-rt/0017-printk-add-processor-number-to-output.patch20
-rw-r--r--debian/patches-rt/0018-console-add-write_atomic-interface.patch4
-rw-r--r--debian/patches-rt/0019-printk-introduce-emergency-messages.patch18
-rw-r--r--debian/patches-rt/0020-serial-8250-implement-write_atomic.patch150
-rw-r--r--debian/patches-rt/0021-printk-implement-KERN_CONT.patch10
-rw-r--r--debian/patches-rt/0022-printk-implement-dev-kmsg.patch14
-rw-r--r--debian/patches-rt/0023-printk-implement-syslog.patch14
-rw-r--r--debian/patches-rt/0024-printk-implement-kmsg_dump.patch24
-rw-r--r--debian/patches-rt/0025-printk-remove-unused-code.patch26
-rw-r--r--debian/patches-rt/ARM-Allow-to-enable-RT.patch22
-rw-r--r--debian/patches-rt/ARM-enable-irq-in-translation-section-permission-fau.patch8
-rw-r--r--debian/patches-rt/ARM64-Allow-to-enable-RT.patch22
-rw-r--r--debian/patches-rt/BPF-Disable-on-PREEMPT_RT.patch36
-rw-r--r--debian/patches-rt/Drivers-hv-vmbus-include-header-for-get_irq_regs.patch34
-rw-r--r--debian/patches-rt/KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch2
-rw-r--r--debian/patches-rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch8
-rw-r--r--debian/patches-rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch35
-rw-r--r--debian/patches-rt/POWERPC-Allow-to-enable-RT.patch22
-rw-r--r--debian/patches-rt/Use-CONFIG_PREEMPTION.patch1524
-rw-r--r--debian/patches-rt/add_migrate_disable.patch650
-rw-r--r--debian/patches-rt/apparmor-use-a-locallock-instead-preempt_disable.patch4
-rw-r--r--debian/patches-rt/arch-arm64-Add-lazy-preempt-support.patch39
-rw-r--r--debian/patches-rt/arm-disable-NEON-in-kernel-mode.patch55
-rw-r--r--debian/patches-rt/arm-enable-highmem-for-rt.patch12
-rw-r--r--debian/patches-rt/arm-highmem-flush-tlb-on-unmap.patch2
-rw-r--r--debian/patches-rt/arm-imx6-cpuidle-Use-raw_spinlock_t.patch43
-rw-r--r--debian/patches-rt/arm-include-definition-for-cpumask_t.patch2
-rw-r--r--debian/patches-rt/arm-preempt-lazy-support.patch8
-rw-r--r--debian/patches-rt/arm-remove-printk_nmi_.patch4
-rw-r--r--debian/patches-rt/arm64-KVM-compute_layout-before-altenates-are-applie.patch80
-rw-r--r--debian/patches-rt/arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch130
-rw-r--r--debian/patches-rt/arm64-preempt-Check-preemption-level-before-looking-.patch25
-rw-r--r--debian/patches-rt/arm64-preempt-Fixup-lazy-preempt.patch27
-rw-r--r--debian/patches-rt/at91_dont_enable_disable_clock.patch14
-rw-r--r--debian/patches-rt/block-Don-t-disable-interrupts-in-trigger_softirq.patch36
-rw-r--r--debian/patches-rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch103
-rw-r--r--debian/patches-rt/block-mq-don-t-complete-requests-via-IPI.patch6
-rw-r--r--debian/patches-rt/block-mq-drop-preempt-disable.patch8
-rw-r--r--debian/patches-rt/block-mq-use-cpu_light.patch30
-rw-r--r--debian/patches-rt/block-use-cpu-chill.patch4
-rw-r--r--debian/patches-rt/cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch44
-rw-r--r--debian/patches-rt/clocksource-tclib-allow-higher-clockrates.patch26
-rw-r--r--debian/patches-rt/completion-use-simple-wait-queues.patch59
-rw-r--r--debian/patches-rt/cond-resched-lock-rt-tweak.patch4
-rw-r--r--debian/patches-rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch2
-rw-r--r--debian/patches-rt/cpu-hotplug--Implement-CPU-pinning.patch109
-rw-r--r--debian/patches-rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch33
-rw-r--r--debian/patches-rt/cpumask-disable-offstack-on-rt.patch10
-rw-r--r--debian/patches-rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch60
-rw-r--r--debian/patches-rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch50
-rw-r--r--debian/patches-rt/crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch16
-rw-r--r--debian/patches-rt/crypto-limit-more-FPU-enabled-sections.patch6
-rw-r--r--debian/patches-rt/debugobjects-rt.patch6
-rw-r--r--debian/patches-rt/dma-buf-Use-seqlock_t-instread-disabling-preemption.patch173
-rw-r--r--debian/patches-rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch6
-rw-r--r--debian/patches-rt/drivers-tty-fix-omap-lock-crap.patch2
-rw-r--r--debian/patches-rt/drivers-tty-pl011-irq-disable-madness.patch6
-rw-r--r--debian/patches-rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch8
-rw-r--r--debian/patches-rt/drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch77
-rw-r--r--debian/patches-rt/drm-i915-Don-t-disable-interrupts-independently-of-t.patch65
-rw-r--r--debian/patches-rt/drm-i915-Drop-the-IRQ-off-asserts.patch22
-rw-r--r--debian/patches-rt/drm-i915-disable-tracing-on-RT.patch4
-rw-r--r--debian/patches-rt/drm-i915-skip-DRM_I915_LOW_LEVEL_TRACEPOINTS-with-NO.patch4
-rw-r--r--debian/patches-rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch20
-rw-r--r--debian/patches-rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch10
-rw-r--r--debian/patches-rt/efi-Allow-efi-runtime.patch8
-rw-r--r--debian/patches-rt/efi-Disable-runtime-services-on-RT.patch6
-rw-r--r--debian/patches-rt/epoll-use-get-cpu-light.patch2
-rw-r--r--debian/patches-rt/fs-aio-simple-simple-work.patch67
-rw-r--r--debian/patches-rt/fs-buffer-Make-BH_Uptodate_Lock-bit_spin_lock-a-regu.patch193
-rw-r--r--debian/patches-rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch8
-rw-r--r--debian/patches-rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch45
-rw-r--r--debian/patches-rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch22
-rw-r--r--debian/patches-rt/fs-jbd-replace-bh_state-lock.patch97
-rw-r--r--debian/patches-rt/fs-namespace-use-cpu-chill-in-trylock-loops.patch (renamed from debian/patches-rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch)30
-rw-r--r--debian/patches-rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch18
-rw-r--r--debian/patches-rt/fs-replace-bh_uptodate_lock-for-rt.patch185
-rw-r--r--debian/patches-rt/fscache-initialize-cookie-hash-table-raw-spinlocks.patch2
-rw-r--r--debian/patches-rt/ftrace-Fix-trace-header-alignment.patch46
-rw-r--r--debian/patches-rt/ftrace-migrate-disable-tracing.patch8
-rw-r--r--debian/patches-rt/futex-Delay-deallocation-of-pi_state.patch174
-rw-r--r--debian/patches-rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch43
-rw-r--r--debian/patches-rt/futex-Make-the-futex_hash_bucket-lock-raw.patch331
-rw-r--r--debian/patches-rt/futex-requeue-pi-fix.patch113
-rw-r--r--debian/patches-rt/futex-workaround-migrate_disable-enable-in-different.patch67
-rw-r--r--debian/patches-rt/genirq-disable-irqpoll-on-rt.patch10
-rw-r--r--debian/patches-rt/genirq-force-threading.patch46
-rw-r--r--debian/patches-rt/genirq-update-irq_set_irqchip_state-documentation.patch4
-rw-r--r--debian/patches-rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch96
-rw-r--r--debian/patches-rt/hotplug-light-get-online-cpus.patch89
-rw-r--r--debian/patches-rt/hrtimer-Add-a-missing-bracket-and-hide-migration_bas.patch66
-rw-r--r--debian/patches-rt/hrtimer-Allow-raw-wakeups-during-boot.patch34
-rw-r--r--debian/patches-rt/hrtimer-Introduce-expiry-spin-lock.patch103
-rw-r--r--debian/patches-rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch210
-rw-r--r--debian/patches-rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch271
-rw-r--r--debian/patches-rt/hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch4
-rw-r--r--debian/patches-rt/i2c-exynos5-Remove-IRQF_ONESHOT.patch39
-rw-r--r--debian/patches-rt/i2c-hix5hd2-Remove-IRQF_ONESHOT.patch33
-rw-r--r--debian/patches-rt/irqwork-push_most_work_into_softirq_context.patch20
-rw-r--r--debian/patches-rt/jump-label-rt.patch6
-rw-r--r--debian/patches-rt/kconfig-disable-a-few-options-rt.patch10
-rw-r--r--debian/patches-rt/kconfig-preempt-rt-full.patch59
-rw-r--r--debian/patches-rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch743
-rw-r--r--debian/patches-rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch23
-rw-r--r--debian/patches-rt/kmemleak-Change-the-lock-of-kmemleak_object-to-raw_s.patch272
-rw-r--r--debian/patches-rt/kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch56
-rw-r--r--debian/patches-rt/leds-trigger-disable-CPU-trigger-on-RT.patch4
-rw-r--r--debian/patches-rt/lib-smp_processor_id-Don-t-use-cpumask_equal.patch36
-rw-r--r--debian/patches-rt/lib-ubsan-Don-t-seralize-UBSAN-report.patch299
-rw-r--r--debian/patches-rt/list_bl-fixup-bogus-lockdep-warning.patch98
-rw-r--r--debian/patches-rt/list_bl.h-make-list-head-locking-RT-safe.patch32
-rw-r--r--debian/patches-rt/locallock-provide-get-put-_locked_ptr-variants.patch43
-rw-r--r--debian/patches-rt/localversion.patch4
-rw-r--r--debian/patches-rt/lockdep-disable-self-test.patch6
-rw-r--r--debian/patches-rt/lockdep-no-softirq-accounting-on-rt.patch10
-rw-r--r--debian/patches-rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch20
-rw-r--r--debian/patches-rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch4
-rw-r--r--debian/patches-rt/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch117
-rw-r--r--debian/patches-rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch2
-rw-r--r--debian/patches-rt/locking-lockdep-Don-t-complain-about-incorrect-name-.patch44
-rw-r--r--debian/patches-rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch4
-rw-r--r--debian/patches-rt/locking-rt-mutex-Flush-block-plug-on-__down_read.patch2
-rw-r--r--debian/patches-rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch8
-rw-r--r--debian/patches-rt/locking-rtmutex-Clean-pi_blocked_on-in-the-error-cas.patch92
-rw-r--r--debian/patches-rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch4
-rw-r--r--debian/patches-rt/md-disable-bcache.patch5
-rw-r--r--debian/patches-rt/md-raid5-percpu-handling-rt-aware.patch6
-rw-r--r--debian/patches-rt/mips-disable-highmem-on-rt.patch6
-rw-r--r--debian/patches-rt/mm-compaction-Disable-compact_unevictable_allowed-on.patch55
-rw-r--r--debian/patches-rt/mm-convert-swap-to-percpu-locked.patch200
-rw-r--r--debian/patches-rt/mm-disable-sloub-rt.patch23
-rw-r--r--debian/patches-rt/mm-enable-slub.patch8
-rw-r--r--debian/patches-rt/mm-make-vmstat-rt-aware.patch2
-rw-r--r--debian/patches-rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch8
-rw-r--r--debian/patches-rt/mm-memcontrol-do_not_disable_irq.patch24
-rw-r--r--debian/patches-rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch79
-rw-r--r--debian/patches-rt/mm-perform-lru_add_drain_all-remotely.patch103
-rw-r--r--debian/patches-rt/mm-protect-activate-switch-mm.patch72
-rw-r--r--debian/patches-rt/mm-rt-kmap-atomic-scheduling.patch38
-rw-r--r--debian/patches-rt/mm-scatterlist-dont-disable-irqs-on-RT.patch4
-rw-r--r--debian/patches-rt/mm-swap-Enable-use-pvec-lock-on-RT.patch42
-rw-r--r--debian/patches-rt/mm-vmalloc-remove-preempt_disable-enable-when-doing-.patch106
-rw-r--r--debian/patches-rt/mm-vmalloc-use-get-cpu-light.patch12
-rw-r--r--debian/patches-rt/mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch2
-rw-r--r--debian/patches-rt/mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch8
-rw-r--r--debian/patches-rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch40
-rw-r--r--debian/patches-rt/mutex-no-spin-on-rt.patch29
-rw-r--r--debian/patches-rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch69
-rw-r--r--debian/patches-rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch53
-rw-r--r--debian/patches-rt/net-another-local-irq-disable-alloc-atomic-headache.patch59
-rw-r--r--debian/patches-rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch113
-rw-r--r--debian/patches-rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch4
-rw-r--r--debian/patches-rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch6
-rw-r--r--debian/patches-rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch76
-rw-r--r--debian/patches-rt/net-make-devnet_rename_seq-a-mutex.patch14
-rw-r--r--debian/patches-rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch4
-rw-r--r--debian/patches-rt/net-use-cpu-chill.patch24
-rw-r--r--debian/patches-rt/net_disable_NET_RX_BUSY_POLL.patch31
-rw-r--r--debian/patches-rt/of-Rework-and-simplify-phandle-cache-to-use-a-fixed-.patch315
-rw-r--r--debian/patches-rt/of-allocate-free-phandle-cache-outside-of-the-devtre.patch96
-rw-r--r--debian/patches-rt/oleg-signal-rt-fix.patch70
-rw-r--r--debian/patches-rt/panic-disable-random-on-rt.patch6
-rw-r--r--debian/patches-rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch18
-rw-r--r--debian/patches-rt/percpu-include-irqflags.h-for-raw_local_irq_save.patch27
-rw-r--r--debian/patches-rt/percpu-refcount-use-normal-instead-of-RCU-sched.patch101
-rw-r--r--debian/patches-rt/perf-core-Add-SRCU-annotation-for-pmus-list-walk.patch31
-rw-r--r--debian/patches-rt/pid.h-include-atomic.h.patch6
-rw-r--r--debian/patches-rt/posix-timers-Unlock-expiry-lock-in-the-early-return.patch32
-rw-r--r--debian/patches-rt/posix-timers-expiry-lock.patch243
-rw-r--r--debian/patches-rt/posix-timers-move-rcu-out-of-union.patch52
-rw-r--r--debian/patches-rt/posix-timers-thread-posix-cpu-timers-on-rt.patch174
-rw-r--r--debian/patches-rt/power-disable-highmem-on-rt.patch6
-rw-r--r--debian/patches-rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch8
-rw-r--r--debian/patches-rt/powerpc-preempt-lazy-support.patch24
-rw-r--r--debian/patches-rt/powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch14
-rw-r--r--debian/patches-rt/powerpc-stackprotector-work-around-stack-guard-init-.patch4
-rw-r--r--debian/patches-rt/preempt-lazy-support.patch136
-rw-r--r--debian/patches-rt/preempt-nort-rt-variants.patch8
-rw-r--r--debian/patches-rt/printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch8
-rw-r--r--debian/patches-rt/printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch4
-rw-r--r--debian/patches-rt/printk-hack-out-emergency-loglevel-usage.patch53
-rw-r--r--debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch44
-rw-r--r--debian/patches-rt/printk-kmsg_dump-remove-mutex-usage.patch12
-rw-r--r--debian/patches-rt/printk-only-allow-kernel-to-emergency-message.patch10
-rw-r--r--debian/patches-rt/printk-print-rate-limitted-message-as-info.patch2
-rw-r--r--debian/patches-rt/printk-set-deferred-to-default-loglevel-enforce-mask.patch6
-rw-r--r--debian/patches-rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch20
-rw-r--r--debian/patches-rt/radix-tree-use-local-locks.patch2
-rw-r--r--debian/patches-rt/random-make-it-work-on-rt.patch78
-rw-r--r--debian/patches-rt/rcu-Acquire-RCU-lock-when-disabling-BHs.patch57
-rw-r--r--debian/patches-rt/rcu-Eliminate-softirq-processing-from-rcutree.patch452
-rw-r--r--debian/patches-rt/rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch8
-rw-r--r--debian/patches-rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch8
-rw-r--r--debian/patches-rt/rcu-make-RCU_BOOST-default-on-RT.patch6
-rw-r--r--debian/patches-rt/rcutorture-Avoid-problematic-critical-section-nestin.patch10
-rw-r--r--debian/patches-rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch69
-rw-r--r--debian/patches-rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch155
-rw-r--r--debian/patches-rt/rt-introduce-cpu-chill.patch8
-rw-r--r--debian/patches-rt/rt-local-irq-lock.patch24
-rw-r--r--debian/patches-rt/rt-preempt-base-config.patch56
-rw-r--r--debian/patches-rt/rt-serial-warn-fix.patch6
-rw-r--r--debian/patches-rt/rtmutex-Make-lock_killable-work.patch4
-rw-r--r--debian/patches-rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch10
-rw-r--r--debian/patches-rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch2
-rw-r--r--debian/patches-rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch2
-rw-r--r--debian/patches-rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch2
-rw-r--r--debian/patches-rt/rtmutex-add-sleeping-lock-implementation.patch98
-rw-r--r--debian/patches-rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch40
-rw-r--r--debian/patches-rt/rtmutex-annotate-sleeping-lock-context.patch294
-rw-r--r--debian/patches-rt/rtmutex-avoid-include-hell.patch2
-rw-r--r--debian/patches-rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch30
-rw-r--r--debian/patches-rt/rtmutex-futex-prepare-rt.patch245
-rw-r--r--debian/patches-rt/rtmutex-lock-killable.patch4
-rw-r--r--debian/patches-rt/rtmutex-trylock-is-okay-on-RT.patch12
-rw-r--r--debian/patches-rt/rtmutex-wire-up-RT-s-locking.patch203
-rw-r--r--debian/patches-rt/rtmutex_dont_include_rcu.patch42
-rw-r--r--debian/patches-rt/sched-Allow-pinned-user-tasks-to-be-awakened-to-the-.patch33
-rw-r--r--debian/patches-rt/sched-Remove-dead-__migrate_disabled-check.patch30
-rw-r--r--debian/patches-rt/sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch8
-rw-r--r--debian/patches-rt/sched-completion-Fix-a-lockup-in-wait_for_completion.patch61
-rw-r--r--debian/patches-rt/sched-core-migrate_enable-must-access-takedown_cpu_t.patch44
-rw-r--r--debian/patches-rt/sched-deadline-Ensure-inactive_timer-runs-in-hardirq.patch41
-rw-r--r--debian/patches-rt/sched-delay-put-task.patch86
-rw-r--r--debian/patches-rt/sched-disable-rt-group-sched-on-rt.patch6
-rw-r--r--debian/patches-rt/sched-disable-ttwu-queue.patch6
-rw-r--r--debian/patches-rt/sched-fair-Make-the-hrtimers-non-hard-again.patch28
-rw-r--r--debian/patches-rt/sched-limit-nr-migrate.patch6
-rw-r--r--debian/patches-rt/sched-might-sleep-do-not-account-rcu-depth.patch6
-rw-r--r--debian/patches-rt/sched-migrate-disable-Protect-cpus_ptr-with-lock.patch38
-rw-r--r--debian/patches-rt/sched-migrate_dis-enable-Use-sleeping_lock-to-annota.patch47
-rw-r--r--debian/patches-rt/sched-migrate_disable-Add-export_symbol_gpl-for-__mi.patch32
-rw-r--r--debian/patches-rt/sched-migrate_disable-fallback-to-preempt_disable-in.patch183
-rw-r--r--debian/patches-rt/sched-migrate_enable-Use-stop_one_cpu_nowait.patch112
-rw-r--r--debian/patches-rt/sched-mmdrop-delayed.patch20
-rw-r--r--debian/patches-rt/sched-rt-mutex-wakeup.patch52
-rw-r--r--debian/patches-rt/scsi-fcoe-rt-aware.patch10
-rw-r--r--debian/patches-rt/seqlock-prevent-rt-starvation.patch4
-rw-r--r--debian/patches-rt/serial-8250-export-symbols-which-are-used-by-symbols.patch8
-rw-r--r--debian/patches-rt/serial-8250-remove-that-trylock-in-serial8250_consol.patch6
-rw-r--r--debian/patches-rt/series471
-rw-r--r--debian/patches-rt/signal-revert-ptrace-preempt-magic.patch7
-rw-r--r--debian/patches-rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch22
-rw-r--r--debian/patches-rt/skbufhead-raw-lock.patch24
-rw-r--r--debian/patches-rt/slub-disable-SLUB_CPU_PARTIAL.patch8
-rw-r--r--debian/patches-rt/slub-enable-irqs-for-no-wait.patch10
-rw-r--r--debian/patches-rt/softirq-Add-preemptible-softirq.patch87
-rw-r--r--debian/patches-rt/softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch6
-rw-r--r--debian/patches-rt/softirq-disable-softirq-stacks-for-rt.patch26
-rw-r--r--debian/patches-rt/softirq-preempt-fix-3-re.patch38
-rw-r--r--debian/patches-rt/spinlock-types-separate-raw.patch2
-rw-r--r--debian/patches-rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch2
-rw-r--r--debian/patches-rt/srcu-replace-local_irqsave-with-a-locallock.patch6
-rw-r--r--debian/patches-rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch2
-rw-r--r--debian/patches-rt/sysfs-realtime-entry.patch6
-rw-r--r--debian/patches-rt/thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch48
-rw-r--r--debian/patches-rt/timekeeping-split-jiffies-lock.patch6
-rw-r--r--debian/patches-rt/timers-Drop-expiry-lock-after-each-timer-invocation.patch50
-rw-r--r--debian/patches-rt/timers-Introduce-expiry-spin-lock.patch153
-rw-r--r--debian/patches-rt/timers-prepare-for-full-preemption.patch48
-rw-r--r--debian/patches-rt/tpm-remove-tpm_dev_wq_lock.patch2
-rw-r--r--debian/patches-rt/tpm_tis-fix-stall-after-iowrite-s.patch6
-rw-r--r--debian/patches-rt/tty-serial-pl011-warning-about-uninitialized.patch4
-rw-r--r--debian/patches-rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch8
-rw-r--r--debian/patches-rt/wait.h-include-atomic.h.patch2
-rw-r--r--debian/patches-rt/watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch18
-rw-r--r--debian/patches-rt/workqueue-Convert-for_each_wq-to-use-built-in-list-c.patch46
-rw-r--r--debian/patches-rt/workqueue-Make-alloc-apply-free_workqueue_attrs-stat.patch65
-rw-r--r--debian/patches-rt/workqueue-Remove-GPF-argument-from-alloc_workqueue_a.patch106
-rw-r--r--debian/patches-rt/x86-Disable-HAVE_ARCH_JUMP_LABEL.patch8
-rw-r--r--debian/patches-rt/x86-Enable-RT-also-on-32bit.patch28
-rw-r--r--debian/patches-rt/x86-Enable-RT.patch22
-rw-r--r--debian/patches-rt/x86-crypto-reduce-preempt-disabled-regions.patch12
-rw-r--r--debian/patches-rt/x86-highmem-add-a-already-used-pte-check.patch4
-rw-r--r--debian/patches-rt/x86-ioapic-Don-t-let-setaffinity-unmask-threaded-EOI.patch106
-rw-r--r--debian/patches-rt/x86-ioapic-Prevent-inconsistent-state-when-moving-an.patch73
-rw-r--r--debian/patches-rt/x86-ioapic-Rename-misnamed-functions.patch87
-rw-r--r--debian/patches-rt/x86-kvm-require-const-tsc-for-rt.patch6
-rw-r--r--debian/patches-rt/x86-ldt-Initialize-the-context-lock-for-init_mm.patch28
-rw-r--r--debian/patches-rt/x86-preempt-Check-preemption-level-before-looking-at.patch25
-rw-r--r--debian/patches-rt/x86-preempt-lazy.patch50
-rw-r--r--debian/patches-rt/x86-signal-delay-calling-signals-on-32bit.patch43
-rw-r--r--debian/patches-rt/x86-stackprot-no-random-on-rt.patch4
326 files changed, 9548 insertions, 9263 deletions
diff --git a/debian/changelog b/debian/changelog
index 3478a0fcdba1..00b7a1134528 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -285,6 +285,9 @@ linux (5.4.5-1~exp1) UNRELEASED; urgency=medium
[ Aurelien Jarno ]
* [armhf,arm64] Fix critical trip point on RPI 3.
+ [ Salvatore Bonaccorso ]
+ * [rt] Update to 5.4.3-rt1 and re-enable
+
-- Ben Hutchings <ben@decadent.org.uk> Thu, 05 Dec 2019 17:31:13 +0000
linux (5.4.2-1~exp1) experimental; urgency=medium
diff --git a/debian/config/defines b/debian/config/defines
index e8b7bcb9e01c..92f55f34f02a 100644
--- a/debian/config/defines
+++ b/debian/config/defines
@@ -141,7 +141,7 @@ debug-info: true
signed-code: false
[featureset-rt_base]
-enabled: false
+enabled: true
[description]
part-long-up: This kernel is not suitable for SMP (multi-processor,
diff --git a/debian/patches-rt/0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch b/debian/patches-rt/0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
index 99315d5cf2c0..b44757ef6e69 100644
--- a/debian/patches-rt/0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
+++ b/debian/patches-rt/0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
@@ -2,7 +2,7 @@ From: Peter Zijlstra <peterz@infradead.org>
Date: Mon, 28 May 2018 15:24:20 +0200
Subject: [PATCH 1/4] Split IRQ-off and zone->lock while freeing pages from PCP
list #1
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Split the IRQ-off section while accessing the PCP list from zone->lock
while freeing pages.
@@ -18,7 +18,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
-@@ -1182,7 +1182,7 @@ static inline void prefetch_buddy(struct
+@@ -1243,7 +1243,7 @@ static inline void prefetch_buddy(struct
}
/*
@@ -27,7 +27,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Assumes all pages on list are in same zone, and of same order.
* count is the number of pages to free.
*
-@@ -1193,14 +1193,41 @@ static inline void prefetch_buddy(struct
+@@ -1254,14 +1254,41 @@ static inline void prefetch_buddy(struct
* pinned" detection logic.
*/
static void free_pcppages_bulk(struct zone *zone, int count,
@@ -73,7 +73,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
while (count) {
struct list_head *list;
-@@ -1232,7 +1259,7 @@ static void free_pcppages_bulk(struct zo
+@@ -1293,7 +1320,7 @@ static void free_pcppages_bulk(struct zo
if (bulkfree_pcp_prepare(page))
continue;
@@ -82,7 +82,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We are going to put the page back to the global
-@@ -1247,26 +1274,6 @@ static void free_pcppages_bulk(struct zo
+@@ -1308,26 +1335,6 @@ static void free_pcppages_bulk(struct zo
prefetch_buddy(page);
} while (--count && --batch_free && !list_empty(list));
}
@@ -109,7 +109,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void free_one_page(struct zone *zone,
-@@ -2713,13 +2720,18 @@ void drain_zone_pages(struct zone *zone,
+@@ -2799,13 +2806,18 @@ void drain_zone_pages(struct zone *zone,
{
unsigned long flags;
int to_drain, batch;
@@ -129,7 +129,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
#endif
-@@ -2735,14 +2747,21 @@ static void drain_pages_zone(unsigned in
+@@ -2821,14 +2833,21 @@ static void drain_pages_zone(unsigned in
unsigned long flags;
struct per_cpu_pageset *pset;
struct per_cpu_pages *pcp;
@@ -153,7 +153,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -2970,7 +2989,10 @@ static void free_unref_page_commit(struc
+@@ -3056,7 +3075,10 @@ static void free_unref_page_commit(struc
pcp->count++;
if (pcp->count >= pcp->high) {
unsigned long batch = READ_ONCE(pcp->batch);
diff --git a/debian/patches-rt/0001-cgroup-Remove-css_rstat_flush.patch b/debian/patches-rt/0001-cgroup-Remove-css_rstat_flush.patch
new file mode 100644
index 000000000000..915ccbf1012c
--- /dev/null
+++ b/debian/patches-rt/0001-cgroup-Remove-css_rstat_flush.patch
@@ -0,0 +1,117 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Thu, 15 Aug 2019 18:14:16 +0200
+Subject: [PATCH 1/4] cgroup: Remove ->css_rstat_flush()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+I was looking at the lifetime of the the ->css_rstat_flush() to see if
+cgroup_rstat_cpu_lock should remain a raw_spinlock_t. I didn't find any
+users and is unused since it was introduced in commit
+ 8f53470bab042 ("cgroup: Add cgroup_subsys->css_rstat_flush()")
+
+Remove the css_rstat_flush callback because it has no users.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/cgroup-defs.h | 5 -----
+ kernel/cgroup/cgroup.c | 12 ------------
+ kernel/cgroup/rstat.c | 10 +---------
+ 3 files changed, 1 insertion(+), 26 deletions(-)
+
+--- a/include/linux/cgroup-defs.h
++++ b/include/linux/cgroup-defs.h
+@@ -144,9 +144,6 @@ struct cgroup_subsys_state {
+ struct list_head sibling;
+ struct list_head children;
+
+- /* flush target list anchored at cgrp->rstat_css_list */
+- struct list_head rstat_css_node;
+-
+ /*
+ * PI: Subsys-unique ID. 0 is unused and root is always 1. The
+ * matching css can be looked up using css_from_id().
+@@ -455,7 +452,6 @@ struct cgroup {
+
+ /* per-cpu recursive resource statistics */
+ struct cgroup_rstat_cpu __percpu *rstat_cpu;
+- struct list_head rstat_css_list;
+
+ /* cgroup basic resource statistics */
+ struct cgroup_base_stat pending_bstat; /* pending from children */
+@@ -633,7 +629,6 @@ struct cgroup_subsys {
+ void (*css_released)(struct cgroup_subsys_state *css);
+ void (*css_free)(struct cgroup_subsys_state *css);
+ void (*css_reset)(struct cgroup_subsys_state *css);
+- void (*css_rstat_flush)(struct cgroup_subsys_state *css, int cpu);
+ int (*css_extra_stat_show)(struct seq_file *seq,
+ struct cgroup_subsys_state *css);
+
+--- a/kernel/cgroup/cgroup.c
++++ b/kernel/cgroup/cgroup.c
+@@ -1957,7 +1957,6 @@ static void init_cgroup_housekeeping(str
+ cgrp->dom_cgrp = cgrp;
+ cgrp->max_descendants = INT_MAX;
+ cgrp->max_depth = INT_MAX;
+- INIT_LIST_HEAD(&cgrp->rstat_css_list);
+ prev_cputime_init(&cgrp->prev_cputime);
+
+ for_each_subsys(ss, ssid)
+@@ -5013,12 +5012,6 @@ static void css_release_work_fn(struct w
+ list_del_rcu(&css->sibling);
+
+ if (ss) {
+- /* css release path */
+- if (!list_empty(&css->rstat_css_node)) {
+- cgroup_rstat_flush(cgrp);
+- list_del_rcu(&css->rstat_css_node);
+- }
+-
+ cgroup_idr_replace(&ss->css_idr, NULL, css->id);
+ if (ss->css_released)
+ ss->css_released(css);
+@@ -5080,7 +5073,6 @@ static void init_and_link_css(struct cgr
+ css->id = -1;
+ INIT_LIST_HEAD(&css->sibling);
+ INIT_LIST_HEAD(&css->children);
+- INIT_LIST_HEAD(&css->rstat_css_node);
+ css->serial_nr = css_serial_nr_next++;
+ atomic_set(&css->online_cnt, 0);
+
+@@ -5089,9 +5081,6 @@ static void init_and_link_css(struct cgr
+ css_get(css->parent);
+ }
+
+- if (cgroup_on_dfl(cgrp) && ss->css_rstat_flush)
+- list_add_rcu(&css->rstat_css_node, &cgrp->rstat_css_list);
+-
+ BUG_ON(cgroup_css(cgrp, ss));
+ }
+
+@@ -5193,7 +5182,6 @@ static struct cgroup_subsys_state *css_c
+ err_list_del:
+ list_del_rcu(&css->sibling);
+ err_free_css:
+- list_del_rcu(&css->rstat_css_node);
+ INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn);
+ queue_rcu_work(cgroup_destroy_wq, &css->destroy_rwork);
+ return ERR_PTR(err);
+--- a/kernel/cgroup/rstat.c
++++ b/kernel/cgroup/rstat.c
+@@ -162,17 +162,9 @@ static void cgroup_rstat_flush_locked(st
+ struct cgroup *pos = NULL;
+
+ raw_spin_lock(cpu_lock);
+- while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu))) {
+- struct cgroup_subsys_state *css;
+-
++ while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu)))
+ cgroup_base_stat_flush(pos, cpu);
+
+- rcu_read_lock();
+- list_for_each_entry_rcu(css, &pos->rstat_css_list,
+- rstat_css_node)
+- css->ss->css_rstat_flush(css, cpu);
+- rcu_read_unlock();
+- }
+ raw_spin_unlock(cpu_lock);
+
+ /* if @may_sleep, play nice and yield if necessary */
diff --git a/debian/patches-rt/0001-hrtimer-Use-READ_ONCE-to-access-timer-base-in-hrimer.patch b/debian/patches-rt/0001-hrtimer-Use-READ_ONCE-to-access-timer-base-in-hrimer.patch
deleted file mode 100644
index 8911788e28da..000000000000
--- a/debian/patches-rt/0001-hrtimer-Use-READ_ONCE-to-access-timer-base-in-hrimer.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Julien Grall <julien.grall@arm.com>
-Date: Wed, 21 Aug 2019 10:24:07 +0100
-Subject: [PATCH 1/3] hrtimer: Use READ_ONCE to access timer->base in
- hrimer_grab_expiry_lock()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The update to timer->base is protected by the base->cpu_base->lock().
-However, hrtimer_grab_expirty_lock() does not access it with the lock.
-
-So it would theorically be possible to have timer->base changed under
-our feet. We need to prevent the compiler to refetch timer->base so the
-check and the access is performed on the same base.
-
-Other access of timer->base are either done with a lock or protected
-with READ_ONCE(). So use READ_ONCE() in hrtimer_grab_expirty_lock().
-
-Signed-off-by: Julien Grall <julien.grall@arm.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/hrtimer.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -932,7 +932,7 @@ EXPORT_SYMBOL_GPL(hrtimer_forward);
-
- void hrtimer_grab_expiry_lock(const struct hrtimer *timer)
- {
-- struct hrtimer_clock_base *base = timer->base;
-+ struct hrtimer_clock_base *base = READ_ONCE(timer->base);
-
- if (base && base->cpu_base) {
- spin_lock(&base->cpu_base->softirq_expiry_lock);
diff --git a/debian/patches-rt/0001-jbd2-Simplify-journal_unmap_buffer.patch b/debian/patches-rt/0001-jbd2-Simplify-journal_unmap_buffer.patch
new file mode 100644
index 000000000000..e85118178b35
--- /dev/null
+++ b/debian/patches-rt/0001-jbd2-Simplify-journal_unmap_buffer.patch
@@ -0,0 +1,58 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 9 Aug 2019 14:42:27 +0200
+Subject: [PATCH 1/7] jbd2: Simplify journal_unmap_buffer()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+journal_unmap_buffer() checks first whether the buffer head is a journal.
+If so it takes locks and then invokes jbd2_journal_grab_journal_head()
+followed by another check whether this is journal head buffer.
+
+The double checking is pointless.
+
+Replace the initial check with jbd2_journal_grab_journal_head() which
+alredy checks whether the buffer head is actually a journal.
+
+Allows also early access to the journal head pointer for the upcoming
+conversion of state lock to a regular spinlock.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Cc: linux-ext4@vger.kernel.org
+Cc: "Theodore Ts'o" <tytso@mit.edu>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/transaction.c | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -2199,7 +2199,8 @@ static int journal_unmap_buffer(journal_
+ * holding the page lock. --sct
+ */
+
+- if (!buffer_jbd(bh))
++ jh = jbd2_journal_grab_journal_head(bh);
++ if (!jh)
+ goto zap_buffer_unlocked;
+
+ /* OK, we have data buffer in journaled mode */
+@@ -2207,10 +2208,6 @@ static int journal_unmap_buffer(journal_
+ jbd_lock_bh_state(bh);
+ spin_lock(&journal->j_list_lock);
+
+- jh = jbd2_journal_grab_journal_head(bh);
+- if (!jh)
+- goto zap_buffer_no_jh;
+-
+ /*
+ * We cannot remove the buffer from checkpoint lists until the
+ * transaction adding inode to orphan list (let's call it T)
+@@ -2332,7 +2329,6 @@ static int journal_unmap_buffer(journal_
+ */
+ jh->b_modified = 0;
+ jbd2_journal_put_journal_head(jh);
+-zap_buffer_no_jh:
+ spin_unlock(&journal->j_list_lock);
+ jbd_unlock_bh_state(bh);
+ write_unlock(&journal->j_state_lock);
diff --git a/debian/patches-rt/0001-mm-page_alloc-Split-drain_local_pages.patch b/debian/patches-rt/0001-mm-page_alloc-Split-drain_local_pages.patch
new file mode 100644
index 000000000000..b2cab4d08c07
--- /dev/null
+++ b/debian/patches-rt/0001-mm-page_alloc-Split-drain_local_pages.patch
@@ -0,0 +1,57 @@
+From: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Date: Thu, 18 Apr 2019 11:09:04 +0200
+Subject: [PATCH 1/4] mm/page_alloc: Split drain_local_pages()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Splitting the functionality of drain_local_pages() into a separate
+function. This is a preparatory work for introducing the static key
+dependend locking mechanism.
+
+No functional change.
+
+Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/gfp.h | 1 +
+ mm/page_alloc.c | 13 +++++++++----
+ 2 files changed, 10 insertions(+), 4 deletions(-)
+
+--- a/include/linux/gfp.h
++++ b/include/linux/gfp.h
+@@ -580,6 +580,7 @@ extern void page_frag_free(void *addr);
+ void page_alloc_init(void);
+ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp);
+ void drain_all_pages(struct zone *zone);
++void drain_cpu_pages(unsigned int cpu, struct zone *zone);
+ void drain_local_pages(struct zone *zone);
+
+ void page_alloc_init_late(void);
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -2894,6 +2894,14 @@ static void drain_pages(unsigned int cpu
+ }
+ }
+
++void drain_cpu_pages(unsigned int cpu, struct zone *zone)
++{
++ if (zone)
++ drain_pages_zone(cpu, zone);
++ else
++ drain_pages(cpu);
++}
++
+ /*
+ * Spill all of this CPU's per-cpu pages back into the buddy allocator.
+ *
+@@ -2904,10 +2912,7 @@ void drain_local_pages(struct zone *zone
+ {
+ int cpu = smp_processor_id();
+
+- if (zone)
+- drain_pages_zone(cpu, zone);
+- else
+- drain_pages(cpu);
++ drain_cpu_pages(cpu, zone);
+ }
+
+ static void drain_local_pages_wq(struct work_struct *work)
diff --git a/debian/patches-rt/0001-printk-rb-add-printk-ring-buffer-documentation.patch b/debian/patches-rt/0001-printk-rb-add-printk-ring-buffer-documentation.patch
index f217a40e18a2..01b8d2bb2a78 100644
--- a/debian/patches-rt/0001-printk-rb-add-printk-ring-buffer-documentation.patch
+++ b/debian/patches-rt/0001-printk-rb-add-printk-ring-buffer-documentation.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:39 +0100
Subject: [PATCH 01/25] printk-rb: add printk ring buffer documentation
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The full documentation file for the printk ring buffer.
diff --git a/debian/patches-rt/0001-workqueue-Don-t-assume-that-the-callback-has-interru.patch b/debian/patches-rt/0001-workqueue-Don-t-assume-that-the-callback-has-interru.patch
new file mode 100644
index 000000000000..abb18a33fd5c
--- /dev/null
+++ b/debian/patches-rt/0001-workqueue-Don-t-assume-that-the-callback-has-interru.patch
@@ -0,0 +1,36 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Tue, 11 Jun 2019 11:21:02 +0200
+Subject: [PATCH 1/4] workqueue: Don't assume that the callback has interrupts
+ disabled
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Due to the TIMER_IRQSAFE flag, the timer callback is invoked with
+disabled interrupts. On -RT the callback is invoked in softirq context
+with enabled interrupts. Since the interrupts are threaded, there are
+are no in_irq() users. The local_bh_disable() around the threaded
+handler ensures that there is either a timer or a threaded handler
+active on the CPU.
+
+Disable interrupts before __queue_work() is invoked from the timer
+callback.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/workqueue.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -1605,9 +1605,11 @@ EXPORT_SYMBOL_GPL(queue_work_node);
+ void delayed_work_timer_fn(struct timer_list *t)
+ {
+ struct delayed_work *dwork = from_timer(dwork, t, timer);
++ unsigned long flags;
+
+- /* should have been called from irqsafe timer with irq already off */
++ local_irq_save(flags);
+ __queue_work(dwork->cpu, dwork->wq, &dwork->work);
++ local_irq_restore(flags);
+ }
+ EXPORT_SYMBOL(delayed_work_timer_fn);
+
diff --git a/debian/patches-rt/0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch b/debian/patches-rt/0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
index 85a7315dcdc2..5a8635a7f6fd 100644
--- a/debian/patches-rt/0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
+++ b/debian/patches-rt/0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
@@ -2,7 +2,7 @@ From: Peter Zijlstra <peterz@infradead.org>
Date: Mon, 28 May 2018 15:24:21 +0200
Subject: [PATCH 2/4] Split IRQ-off and zone->lock while freeing pages from PCP
list #2
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Split the IRQ-off section while accessing the PCP list from zone->lock
while freeing pages.
@@ -18,7 +18,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
-@@ -1192,8 +1192,8 @@ static inline void prefetch_buddy(struct
+@@ -1253,8 +1253,8 @@ static inline void prefetch_buddy(struct
* And clear the zone's pages_scanned counter, to hold off the "all pages are
* pinned" detection logic.
*/
@@ -29,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
bool isolated_pageblocks;
struct page *page, *tmp;
-@@ -1208,12 +1208,27 @@ static void free_pcppages_bulk(struct zo
+@@ -1269,12 +1269,27 @@ static void free_pcppages_bulk(struct zo
*/
list_for_each_entry_safe(page, tmp, head, lru) {
int mt = get_pcppage_migratetype(page);
@@ -57,7 +57,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
__free_one_page(page, page_to_pfn(page), zone, 0, mt);
trace_mm_page_pcpu_drain(page, 0, mt);
}
-@@ -2731,7 +2746,7 @@ void drain_zone_pages(struct zone *zone,
+@@ -2817,7 +2832,7 @@ void drain_zone_pages(struct zone *zone,
local_irq_restore(flags);
if (to_drain > 0)
@@ -66,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
#endif
-@@ -2761,7 +2776,7 @@ static void drain_pages_zone(unsigned in
+@@ -2847,7 +2862,7 @@ static void drain_pages_zone(unsigned in
local_irq_restore(flags);
if (count)
@@ -75,7 +75,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -2960,7 +2975,8 @@ static bool free_unref_page_prepare(stru
+@@ -3046,7 +3061,8 @@ static bool free_unref_page_prepare(stru
return true;
}
@@ -85,7 +85,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
struct zone *zone = page_zone(page);
struct per_cpu_pages *pcp;
-@@ -2989,10 +3005,8 @@ static void free_unref_page_commit(struc
+@@ -3075,10 +3091,8 @@ static void free_unref_page_commit(struc
pcp->count++;
if (pcp->count >= pcp->high) {
unsigned long batch = READ_ONCE(pcp->batch);
@@ -97,7 +97,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -3003,13 +3017,17 @@ void free_unref_page(struct page *page)
+@@ -3089,13 +3103,17 @@ void free_unref_page(struct page *page)
{
unsigned long flags;
unsigned long pfn = page_to_pfn(page);
@@ -116,7 +116,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -3020,6 +3038,11 @@ void free_unref_page_list(struct list_he
+@@ -3106,6 +3124,11 @@ void free_unref_page_list(struct list_he
struct page *page, *next;
unsigned long flags, pfn;
int batch_count = 0;
@@ -128,7 +128,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Prepare pages for freeing */
list_for_each_entry_safe(page, next, list, lru) {
-@@ -3032,10 +3055,12 @@ void free_unref_page_list(struct list_he
+@@ -3118,10 +3141,12 @@ void free_unref_page_list(struct list_he
local_irq_save(flags);
list_for_each_entry_safe(page, next, list, lru) {
unsigned long pfn = page_private(page);
@@ -142,7 +142,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Guard against excessive IRQ disabled times when we get
-@@ -3048,6 +3073,21 @@ void free_unref_page_list(struct list_he
+@@ -3134,6 +3159,21 @@ void free_unref_page_list(struct list_he
}
}
local_irq_restore(flags);
diff --git a/debian/patches-rt/0002-cgroup-Consolidate-users-of-cgroup_rstat_lock.patch b/debian/patches-rt/0002-cgroup-Consolidate-users-of-cgroup_rstat_lock.patch
new file mode 100644
index 000000000000..9ca443ca149b
--- /dev/null
+++ b/debian/patches-rt/0002-cgroup-Consolidate-users-of-cgroup_rstat_lock.patch
@@ -0,0 +1,69 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 16 Aug 2019 12:20:42 +0200
+Subject: [PATCH 2/4] cgroup: Consolidate users of cgroup_rstat_lock.
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+cgroup_rstat_flush_irqsafe() has no users, remove it.
+cgroup_rstat_flush_hold() and cgroup_rstat_flush_release() are only used within
+this file. Make it static.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/cgroup.h | 3 ---
+ kernel/cgroup/rstat.c | 19 ++-----------------
+ 2 files changed, 2 insertions(+), 20 deletions(-)
+
+--- a/include/linux/cgroup.h
++++ b/include/linux/cgroup.h
+@@ -750,9 +750,6 @@ static inline void cgroup_path_from_kern
+ */
+ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
+ void cgroup_rstat_flush(struct cgroup *cgrp);
+-void cgroup_rstat_flush_irqsafe(struct cgroup *cgrp);
+-void cgroup_rstat_flush_hold(struct cgroup *cgrp);
+-void cgroup_rstat_flush_release(void);
+
+ /*
+ * Basic resource stats.
+--- a/kernel/cgroup/rstat.c
++++ b/kernel/cgroup/rstat.c
+@@ -201,21 +201,6 @@ void cgroup_rstat_flush(struct cgroup *c
+ }
+
+ /**
+- * cgroup_rstat_flush_irqsafe - irqsafe version of cgroup_rstat_flush()
+- * @cgrp: target cgroup
+- *
+- * This function can be called from any context.
+- */
+-void cgroup_rstat_flush_irqsafe(struct cgroup *cgrp)
+-{
+- unsigned long flags;
+-
+- spin_lock_irqsave(&cgroup_rstat_lock, flags);
+- cgroup_rstat_flush_locked(cgrp, false);
+- spin_unlock_irqrestore(&cgroup_rstat_lock, flags);
+-}
+-
+-/**
+ * cgroup_rstat_flush_begin - flush stats in @cgrp's subtree and hold
+ * @cgrp: target cgroup
+ *
+@@ -224,7 +209,7 @@ void cgroup_rstat_flush_irqsafe(struct c
+ *
+ * This function may block.
+ */
+-void cgroup_rstat_flush_hold(struct cgroup *cgrp)
++static void cgroup_rstat_flush_hold(struct cgroup *cgrp)
+ __acquires(&cgroup_rstat_lock)
+ {
+ might_sleep();
+@@ -235,7 +220,7 @@ void cgroup_rstat_flush_hold(struct cgro
+ /**
+ * cgroup_rstat_flush_release - release cgroup_rstat_flush_hold()
+ */
+-void cgroup_rstat_flush_release(void)
++static void cgroup_rstat_flush_release(void)
+ __releases(&cgroup_rstat_lock)
+ {
+ spin_unlock_irq(&cgroup_rstat_lock);
diff --git a/debian/patches-rt/0002-hrtimer-Don-t-grab-the-expiry-lock-for-non-soft-hrti.patch b/debian/patches-rt/0002-hrtimer-Don-t-grab-the-expiry-lock-for-non-soft-hrti.patch
deleted file mode 100644
index 63f20d98a53b..000000000000
--- a/debian/patches-rt/0002-hrtimer-Don-t-grab-the-expiry-lock-for-non-soft-hrti.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From: Julien Grall <julien.grall@arm.com>
-Date: Wed, 21 Aug 2019 10:24:08 +0100
-Subject: [PATCH 2/3] hrtimer: Don't grab the expiry lock for non-soft hrtimer
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Acquiring the lock in hrtimer_grab_expiry_lock() is designed for
-sleeping-locks and should not be used with disabled interrupts.
-hrtimer_cancel() may invoke hrtimer_grab_expiry_lock() also for locks
-which expire in hard-IRQ context.
-
-Let hrtimer_cancel() invoke hrtimer_grab_expiry_lock() only for locks
-which expire in softirq context.
-
-Signed-off-by: Julien Grall <julien.grall@arm.com>
-[bigeasy: rewrite changelog]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/hrtimer.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -934,7 +934,7 @@ void hrtimer_grab_expiry_lock(const stru
- {
- struct hrtimer_clock_base *base = READ_ONCE(timer->base);
-
-- if (base && base->cpu_base) {
-+ if (timer->is_soft && base && base->cpu_base) {
- spin_lock(&base->cpu_base->softirq_expiry_lock);
- spin_unlock(&base->cpu_base->softirq_expiry_lock);
- }
diff --git a/debian/patches-rt/0002-jbd2-Remove-jbd_trylock_bh_state.patch b/debian/patches-rt/0002-jbd2-Remove-jbd_trylock_bh_state.patch
new file mode 100644
index 000000000000..273e86f79b79
--- /dev/null
+++ b/debian/patches-rt/0002-jbd2-Remove-jbd_trylock_bh_state.patch
@@ -0,0 +1,31 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 9 Aug 2019 14:42:28 +0200
+Subject: [PATCH 2/7] jbd2: Remove jbd_trylock_bh_state()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+No users.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Cc: linux-ext4@vger.kernel.org
+Cc: "Theodore Ts'o" <tytso@mit.edu>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/jbd2.h | 5 -----
+ 1 file changed, 5 deletions(-)
+
+--- a/include/linux/jbd2.h
++++ b/include/linux/jbd2.h
+@@ -347,11 +347,6 @@ static inline void jbd_lock_bh_state(str
+ bit_spin_lock(BH_State, &bh->b_state);
+ }
+
+-static inline int jbd_trylock_bh_state(struct buffer_head *bh)
+-{
+- return bit_spin_trylock(BH_State, &bh->b_state);
+-}
+-
+ static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
+ {
+ return bit_spin_is_locked(BH_State, &bh->b_state);
diff --git a/debian/patches-rt/0002-mm-swap-Add-static-key-dependent-pagevec-locking.patch b/debian/patches-rt/0002-mm-swap-Add-static-key-dependent-pagevec-locking.patch
new file mode 100644
index 000000000000..c4f2d5a93ad6
--- /dev/null
+++ b/debian/patches-rt/0002-mm-swap-Add-static-key-dependent-pagevec-locking.patch
@@ -0,0 +1,419 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 18 Apr 2019 11:09:05 +0200
+Subject: [PATCH 2/4] mm/swap: Add static key dependent pagevec locking
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The locking of struct pagevec is done by disabling preemption. In case the
+struct has be accessed form interrupt context then interrupts are
+disabled. This means the struct can only be accessed locally from the
+CPU. There is also no lockdep coverage which would scream during if it
+accessed from wrong context.
+
+Create struct swap_pagevec which contains of a pagevec member and a
+spin_lock_t. Introduce a static key, which changes the locking behavior
+only if the key is set in the following way: Before the struct is accessed
+the spin_lock has to be acquired instead of using preempt_disable(). Since
+the struct is used CPU-locally there is no spinning on the lock but the
+lock is acquired immediately. If the struct is accessed from interrupt
+context, spin_lock_irqsave() is used.
+
+No functional change yet because static key is not enabled.
+
+[anna-maria: introduce static key]
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ mm/compaction.c | 14 ++-
+ mm/internal.h | 2
+ mm/swap.c | 202 +++++++++++++++++++++++++++++++++++++++++++++-----------
+ 3 files changed, 176 insertions(+), 42 deletions(-)
+
+--- a/mm/compaction.c
++++ b/mm/compaction.c
+@@ -2244,10 +2244,16 @@ compact_zone(struct compact_control *cc,
+ block_start_pfn(cc->migrate_pfn, cc->order);
+
+ if (last_migrated_pfn < current_block_start) {
+- cpu = get_cpu();
+- lru_add_drain_cpu(cpu);
+- drain_local_pages(cc->zone);
+- put_cpu();
++ if (static_branch_likely(&use_pvec_lock)) {
++ cpu = raw_smp_processor_id();
++ lru_add_drain_cpu(cpu);
++ drain_cpu_pages(cpu, cc->zone);
++ } else {
++ cpu = get_cpu();
++ lru_add_drain_cpu(cpu);
++ drain_local_pages(cc->zone);
++ put_cpu();
++ }
+ /* No more flushing until we migrate again */
+ last_migrated_pfn = 0;
+ }
+--- a/mm/internal.h
++++ b/mm/internal.h
+@@ -32,6 +32,8 @@
+ /* Do not use these with a slab allocator */
+ #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
+
++extern struct static_key_false use_pvec_lock;
++
+ void page_writeback_init(void);
+
+ vm_fault_t do_swap_page(struct vm_fault *vmf);
+--- a/mm/swap.c
++++ b/mm/swap.c
+@@ -44,15 +44,108 @@
+ /* How many pages do we try to swap or page in/out together? */
+ int page_cluster;
+
+-static DEFINE_PER_CPU(struct pagevec, lru_add_pvec);
+-static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
+-static DEFINE_PER_CPU(struct pagevec, lru_deactivate_file_pvecs);
+-static DEFINE_PER_CPU(struct pagevec, lru_deactivate_pvecs);
+-static DEFINE_PER_CPU(struct pagevec, lru_lazyfree_pvecs);
++DEFINE_STATIC_KEY_FALSE(use_pvec_lock);
++
++struct swap_pagevec {
++ spinlock_t lock;
++ struct pagevec pvec;
++};
++
++#define DEFINE_PER_CPU_PAGEVEC(lvar) \
++ DEFINE_PER_CPU(struct swap_pagevec, lvar) = { \
++ .lock = __SPIN_LOCK_UNLOCKED((lvar).lock) }
++
++static DEFINE_PER_CPU_PAGEVEC(lru_add_pvec);
++static DEFINE_PER_CPU_PAGEVEC(lru_rotate_pvecs);
++static DEFINE_PER_CPU_PAGEVEC(lru_deactivate_file_pvecs);
++static DEFINE_PER_CPU_PAGEVEC(lru_deactivate_pvecs);
++static DEFINE_PER_CPU_PAGEVEC(lru_lazyfree_pvecs);
+ #ifdef CONFIG_SMP
+-static DEFINE_PER_CPU(struct pagevec, activate_page_pvecs);
++static DEFINE_PER_CPU_PAGEVEC(activate_page_pvecs);
+ #endif
+
++static inline
++struct swap_pagevec *lock_swap_pvec(struct swap_pagevec __percpu *p)
++{
++ struct swap_pagevec *swpvec;
++
++ if (static_branch_likely(&use_pvec_lock)) {
++ swpvec = raw_cpu_ptr(p);
++
++ spin_lock(&swpvec->lock);
++ } else {
++ swpvec = &get_cpu_var(*p);
++ }
++ return swpvec;
++}
++
++static inline struct swap_pagevec *
++lock_swap_pvec_cpu(struct swap_pagevec __percpu *p, int cpu)
++{
++ struct swap_pagevec *swpvec = per_cpu_ptr(p, cpu);
++
++ if (static_branch_likely(&use_pvec_lock))
++ spin_lock(&swpvec->lock);
++
++ return swpvec;
++}
++
++static inline struct swap_pagevec *
++lock_swap_pvec_irqsave(struct swap_pagevec __percpu *p, unsigned long *flags)
++{
++ struct swap_pagevec *swpvec;
++
++ if (static_branch_likely(&use_pvec_lock)) {
++ swpvec = raw_cpu_ptr(p);
++
++ spin_lock_irqsave(&swpvec->lock, (*flags));
++ } else {
++ local_irq_save(*flags);
++
++ swpvec = this_cpu_ptr(p);
++ }
++ return swpvec;
++}
++
++static inline struct swap_pagevec *
++lock_swap_pvec_cpu_irqsave(struct swap_pagevec __percpu *p, int cpu,
++ unsigned long *flags)
++{
++ struct swap_pagevec *swpvec = per_cpu_ptr(p, cpu);
++
++ if (static_branch_likely(&use_pvec_lock))
++ spin_lock_irqsave(&swpvec->lock, *flags);
++ else
++ local_irq_save(*flags);
++
++ return swpvec;
++}
++
++static inline void unlock_swap_pvec(struct swap_pagevec *swpvec,
++ struct swap_pagevec __percpu *p)
++{
++ if (static_branch_likely(&use_pvec_lock))
++ spin_unlock(&swpvec->lock);
++ else
++ put_cpu_var(*p);
++
++}
++
++static inline void unlock_swap_pvec_cpu(struct swap_pagevec *swpvec)
++{
++ if (static_branch_likely(&use_pvec_lock))
++ spin_unlock(&swpvec->lock);
++}
++
++static inline void
++unlock_swap_pvec_irqrestore(struct swap_pagevec *swpvec, unsigned long flags)
++{
++ if (static_branch_likely(&use_pvec_lock))
++ spin_unlock_irqrestore(&swpvec->lock, flags);
++ else
++ local_irq_restore(flags);
++}
++
+ /*
+ * This path almost never happens for VM activity - pages are normally
+ * freed via pagevecs. But it gets used by networking.
+@@ -250,15 +343,17 @@ void rotate_reclaimable_page(struct page
+ {
+ if (!PageLocked(page) && !PageDirty(page) &&
+ !PageUnevictable(page) && PageLRU(page)) {
++ struct swap_pagevec *swpvec;
+ struct pagevec *pvec;
+ unsigned long flags;
+
+ get_page(page);
+- local_irq_save(flags);
+- pvec = this_cpu_ptr(&lru_rotate_pvecs);
++
++ swpvec = lock_swap_pvec_irqsave(&lru_rotate_pvecs, &flags);
++ pvec = &swpvec->pvec;
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ pagevec_move_tail(pvec);
+- local_irq_restore(flags);
++ unlock_swap_pvec_irqrestore(swpvec, flags);
+ }
+ }
+
+@@ -293,27 +388,32 @@ static void __activate_page(struct page
+ #ifdef CONFIG_SMP
+ static void activate_page_drain(int cpu)
+ {
+- struct pagevec *pvec = &per_cpu(activate_page_pvecs, cpu);
++ struct swap_pagevec *swpvec = lock_swap_pvec_cpu(&activate_page_pvecs, cpu);
++ struct pagevec *pvec = &swpvec->pvec;
+
+ if (pagevec_count(pvec))
+ pagevec_lru_move_fn(pvec, __activate_page, NULL);
++ unlock_swap_pvec_cpu(swpvec);
+ }
+
+ static bool need_activate_page_drain(int cpu)
+ {
+- return pagevec_count(&per_cpu(activate_page_pvecs, cpu)) != 0;
++ return pagevec_count(per_cpu_ptr(&activate_page_pvecs.pvec, cpu)) != 0;
+ }
+
+ void activate_page(struct page *page)
+ {
+ page = compound_head(page);
+ if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
+- struct pagevec *pvec = &get_cpu_var(activate_page_pvecs);
++ struct swap_pagevec *swpvec;
++ struct pagevec *pvec;
+
+ get_page(page);
++ swpvec = lock_swap_pvec(&activate_page_pvecs);
++ pvec = &swpvec->pvec;
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ pagevec_lru_move_fn(pvec, __activate_page, NULL);
+- put_cpu_var(activate_page_pvecs);
++ unlock_swap_pvec(swpvec, &activate_page_pvecs);
+ }
+ }
+
+@@ -335,7 +435,8 @@ void activate_page(struct page *page)
+
+ static void __lru_cache_activate_page(struct page *page)
+ {
+- struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
++ struct swap_pagevec *swpvec = lock_swap_pvec(&lru_add_pvec);
++ struct pagevec *pvec = &swpvec->pvec;
+ int i;
+
+ /*
+@@ -357,7 +458,7 @@ static void __lru_cache_activate_page(st
+ }
+ }
+
+- put_cpu_var(lru_add_pvec);
++ unlock_swap_pvec(swpvec, &lru_add_pvec);
+ }
+
+ /*
+@@ -399,12 +500,13 @@ EXPORT_SYMBOL(mark_page_accessed);
+
+ static void __lru_cache_add(struct page *page)
+ {
+- struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
++ struct swap_pagevec *swpvec = lock_swap_pvec(&lru_add_pvec);
++ struct pagevec *pvec = &swpvec->pvec;
+
+ get_page(page);
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ __pagevec_lru_add(pvec);
+- put_cpu_var(lru_add_pvec);
++ unlock_swap_pvec(swpvec, &lru_add_pvec);
+ }
+
+ /**
+@@ -588,32 +690,40 @@ static void lru_lazyfree_fn(struct page
+ */
+ void lru_add_drain_cpu(int cpu)
+ {
+- struct pagevec *pvec = &per_cpu(lru_add_pvec, cpu);
++ struct swap_pagevec *swpvec = lock_swap_pvec_cpu(&lru_add_pvec, cpu);
++ struct pagevec *pvec = &swpvec->pvec;
++ unsigned long flags;
+
+ if (pagevec_count(pvec))
+ __pagevec_lru_add(pvec);
++ unlock_swap_pvec_cpu(swpvec);
+
+- pvec = &per_cpu(lru_rotate_pvecs, cpu);
++ swpvec = lock_swap_pvec_cpu_irqsave(&lru_rotate_pvecs, cpu, &flags);
++ pvec = &swpvec->pvec;
+ if (pagevec_count(pvec)) {
+- unsigned long flags;
+
+ /* No harm done if a racing interrupt already did this */
+- local_irq_save(flags);
+ pagevec_move_tail(pvec);
+- local_irq_restore(flags);
+ }
++ unlock_swap_pvec_irqrestore(swpvec, flags);
+
+- pvec = &per_cpu(lru_deactivate_file_pvecs, cpu);
++ swpvec = lock_swap_pvec_cpu(&lru_deactivate_file_pvecs, cpu);
++ pvec = &swpvec->pvec;
+ if (pagevec_count(pvec))
+ pagevec_lru_move_fn(pvec, lru_deactivate_file_fn, NULL);
++ unlock_swap_pvec_cpu(swpvec);
+
+- pvec = &per_cpu(lru_deactivate_pvecs, cpu);
++ swpvec = lock_swap_pvec_cpu(&lru_deactivate_pvecs, cpu);
++ pvec = &swpvec->pvec;
+ if (pagevec_count(pvec))
+ pagevec_lru_move_fn(pvec, lru_deactivate_fn, NULL);
++ unlock_swap_pvec_cpu(swpvec);
+
+- pvec = &per_cpu(lru_lazyfree_pvecs, cpu);
++ swpvec = lock_swap_pvec_cpu(&lru_lazyfree_pvecs, cpu);
++ pvec = &swpvec->pvec;
+ if (pagevec_count(pvec))
+ pagevec_lru_move_fn(pvec, lru_lazyfree_fn, NULL);
++ unlock_swap_pvec_cpu(swpvec);
+
+ activate_page_drain(cpu);
+ }
+@@ -628,6 +738,9 @@ void lru_add_drain_cpu(int cpu)
+ */
+ void deactivate_file_page(struct page *page)
+ {
++ struct swap_pagevec *swpvec;
++ struct pagevec *pvec;
++
+ /*
+ * In a workload with many unevictable page such as mprotect,
+ * unevictable page deactivation for accelerating reclaim is pointless.
+@@ -636,11 +749,12 @@ void deactivate_file_page(struct page *p
+ return;
+
+ if (likely(get_page_unless_zero(page))) {
+- struct pagevec *pvec = &get_cpu_var(lru_deactivate_file_pvecs);
++ swpvec = lock_swap_pvec(&lru_deactivate_file_pvecs);
++ pvec = &swpvec->pvec;
+
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ pagevec_lru_move_fn(pvec, lru_deactivate_file_fn, NULL);
+- put_cpu_var(lru_deactivate_file_pvecs);
++ unlock_swap_pvec(swpvec, &lru_deactivate_file_pvecs);
+ }
+ }
+
+@@ -655,12 +769,16 @@ void deactivate_file_page(struct page *p
+ void deactivate_page(struct page *page)
+ {
+ if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) {
+- struct pagevec *pvec = &get_cpu_var(lru_deactivate_pvecs);
++ struct swap_pagevec *swpvec;
++ struct pagevec *pvec;
++
++ swpvec = lock_swap_pvec(&lru_deactivate_pvecs);
++ pvec = &swpvec->pvec;
+
+ get_page(page);
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ pagevec_lru_move_fn(pvec, lru_deactivate_fn, NULL);
+- put_cpu_var(lru_deactivate_pvecs);
++ unlock_swap_pvec(swpvec, &lru_deactivate_pvecs);
+ }
+ }
+
+@@ -673,21 +791,29 @@ void deactivate_page(struct page *page)
+ */
+ void mark_page_lazyfree(struct page *page)
+ {
++ struct swap_pagevec *swpvec;
++ struct pagevec *pvec;
++
+ if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) &&
+ !PageSwapCache(page) && !PageUnevictable(page)) {
+- struct pagevec *pvec = &get_cpu_var(lru_lazyfree_pvecs);
++ swpvec = lock_swap_pvec(&lru_lazyfree_pvecs);
++ pvec = &swpvec->pvec;
+
+ get_page(page);
+ if (!pagevec_add(pvec, page) || PageCompound(page))
+ pagevec_lru_move_fn(pvec, lru_lazyfree_fn, NULL);
+- put_cpu_var(lru_lazyfree_pvecs);
++ unlock_swap_pvec(swpvec, &lru_lazyfree_pvecs);
+ }
+ }
+
+ void lru_add_drain(void)
+ {
+- lru_add_drain_cpu(get_cpu());
+- put_cpu();
++ if (static_branch_likely(&use_pvec_lock)) {
++ lru_add_drain_cpu(raw_smp_processor_id());
++ } else {
++ lru_add_drain_cpu(get_cpu());
++ put_cpu();
++ }
+ }
+
+ #ifdef CONFIG_SMP
+@@ -725,11 +851,11 @@ void lru_add_drain_all(void)
+ for_each_online_cpu(cpu) {
+ struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
+
+- if (pagevec_count(&per_cpu(lru_add_pvec, cpu)) ||
+- pagevec_count(&per_cpu(lru_rotate_pvecs, cpu)) ||
+- pagevec_count(&per_cpu(lru_deactivate_file_pvecs, cpu)) ||
+- pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) ||
+- pagevec_count(&per_cpu(lru_lazyfree_pvecs, cpu)) ||
++ if (pagevec_count(&per_cpu(lru_add_pvec.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_rotate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_file_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_lazyfree_pvecs.pvec, cpu)) ||
+ need_activate_page_drain(cpu)) {
+ INIT_WORK(work, lru_add_drain_per_cpu);
+ queue_work_on(cpu, mm_percpu_wq, work);
diff --git a/debian/patches-rt/0002-printk-rb-add-prb-locking-functions.patch b/debian/patches-rt/0002-printk-rb-add-prb-locking-functions.patch
index 191c249760ab..4f4dffe20209 100644
--- a/debian/patches-rt/0002-printk-rb-add-prb-locking-functions.patch
+++ b/debian/patches-rt/0002-printk-rb-add-prb-locking-functions.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:40 +0100
Subject: [PATCH 02/25] printk-rb: add prb locking functions
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add processor-reentrant spin locking functions. These allow
restricting the number of possible contexts to 2, which can simplify
@@ -68,7 +68,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#endif /*_LINUX_PRINTK_RINGBUFFER_H */
--- a/lib/Makefile
+++ b/lib/Makefile
-@@ -30,7 +30,7 @@ endif
+@@ -26,7 +26,7 @@ endif
lib-y := ctype.o string.o vsprintf.o cmdline.o \
rbtree.o radix-tree.o timerqueue.o xarray.o \
diff --git a/debian/patches-rt/sched-swait-Add-swait_event_lock_irq.patch b/debian/patches-rt/0002-sched-swait-Add-swait_event_lock_irq.patch
index 277f748aca06..86110023ddf5 100644
--- a/debian/patches-rt/sched-swait-Add-swait_event_lock_irq.patch
+++ b/debian/patches-rt/0002-sched-swait-Add-swait_event_lock_irq.patch
@@ -1,9 +1,10 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 22 May 2019 12:42:26 +0200
-Subject: [PATCH] sched/swait: Add swait_event_lock_irq()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: [PATCH 2/4] sched/swait: Add swait_event_lock_irq()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-The swait_event_lock_irq() is inspired by wait_event_lock_irq().
+The swait_event_lock_irq() is inspired by wait_event_lock_irq(). This is
+required by the workqueue code once it switches to swait.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
diff --git a/debian/patches-rt/0003-cgroup-Remove-may_sleep-from-cgroup_rstat_flush_lock.patch b/debian/patches-rt/0003-cgroup-Remove-may_sleep-from-cgroup_rstat_flush_lock.patch
new file mode 100644
index 000000000000..14ea9d2e0674
--- /dev/null
+++ b/debian/patches-rt/0003-cgroup-Remove-may_sleep-from-cgroup_rstat_flush_lock.patch
@@ -0,0 +1,56 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 16 Aug 2019 12:25:35 +0200
+Subject: [PATCH 3/4] cgroup: Remove `may_sleep' from
+ cgroup_rstat_flush_locked()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+cgroup_rstat_flush_locked() is always invoked with `may_sleep' set to
+true so that this case can be made default and the parameter removed.
+
+Remove the `may_sleep' parameter.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/cgroup/rstat.c | 10 ++++------
+ 1 file changed, 4 insertions(+), 6 deletions(-)
+
+--- a/kernel/cgroup/rstat.c
++++ b/kernel/cgroup/rstat.c
+@@ -149,7 +149,7 @@ static struct cgroup *cgroup_rstat_cpu_p
+ }
+
+ /* see cgroup_rstat_flush() */
+-static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep)
++static void cgroup_rstat_flush_locked(struct cgroup *cgrp)
+ __releases(&cgroup_rstat_lock) __acquires(&cgroup_rstat_lock)
+ {
+ int cpu;
+@@ -167,9 +167,7 @@ static void cgroup_rstat_flush_locked(st
+
+ raw_spin_unlock(cpu_lock);
+
+- /* if @may_sleep, play nice and yield if necessary */
+- if (may_sleep && (need_resched() ||
+- spin_needbreak(&cgroup_rstat_lock))) {
++ if (need_resched() || spin_needbreak(&cgroup_rstat_lock)) {
+ spin_unlock_irq(&cgroup_rstat_lock);
+ if (!cond_resched())
+ cpu_relax();
+@@ -196,7 +194,7 @@ void cgroup_rstat_flush(struct cgroup *c
+ might_sleep();
+
+ spin_lock_irq(&cgroup_rstat_lock);
+- cgroup_rstat_flush_locked(cgrp, true);
++ cgroup_rstat_flush_locked(cgrp);
+ spin_unlock_irq(&cgroup_rstat_lock);
+ }
+
+@@ -214,7 +212,7 @@ static void cgroup_rstat_flush_hold(stru
+ {
+ might_sleep();
+ spin_lock_irq(&cgroup_rstat_lock);
+- cgroup_rstat_flush_locked(cgrp, true);
++ cgroup_rstat_flush_locked(cgrp);
+ }
+
+ /**
diff --git a/debian/patches-rt/0003-hrtimer-Prevent-using-hrtimer_grab_expiry_lock-on-mi.patch b/debian/patches-rt/0003-hrtimer-Prevent-using-hrtimer_grab_expiry_lock-on-mi.patch
deleted file mode 100644
index 2de1f5080b61..000000000000
--- a/debian/patches-rt/0003-hrtimer-Prevent-using-hrtimer_grab_expiry_lock-on-mi.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From: Julien Grall <julien.grall@arm.com>
-Date: Wed, 21 Aug 2019 10:24:09 +0100
-Subject: [PATCH 3/3] hrtimer: Prevent using hrtimer_grab_expiry_lock() on
- migration_base
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-As tglx puts it:
-|If base == migration_base then there is no point to lock soft_expiry_lock
-|simply because the timer is not executing the callback in soft irq context
-|and the whole lock/unlock dance can be avoided.
-
-Furthermore, all the path leading to hrtimer_grab_expiry_lock() assumes
-timer->base and timer->base->cpu_base are always non-NULL. So it is safe
-to remove the NULL checks here.
-
-Signed-off-by: Julien Grall <julien.grall@arm.com>
-Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1908211557420.2223@nanos.tec.linutronix.de
-[bigeasy: rewrite changelog]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/hrtimer.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -934,7 +934,7 @@ void hrtimer_grab_expiry_lock(const stru
- {
- struct hrtimer_clock_base *base = READ_ONCE(timer->base);
-
-- if (timer->is_soft && base && base->cpu_base) {
-+ if (timer->is_soft && base != &migration_base) {
- spin_lock(&base->cpu_base->softirq_expiry_lock);
- spin_unlock(&base->cpu_base->softirq_expiry_lock);
- }
diff --git a/debian/patches-rt/0003-jbd2-Move-dropping-of-jh-reference-out-of-un-re-fili.patch b/debian/patches-rt/0003-jbd2-Move-dropping-of-jh-reference-out-of-un-re-fili.patch
new file mode 100644
index 000000000000..bf61f7d0ae4a
--- /dev/null
+++ b/debian/patches-rt/0003-jbd2-Move-dropping-of-jh-reference-out-of-un-re-fili.patch
@@ -0,0 +1,151 @@
+From: Jan Kara <jack@suse.cz>
+Date: Fri, 9 Aug 2019 14:42:29 +0200
+Subject: [PATCH 3/7] jbd2: Move dropping of jh reference out of un/re-filing
+ functions
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+__jbd2_journal_unfile_buffer() and __jbd2_journal_refile_buffer() drop
+transaction's jh reference when they remove jh from a transaction. This
+will be however inconvenient once we move state lock into journal_head
+itself as we still need to unlock it and we'd need to grab jh reference
+just for that. Move dropping of jh reference out of these functions into
+the few callers.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/commit.c | 5 ++++-
+ fs/jbd2/transaction.c | 23 +++++++++++++++--------
+ include/linux/jbd2.h | 2 +-
+ 3 files changed, 20 insertions(+), 10 deletions(-)
+
+--- a/fs/jbd2/commit.c
++++ b/fs/jbd2/commit.c
+@@ -918,6 +918,7 @@ void jbd2_journal_commit_transaction(jou
+ transaction_t *cp_transaction;
+ struct buffer_head *bh;
+ int try_to_free = 0;
++ bool drop_ref;
+
+ jh = commit_transaction->t_forget;
+ spin_unlock(&journal->j_list_lock);
+@@ -1022,8 +1023,10 @@ void jbd2_journal_commit_transaction(jou
+ try_to_free = 1;
+ }
+ JBUFFER_TRACE(jh, "refile or unfile buffer");
+- __jbd2_journal_refile_buffer(jh);
++ drop_ref = __jbd2_journal_refile_buffer(jh);
+ jbd_unlock_bh_state(bh);
++ if (drop_ref)
++ jbd2_journal_put_journal_head(jh);
+ if (try_to_free)
+ release_buffer_page(bh); /* Drops bh reference */
+ else
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -1598,6 +1598,7 @@ int jbd2_journal_forget (handle_t *handl
+ __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
+ } else {
+ __jbd2_journal_unfile_buffer(jh);
++ jbd2_journal_put_journal_head(jh);
+ if (!buffer_jbd(bh)) {
+ spin_unlock(&journal->j_list_lock);
+ goto not_jbd;
+@@ -1971,17 +1972,15 @@ static void __jbd2_journal_temp_unlink_b
+ }
+
+ /*
+- * Remove buffer from all transactions.
++ * Remove buffer from all transactions. The caller is responsible for dropping
++ * the jh reference that belonged to the transaction.
+ *
+ * Called with bh_state lock and j_list_lock
+- *
+- * jh and bh may be already freed when this function returns.
+ */
+ static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
+ {
+ __jbd2_journal_temp_unlink_buffer(jh);
+ jh->b_transaction = NULL;
+- jbd2_journal_put_journal_head(jh);
+ }
+
+ void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
+@@ -1995,6 +1994,7 @@ void jbd2_journal_unfile_buffer(journal_
+ __jbd2_journal_unfile_buffer(jh);
+ spin_unlock(&journal->j_list_lock);
+ jbd_unlock_bh_state(bh);
++ jbd2_journal_put_journal_head(jh);
+ __brelse(bh);
+ }
+
+@@ -2133,6 +2133,7 @@ static int __dispose_buffer(struct journ
+ } else {
+ JBUFFER_TRACE(jh, "on running transaction");
+ __jbd2_journal_unfile_buffer(jh);
++ jbd2_journal_put_journal_head(jh);
+ }
+ return may_free;
+ }
+@@ -2496,9 +2497,11 @@ void jbd2_journal_file_buffer(struct jou
+ * Called under j_list_lock
+ * Called under jbd_lock_bh_state(jh2bh(jh))
+ *
+- * jh and bh may be already free when this function returns
++ * When this function returns true, there's no next transaction to refile to
++ * and the caller has to drop jh reference through
++ * jbd2_journal_put_journal_head().
+ */
+-void __jbd2_journal_refile_buffer(struct journal_head *jh)
++bool __jbd2_journal_refile_buffer(struct journal_head *jh)
+ {
+ int was_dirty, jlist;
+ struct buffer_head *bh = jh2bh(jh);
+@@ -2510,7 +2513,7 @@ void __jbd2_journal_refile_buffer(struct
+ /* If the buffer is now unused, just drop it. */
+ if (jh->b_next_transaction == NULL) {
+ __jbd2_journal_unfile_buffer(jh);
+- return;
++ return true;
+ }
+
+ /*
+@@ -2538,6 +2541,7 @@ void __jbd2_journal_refile_buffer(struct
+
+ if (was_dirty)
+ set_buffer_jbddirty(bh);
++ return false;
+ }
+
+ /*
+@@ -2549,15 +2553,18 @@ void __jbd2_journal_refile_buffer(struct
+ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
+ {
+ struct buffer_head *bh = jh2bh(jh);
++ bool drop;
+
+ /* Get reference so that buffer cannot be freed before we unlock it */
+ get_bh(bh);
+ jbd_lock_bh_state(bh);
+ spin_lock(&journal->j_list_lock);
+- __jbd2_journal_refile_buffer(jh);
++ drop = __jbd2_journal_refile_buffer(jh);
+ jbd_unlock_bh_state(bh);
+ spin_unlock(&journal->j_list_lock);
+ __brelse(bh);
++ if (drop)
++ jbd2_journal_put_journal_head(jh);
+ }
+
+ /*
+--- a/include/linux/jbd2.h
++++ b/include/linux/jbd2.h
+@@ -1252,7 +1252,7 @@ JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM
+
+ /* Filing buffers */
+ extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
+-extern void __jbd2_journal_refile_buffer(struct journal_head *);
++extern bool __jbd2_journal_refile_buffer(struct journal_head *);
+ extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
+ extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
+ extern void __journal_free_buffer(struct journal_head *bh);
diff --git a/debian/patches-rt/0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch b/debian/patches-rt/0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch
index 0d8834b94a00..95d3aa93d95c 100644
--- a/debian/patches-rt/0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch
+++ b/debian/patches-rt/0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 28 May 2018 15:24:22 +0200
Subject: [PATCH 3/4] mm/SLxB: change list_lock to raw_spinlock_t
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The list_lock is used with used with IRQs off on RT. Make it a raw_spinlock_t
otherwise the interrupts won't be disabled on -RT. The locking rules remain
@@ -28,7 +28,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
parent->free_objects = 0;
parent->free_touched = 0;
}
-@@ -564,9 +564,9 @@ static noinline void cache_free_pfmemall
+@@ -558,9 +558,9 @@ static noinline void cache_free_pfmemall
page_node = page_to_nid(page);
n = get_node(cachep, page_node);
@@ -40,7 +40,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
}
-@@ -694,7 +694,7 @@ static void __drain_alien_cache(struct k
+@@ -688,7 +688,7 @@ static void __drain_alien_cache(struct k
struct kmem_cache_node *n = get_node(cachep, node);
if (ac->avail) {
@@ -49,7 +49,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Stuff objects into the remote nodes shared array first.
* That way we could avoid the overhead of putting the objects
-@@ -705,7 +705,7 @@ static void __drain_alien_cache(struct k
+@@ -699,7 +699,7 @@ static void __drain_alien_cache(struct k
free_block(cachep, ac->entry, ac->avail, node, list);
ac->avail = 0;
@@ -58,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -778,9 +778,9 @@ static int __cache_free_alien(struct kme
+@@ -772,9 +772,9 @@ static int __cache_free_alien(struct kme
slabs_destroy(cachep, &list);
} else {
n = get_node(cachep, page_node);
@@ -70,7 +70,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
}
return 1;
-@@ -821,10 +821,10 @@ static int init_cache_node(struct kmem_c
+@@ -815,10 +815,10 @@ static int init_cache_node(struct kmem_c
*/
n = get_node(cachep, node);
if (n) {
@@ -83,7 +83,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 0;
}
-@@ -903,7 +903,7 @@ static int setup_kmem_cache_node(struct
+@@ -897,7 +897,7 @@ static int setup_kmem_cache_node(struct
goto fail;
n = get_node(cachep, node);
@@ -92,7 +92,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (n->shared && force_change) {
free_block(cachep, n->shared->entry,
n->shared->avail, node, &list);
-@@ -921,7 +921,7 @@ static int setup_kmem_cache_node(struct
+@@ -915,7 +915,7 @@ static int setup_kmem_cache_node(struct
new_alien = NULL;
}
@@ -101,7 +101,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
/*
-@@ -960,7 +960,7 @@ static void cpuup_canceled(long cpu)
+@@ -954,7 +954,7 @@ static void cpuup_canceled(long cpu)
if (!n)
continue;
@@ -110,7 +110,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Free limit for this kmem_cache_node */
n->free_limit -= cachep->batchcount;
-@@ -971,7 +971,7 @@ static void cpuup_canceled(long cpu)
+@@ -965,7 +965,7 @@ static void cpuup_canceled(long cpu)
nc->avail = 0;
if (!cpumask_empty(mask)) {
@@ -119,7 +119,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
goto free_slab;
}
-@@ -985,7 +985,7 @@ static void cpuup_canceled(long cpu)
+@@ -979,7 +979,7 @@ static void cpuup_canceled(long cpu)
alien = n->alien;
n->alien = NULL;
@@ -128,7 +128,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
kfree(shared);
if (alien) {
-@@ -1169,7 +1169,7 @@ static void __init init_list(struct kmem
+@@ -1163,7 +1163,7 @@ static void __init init_list(struct kmem
/*
* Do not assume that spinlocks can be initialized via memcpy:
*/
@@ -137,7 +137,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
MAKE_ALL_LISTS(cachep, ptr, nodeid);
cachep->node[nodeid] = ptr;
-@@ -1340,11 +1340,11 @@ slab_out_of_memory(struct kmem_cache *ca
+@@ -1334,11 +1334,11 @@ slab_out_of_memory(struct kmem_cache *ca
for_each_kmem_cache_node(cachep, node, n) {
unsigned long total_slabs, free_slabs, free_objs;
@@ -151,7 +151,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
pr_warn(" node %d: slabs: %ld/%ld, objs: %ld/%ld\n",
node, total_slabs - free_slabs, total_slabs,
-@@ -2107,7 +2107,7 @@ static void check_spinlock_acquired(stru
+@@ -2096,7 +2096,7 @@ static void check_spinlock_acquired(stru
{
#ifdef CONFIG_SMP
check_irq_off();
@@ -160,7 +160,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#endif
}
-@@ -2115,7 +2115,7 @@ static void check_spinlock_acquired_node
+@@ -2104,7 +2104,7 @@ static void check_spinlock_acquired_node
{
#ifdef CONFIG_SMP
check_irq_off();
@@ -169,7 +169,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#endif
}
-@@ -2155,9 +2155,9 @@ static void do_drain(void *arg)
+@@ -2144,9 +2144,9 @@ static void do_drain(void *arg)
check_irq_off();
ac = cpu_cache_get(cachep);
n = get_node(cachep, node);
@@ -181,7 +181,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
ac->avail = 0;
}
-@@ -2175,9 +2175,9 @@ static void drain_cpu_caches(struct kmem
+@@ -2164,9 +2164,9 @@ static void drain_cpu_caches(struct kmem
drain_alien_cache(cachep, n->alien);
for_each_kmem_cache_node(cachep, node, n) {
@@ -193,7 +193,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
}
-@@ -2199,10 +2199,10 @@ static int drain_freelist(struct kmem_ca
+@@ -2188,10 +2188,10 @@ static int drain_freelist(struct kmem_ca
nr_freed = 0;
while (nr_freed < tofree && !list_empty(&n->slabs_free)) {
@@ -206,7 +206,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
goto out;
}
-@@ -2215,7 +2215,7 @@ static int drain_freelist(struct kmem_ca
+@@ -2204,7 +2204,7 @@ static int drain_freelist(struct kmem_ca
* to the cache.
*/
n->free_objects -= cache->num;
@@ -215,7 +215,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slab_destroy(cache, page);
nr_freed++;
}
-@@ -2664,7 +2664,7 @@ static void cache_grow_end(struct kmem_c
+@@ -2657,7 +2657,7 @@ static void cache_grow_end(struct kmem_c
INIT_LIST_HEAD(&page->slab_list);
n = get_node(cachep, page_to_nid(page));
@@ -224,7 +224,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
n->total_slabs++;
if (!page->active) {
list_add_tail(&page->slab_list, &n->slabs_free);
-@@ -2674,7 +2674,7 @@ static void cache_grow_end(struct kmem_c
+@@ -2667,7 +2667,7 @@ static void cache_grow_end(struct kmem_c
STATS_INC_GROWN(cachep);
n->free_objects += cachep->num - page->active;
@@ -233,7 +233,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fixup_objfreelist_debug(cachep, &list);
}
-@@ -2840,7 +2840,7 @@ static struct page *get_first_slab(struc
+@@ -2833,7 +2833,7 @@ static struct page *get_first_slab(struc
{
struct page *page;
@@ -242,7 +242,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
page = list_first_entry_or_null(&n->slabs_partial, struct page,
slab_list);
if (!page) {
-@@ -2867,10 +2867,10 @@ static noinline void *cache_alloc_pfmema
+@@ -2860,10 +2860,10 @@ static noinline void *cache_alloc_pfmema
if (!gfp_pfmemalloc_allowed(flags))
return NULL;
@@ -255,7 +255,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return NULL;
}
-@@ -2879,7 +2879,7 @@ static noinline void *cache_alloc_pfmema
+@@ -2872,7 +2872,7 @@ static noinline void *cache_alloc_pfmema
fixup_slab_list(cachep, n, page, &list);
@@ -264,7 +264,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fixup_objfreelist_debug(cachep, &list);
return obj;
-@@ -2938,7 +2938,7 @@ static void *cache_alloc_refill(struct k
+@@ -2931,7 +2931,7 @@ static void *cache_alloc_refill(struct k
if (!n->free_objects && (!shared || !shared->avail))
goto direct_grow;
@@ -273,7 +273,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
shared = READ_ONCE(n->shared);
/* See if we can refill from the shared array */
-@@ -2962,7 +2962,7 @@ static void *cache_alloc_refill(struct k
+@@ -2955,7 +2955,7 @@ static void *cache_alloc_refill(struct k
must_grow:
n->free_objects -= ac->avail;
alloc_done:
@@ -282,7 +282,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fixup_objfreelist_debug(cachep, &list);
direct_grow:
-@@ -3187,7 +3187,7 @@ static void *____cache_alloc_node(struct
+@@ -3180,7 +3180,7 @@ static void *____cache_alloc_node(struct
BUG_ON(!n);
check_irq_off();
@@ -291,7 +291,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
page = get_first_slab(n, false);
if (!page)
goto must_grow;
-@@ -3205,12 +3205,12 @@ static void *____cache_alloc_node(struct
+@@ -3198,12 +3198,12 @@ static void *____cache_alloc_node(struct
fixup_slab_list(cachep, n, page, &list);
@@ -306,7 +306,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
page = cache_grow_begin(cachep, gfp_exact_node(flags), nodeid);
if (page) {
/* This slab isn't counted yet so don't update free_objects */
-@@ -3386,7 +3386,7 @@ static void cache_flusharray(struct kmem
+@@ -3379,7 +3379,7 @@ static void cache_flusharray(struct kmem
check_irq_off();
n = get_node(cachep, node);
@@ -315,7 +315,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (n->shared) {
struct array_cache *shared_array = n->shared;
int max = shared_array->limit - shared_array->avail;
-@@ -3415,7 +3415,7 @@ static void cache_flusharray(struct kmem
+@@ -3408,7 +3408,7 @@ static void cache_flusharray(struct kmem
STATS_SET_FREEABLE(cachep, i);
}
#endif
@@ -324,7 +324,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
ac->avail -= batchcount;
memmove(ac->entry, &(ac->entry[batchcount]), sizeof(void *)*ac->avail);
-@@ -3829,9 +3829,9 @@ static int __do_tune_cpucache(struct kme
+@@ -3830,9 +3830,9 @@ static int __do_tune_cpucache(struct kme
node = cpu_to_mem(cpu);
n = get_node(cachep, node);
@@ -336,7 +336,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
}
free_percpu(prev);
-@@ -3956,9 +3956,9 @@ static void drain_array(struct kmem_cach
+@@ -3957,9 +3957,9 @@ static void drain_array(struct kmem_cach
return;
}
@@ -348,7 +348,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slabs_destroy(cachep, &list);
}
-@@ -4042,7 +4042,7 @@ void get_slabinfo(struct kmem_cache *cac
+@@ -4043,7 +4043,7 @@ void get_slabinfo(struct kmem_cache *cac
for_each_kmem_cache_node(cachep, node, n) {
check_irq_on();
@@ -357,7 +357,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
total_slabs += n->total_slabs;
free_slabs += n->free_slabs;
-@@ -4051,7 +4051,7 @@ void get_slabinfo(struct kmem_cache *cac
+@@ -4052,7 +4052,7 @@ void get_slabinfo(struct kmem_cache *cac
if (n->shared)
shared_avail += n->shared->avail;
@@ -368,7 +368,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
active_slabs = total_slabs - free_slabs;
--- a/mm/slab.h
+++ b/mm/slab.h
-@@ -449,7 +449,7 @@ static inline void slab_post_alloc_hook(
+@@ -596,7 +596,7 @@ static inline void slab_post_alloc_hook(
* The slab lists for all objects.
*/
struct kmem_cache_node {
@@ -379,7 +379,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct list_head slabs_partial; /* partial list first, better asm code */
--- a/mm/slub.c
+++ b/mm/slub.c
-@@ -1175,7 +1175,7 @@ static noinline int free_debug_processin
+@@ -1176,7 +1176,7 @@ static noinline int free_debug_processin
unsigned long uninitialized_var(flags);
int ret = 0;
@@ -388,7 +388,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slab_lock(page);
if (s->flags & SLAB_CONSISTENCY_CHECKS) {
-@@ -1210,7 +1210,7 @@ static noinline int free_debug_processin
+@@ -1211,7 +1211,7 @@ static noinline int free_debug_processin
bulk_cnt, cnt);
slab_unlock(page);
@@ -397,7 +397,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!ret)
slab_fix(s, "Object at 0x%p not freed", object);
return ret;
-@@ -1854,7 +1854,7 @@ static void *get_partial_node(struct kme
+@@ -1849,7 +1849,7 @@ static void *get_partial_node(struct kme
if (!n || !n->nr_partial)
return NULL;
@@ -406,7 +406,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_for_each_entry_safe(page, page2, &n->partial, slab_list) {
void *t;
-@@ -1879,7 +1879,7 @@ static void *get_partial_node(struct kme
+@@ -1874,7 +1874,7 @@ static void *get_partial_node(struct kme
break;
}
@@ -415,7 +415,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return object;
}
-@@ -2125,7 +2125,7 @@ static void deactivate_slab(struct kmem_
+@@ -2122,7 +2122,7 @@ static void deactivate_slab(struct kmem_
* that acquire_slab() will see a slab page that
* is frozen
*/
@@ -424,7 +424,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
} else {
m = M_FULL;
-@@ -2136,7 +2136,7 @@ static void deactivate_slab(struct kmem_
+@@ -2133,7 +2133,7 @@ static void deactivate_slab(struct kmem_
* slabs from diagnostic functions will not see
* any frozen slabs.
*/
@@ -433,7 +433,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -2160,7 +2160,7 @@ static void deactivate_slab(struct kmem_
+@@ -2157,7 +2157,7 @@ static void deactivate_slab(struct kmem_
goto redo;
if (lock)
@@ -442,7 +442,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (m == M_PARTIAL)
stat(s, tail);
-@@ -2199,10 +2199,10 @@ static void unfreeze_partials(struct kme
+@@ -2196,10 +2196,10 @@ static void unfreeze_partials(struct kme
n2 = get_node(s, page_to_nid(page));
if (n != n2) {
if (n)
@@ -455,7 +455,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
do {
-@@ -2231,7 +2231,7 @@ static void unfreeze_partials(struct kme
+@@ -2228,7 +2228,7 @@ static void unfreeze_partials(struct kme
}
if (n)
@@ -464,7 +464,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
while (discard_page) {
page = discard_page;
-@@ -2398,10 +2398,10 @@ static unsigned long count_partial(struc
+@@ -2395,10 +2395,10 @@ static unsigned long count_partial(struc
unsigned long x = 0;
struct page *page;
@@ -477,7 +477,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return x;
}
#endif /* CONFIG_SLUB_DEBUG || CONFIG_SYSFS */
-@@ -2835,7 +2835,7 @@ static void __slab_free(struct kmem_cach
+@@ -2845,7 +2845,7 @@ static void __slab_free(struct kmem_cach
do {
if (unlikely(n)) {
@@ -486,7 +486,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
n = NULL;
}
prior = page->freelist;
-@@ -2867,7 +2867,7 @@ static void __slab_free(struct kmem_cach
+@@ -2877,7 +2877,7 @@ static void __slab_free(struct kmem_cach
* Otherwise the list_lock will synchronize with
* other processors updating the list of slabs.
*/
@@ -495,7 +495,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -2908,7 +2908,7 @@ static void __slab_free(struct kmem_cach
+@@ -2918,7 +2918,7 @@ static void __slab_free(struct kmem_cach
add_partial(n, page, DEACTIVATE_TO_TAIL);
stat(s, FREE_ADD_PARTIAL);
}
@@ -504,7 +504,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return;
slab_empty:
-@@ -2923,7 +2923,7 @@ static void __slab_free(struct kmem_cach
+@@ -2933,7 +2933,7 @@ static void __slab_free(struct kmem_cach
remove_full(s, n, page);
}
@@ -513,7 +513,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
stat(s, FREE_SLAB);
discard_slab(s, page);
}
-@@ -3310,7 +3310,7 @@ static void
+@@ -3323,7 +3323,7 @@ static void
init_kmem_cache_node(struct kmem_cache_node *n)
{
n->nr_partial = 0;
@@ -522,7 +522,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
INIT_LIST_HEAD(&n->partial);
#ifdef CONFIG_SLUB_DEBUG
atomic_long_set(&n->nr_slabs, 0);
-@@ -3695,7 +3695,7 @@ static void free_partial(struct kmem_cac
+@@ -3704,7 +3704,7 @@ static void free_partial(struct kmem_cac
struct page *page, *h;
BUG_ON(irqs_disabled());
@@ -531,7 +531,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_for_each_entry_safe(page, h, &n->partial, slab_list) {
if (!page->inuse) {
remove_partial(n, page);
-@@ -3705,7 +3705,7 @@ static void free_partial(struct kmem_cac
+@@ -3714,7 +3714,7 @@ static void free_partial(struct kmem_cac
"Objects remaining in %s on __kmem_cache_shutdown()");
}
}
@@ -540,7 +540,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_for_each_entry_safe(page, h, &discard, slab_list)
discard_slab(s, page);
-@@ -3979,7 +3979,7 @@ int __kmem_cache_shrink(struct kmem_cach
+@@ -3986,7 +3986,7 @@ int __kmem_cache_shrink(struct kmem_cach
for (i = 0; i < SHRINK_PROMOTE_MAX; i++)
INIT_LIST_HEAD(promote + i);
@@ -549,7 +549,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Build lists of slabs to discard or promote.
-@@ -4010,7 +4010,7 @@ int __kmem_cache_shrink(struct kmem_cach
+@@ -4017,7 +4017,7 @@ int __kmem_cache_shrink(struct kmem_cach
for (i = SHRINK_PROMOTE_MAX - 1; i >= 0; i--)
list_splice(promote + i, &n->partial);
@@ -558,7 +558,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Release empty slabs */
list_for_each_entry_safe(page, t, &discard, slab_list)
-@@ -4424,7 +4424,7 @@ static int validate_slab_node(struct kme
+@@ -4425,7 +4425,7 @@ static int validate_slab_node(struct kme
struct page *page;
unsigned long flags;
@@ -567,7 +567,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_for_each_entry(page, &n->partial, slab_list) {
validate_slab_slab(s, page, map);
-@@ -4446,7 +4446,7 @@ static int validate_slab_node(struct kme
+@@ -4447,7 +4447,7 @@ static int validate_slab_node(struct kme
s->name, count, atomic_long_read(&n->nr_slabs));
out:
@@ -576,7 +576,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return count;
}
-@@ -4632,12 +4632,12 @@ static int list_locations(struct kmem_ca
+@@ -4633,12 +4633,12 @@ static int list_locations(struct kmem_ca
if (!atomic_long_read(&n->nr_slabs))
continue;
diff --git a/debian/patches-rt/0003-mm-swap-Access-struct-pagevec-remotely.patch b/debian/patches-rt/0003-mm-swap-Access-struct-pagevec-remotely.patch
new file mode 100644
index 000000000000..5bc3c0f19472
--- /dev/null
+++ b/debian/patches-rt/0003-mm-swap-Access-struct-pagevec-remotely.patch
@@ -0,0 +1,137 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 18 Apr 2019 11:09:06 +0200
+Subject: [PATCH 3/4] mm/swap: Access struct pagevec remotely
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+When the newly introduced static key would be enabled, struct pagevec is
+locked during access. So it is possible to access it from a remote CPU. The
+advantage is that the work can be done from the "requesting" CPU without
+firing a worker on a remote CPU and waiting for it to complete the work.
+
+No functional change because static key is not enabled.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ mm/page_alloc.c | 19 ++++++++------
+ mm/swap.c | 75 +++++++++++++++++++++++++++++++++-----------------------
+ 2 files changed, 57 insertions(+), 37 deletions(-)
+
+--- a/mm/page_alloc.c
++++ b/mm/page_alloc.c
+@@ -2999,15 +2999,20 @@ void drain_all_pages(struct zone *zone)
+ cpumask_clear_cpu(cpu, &cpus_with_pcps);
+ }
+
+- for_each_cpu(cpu, &cpus_with_pcps) {
+- struct pcpu_drain *drain = per_cpu_ptr(&pcpu_drain, cpu);
++ if (static_branch_likely(&use_pvec_lock)) {
++ for_each_cpu(cpu, &cpus_with_pcps)
++ drain_cpu_pages(cpu, zone);
++ } else {
++ for_each_cpu(cpu, &cpus_with_pcps) {
++ struct pcpu_drain *drain = per_cpu_ptr(&pcpu_drain, cpu);
+
+- drain->zone = zone;
+- INIT_WORK(&drain->work, drain_local_pages_wq);
+- queue_work_on(cpu, mm_percpu_wq, &drain->work);
++ drain->zone = zone;
++ INIT_WORK(&drain->work, drain_local_pages_wq);
++ queue_work_on(cpu, mm_percpu_wq, &drain->work);
++ }
++ for_each_cpu(cpu, &cpus_with_pcps)
++ flush_work(&per_cpu_ptr(&pcpu_drain, cpu)->work);
+ }
+- for_each_cpu(cpu, &cpus_with_pcps)
+- flush_work(&per_cpu_ptr(&pcpu_drain, cpu)->work);
+
+ mutex_unlock(&pcpu_drain_mutex);
+ }
+--- a/mm/swap.c
++++ b/mm/swap.c
+@@ -834,39 +834,54 @@ static void lru_add_drain_per_cpu(struct
+ */
+ void lru_add_drain_all(void)
+ {
+- static DEFINE_MUTEX(lock);
+- static struct cpumask has_work;
+- int cpu;
+-
+- /*
+- * Make sure nobody triggers this path before mm_percpu_wq is fully
+- * initialized.
+- */
+- if (WARN_ON(!mm_percpu_wq))
+- return;
+-
+- mutex_lock(&lock);
+- cpumask_clear(&has_work);
+-
+- for_each_online_cpu(cpu) {
+- struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
+-
+- if (pagevec_count(&per_cpu(lru_add_pvec.pvec, cpu)) ||
+- pagevec_count(&per_cpu(lru_rotate_pvecs.pvec, cpu)) ||
+- pagevec_count(&per_cpu(lru_deactivate_file_pvecs.pvec, cpu)) ||
+- pagevec_count(&per_cpu(lru_deactivate_pvecs.pvec, cpu)) ||
+- pagevec_count(&per_cpu(lru_lazyfree_pvecs.pvec, cpu)) ||
+- need_activate_page_drain(cpu)) {
+- INIT_WORK(work, lru_add_drain_per_cpu);
+- queue_work_on(cpu, mm_percpu_wq, work);
+- cpumask_set_cpu(cpu, &has_work);
++ if (static_branch_likely(&use_pvec_lock)) {
++ int cpu;
++
++ for_each_online_cpu(cpu) {
++ if (pagevec_count(&per_cpu(lru_add_pvec.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_rotate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_file_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_lazyfree_pvecs.pvec, cpu)) ||
++ need_activate_page_drain(cpu)) {
++ lru_add_drain_cpu(cpu);
++ }
++ }
++ } else {
++ static DEFINE_MUTEX(lock);
++ static struct cpumask has_work;
++ int cpu;
++
++ /*
++ * Make sure nobody triggers this path before mm_percpu_wq
++ * is fully initialized.
++ */
++ if (WARN_ON(!mm_percpu_wq))
++ return;
++
++ mutex_lock(&lock);
++ cpumask_clear(&has_work);
++
++ for_each_online_cpu(cpu) {
++ struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
++
++ if (pagevec_count(&per_cpu(lru_add_pvec.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_rotate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_file_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_deactivate_pvecs.pvec, cpu)) ||
++ pagevec_count(&per_cpu(lru_lazyfree_pvecs.pvec, cpu)) ||
++ need_activate_page_drain(cpu)) {
++ INIT_WORK(work, lru_add_drain_per_cpu);
++ queue_work_on(cpu, mm_percpu_wq, work);
++ cpumask_set_cpu(cpu, &has_work);
++ }
+ }
+- }
+
+- for_each_cpu(cpu, &has_work)
+- flush_work(&per_cpu(lru_add_drain_work, cpu));
++ for_each_cpu(cpu, &has_work)
++ flush_work(&per_cpu(lru_add_drain_work, cpu));
+
+- mutex_unlock(&lock);
++ mutex_unlock(&lock);
++ }
+ }
+ #else
+ void lru_add_drain_all(void)
diff --git a/debian/patches-rt/0003-printk-rb-define-ring-buffer-struct-and-initializer.patch b/debian/patches-rt/0003-printk-rb-define-ring-buffer-struct-and-initializer.patch
index 7a2a6730bcc8..912fa575dc3a 100644
--- a/debian/patches-rt/0003-printk-rb-define-ring-buffer-struct-and-initializer.patch
+++ b/debian/patches-rt/0003-printk-rb-define-ring-buffer-struct-and-initializer.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:41 +0100
Subject: [PATCH 03/25] printk-rb: define ring buffer struct and initializer
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
See Documentation/printk-ringbuffer.txt for details about the
initializer arguments.
diff --git a/debian/patches-rt/0003-workqueue-Use-swait-for-wq_manager_wait.patch b/debian/patches-rt/0003-workqueue-Use-swait-for-wq_manager_wait.patch
new file mode 100644
index 000000000000..1df8ad7b60d9
--- /dev/null
+++ b/debian/patches-rt/0003-workqueue-Use-swait-for-wq_manager_wait.patch
@@ -0,0 +1,54 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Tue, 11 Jun 2019 11:21:09 +0200
+Subject: [PATCH 3/4] workqueue: Use swait for wq_manager_wait
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+In order for the workqueue code use raw_spinlock_t typed locking there
+must not be a spinlock_t typed lock be acquired. A wait_queue_head uses
+a spinlock_t lock for its list protection.
+
+Use a swait based queue head to avoid raw_spinlock_t -> spinlock_t
+locking.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/workqueue.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -50,6 +50,7 @@
+ #include <linux/uaccess.h>
+ #include <linux/sched/isolation.h>
+ #include <linux/nmi.h>
++#include <linux/swait.h>
+
+ #include "workqueue_internal.h"
+
+@@ -301,7 +302,7 @@ static struct workqueue_attrs *wq_update
+ static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list */
+ static DEFINE_MUTEX(wq_pool_attach_mutex); /* protects worker attach/detach */
+ static DEFINE_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */
+-static DECLARE_WAIT_QUEUE_HEAD(wq_manager_wait); /* wait for manager to go away */
++static DECLARE_SWAIT_QUEUE_HEAD(wq_manager_wait); /* wait for manager to go away */
+
+ static LIST_HEAD(workqueues); /* PR: list of all workqueues */
+ static bool workqueue_freezing; /* PL: have wqs started freezing? */
+@@ -2137,7 +2138,7 @@ static bool manage_workers(struct worker
+
+ pool->manager = NULL;
+ pool->flags &= ~POOL_MANAGER_ACTIVE;
+- wake_up(&wq_manager_wait);
++ swake_up_one(&wq_manager_wait);
+ return true;
+ }
+
+@@ -3532,7 +3533,7 @@ static void put_unbound_pool(struct work
+ * manager and @pool gets freed with the flag set.
+ */
+ spin_lock_irq(&pool->lock);
+- wait_event_lock_irq(wq_manager_wait,
++ swait_event_lock_irq(wq_manager_wait,
+ !(pool->flags & POOL_MANAGER_ACTIVE), pool->lock);
+ pool->flags |= POOL_MANAGER_ACTIVE;
+
diff --git a/debian/patches-rt/0004-cgroup-Acquire-cgroup_rstat_lock-with-enabled-interr.patch b/debian/patches-rt/0004-cgroup-Acquire-cgroup_rstat_lock-with-enabled-interr.patch
new file mode 100644
index 000000000000..d75a1b4c5382
--- /dev/null
+++ b/debian/patches-rt/0004-cgroup-Acquire-cgroup_rstat_lock-with-enabled-interr.patch
@@ -0,0 +1,72 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 16 Aug 2019 12:49:36 +0200
+Subject: [PATCH 4/4] cgroup: Acquire cgroup_rstat_lock with enabled interrupts
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+There is no need to disable interrupts while cgroup_rstat_lock is
+acquired. The lock is never used in-IRQ context so a simple spin_lock()
+is enough for synchronisation purpose.
+
+Acquire cgroup_rstat_lock without disabling interrupts and ensure that
+cgroup_rstat_cpu_lock is acquired with disabled interrupts (this one is
+acquired in-IRQ context).
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/cgroup/rstat.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/kernel/cgroup/rstat.c
++++ b/kernel/cgroup/rstat.c
+@@ -161,17 +161,17 @@ static void cgroup_rstat_flush_locked(st
+ cpu);
+ struct cgroup *pos = NULL;
+
+- raw_spin_lock(cpu_lock);
++ raw_spin_lock_irq(cpu_lock);
+ while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu)))
+ cgroup_base_stat_flush(pos, cpu);
+
+- raw_spin_unlock(cpu_lock);
++ raw_spin_unlock_irq(cpu_lock);
+
+ if (need_resched() || spin_needbreak(&cgroup_rstat_lock)) {
+- spin_unlock_irq(&cgroup_rstat_lock);
++ spin_unlock(&cgroup_rstat_lock);
+ if (!cond_resched())
+ cpu_relax();
+- spin_lock_irq(&cgroup_rstat_lock);
++ spin_lock(&cgroup_rstat_lock);
+ }
+ }
+ }
+@@ -193,9 +193,9 @@ void cgroup_rstat_flush(struct cgroup *c
+ {
+ might_sleep();
+
+- spin_lock_irq(&cgroup_rstat_lock);
++ spin_lock(&cgroup_rstat_lock);
+ cgroup_rstat_flush_locked(cgrp);
+- spin_unlock_irq(&cgroup_rstat_lock);
++ spin_unlock(&cgroup_rstat_lock);
+ }
+
+ /**
+@@ -211,7 +211,7 @@ static void cgroup_rstat_flush_hold(stru
+ __acquires(&cgroup_rstat_lock)
+ {
+ might_sleep();
+- spin_lock_irq(&cgroup_rstat_lock);
++ spin_lock(&cgroup_rstat_lock);
+ cgroup_rstat_flush_locked(cgrp);
+ }
+
+@@ -221,7 +221,7 @@ static void cgroup_rstat_flush_hold(stru
+ static void cgroup_rstat_flush_release(void)
+ __releases(&cgroup_rstat_lock)
+ {
+- spin_unlock_irq(&cgroup_rstat_lock);
++ spin_unlock(&cgroup_rstat_lock);
+ }
+
+ int cgroup_rstat_init(struct cgroup *cgrp)
diff --git a/debian/patches-rt/0004-jbd2-Drop-unnecessary-branch-from-jbd2_journal_forge.patch b/debian/patches-rt/0004-jbd2-Drop-unnecessary-branch-from-jbd2_journal_forge.patch
new file mode 100644
index 000000000000..fb5f3bc4a1c6
--- /dev/null
+++ b/debian/patches-rt/0004-jbd2-Drop-unnecessary-branch-from-jbd2_journal_forge.patch
@@ -0,0 +1,28 @@
+From: Jan Kara <jack@suse.cz>
+Date: Fri, 9 Aug 2019 14:42:30 +0200
+Subject: [PATCH 4/7] jbd2: Drop unnecessary branch from jbd2_journal_forget()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+We have cleared both dirty & jbddirty bits from the bh. So there's no
+difference between bforget() and brelse(). Thus there's no point jumping
+to no_jbd branch.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/transaction.c | 4 ----
+ 1 file changed, 4 deletions(-)
+
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -1599,10 +1599,6 @@ int jbd2_journal_forget (handle_t *handl
+ } else {
+ __jbd2_journal_unfile_buffer(jh);
+ jbd2_journal_put_journal_head(jh);
+- if (!buffer_jbd(bh)) {
+- spin_unlock(&journal->j_list_lock);
+- goto not_jbd;
+- }
+ }
+ spin_unlock(&journal->j_list_lock);
+ } else if (jh->b_transaction) {
diff --git a/debian/patches-rt/0004-mm-SLUB-delay-giving-back-empty-slubs-to-IRQ-enabled.patch b/debian/patches-rt/0004-mm-SLUB-delay-giving-back-empty-slubs-to-IRQ-enabled.patch
index 3d59a230bb31..fc3ccbde1077 100644
--- a/debian/patches-rt/0004-mm-SLUB-delay-giving-back-empty-slubs-to-IRQ-enabled.patch
+++ b/debian/patches-rt/0004-mm-SLUB-delay-giving-back-empty-slubs-to-IRQ-enabled.patch
@@ -2,7 +2,7 @@ From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 21 Jun 2018 17:29:19 +0200
Subject: [PATCH 4/4] mm/SLUB: delay giving back empty slubs to IRQ enabled
regions
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
__free_slab() is invoked with disabled interrupts which increases the
irq-off time while __free_pages() is doing the work.
@@ -18,7 +18,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/slub.c
+++ b/mm/slub.c
-@@ -1378,6 +1378,12 @@ static inline void dec_slabs_node(struct
+@@ -1381,6 +1381,12 @@ static inline void dec_slabs_node(struct
#endif /* CONFIG_SLUB_DEBUG */
@@ -31,7 +31,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Hooks for other subsystems that check memory allocations. In a typical
* production configuration these hooks all should produce no code at all.
-@@ -1736,6 +1742,16 @@ static void __free_slab(struct kmem_cach
+@@ -1731,6 +1737,16 @@ static void __free_slab(struct kmem_cach
__free_pages(page, order);
}
@@ -48,7 +48,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void rcu_free_slab(struct rcu_head *h)
{
struct page *page = container_of(h, struct page, rcu_head);
-@@ -1747,6 +1763,12 @@ static void free_slab(struct kmem_cache
+@@ -1742,6 +1758,12 @@ static void free_slab(struct kmem_cache
{
if (unlikely(s->flags & SLAB_TYPESAFE_BY_RCU)) {
call_rcu(&page->rcu_head, rcu_free_slab);
@@ -61,7 +61,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
} else
__free_slab(s, page);
}
-@@ -2268,14 +2290,21 @@ static void put_cpu_partial(struct kmem_
+@@ -2265,14 +2287,21 @@ static void put_cpu_partial(struct kmem_
pobjects = oldpage->pobjects;
pages = oldpage->pages;
if (drain && pobjects > s->cpu_partial) {
@@ -83,7 +83,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
oldpage = NULL;
pobjects = 0;
pages = 0;
-@@ -2343,7 +2372,22 @@ static bool has_cpu_slab(int cpu, void *
+@@ -2340,7 +2369,22 @@ static bool has_cpu_slab(int cpu, void *
static void flush_all(struct kmem_cache *s)
{
@@ -106,7 +106,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -2540,8 +2584,10 @@ static inline void *get_freelist(struct
+@@ -2537,8 +2581,10 @@ static inline void *get_freelist(struct
* already disabled (which is the case for bulk allocation).
*/
static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
@@ -118,7 +118,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
void *freelist;
struct page *page;
-@@ -2597,6 +2643,13 @@ static void *___slab_alloc(struct kmem_c
+@@ -2594,6 +2640,13 @@ static void *___slab_alloc(struct kmem_c
VM_BUG_ON(!c->page->frozen);
c->freelist = get_freepointer(s, freelist);
c->tid = next_tid(c->tid);
@@ -132,7 +132,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return freelist;
new_slab:
-@@ -2612,7 +2665,7 @@ static void *___slab_alloc(struct kmem_c
+@@ -2609,7 +2662,7 @@ static void *___slab_alloc(struct kmem_c
if (unlikely(!freelist)) {
slab_out_of_memory(s, gfpflags, node);
@@ -141,7 +141,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
page = c->page;
-@@ -2625,7 +2678,7 @@ static void *___slab_alloc(struct kmem_c
+@@ -2622,7 +2675,7 @@ static void *___slab_alloc(struct kmem_c
goto new_slab; /* Slab failed checks. Next slab needed */
deactivate_slab(s, page, get_freepointer(s, freelist), c);
@@ -150,15 +150,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -2637,6 +2690,7 @@ static void *__slab_alloc(struct kmem_ca
+@@ -2634,6 +2687,7 @@ static void *__slab_alloc(struct kmem_ca
{
void *p;
unsigned long flags;
+ LIST_HEAD(tofree);
local_irq_save(flags);
- #ifdef CONFIG_PREEMPT
-@@ -2648,8 +2702,9 @@ static void *__slab_alloc(struct kmem_ca
+ #ifdef CONFIG_PREEMPTION
+@@ -2645,8 +2699,9 @@ static void *__slab_alloc(struct kmem_ca
c = this_cpu_ptr(s->cpu_slab);
#endif
@@ -169,7 +169,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return p;
}
-@@ -3126,6 +3181,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
+@@ -3136,6 +3191,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
void **p)
{
struct kmem_cache_cpu *c;
@@ -177,7 +177,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int i;
/* memcg and kmem_cache debug support */
-@@ -3149,7 +3205,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
+@@ -3159,7 +3215,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
* of re-populating per CPU c->freelist
*/
p[i] = ___slab_alloc(s, flags, NUMA_NO_NODE,
@@ -186,15 +186,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (unlikely(!p[i]))
goto error;
-@@ -3161,6 +3217,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
+@@ -3174,6 +3230,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
}
c->tid = next_tid(c->tid);
local_irq_enable();
+ free_delayed(&to_free);
/* Clear memory outside IRQ disabled fastpath loop */
- if (unlikely(flags & __GFP_ZERO)) {
-@@ -3175,6 +3232,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
+ if (unlikely(slab_want_init_on_alloc(flags, s))) {
+@@ -3188,6 +3245,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca
return i;
error:
local_irq_enable();
@@ -202,7 +202,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
slab_post_alloc_hook(s, flags, i, p);
__kmem_cache_free_bulk(s, i, p);
return 0;
-@@ -4223,6 +4281,12 @@ void __init kmem_cache_init(void)
+@@ -4224,6 +4282,12 @@ void __init kmem_cache_init(void)
{
static __initdata struct kmem_cache boot_kmem_cache,
boot_kmem_cache_node;
diff --git a/debian/patches-rt/0004-mm-swap-Enable-use_pvec_lock-nohz_full-dependent.patch b/debian/patches-rt/0004-mm-swap-Enable-use_pvec_lock-nohz_full-dependent.patch
new file mode 100644
index 000000000000..ad25271a1d75
--- /dev/null
+++ b/debian/patches-rt/0004-mm-swap-Enable-use_pvec_lock-nohz_full-dependent.patch
@@ -0,0 +1,57 @@
+From: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Date: Thu, 18 Apr 2019 11:09:07 +0200
+Subject: [PATCH 4/4] mm/swap: Enable "use_pvec_lock" nohz_full dependent
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+When a system runs with CONFIG_NO_HZ_FULL enabled, the tick of CPUs listed
+in 'nohz_full=' kernel command line parameter should be stopped whenever
+possible. The tick stays longer stopped, when work for this CPU is handled
+by another CPU.
+
+With the already introduced static key 'use_pvec_lock' there is the
+possibility to prevent firing a worker for mm/swap work on a remote CPU
+with a stopped tick.
+
+Therefore enabling the static key in case kernel command line parameter
+'nohz_full=' setup was successful, which implies that CONFIG_NO_HZ_FULL is
+set.
+
+Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/sched/isolation.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+--- a/kernel/sched/isolation.c
++++ b/kernel/sched/isolation.c
+@@ -8,6 +8,7 @@
+ *
+ */
+ #include "sched.h"
++#include "../../mm/internal.h"
+
+ DEFINE_STATIC_KEY_FALSE(housekeeping_overridden);
+ EXPORT_SYMBOL_GPL(housekeeping_overridden);
+@@ -139,10 +140,21 @@ static int __init housekeeping_setup(cha
+ static int __init housekeeping_nohz_full_setup(char *str)
+ {
+ unsigned int flags;
++ int ret;
+
+ flags = HK_FLAG_TICK | HK_FLAG_WQ | HK_FLAG_TIMER | HK_FLAG_RCU | HK_FLAG_MISC;
+
+- return housekeeping_setup(str, flags);
++ ret = housekeeping_setup(str, flags);
++
++ /*
++ * Protect struct pagevec with a lock instead using preemption disable;
++ * with lock protection, remote handling of events instead of queue
++ * work on remote cpu is default behavior.
++ */
++ if (ret)
++ static_branch_enable(&use_pvec_lock);
++
++ return ret;
+ }
+ __setup("nohz_full=", housekeeping_nohz_full_setup);
+
diff --git a/debian/patches-rt/0004-printk-rb-add-writer-interface.patch b/debian/patches-rt/0004-printk-rb-add-writer-interface.patch
index 4117a4c9a195..dcc4bfa6cdfa 100644
--- a/debian/patches-rt/0004-printk-rb-add-writer-interface.patch
+++ b/debian/patches-rt/0004-printk-rb-add-writer-interface.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:42 +0100
Subject: [PATCH 04/25] printk-rb: add writer interface
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add the writer functions prb_reserve() and prb_commit(). These make
use of processor-reentrant spin locks to limit the number of possible
diff --git a/debian/patches-rt/workqueue-Convert-the-locks-to-raw-type.patch b/debian/patches-rt/0004-workqueue-Convert-the-locks-to-raw-type.patch
index 5c7d0a20eb78..7fc27cb4b13c 100644
--- a/debian/patches-rt/workqueue-Convert-the-locks-to-raw-type.patch
+++ b/debian/patches-rt/0004-workqueue-Convert-the-locks-to-raw-type.patch
@@ -1,28 +1,24 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 22 May 2019 12:43:56 +0200
-Subject: [PATCH] workqueue: Convert the locks to raw type
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: [PATCH 4/4] workqueue: Convert the locks to raw type
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
After all the workqueue and the timer rework, we can finally make the
worker_pool lock raw.
The lock is not held over an unbounded period of time/iterations.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+[Salvatore Bonaccorso: Adjust for context changes due to backport of
+e66b39af00f4 ("workqueue: Fix pwq ref leak in rescuer_thread()") and
+def98c84b6cd ("workqueue: Fix spurious sanity check failures in
+destroy_workqueue()") in 5.4.4.]
---
- kernel/workqueue.c | 175 ++++++++++++++++++++++++++---------------------------
- 1 file changed, 89 insertions(+), 86 deletions(-)
+ kernel/workqueue.c | 164 ++++++++++++++++++++++++++---------------------------
+ 1 file changed, 82 insertions(+), 82 deletions(-)
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
-@@ -50,6 +50,7 @@
- #include <linux/uaccess.h>
- #include <linux/sched/isolation.h>
- #include <linux/nmi.h>
-+#include <linux/swait.h>
-
- #include "workqueue_internal.h"
-
-@@ -145,7 +146,7 @@ enum {
+@@ -146,7 +146,7 @@
/* struct worker is defined in workqueue_internal.h */
struct worker_pool {
@@ -31,18 +27,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int cpu; /* I: the associated cpu */
int node; /* I: the associated node ID */
int id; /* I: pool ID */
-@@ -300,8 +301,8 @@ static struct workqueue_attrs *wq_update
+@@ -301,7 +301,7 @@
static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list */
static DEFINE_MUTEX(wq_pool_attach_mutex); /* protects worker attach/detach */
-static DEFINE_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */
--static DECLARE_WAIT_QUEUE_HEAD(wq_manager_wait); /* wait for manager to go away */
+static DEFINE_RAW_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */
-+static DECLARE_SWAIT_QUEUE_HEAD(wq_manager_wait); /* wait for manager to go away */
+ static DECLARE_SWAIT_QUEUE_HEAD(wq_manager_wait); /* wait for manager to go away */
static LIST_HEAD(workqueues); /* PR: list of all workqueues */
- static bool workqueue_freezing; /* PL: have wqs started freezing? */
-@@ -831,7 +832,7 @@ static struct worker *first_idle_worker(
+@@ -826,7 +826,7 @@
* Wake up the first idle worker of @pool.
*
* CONTEXT:
@@ -51,7 +45,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void wake_up_worker(struct worker_pool *pool)
{
-@@ -884,7 +885,7 @@ void wq_worker_sleeping(struct task_stru
+@@ -879,7 +879,7 @@
return;
worker->sleeping = 1;
@@ -60,7 +54,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* The counterpart of the following dec_and_test, implied mb,
-@@ -903,7 +904,7 @@ void wq_worker_sleeping(struct task_stru
+@@ -898,7 +898,7 @@
if (next)
wake_up_process(next->task);
}
@@ -69,7 +63,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -914,7 +915,7 @@ void wq_worker_sleeping(struct task_stru
+@@ -909,7 +909,7 @@
* the scheduler to get a worker's last known identity.
*
* CONTEXT:
@@ -78,7 +72,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*
* This function is called during schedule() when a kworker is going
* to sleep. It's used by psi to identify aggregation workers during
-@@ -945,7 +946,7 @@ work_func_t wq_worker_last_func(struct t
+@@ -940,7 +940,7 @@
* Set @flags in @worker->flags and adjust nr_running accordingly.
*
* CONTEXT:
@@ -87,7 +81,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static inline void worker_set_flags(struct worker *worker, unsigned int flags)
{
-@@ -970,7 +971,7 @@ static inline void worker_set_flags(stru
+@@ -965,7 +965,7 @@
* Clear @flags in @worker->flags and adjust nr_running accordingly.
*
* CONTEXT:
@@ -96,7 +90,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static inline void worker_clr_flags(struct worker *worker, unsigned int flags)
{
-@@ -1018,7 +1019,7 @@ static inline void worker_clr_flags(stru
+@@ -1013,7 +1013,7 @@
* actually occurs, it should be easy to locate the culprit work function.
*
* CONTEXT:
@@ -105,7 +99,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*
* Return:
* Pointer to worker which is executing @work if found, %NULL
-@@ -1053,7 +1054,7 @@ static struct worker *find_worker_execut
+@@ -1048,7 +1048,7 @@
* nested inside outer list_for_each_entry_safe().
*
* CONTEXT:
@@ -114,7 +108,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void move_linked_works(struct work_struct *work, struct list_head *head,
struct work_struct **nextp)
-@@ -1131,9 +1132,9 @@ static void put_pwq_unlocked(struct pool
+@@ -1126,9 +1126,9 @@
* As both pwqs and pools are RCU protected, the
* following lock operations are safe.
*/
@@ -126,7 +120,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -1166,7 +1167,7 @@ static void pwq_activate_first_delayed(s
+@@ -1161,7 +1161,7 @@
* decrement nr_in_flight of its pwq and handle workqueue flushing.
*
* CONTEXT:
@@ -135,7 +129,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void pwq_dec_nr_in_flight(struct pool_workqueue *pwq, int color)
{
-@@ -1265,7 +1266,7 @@ static int try_to_grab_pending(struct wo
+@@ -1260,7 +1260,7 @@
if (!pool)
goto fail;
@@ -144,7 +138,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* work->data is guaranteed to point to pwq only while the work
* item is queued on pwq->wq, and both updating work->data to point
-@@ -1294,11 +1295,11 @@ static int try_to_grab_pending(struct wo
+@@ -1289,11 +1289,11 @@
/* work->data points to pwq iff queued, point to pool */
set_work_pool_and_keep_pending(work, pool->id);
@@ -158,7 +152,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fail:
rcu_read_unlock();
local_irq_restore(*flags);
-@@ -1319,7 +1320,7 @@ static int try_to_grab_pending(struct wo
+@@ -1314,7 +1314,7 @@
* work_struct flags.
*
* CONTEXT:
@@ -167,7 +161,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void insert_work(struct pool_workqueue *pwq, struct work_struct *work,
struct list_head *head, unsigned int extra_flags)
-@@ -1434,7 +1435,7 @@ static void __queue_work(int cpu, struct
+@@ -1429,7 +1429,7 @@
if (last_pool && last_pool != pwq->pool) {
struct worker *worker;
@@ -176,7 +170,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
worker = find_worker_executing_work(last_pool, work);
-@@ -1442,11 +1443,11 @@ static void __queue_work(int cpu, struct
+@@ -1437,11 +1437,11 @@
pwq = worker->current_pwq;
} else {
/* meh... not running there, queue here */
@@ -191,7 +185,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -1459,7 +1460,7 @@ static void __queue_work(int cpu, struct
+@@ -1454,7 +1454,7 @@
*/
if (unlikely(!pwq->refcnt)) {
if (wq->flags & WQ_UNBOUND) {
@@ -200,7 +194,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
cpu_relax();
goto retry;
}
-@@ -1491,7 +1492,7 @@ static void __queue_work(int cpu, struct
+@@ -1486,7 +1486,7 @@
insert_work(pwq, work, worklist, work_flags);
out:
@@ -209,20 +203,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rcu_read_unlock();
}
-@@ -1611,9 +1612,11 @@ EXPORT_SYMBOL_GPL(queue_work_node);
- void delayed_work_timer_fn(struct timer_list *t)
- {
- struct delayed_work *dwork = from_timer(dwork, t, timer);
-+ unsigned long flags;
-
-- /* should have been called from irqsafe timer with irq already off */
-+ local_irq_save(flags);
- __queue_work(dwork->cpu, dwork->wq, &dwork->work);
-+ local_irq_restore(flags);
- }
- EXPORT_SYMBOL(delayed_work_timer_fn);
-
-@@ -1760,7 +1763,7 @@ EXPORT_SYMBOL(queue_rcu_work);
+@@ -1757,7 +1757,7 @@
* necessary.
*
* LOCKING:
@@ -231,7 +212,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void worker_enter_idle(struct worker *worker)
{
-@@ -1800,7 +1803,7 @@ static void worker_enter_idle(struct wor
+@@ -1797,7 +1797,7 @@
* @worker is leaving idle state. Update stats.
*
* LOCKING:
@@ -240,7 +221,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void worker_leave_idle(struct worker *worker)
{
-@@ -1938,11 +1941,11 @@ static struct worker *create_worker(stru
+@@ -1935,11 +1935,11 @@
worker_attach_to_pool(worker, pool);
/* start the newly created worker */
@@ -254,7 +235,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return worker;
-@@ -1961,7 +1964,7 @@ static struct worker *create_worker(stru
+@@ -1958,7 +1958,7 @@
* be idle.
*
* CONTEXT:
@@ -263,7 +244,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void destroy_worker(struct worker *worker)
{
-@@ -1987,7 +1990,7 @@ static void idle_worker_timeout(struct t
+@@ -1984,7 +1984,7 @@
{
struct worker_pool *pool = from_timer(pool, t, idle_timer);
@@ -272,7 +253,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
while (too_many_workers(pool)) {
struct worker *worker;
-@@ -2005,7 +2008,7 @@ static void idle_worker_timeout(struct t
+@@ -2002,7 +2002,7 @@
destroy_worker(worker);
}
@@ -281,7 +262,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void send_mayday(struct work_struct *work)
-@@ -2036,8 +2039,8 @@ static void pool_mayday_timeout(struct t
+@@ -2033,8 +2033,8 @@
struct worker_pool *pool = from_timer(pool, t, mayday_timer);
struct work_struct *work;
@@ -292,7 +273,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (need_to_create_worker(pool)) {
/*
-@@ -2050,8 +2053,8 @@ static void pool_mayday_timeout(struct t
+@@ -2047,8 +2047,8 @@
send_mayday(work);
}
@@ -303,7 +284,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
mod_timer(&pool->mayday_timer, jiffies + MAYDAY_INTERVAL);
}
-@@ -2070,7 +2073,7 @@ static void pool_mayday_timeout(struct t
+@@ -2067,7 +2067,7 @@
* may_start_working() %true.
*
* LOCKING:
@@ -312,7 +293,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* multiple times. Does GFP_KERNEL allocations. Called only from
* manager.
*/
-@@ -2079,7 +2082,7 @@ static void maybe_create_worker(struct w
+@@ -2076,7 +2076,7 @@
__acquires(&pool->lock)
{
restart:
@@ -321,7 +302,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* if we don't make progress in MAYDAY_INITIAL_TIMEOUT, call for help */
mod_timer(&pool->mayday_timer, jiffies + MAYDAY_INITIAL_TIMEOUT);
-@@ -2095,7 +2098,7 @@ static void maybe_create_worker(struct w
+@@ -2092,7 +2092,7 @@
}
del_timer_sync(&pool->mayday_timer);
@@ -330,7 +311,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* This is necessary even after a new worker was just successfully
* created as @pool->lock was dropped and the new worker might have
-@@ -2118,7 +2121,7 @@ static void maybe_create_worker(struct w
+@@ -2115,7 +2115,7 @@
* and may_start_working() is true.
*
* CONTEXT:
@@ -339,16 +320,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* multiple times. Does GFP_KERNEL allocations.
*
* Return:
-@@ -2141,7 +2144,7 @@ static bool manage_workers(struct worker
-
- pool->manager = NULL;
- pool->flags &= ~POOL_MANAGER_ACTIVE;
-- wake_up(&wq_manager_wait);
-+ swake_up_one(&wq_manager_wait);
- return true;
- }
-
-@@ -2157,7 +2160,7 @@ static bool manage_workers(struct worker
+@@ -2154,7 +2154,7 @@
* call this function to process a work.
*
* CONTEXT:
@@ -357,7 +329,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void process_one_work(struct worker *worker, struct work_struct *work)
__releases(&pool->lock)
-@@ -2239,7 +2242,7 @@ static void process_one_work(struct work
+@@ -2236,7 +2236,7 @@
*/
set_work_pool_and_clear_pending(work, pool->id);
@@ -366,7 +338,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
lock_map_acquire(&pwq->wq->lockdep_map);
lock_map_acquire(&lockdep_map);
-@@ -2294,7 +2297,7 @@ static void process_one_work(struct work
+@@ -2291,7 +2291,7 @@
*/
cond_resched();
@@ -375,7 +347,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* clear cpu intensive status */
if (unlikely(cpu_intensive))
-@@ -2320,7 +2323,7 @@ static void process_one_work(struct work
+@@ -2317,7 +2317,7 @@
* fetches a work from the top and executes it.
*
* CONTEXT:
@@ -384,7 +356,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* multiple times.
*/
static void process_scheduled_works(struct worker *worker)
-@@ -2362,11 +2365,11 @@ static int worker_thread(void *__worker)
+@@ -2359,11 +2359,11 @@
/* tell the scheduler that this is a workqueue worker */
set_pf_worker(true);
woke_up:
@@ -398,7 +370,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
WARN_ON_ONCE(!list_empty(&worker->entry));
set_pf_worker(false);
-@@ -2432,7 +2435,7 @@ static int worker_thread(void *__worker)
+@@ -2429,7 +2429,7 @@
*/
worker_enter_idle(worker);
__set_current_state(TASK_IDLE);
@@ -407,7 +379,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
schedule();
goto woke_up;
}
-@@ -2486,7 +2489,7 @@ static int rescuer_thread(void *__rescue
+@@ -2483,7 +2483,7 @@
should_stop = kthread_should_stop();
/* see whether any pwq is asking for help */
@@ -416,7 +388,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
while (!list_empty(&wq->maydays)) {
struct pool_workqueue *pwq = list_first_entry(&wq->maydays,
-@@ -2498,11 +2501,11 @@ static int rescuer_thread(void *__rescue
+@@ -2495,11 +2495,11 @@
__set_current_state(TASK_RUNNING);
list_del_init(&pwq->mayday_node);
@@ -430,20 +402,25 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Slurp in all works issued via this workqueue and
-@@ -2531,10 +2534,10 @@ static int rescuer_thread(void *__rescue
+@@ -2528,7 +2528,7 @@
* incur MAYDAY_INTERVAL delay inbetween.
*/
if (need_to_create_worker(pool)) {
- spin_lock(&wq_mayday_lock);
+ raw_spin_lock(&wq_mayday_lock);
- get_pwq(pwq);
- list_move_tail(&pwq->mayday_node, &wq->maydays);
+ /*
+ * Queue iff we aren't racing destruction
+ * and somebody else hasn't queued it already.
+@@ -2537,7 +2537,7 @@
+ get_pwq(pwq);
+ list_add_tail(&pwq->mayday_node, &wq->maydays);
+ }
- spin_unlock(&wq_mayday_lock);
+ raw_spin_unlock(&wq_mayday_lock);
}
}
-@@ -2552,14 +2555,14 @@ static int rescuer_thread(void *__rescue
+@@ -2555,14 +2555,14 @@
if (need_more_worker(pool))
wake_up_worker(pool);
@@ -461,7 +438,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (should_stop) {
__set_current_state(TASK_RUNNING);
-@@ -2639,7 +2642,7 @@ static void wq_barrier_func(struct work_
+@@ -2642,7 +2642,7 @@
* underneath us, so we can't reliably determine pwq from @target.
*
* CONTEXT:
@@ -470,7 +447,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
static void insert_wq_barrier(struct pool_workqueue *pwq,
struct wq_barrier *barr,
-@@ -2726,7 +2729,7 @@ static bool flush_workqueue_prep_pwqs(st
+@@ -2729,7 +2729,7 @@
for_each_pwq(pwq, wq) {
struct worker_pool *pool = pwq->pool;
@@ -479,7 +456,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (flush_color >= 0) {
WARN_ON_ONCE(pwq->flush_color != -1);
-@@ -2743,7 +2746,7 @@ static bool flush_workqueue_prep_pwqs(st
+@@ -2746,7 +2746,7 @@
pwq->work_color = work_color;
}
@@ -488,7 +465,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
if (flush_color >= 0 && atomic_dec_and_test(&wq->nr_pwqs_to_flush))
-@@ -2943,9 +2946,9 @@ void drain_workqueue(struct workqueue_st
+@@ -2946,9 +2946,9 @@
for_each_pwq(pwq, wq) {
bool drained;
@@ -500,7 +477,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (drained)
continue;
-@@ -2981,7 +2984,7 @@ static bool start_flush_work(struct work
+@@ -2984,7 +2984,7 @@
return false;
}
@@ -509,7 +486,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* see the comment in try_to_grab_pending() with the same code */
pwq = get_work_pwq(work);
if (pwq) {
-@@ -2997,7 +3000,7 @@ static bool start_flush_work(struct work
+@@ -3000,7 +3000,7 @@
check_flush_dependency(pwq->wq, work);
insert_wq_barrier(pwq, barr, work, worker);
@@ -518,7 +495,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Force a lock recursion deadlock when using flush_work() inside a
-@@ -3016,7 +3019,7 @@ static bool start_flush_work(struct work
+@@ -3019,7 +3019,7 @@
rcu_read_unlock();
return true;
already_gone:
@@ -527,7 +504,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rcu_read_unlock();
return false;
}
-@@ -3409,7 +3412,7 @@ static bool wqattrs_equal(const struct w
+@@ -3412,7 +3412,7 @@
*/
static int init_worker_pool(struct worker_pool *pool)
{
@@ -536,17 +513,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
pool->id = -1;
pool->cpu = -1;
pool->node = NUMA_NO_NODE;
-@@ -3535,15 +3538,15 @@ static void put_unbound_pool(struct work
+@@ -3538,7 +3538,7 @@
* @pool's workers from blocking on attach_mutex. We're the last
* manager and @pool gets freed with the flag set.
*/
- spin_lock_irq(&pool->lock);
-- wait_event_lock_irq(wq_manager_wait,
+ raw_spin_lock_irq(&pool->lock);
-+ swait_event_lock_irq(wq_manager_wait,
+ swait_event_lock_irq(wq_manager_wait,
!(pool->flags & POOL_MANAGER_ACTIVE), pool->lock);
pool->flags |= POOL_MANAGER_ACTIVE;
-
+@@ -3546,7 +3546,7 @@
while ((worker = first_idle_worker(pool)))
destroy_worker(worker);
WARN_ON(pool->nr_workers || pool->nr_idle);
@@ -555,7 +531,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
mutex_lock(&wq_pool_attach_mutex);
if (!list_empty(&pool->workers))
-@@ -3699,7 +3702,7 @@ static void pwq_adjust_max_active(struct
+@@ -3702,7 +3702,7 @@
return;
/* this function can be called during early boot w/ irq disabled */
@@ -564,7 +540,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* During [un]freezing, the caller is responsible for ensuring that
-@@ -3722,7 +3725,7 @@ static void pwq_adjust_max_active(struct
+@@ -3725,7 +3725,7 @@
pwq->max_active = 0;
}
@@ -573,7 +549,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/* initialize newly alloced @pwq which is associated with @wq and @pool */
-@@ -4120,9 +4123,9 @@ static void wq_update_unbound_numa(struc
+@@ -4127,9 +4127,9 @@
use_dfl_pwq:
mutex_lock(&wq->mutex);
@@ -585,7 +561,19 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
old_pwq = numa_pwq_tbl_install(wq, node, wq->dfl_pwq);
out_unlock:
mutex_unlock(&wq->mutex);
-@@ -4513,10 +4516,10 @@ unsigned int work_busy(struct work_struc
+@@ -4342,9 +4342,9 @@
+ struct worker *rescuer = wq->rescuer;
+
+ /* this prevents new queueing */
+- spin_lock_irq(&wq_mayday_lock);
++ raw_spin_lock_irq(&wq_mayday_lock);
+ wq->rescuer = NULL;
+- spin_unlock_irq(&wq_mayday_lock);
++ raw_spin_unlock_irq(&wq_mayday_lock);
+
+ /* rescuer will empty maydays list before exiting */
+ kthread_stop(rescuer->task);
+@@ -4540,10 +4540,10 @@
rcu_read_lock();
pool = get_work_pool(work);
if (pool) {
@@ -598,7 +586,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
rcu_read_unlock();
-@@ -4722,10 +4725,10 @@ void show_workqueue_state(void)
+@@ -4750,10 +4750,10 @@
pr_info("workqueue %s: flags=0x%x\n", wq->name, wq->flags);
for_each_pwq(pwq, wq) {
@@ -611,7 +599,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We could be printing a lot from atomic context, e.g.
* sysrq-t -> show_workqueue_state(). Avoid triggering
-@@ -4739,7 +4742,7 @@ void show_workqueue_state(void)
+@@ -4767,7 +4767,7 @@
struct worker *worker;
bool first = true;
@@ -620,7 +608,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (pool->nr_workers == pool->nr_idle)
goto next_pool;
-@@ -4758,7 +4761,7 @@ void show_workqueue_state(void)
+@@ -4786,7 +4786,7 @@
}
pr_cont("\n");
next_pool:
@@ -629,7 +617,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We could be printing a lot from atomic context, e.g.
* sysrq-t -> show_workqueue_state(). Avoid triggering
-@@ -4788,7 +4791,7 @@ void wq_worker_comm(char *buf, size_t si
+@@ -4816,7 +4816,7 @@
struct worker_pool *pool = worker->pool;
if (pool) {
@@ -638,7 +626,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* ->desc tracks information (wq name or
* set_worker_desc()) for the latest execution. If
-@@ -4802,7 +4805,7 @@ void wq_worker_comm(char *buf, size_t si
+@@ -4830,7 +4830,7 @@
scnprintf(buf + off, size - off, "-%s",
worker->desc);
}
@@ -647,7 +635,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -4833,7 +4836,7 @@ static void unbind_workers(int cpu)
+@@ -4861,7 +4861,7 @@
for_each_cpu_worker_pool(pool, cpu) {
mutex_lock(&wq_pool_attach_mutex);
@@ -656,7 +644,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We've blocked all attach/detach operations. Make all workers
-@@ -4847,7 +4850,7 @@ static void unbind_workers(int cpu)
+@@ -4875,7 +4875,7 @@
pool->flags |= POOL_DISASSOCIATED;
@@ -665,7 +653,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
mutex_unlock(&wq_pool_attach_mutex);
/*
-@@ -4873,9 +4876,9 @@ static void unbind_workers(int cpu)
+@@ -4901,9 +4901,9 @@
* worker blocking could lead to lengthy stalls. Kick off
* unbound chain execution of currently pending work items.
*/
@@ -677,7 +665,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
-@@ -4902,7 +4905,7 @@ static void rebind_workers(struct worker
+@@ -4930,7 +4930,7 @@
WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task,
pool->attrs->cpumask) < 0);
@@ -686,7 +674,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
pool->flags &= ~POOL_DISASSOCIATED;
-@@ -4941,7 +4944,7 @@ static void rebind_workers(struct worker
+@@ -4969,7 +4969,7 @@
WRITE_ONCE(worker->flags, worker_flags);
}
diff --git a/debian/patches-rt/0005-jbd2-Don-t-call-__bforget-unnecessarily.patch b/debian/patches-rt/0005-jbd2-Don-t-call-__bforget-unnecessarily.patch
new file mode 100644
index 000000000000..ebd16e2552a7
--- /dev/null
+++ b/debian/patches-rt/0005-jbd2-Don-t-call-__bforget-unnecessarily.patch
@@ -0,0 +1,59 @@
+From: Jan Kara <jack@suse.cz>
+Date: Fri, 9 Aug 2019 14:42:31 +0200
+Subject: [PATCH 5/7] jbd2: Don't call __bforget() unnecessarily
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+jbd2_journal_forget() jumps to 'not_jbd' branch which calls __bforget()
+in cases where the buffer is clean which is pointless. In case of failed
+assertion, it can be even argued that it is safer not to touch buffer's
+dirty bits. Also logically it makes more sense to just jump to 'drop'
+and that will make logic also simpler when we switch bh_state_lock to a
+spinlock.
+
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/transaction.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -1550,7 +1550,7 @@ int jbd2_journal_forget (handle_t *handl
+ if (!J_EXPECT_JH(jh, !jh->b_committed_data,
+ "inconsistent data on disk")) {
+ err = -EIO;
+- goto not_jbd;
++ goto drop;
+ }
+
+ /* keep track of whether or not this transaction modified us */
+@@ -1640,7 +1640,7 @@ int jbd2_journal_forget (handle_t *handl
+ if (!jh->b_cp_transaction) {
+ JBUFFER_TRACE(jh, "belongs to none transaction");
+ spin_unlock(&journal->j_list_lock);
+- goto not_jbd;
++ goto drop;
+ }
+
+ /*
+@@ -1650,7 +1650,7 @@ int jbd2_journal_forget (handle_t *handl
+ if (!buffer_dirty(bh)) {
+ __jbd2_journal_remove_checkpoint(jh);
+ spin_unlock(&journal->j_list_lock);
+- goto not_jbd;
++ goto drop;
+ }
+
+ /*
+@@ -1663,10 +1663,9 @@ int jbd2_journal_forget (handle_t *handl
+ __jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
+ spin_unlock(&journal->j_list_lock);
+ }
+-
++drop:
+ jbd_unlock_bh_state(bh);
+ __brelse(bh);
+-drop:
+ if (drop_reserve) {
+ /* no need to reserve log space for this block -bzzz */
+ handle->h_buffer_credits++;
diff --git a/debian/patches-rt/0005-printk-rb-add-basic-non-blocking-reading-interface.patch b/debian/patches-rt/0005-printk-rb-add-basic-non-blocking-reading-interface.patch
index d999b88dbfc9..1ca06c8ab884 100644
--- a/debian/patches-rt/0005-printk-rb-add-basic-non-blocking-reading-interface.patch
+++ b/debian/patches-rt/0005-printk-rb-add-basic-non-blocking-reading-interface.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:43 +0100
Subject: [PATCH 05/25] printk-rb: add basic non-blocking reading interface
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add reader iterator static declaration/initializer, dynamic
initializer, and functions to iterate and retrieve ring buffer data.
diff --git a/debian/patches-rt/0006-jbd2-Make-state-lock-a-spinlock.patch b/debian/patches-rt/0006-jbd2-Make-state-lock-a-spinlock.patch
new file mode 100644
index 000000000000..b4e9d3c84264
--- /dev/null
+++ b/debian/patches-rt/0006-jbd2-Make-state-lock-a-spinlock.patch
@@ -0,0 +1,676 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 9 Aug 2019 14:42:32 +0200
+Subject: [PATCH 6/7] jbd2: Make state lock a spinlock
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Bit-spinlocks are problematic on PREEMPT_RT if functions which might sleep
+on RT, e.g. spin_lock(), alloc/free(), are invoked inside the lock held
+region because bit spinlocks disable preemption even on RT.
+
+A first attempt was to replace state lock with a spinlock placed in struct
+buffer_head and make the locking conditional on PREEMPT_RT and
+DEBUG_BIT_SPINLOCKS.
+
+Jan pointed out that there is a 4 byte hole in struct journal_head where a
+regular spinlock fits in and he would not object to convert the state lock
+to a spinlock unconditionally.
+
+Aside of solving the RT problem, this also gains lockdep coverage for the
+journal head state lock (bit-spinlocks are not covered by lockdep as it's
+hard to fit a lockdep map into a single bit).
+
+The trivial change would have been to convert the jbd_*lock_bh_state()
+inlines, but that comes with the downside that these functions take a
+buffer head pointer which needs to be converted to a journal head pointer
+which adds another level of indirection.
+
+As almost all functions which use this lock have a journal head pointer
+readily available, it makes more sense to remove the lock helper inlines
+and write out spin_*lock() at all call sites.
+
+Fixup all locking comments as well.
+
+Suggested-by: Jan Kara <jack@suse.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Cc: "Theodore Ts'o" <tytso@mit.edu>
+Cc: Mark Fasheh <mark@fasheh.com>
+Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Cc: Jan Kara <jack@suse.com>
+Cc: linux-ext4@vger.kernel.org
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/commit.c | 8 +--
+ fs/jbd2/journal.c | 10 ++--
+ fs/jbd2/transaction.c | 100 ++++++++++++++++++++-----------------------
+ fs/ocfs2/suballoc.c | 19 ++++----
+ include/linux/jbd2.h | 20 --------
+ include/linux/journal-head.h | 21 ++++++---
+ 6 files changed, 84 insertions(+), 94 deletions(-)
+
+--- a/fs/jbd2/commit.c
++++ b/fs/jbd2/commit.c
+@@ -482,10 +482,10 @@ void jbd2_journal_commit_transaction(jou
+ if (jh->b_committed_data) {
+ struct buffer_head *bh = jh2bh(jh);
+
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ jbd2_free(jh->b_committed_data, bh->b_size);
+ jh->b_committed_data = NULL;
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ }
+ jbd2_journal_refile_buffer(journal, jh);
+ }
+@@ -928,7 +928,7 @@ void jbd2_journal_commit_transaction(jou
+ * done with it.
+ */
+ get_bh(bh);
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ J_ASSERT_JH(jh, jh->b_transaction == commit_transaction);
+
+ /*
+@@ -1024,7 +1024,7 @@ void jbd2_journal_commit_transaction(jou
+ }
+ JBUFFER_TRACE(jh, "refile or unfile buffer");
+ drop_ref = __jbd2_journal_refile_buffer(jh);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ if (drop_ref)
+ jbd2_journal_put_journal_head(jh);
+ if (try_to_free)
+--- a/fs/jbd2/journal.c
++++ b/fs/jbd2/journal.c
+@@ -363,7 +363,7 @@ int jbd2_journal_write_metadata_buffer(t
+ /* keep subsequent assertions sane */
+ atomic_set(&new_bh->b_count, 1);
+
+- jbd_lock_bh_state(bh_in);
++ spin_lock(&jh_in->b_state_lock);
+ repeat:
+ /*
+ * If a new transaction has already done a buffer copy-out, then
+@@ -405,13 +405,13 @@ int jbd2_journal_write_metadata_buffer(t
+ if (need_copy_out && !done_copy_out) {
+ char *tmp;
+
+- jbd_unlock_bh_state(bh_in);
++ spin_unlock(&jh_in->b_state_lock);
+ tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
+ if (!tmp) {
+ brelse(new_bh);
+ return -ENOMEM;
+ }
+- jbd_lock_bh_state(bh_in);
++ spin_lock(&jh_in->b_state_lock);
+ if (jh_in->b_frozen_data) {
+ jbd2_free(tmp, bh_in->b_size);
+ goto repeat;
+@@ -464,7 +464,7 @@ int jbd2_journal_write_metadata_buffer(t
+ __jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow);
+ spin_unlock(&journal->j_list_lock);
+ set_buffer_shadow(bh_in);
+- jbd_unlock_bh_state(bh_in);
++ spin_unlock(&jh_in->b_state_lock);
+
+ return do_escape | (done_copy_out << 1);
+ }
+@@ -2410,6 +2410,8 @@ static struct journal_head *journal_allo
+ ret = kmem_cache_zalloc(jbd2_journal_head_cache,
+ GFP_NOFS | __GFP_NOFAIL);
+ }
++ if (ret)
++ spin_lock_init(&ret->b_state_lock);
+ return ret;
+ }
+
+--- a/fs/jbd2/transaction.c
++++ b/fs/jbd2/transaction.c
+@@ -879,7 +879,7 @@ do_get_write_access(handle_t *handle, st
+
+ start_lock = jiffies;
+ lock_buffer(bh);
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+
+ /* If it takes too long to lock the buffer, trace it */
+ time_lock = jbd2_time_diff(start_lock, jiffies);
+@@ -929,7 +929,7 @@ do_get_write_access(handle_t *handle, st
+
+ error = -EROFS;
+ if (is_handle_aborted(handle)) {
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ goto out;
+ }
+ error = 0;
+@@ -993,7 +993,7 @@ do_get_write_access(handle_t *handle, st
+ */
+ if (buffer_shadow(bh)) {
+ JBUFFER_TRACE(jh, "on shadow: sleep");
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ wait_on_bit_io(&bh->b_state, BH_Shadow, TASK_UNINTERRUPTIBLE);
+ goto repeat;
+ }
+@@ -1014,7 +1014,7 @@ do_get_write_access(handle_t *handle, st
+ JBUFFER_TRACE(jh, "generate frozen data");
+ if (!frozen_buffer) {
+ JBUFFER_TRACE(jh, "allocate memory for buffer");
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ frozen_buffer = jbd2_alloc(jh2bh(jh)->b_size,
+ GFP_NOFS | __GFP_NOFAIL);
+ goto repeat;
+@@ -1033,7 +1033,7 @@ do_get_write_access(handle_t *handle, st
+ jh->b_next_transaction = transaction;
+
+ done:
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+
+ /*
+ * If we are about to journal a buffer, then any revoke pending on it is
+@@ -1172,7 +1172,7 @@ int jbd2_journal_get_create_access(handl
+ * that case: the transaction must have deleted the buffer for it to be
+ * reused here.
+ */
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
+ jh->b_transaction == NULL ||
+ (jh->b_transaction == journal->j_committing_transaction &&
+@@ -1207,7 +1207,7 @@ int jbd2_journal_get_create_access(handl
+ jh->b_next_transaction = transaction;
+ spin_unlock(&journal->j_list_lock);
+ }
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+
+ /*
+ * akpm: I added this. ext3_alloc_branch can pick up new indirect
+@@ -1275,13 +1275,13 @@ int jbd2_journal_get_undo_access(handle_
+ committed_data = jbd2_alloc(jh2bh(jh)->b_size,
+ GFP_NOFS|__GFP_NOFAIL);
+
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ if (!jh->b_committed_data) {
+ /* Copy out the current buffer contents into the
+ * preserved, committed copy. */
+ JBUFFER_TRACE(jh, "generate b_committed data");
+ if (!committed_data) {
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ goto repeat;
+ }
+
+@@ -1289,7 +1289,7 @@ int jbd2_journal_get_undo_access(handle_
+ committed_data = NULL;
+ memcpy(jh->b_committed_data, bh->b_data, bh->b_size);
+ }
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ out:
+ jbd2_journal_put_journal_head(jh);
+ if (unlikely(committed_data))
+@@ -1390,16 +1390,16 @@ int jbd2_journal_dirty_metadata(handle_t
+ */
+ if (jh->b_transaction != transaction &&
+ jh->b_next_transaction != transaction) {
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ J_ASSERT_JH(jh, jh->b_transaction == transaction ||
+ jh->b_next_transaction == transaction);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ }
+ if (jh->b_modified == 1) {
+ /* If it's in our transaction it must be in BJ_Metadata list. */
+ if (jh->b_transaction == transaction &&
+ jh->b_jlist != BJ_Metadata) {
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ if (jh->b_transaction == transaction &&
+ jh->b_jlist != BJ_Metadata)
+ pr_err("JBD2: assertion failure: h_type=%u "
+@@ -1409,13 +1409,13 @@ int jbd2_journal_dirty_metadata(handle_t
+ jh->b_jlist);
+ J_ASSERT_JH(jh, jh->b_transaction != transaction ||
+ jh->b_jlist == BJ_Metadata);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ }
+ goto out;
+ }
+
+ journal = transaction->t_journal;
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+
+ if (jh->b_modified == 0) {
+ /*
+@@ -1501,7 +1501,7 @@ int jbd2_journal_dirty_metadata(handle_t
+ __jbd2_journal_file_buffer(jh, transaction, BJ_Metadata);
+ spin_unlock(&journal->j_list_lock);
+ out_unlock_bh:
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ out:
+ JBUFFER_TRACE(jh, "exit");
+ return ret;
+@@ -1539,11 +1539,13 @@ int jbd2_journal_forget (handle_t *handl
+
+ BUFFER_TRACE(bh, "entry");
+
+- jbd_lock_bh_state(bh);
++ jh = jbd2_journal_grab_journal_head(bh);
++ if (!jh) {
++ __bforget(bh);
++ return 0;
++ }
+
+- if (!buffer_jbd(bh))
+- goto not_jbd;
+- jh = bh2jh(bh);
++ spin_lock(&jh->b_state_lock);
+
+ /* Critical error: attempting to delete a bitmap buffer, maybe?
+ * Don't do any jbd operations, and return an error. */
+@@ -1664,18 +1666,14 @@ int jbd2_journal_forget (handle_t *handl
+ spin_unlock(&journal->j_list_lock);
+ }
+ drop:
+- jbd_unlock_bh_state(bh);
+ __brelse(bh);
++ spin_unlock(&jh->b_state_lock);
++ jbd2_journal_put_journal_head(jh);
+ if (drop_reserve) {
+ /* no need to reserve log space for this block -bzzz */
+ handle->h_buffer_credits++;
+ }
+ return err;
+-
+-not_jbd:
+- jbd_unlock_bh_state(bh);
+- __bforget(bh);
+- goto drop;
+ }
+
+ /**
+@@ -1874,7 +1872,7 @@ int jbd2_journal_stop(handle_t *handle)
+ *
+ * j_list_lock is held.
+ *
+- * jbd_lock_bh_state(jh2bh(jh)) is held.
++ * jh->b_state_lock is held.
+ */
+
+ static inline void
+@@ -1898,7 +1896,7 @@ static inline void
+ *
+ * Called with j_list_lock held, and the journal may not be locked.
+ *
+- * jbd_lock_bh_state(jh2bh(jh)) is held.
++ * jh->b_state_lock is held.
+ */
+
+ static inline void
+@@ -1930,7 +1928,7 @@ static void __jbd2_journal_temp_unlink_b
+ transaction_t *transaction;
+ struct buffer_head *bh = jh2bh(jh);
+
+- J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
++ lockdep_assert_held(&jh->b_state_lock);
+ transaction = jh->b_transaction;
+ if (transaction)
+ assert_spin_locked(&transaction->t_journal->j_list_lock);
+@@ -1984,11 +1982,11 @@ void jbd2_journal_unfile_buffer(journal_
+
+ /* Get reference so that buffer cannot be freed before we unlock it */
+ get_bh(bh);
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ spin_lock(&journal->j_list_lock);
+ __jbd2_journal_unfile_buffer(jh);
+ spin_unlock(&journal->j_list_lock);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ jbd2_journal_put_journal_head(jh);
+ __brelse(bh);
+ }
+@@ -1996,7 +1994,7 @@ void jbd2_journal_unfile_buffer(journal_
+ /*
+ * Called from jbd2_journal_try_to_free_buffers().
+ *
+- * Called under jbd_lock_bh_state(bh)
++ * Called under jh->b_state_lock
+ */
+ static void
+ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
+@@ -2083,10 +2081,10 @@ int jbd2_journal_try_to_free_buffers(jou
+ if (!jh)
+ continue;
+
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ __journal_try_to_free_buffer(journal, bh);
++ spin_unlock(&jh->b_state_lock);
+ jbd2_journal_put_journal_head(jh);
+- jbd_unlock_bh_state(bh);
+ if (buffer_jbd(bh))
+ goto busy;
+ } while ((bh = bh->b_this_page) != head);
+@@ -2107,7 +2105,7 @@ int jbd2_journal_try_to_free_buffers(jou
+ *
+ * Called under j_list_lock.
+ *
+- * Called under jbd_lock_bh_state(bh).
++ * Called under jh->b_state_lock.
+ */
+ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
+ {
+@@ -2201,7 +2199,7 @@ static int journal_unmap_buffer(journal_
+
+ /* OK, we have data buffer in journaled mode */
+ write_lock(&journal->j_state_lock);
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ spin_lock(&journal->j_list_lock);
+
+ /*
+@@ -2282,10 +2280,10 @@ static int journal_unmap_buffer(journal_
+ * for commit and try again.
+ */
+ if (partial_page) {
+- jbd2_journal_put_journal_head(jh);
+ spin_unlock(&journal->j_list_lock);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ write_unlock(&journal->j_state_lock);
++ jbd2_journal_put_journal_head(jh);
+ return -EBUSY;
+ }
+ /*
+@@ -2297,10 +2295,10 @@ static int journal_unmap_buffer(journal_
+ set_buffer_freed(bh);
+ if (journal->j_running_transaction && buffer_jbddirty(bh))
+ jh->b_next_transaction = journal->j_running_transaction;
+- jbd2_journal_put_journal_head(jh);
+ spin_unlock(&journal->j_list_lock);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ write_unlock(&journal->j_state_lock);
++ jbd2_journal_put_journal_head(jh);
+ return 0;
+ } else {
+ /* Good, the buffer belongs to the running transaction.
+@@ -2324,10 +2322,10 @@ static int journal_unmap_buffer(journal_
+ * here.
+ */
+ jh->b_modified = 0;
+- jbd2_journal_put_journal_head(jh);
+ spin_unlock(&journal->j_list_lock);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ write_unlock(&journal->j_state_lock);
++ jbd2_journal_put_journal_head(jh);
+ zap_buffer_unlocked:
+ clear_buffer_dirty(bh);
+ J_ASSERT_BH(bh, !buffer_jbddirty(bh));
+@@ -2414,7 +2412,7 @@ void __jbd2_journal_file_buffer(struct j
+ int was_dirty = 0;
+ struct buffer_head *bh = jh2bh(jh);
+
+- J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
++ lockdep_assert_held(&jh->b_state_lock);
+ assert_spin_locked(&transaction->t_journal->j_list_lock);
+
+ J_ASSERT_JH(jh, jh->b_jlist < BJ_Types);
+@@ -2476,11 +2474,11 @@ void __jbd2_journal_file_buffer(struct j
+ void jbd2_journal_file_buffer(struct journal_head *jh,
+ transaction_t *transaction, int jlist)
+ {
+- jbd_lock_bh_state(jh2bh(jh));
++ spin_lock(&jh->b_state_lock);
+ spin_lock(&transaction->t_journal->j_list_lock);
+ __jbd2_journal_file_buffer(jh, transaction, jlist);
+ spin_unlock(&transaction->t_journal->j_list_lock);
+- jbd_unlock_bh_state(jh2bh(jh));
++ spin_unlock(&jh->b_state_lock);
+ }
+
+ /*
+@@ -2490,7 +2488,7 @@ void jbd2_journal_file_buffer(struct jou
+ * buffer on that transaction's metadata list.
+ *
+ * Called under j_list_lock
+- * Called under jbd_lock_bh_state(jh2bh(jh))
++ * Called under jh->b_state_lock
+ *
+ * When this function returns true, there's no next transaction to refile to
+ * and the caller has to drop jh reference through
+@@ -2501,7 +2499,7 @@ bool __jbd2_journal_refile_buffer(struct
+ int was_dirty, jlist;
+ struct buffer_head *bh = jh2bh(jh);
+
+- J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
++ lockdep_assert_held(&jh->b_state_lock);
+ if (jh->b_transaction)
+ assert_spin_locked(&jh->b_transaction->t_journal->j_list_lock);
+
+@@ -2547,17 +2545,13 @@ bool __jbd2_journal_refile_buffer(struct
+ */
+ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
+ {
+- struct buffer_head *bh = jh2bh(jh);
+ bool drop;
+
+- /* Get reference so that buffer cannot be freed before we unlock it */
+- get_bh(bh);
+- jbd_lock_bh_state(bh);
++ spin_lock(&jh->b_state_lock);
+ spin_lock(&journal->j_list_lock);
+ drop = __jbd2_journal_refile_buffer(jh);
+- jbd_unlock_bh_state(bh);
++ spin_unlock(&jh->b_state_lock);
+ spin_unlock(&journal->j_list_lock);
+- __brelse(bh);
+ if (drop)
+ jbd2_journal_put_journal_head(jh);
+ }
+--- a/fs/ocfs2/suballoc.c
++++ b/fs/ocfs2/suballoc.c
+@@ -1252,6 +1252,7 @@ static int ocfs2_test_bg_bit_allocatable
+ int nr)
+ {
+ struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
++ struct journal_head *jh;
+ int ret;
+
+ if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
+@@ -1260,13 +1261,14 @@ static int ocfs2_test_bg_bit_allocatable
+ if (!buffer_jbd(bg_bh))
+ return 1;
+
+- jbd_lock_bh_state(bg_bh);
+- bg = (struct ocfs2_group_desc *) bh2jh(bg_bh)->b_committed_data;
++ jh = bh2jh(bg_bh);
++ spin_lock(&jh->b_state_lock);
++ bg = (struct ocfs2_group_desc *) jh->b_committed_data;
+ if (bg)
+ ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
+ else
+ ret = 1;
+- jbd_unlock_bh_state(bg_bh);
++ spin_unlock(&jh->b_state_lock);
+
+ return ret;
+ }
+@@ -2387,6 +2389,7 @@ static int ocfs2_block_group_clear_bits(
+ int status;
+ unsigned int tmp;
+ struct ocfs2_group_desc *undo_bg = NULL;
++ struct journal_head *jh;
+
+ /* The caller got this descriptor from
+ * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
+@@ -2405,10 +2408,10 @@ static int ocfs2_block_group_clear_bits(
+ goto bail;
+ }
+
++ jh = bh2jh(group_bh);
+ if (undo_fn) {
+- jbd_lock_bh_state(group_bh);
+- undo_bg = (struct ocfs2_group_desc *)
+- bh2jh(group_bh)->b_committed_data;
++ spin_lock(&jh->b_state_lock);
++ undo_bg = (struct ocfs2_group_desc *) jh->b_committed_data;
+ BUG_ON(!undo_bg);
+ }
+
+@@ -2423,7 +2426,7 @@ static int ocfs2_block_group_clear_bits(
+ le16_add_cpu(&bg->bg_free_bits_count, num_bits);
+ if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) {
+ if (undo_fn)
+- jbd_unlock_bh_state(group_bh);
++ spin_unlock(&jh->b_state_lock);
+ return ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit count %u but claims %u are freed. num_bits %d\n",
+ (unsigned long long)le64_to_cpu(bg->bg_blkno),
+ le16_to_cpu(bg->bg_bits),
+@@ -2432,7 +2435,7 @@ static int ocfs2_block_group_clear_bits(
+ }
+
+ if (undo_fn)
+- jbd_unlock_bh_state(group_bh);
++ spin_unlock(&jh->b_state_lock);
+
+ ocfs2_journal_dirty(handle, group_bh);
+ bail:
+--- a/include/linux/jbd2.h
++++ b/include/linux/jbd2.h
+@@ -313,7 +313,6 @@ enum jbd_state_bits {
+ BH_Revoked, /* Has been revoked from the log */
+ BH_RevokeValid, /* Revoked flag is valid */
+ BH_JBDDirty, /* Is dirty but journaled */
+- BH_State, /* Pins most journal_head state */
+ BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
+ BH_Shadow, /* IO on shadow buffer is running */
+ BH_Verified, /* Metadata block has been verified ok */
+@@ -342,21 +341,6 @@ static inline struct journal_head *bh2jh
+ return bh->b_private;
+ }
+
+-static inline void jbd_lock_bh_state(struct buffer_head *bh)
+-{
+- bit_spin_lock(BH_State, &bh->b_state);
+-}
+-
+-static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
+-{
+- return bit_spin_is_locked(BH_State, &bh->b_state);
+-}
+-
+-static inline void jbd_unlock_bh_state(struct buffer_head *bh)
+-{
+- bit_spin_unlock(BH_State, &bh->b_state);
+-}
+-
+ static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
+ {
+ bit_spin_lock(BH_JournalHead, &bh->b_state);
+@@ -551,9 +535,9 @@ struct transaction_chp_stats_s {
+ * ->jbd_lock_bh_journal_head() (This is "innermost")
+ *
+ * j_state_lock
+- * ->jbd_lock_bh_state()
++ * ->b_state_lock
+ *
+- * jbd_lock_bh_state()
++ * b_state_lock
+ * ->j_list_lock
+ *
+ * j_state_lock
+--- a/include/linux/journal-head.h
++++ b/include/linux/journal-head.h
+@@ -11,6 +11,8 @@
+ #ifndef JOURNAL_HEAD_H_INCLUDED
+ #define JOURNAL_HEAD_H_INCLUDED
+
++#include <linux/spinlock.h>
++
+ typedef unsigned int tid_t; /* Unique transaction ID */
+ typedef struct transaction_s transaction_t; /* Compound transaction type */
+
+@@ -24,13 +26,18 @@ struct journal_head {
+ struct buffer_head *b_bh;
+
+ /*
++ * Protect the buffer head state
++ */
++ spinlock_t b_state_lock;
++
++ /*
+ * Reference count - see description in journal.c
+ * [jbd_lock_bh_journal_head()]
+ */
+ int b_jcount;
+
+ /*
+- * Journalling list for this buffer [jbd_lock_bh_state()]
++ * Journalling list for this buffer [b_state_lock]
+ * NOTE: We *cannot* combine this with b_modified into a bitfield
+ * as gcc would then (which the C standard allows but which is
+ * very unuseful) make 64-bit accesses to the bitfield and clobber
+@@ -41,20 +48,20 @@ struct journal_head {
+ /*
+ * This flag signals the buffer has been modified by
+ * the currently running transaction
+- * [jbd_lock_bh_state()]
++ * [b_state_lock]
+ */
+ unsigned b_modified;
+
+ /*
+ * Copy of the buffer data frozen for writing to the log.
+- * [jbd_lock_bh_state()]
++ * [b_state_lock]
+ */
+ char *b_frozen_data;
+
+ /*
+ * Pointer to a saved copy of the buffer containing no uncommitted
+ * deallocation references, so that allocations can avoid overwriting
+- * uncommitted deletes. [jbd_lock_bh_state()]
++ * uncommitted deletes. [b_state_lock]
+ */
+ char *b_committed_data;
+
+@@ -63,7 +70,7 @@ struct journal_head {
+ * metadata: either the running transaction or the committing
+ * transaction (if there is one). Only applies to buffers on a
+ * transaction's data or metadata journaling list.
+- * [j_list_lock] [jbd_lock_bh_state()]
++ * [j_list_lock] [b_state_lock]
+ * Either of these locks is enough for reading, both are needed for
+ * changes.
+ */
+@@ -73,13 +80,13 @@ struct journal_head {
+ * Pointer to the running compound transaction which is currently
+ * modifying the buffer's metadata, if there was already a transaction
+ * committing it when the new transaction touched it.
+- * [t_list_lock] [jbd_lock_bh_state()]
++ * [t_list_lock] [b_state_lock]
+ */
+ transaction_t *b_next_transaction;
+
+ /*
+ * Doubly-linked list of buffers on a transaction's data, metadata or
+- * forget queue. [t_list_lock] [jbd_lock_bh_state()]
++ * forget queue. [t_list_lock] [b_state_lock]
+ */
+ struct journal_head *b_tnext, *b_tprev;
+
diff --git a/debian/patches-rt/0006-printk-rb-add-blocking-reader-support.patch b/debian/patches-rt/0006-printk-rb-add-blocking-reader-support.patch
index 00bdb21b7197..43e086ccb083 100644
--- a/debian/patches-rt/0006-printk-rb-add-blocking-reader-support.patch
+++ b/debian/patches-rt/0006-printk-rb-add-blocking-reader-support.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:44 +0100
Subject: [PATCH 06/25] printk-rb: add blocking reader support
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add a blocking read function for readers. An irq_work function is
used to signal the wait queue so that write notification can
diff --git a/debian/patches-rt/0007-jbd2-Free-journal-head-outside-of-locked-region.patch b/debian/patches-rt/0007-jbd2-Free-journal-head-outside-of-locked-region.patch
new file mode 100644
index 000000000000..17a2978c9946
--- /dev/null
+++ b/debian/patches-rt/0007-jbd2-Free-journal-head-outside-of-locked-region.patch
@@ -0,0 +1,89 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 9 Aug 2019 14:42:33 +0200
+Subject: [PATCH 7/7] jbd2: Free journal head outside of locked region
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+On PREEMPT_RT bit-spinlocks have the same semantics as on PREEMPT_RT=n,
+i.e. they disable preemption. That means functions which are not safe to be
+called in preempt disabled context on RT trigger a might_sleep() assert.
+
+The journal head bit spinlock is mostly held for short code sequences with
+trivial RT safe functionality, except for one place:
+
+jbd2_journal_put_journal_head() invokes __journal_remove_journal_head()
+with the journal head bit spinlock held. __journal_remove_journal_head()
+invokes kmem_cache_free() which must not be called with preemption disabled
+on RT.
+
+Jan suggested to rework the removal function so the actual free happens
+outside the bit-spinlocked region.
+
+Split it into two parts:
+
+ - Do the sanity checks and the buffer head detach under the lock
+
+ - Do the actual free after dropping the lock
+
+There is error case handling in the free part which needs to dereference
+the b_size field of the now detached buffer head. Due to paranoia (caused
+by ignorance) the size is retrieved in the detach function and handed into
+the free function. Might be over-engineered, but better safe than sorry.
+
+This makes the journal head bit-spinlock usage RT compliant and also avoids
+nested locking which is not covered by lockdep.
+
+Suggested-by: Jan Kara <jack@suse.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-ext4@vger.kernel.org
+Cc: "Theodore Ts'o" <tytso@mit.edu>
+Cc: Jan Kara <jack@suse.com>
+Signed-off-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ fs/jbd2/journal.c | 20 ++++++++++++++------
+ 1 file changed, 14 insertions(+), 6 deletions(-)
+
+--- a/fs/jbd2/journal.c
++++ b/fs/jbd2/journal.c
+@@ -2531,17 +2531,23 @@ static void __journal_remove_journal_hea
+ J_ASSERT_BH(bh, buffer_jbd(bh));
+ J_ASSERT_BH(bh, jh2bh(jh) == bh);
+ BUFFER_TRACE(bh, "remove journal_head");
++
++ /* Unlink before dropping the lock */
++ bh->b_private = NULL;
++ jh->b_bh = NULL; /* debug, really */
++ clear_buffer_jbd(bh);
++}
++
++static void journal_release_journal_head(struct journal_head *jh, size_t b_size)
++{
+ if (jh->b_frozen_data) {
+ printk(KERN_WARNING "%s: freeing b_frozen_data\n", __func__);
+- jbd2_free(jh->b_frozen_data, bh->b_size);
++ jbd2_free(jh->b_frozen_data, b_size);
+ }
+ if (jh->b_committed_data) {
+ printk(KERN_WARNING "%s: freeing b_committed_data\n", __func__);
+- jbd2_free(jh->b_committed_data, bh->b_size);
++ jbd2_free(jh->b_committed_data, b_size);
+ }
+- bh->b_private = NULL;
+- jh->b_bh = NULL; /* debug, really */
+- clear_buffer_jbd(bh);
+ journal_free_journal_head(jh);
+ }
+
+@@ -2559,9 +2565,11 @@ void jbd2_journal_put_journal_head(struc
+ if (!jh->b_jcount) {
+ __journal_remove_journal_head(bh);
+ jbd_unlock_bh_journal_head(bh);
++ journal_release_journal_head(jh, bh->b_size);
+ __brelse(bh);
+- } else
++ } else {
+ jbd_unlock_bh_journal_head(bh);
++ }
+ }
+
+ /*
diff --git a/debian/patches-rt/0007-printk-rb-add-functionality-required-by-printk.patch b/debian/patches-rt/0007-printk-rb-add-functionality-required-by-printk.patch
index 5a55f5de56dd..a78ccb2c8eb3 100644
--- a/debian/patches-rt/0007-printk-rb-add-functionality-required-by-printk.patch
+++ b/debian/patches-rt/0007-printk-rb-add-functionality-required-by-printk.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:45 +0100
Subject: [PATCH 07/25] printk-rb: add functionality required by printk
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The printk subsystem needs to be able to query the size of the ring
buffer, seek to specific entries within the ring buffer, and track
diff --git a/debian/patches-rt/0008-printk-add-ring-buffer-and-kthread.patch b/debian/patches-rt/0008-printk-add-ring-buffer-and-kthread.patch
index 471f5a9c7e00..46a555e41ea8 100644
--- a/debian/patches-rt/0008-printk-add-ring-buffer-and-kthread.patch
+++ b/debian/patches-rt/0008-printk-add-ring-buffer-and-kthread.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:46 +0100
Subject: [PATCH 08/25] printk: add ring buffer and kthread
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The printk ring buffer provides an NMI-safe interface for writing
messages to a ring buffer. Using such a buffer for alleviates printk
@@ -35,7 +35,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/sched/clock.h>
#include <linux/sched/debug.h>
#include <linux/sched/task_stack.h>
-@@ -407,7 +409,12 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
+@@ -417,7 +419,12 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
printk_safe_exit_irqrestore(flags); \
} while (0)
@@ -48,7 +48,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
DECLARE_WAIT_QUEUE_HEAD(log_wait);
/* the next printk record to read by syslog(READ) or /proc/kmsg */
static u64 syslog_seq;
-@@ -770,6 +777,10 @@ static ssize_t msg_print_ext_body(char *
+@@ -780,6 +787,10 @@ static ssize_t msg_print_ext_body(char *
return p - buf;
}
@@ -59,7 +59,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* /dev/kmsg - userspace message inject/listen interface */
struct devkmsg_user {
u64 seq;
-@@ -1610,6 +1621,34 @@ SYSCALL_DEFINE3(syslog, int, type, char
+@@ -1620,6 +1631,34 @@ SYSCALL_DEFINE3(syslog, int, type, char
return do_syslog(type, buf, len, SYSLOG_FROM_READER);
}
@@ -94,7 +94,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Special console_lock variants that help to reduce the risk of soft-lockups.
* They allow to pass console_lock to another printk() call using a busy wait.
-@@ -2964,6 +3003,72 @@ void wake_up_klogd(void)
+@@ -2974,6 +3013,72 @@ void wake_up_klogd(void)
preempt_enable();
}
diff --git a/debian/patches-rt/0009-printk-remove-exclusive-console-hack.patch b/debian/patches-rt/0009-printk-remove-exclusive-console-hack.patch
index 12aa27ef2bc7..50bd77a81d38 100644
--- a/debian/patches-rt/0009-printk-remove-exclusive-console-hack.patch
+++ b/debian/patches-rt/0009-printk-remove-exclusive-console-hack.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:47 +0100
Subject: [PATCH 09/25] printk: remove exclusive console hack
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
In order to support printing the printk log history when new
consoles are registered, a global exclusive_console variable is
@@ -21,7 +21,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -259,11 +259,6 @@ static void __up_console_sem(unsigned lo
+@@ -269,11 +269,6 @@ static void __up_console_sem(unsigned lo
static int console_locked, console_suspended;
/*
@@ -33,7 +33,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Array of consoles built from command line options (console=)
*/
-@@ -433,7 +428,6 @@ static u32 log_next_idx;
+@@ -443,7 +438,6 @@ static u32 log_next_idx;
/* the next printk record to write to the console */
static u64 console_seq;
static u32 console_idx;
@@ -41,7 +41,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
-@@ -1805,8 +1799,6 @@ static void call_console_drivers(const c
+@@ -1815,8 +1809,6 @@ static void call_console_drivers(const c
return;
for_each_console(con) {
@@ -50,7 +50,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!(con->flags & CON_ENABLED))
continue;
if (!con->write)
-@@ -2099,7 +2091,6 @@ static u64 syslog_seq;
+@@ -2109,7 +2101,6 @@ static u64 syslog_seq;
static u32 syslog_idx;
static u64 console_seq;
static u32 console_idx;
@@ -58,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static u64 log_first_seq;
static u32 log_first_idx;
static u64 log_next_seq;
-@@ -2468,12 +2459,6 @@ void console_unlock(void)
+@@ -2478,12 +2469,6 @@ void console_unlock(void)
goto skip;
}
@@ -71,7 +71,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
len += msg_print_text(msg,
console_msg_format & MSG_FORMAT_SYSLOG,
printk_time, text + len, sizeof(text) - len);
-@@ -2801,17 +2786,6 @@ void register_console(struct console *ne
+@@ -2811,17 +2796,6 @@ void register_console(struct console *ne
logbuf_lock_irqsave(flags);
console_seq = syslog_seq;
console_idx = syslog_idx;
@@ -89,7 +89,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
logbuf_unlock_irqrestore(flags);
}
console_unlock();
-@@ -2823,6 +2797,10 @@ void register_console(struct console *ne
+@@ -2833,6 +2807,10 @@ void register_console(struct console *ne
* boot consoles, real consoles, etc - this is to ensure that end
* users know there might be something in the kernel's log buffer that
* went to the bootconsole (that they do not see on the real console)
diff --git a/debian/patches-rt/0010-printk-redirect-emit-store-to-new-ringbuffer.patch b/debian/patches-rt/0010-printk-redirect-emit-store-to-new-ringbuffer.patch
index 9ff16c781627..893f69198f85 100644
--- a/debian/patches-rt/0010-printk-redirect-emit-store-to-new-ringbuffer.patch
+++ b/debian/patches-rt/0010-printk-redirect-emit-store-to-new-ringbuffer.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:48 +0100
Subject: [PATCH 10/25] printk: redirect emit/store to new ringbuffer
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
vprintk_emit and vprintk_store are the main functions that all printk
variants eventually go through. Change these to store the message in
@@ -26,7 +26,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -507,90 +507,6 @@ static u32 log_next(u32 idx)
+@@ -517,90 +517,6 @@ static u32 log_next(u32 idx)
return idx + msg->len;
}
@@ -117,7 +117,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* insert record into the buffer, discard old ones, update heads */
static int log_store(u32 caller_id, int facility, int level,
enum log_flags flags, u64 ts_nsec,
-@@ -598,57 +514,39 @@ static int log_store(u32 caller_id, int
+@@ -608,57 +524,39 @@ static int log_store(u32 caller_id, int
const char *text, u16 text_len)
{
struct printk_log *msg;
@@ -188,7 +188,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return msg->text_len;
}
-@@ -1719,70 +1617,6 @@ static int console_lock_spinning_disable
+@@ -1729,70 +1627,6 @@ static int console_lock_spinning_disable
return 1;
}
@@ -259,7 +259,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Call the console drivers, asking them to write out
* log_buf[start] to log_buf[end - 1].
-@@ -1803,7 +1637,7 @@ static void call_console_drivers(const c
+@@ -1813,7 +1647,7 @@ static void call_console_drivers(const c
continue;
if (!con->write)
continue;
@@ -268,7 +268,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
!(con->flags & CON_ANYTIME))
continue;
if (con->flags & CON_EXTENDED)
-@@ -1833,6 +1667,8 @@ static inline u32 printk_caller_id(void)
+@@ -1843,6 +1677,8 @@ static inline u32 printk_caller_id(void)
0x80000000 + raw_smp_processor_id();
}
@@ -277,7 +277,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Continuation lines are buffered, and not committed to the record buffer
* until the line is complete, or a race forces it. The line fragments
-@@ -1888,56 +1724,45 @@ static bool cont_add(u32 caller_id, int
+@@ -1898,56 +1734,45 @@ static bool cont_add(u32 caller_id, int
return true;
}
@@ -365,7 +365,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (text_len && text[text_len-1] == '\n') {
text_len--;
lflags |= LOG_NEWLINE;
-@@ -1968,58 +1793,10 @@ int vprintk_store(int facility, int leve
+@@ -1978,58 +1803,10 @@ int vprintk_store(int facility, int leve
if (dict)
lflags |= LOG_NEWLINE;
@@ -427,7 +427,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return printed_len;
}
EXPORT_SYMBOL(vprintk_emit);
-@@ -2484,7 +2261,7 @@ void console_unlock(void)
+@@ -2494,7 +2271,7 @@ void console_unlock(void)
console_lock_spinning_enable();
stop_critical_timings(); /* don't trace print latency */
diff --git a/debian/patches-rt/0011-printk_safe-remove-printk-safe-code.patch b/debian/patches-rt/0011-printk_safe-remove-printk-safe-code.patch
index 2c59b07e72ea..d62ed2bef2c3 100644
--- a/debian/patches-rt/0011-printk_safe-remove-printk-safe-code.patch
+++ b/debian/patches-rt/0011-printk_safe-remove-printk-safe-code.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:49 +0100
Subject: [PATCH 11/25] printk_safe: remove printk safe code
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
vprintk variants are now NMI-safe so there is no longer a need for
the "safe" calls.
@@ -121,7 +121,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
extern int kptr_restrict;
--- a/init/main.c
+++ b/init/main.c
-@@ -669,7 +669,6 @@ asmlinkage __visible void __init start_k
+@@ -693,7 +693,6 @@ asmlinkage __visible void __init start_k
boot_init_stack_canary();
time_init();
@@ -131,7 +131,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
call_function_init();
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
-@@ -970,7 +970,6 @@ void crash_kexec(struct pt_regs *regs)
+@@ -972,7 +972,6 @@ void crash_kexec(struct pt_regs *regs)
old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
if (old_cpu == PANIC_CPU_INVALID) {
/* This is the 1st CPU which comes here, so go ahead. */
@@ -141,7 +141,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
--- a/kernel/panic.c
+++ b/kernel/panic.c
-@@ -228,7 +228,6 @@ void panic(const char *fmt, ...)
+@@ -237,7 +237,6 @@ void panic(const char *fmt, ...)
* Bypass the panic_cpu check and call __crash_kexec directly.
*/
if (!_crash_kexec_post_notifiers) {
@@ -149,7 +149,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
__crash_kexec(NULL);
/*
-@@ -252,8 +251,6 @@ void panic(const char *fmt, ...)
+@@ -261,8 +260,6 @@ void panic(const char *fmt, ...)
*/
atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
@@ -215,7 +215,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-#endif /* CONFIG_PRINTK */
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1726,13 +1726,6 @@ static bool cont_add(u32 caller_id, int
+@@ -1736,13 +1736,6 @@ static bool cont_add(u32 caller_id, int
}
#endif /* 0 */
@@ -229,7 +229,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* ring buffer used as memory allocator for temporary sprint buffers */
DECLARE_STATIC_PRINTKRB(sprint_rb,
ilog2(PRINTK_RECORD_MAX + sizeof(struct prb_entry) +
-@@ -1801,6 +1794,11 @@ asmlinkage int vprintk_emit(int facility
+@@ -1811,6 +1804,11 @@ asmlinkage int vprintk_emit(int facility
}
EXPORT_SYMBOL(vprintk_emit);
@@ -241,7 +241,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
asmlinkage int vprintk(const char *fmt, va_list args)
{
return vprintk_func(fmt, args);
-@@ -3201,5 +3199,4 @@ void kmsg_dump_rewind(struct kmsg_dumper
+@@ -3211,5 +3209,4 @@ void kmsg_dump_rewind(struct kmsg_dumper
logbuf_unlock_irqrestore(flags);
}
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
@@ -667,7 +667,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-}
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
-@@ -8874,7 +8874,6 @@ void ftrace_dump(enum ftrace_dump_mode o
+@@ -8908,7 +8908,6 @@ void ftrace_dump(enum ftrace_dump_mode o
tracing_off();
local_irq_save(flags);
@@ -675,7 +675,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Simulate the iterator */
trace_init_global_iter(&iter);
-@@ -8951,7 +8950,6 @@ void ftrace_dump(enum ftrace_dump_mode o
+@@ -8985,7 +8984,6 @@ void ftrace_dump(enum ftrace_dump_mode o
atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
}
atomic_dec(&dump_running);
diff --git a/debian/patches-rt/0012-printk-minimize-console-locking-implementation.patch b/debian/patches-rt/0012-printk-minimize-console-locking-implementation.patch
index 3510c1d16277..3c26c368bbb4 100644
--- a/debian/patches-rt/0012-printk-minimize-console-locking-implementation.patch
+++ b/debian/patches-rt/0012-printk-minimize-console-locking-implementation.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:50 +0100
Subject: [PATCH 12/25] printk: minimize console locking implementation
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Since printing of the printk buffer is now handled by the printk
kthread, minimize the console locking functions to just handle
@@ -17,7 +17,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -217,19 +217,7 @@ static int nr_ext_console_drivers;
+@@ -227,19 +227,7 @@ static int nr_ext_console_drivers;
static int __down_trylock_console_sem(unsigned long ip)
{
@@ -38,7 +38,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 1;
mutex_acquire(&console_lock_dep_map, 0, 1, ip);
return 0;
-@@ -238,13 +226,9 @@ static int __down_trylock_console_sem(un
+@@ -248,13 +236,9 @@ static int __down_trylock_console_sem(un
static void __up_console_sem(unsigned long ip)
{
@@ -52,7 +52,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
#define up_console_sem() __up_console_sem(_RET_IP_)
-@@ -1542,82 +1526,6 @@ static void format_text(struct printk_lo
+@@ -1552,82 +1536,6 @@ static void format_text(struct printk_lo
}
/*
@@ -135,7 +135,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Call the console drivers, asking them to write out
* log_buf[start] to log_buf[end - 1].
* The console_lock must be held.
-@@ -1879,8 +1787,6 @@ static ssize_t msg_print_ext_header(char
+@@ -1889,8 +1797,6 @@ static ssize_t msg_print_ext_header(char
static ssize_t msg_print_ext_body(char *buf, size_t size,
char *dict, size_t dict_len,
char *text, size_t text_len) { return 0; }
@@ -144,7 +144,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void call_console_drivers(const char *ext_text, size_t ext_len,
const char *text, size_t len) {}
static size_t msg_print_text(const struct printk_log *msg, bool syslog,
-@@ -2115,35 +2021,6 @@ int is_console_locked(void)
+@@ -2125,35 +2031,6 @@ int is_console_locked(void)
{
return console_locked;
}
@@ -180,7 +180,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/**
* console_unlock - unlock the console system
-@@ -2151,147 +2028,17 @@ static inline int can_use_console(void)
+@@ -2161,147 +2038,17 @@ static inline int can_use_console(void)
* Releases the console_lock which the caller holds on the console system
* and the console driver list.
*
diff --git a/debian/patches-rt/0013-printk-track-seq-per-console.patch b/debian/patches-rt/0013-printk-track-seq-per-console.patch
index 0d28978f9cc6..e684ef919d0e 100644
--- a/debian/patches-rt/0013-printk-track-seq-per-console.patch
+++ b/debian/patches-rt/0013-printk-track-seq-per-console.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:51 +0100
Subject: [PATCH 13/25] printk: track seq per console
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Allow each console to track which seq record was last printed. This
simplifies identifying dropped records.
@@ -25,7 +25,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
};
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1497,6 +1497,16 @@ SYSCALL_DEFINE3(syslog, int, type, char
+@@ -1507,6 +1507,16 @@ SYSCALL_DEFINE3(syslog, int, type, char
return do_syslog(type, buf, len, SYSLOG_FROM_READER);
}
@@ -42,7 +42,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void format_text(struct printk_log *msg, u64 seq,
char *ext_text, size_t *ext_len,
char *text, size_t *len, bool time)
-@@ -1530,7 +1540,7 @@ static void format_text(struct printk_lo
+@@ -1540,7 +1550,7 @@ static void format_text(struct printk_lo
* log_buf[start] to log_buf[end - 1].
* The console_lock must be held.
*/
@@ -51,7 +51,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
const char *text, size_t len)
{
struct console *con;
-@@ -1548,6 +1558,19 @@ static void call_console_drivers(const c
+@@ -1558,6 +1568,19 @@ static void call_console_drivers(const c
if (!cpu_online(raw_smp_processor_id()) &&
!(con->flags & CON_ANYTIME))
continue;
@@ -71,7 +71,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (con->flags & CON_EXTENDED)
con->write(con, ext_text, ext_len);
else
-@@ -1787,7 +1810,7 @@ static ssize_t msg_print_ext_header(char
+@@ -1797,7 +1820,7 @@ static ssize_t msg_print_ext_header(char
static ssize_t msg_print_ext_body(char *buf, size_t size,
char *dict, size_t dict_len,
char *text, size_t text_len) { return 0; }
@@ -80,7 +80,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
const char *text, size_t len) {}
static size_t msg_print_text(const struct printk_log *msg, bool syslog,
bool time, char *buf, size_t size) { return 0; }
-@@ -2540,8 +2563,9 @@ static int printk_kthread_func(void *dat
+@@ -2550,8 +2573,9 @@ static int printk_kthread_func(void *dat
&len, printk_time);
console_lock();
diff --git a/debian/patches-rt/0014-printk-do-boot_delay_msec-inside-printk_delay.patch b/debian/patches-rt/0014-printk-do-boot_delay_msec-inside-printk_delay.patch
index f1aabfa37b57..a47557e32c3f 100644
--- a/debian/patches-rt/0014-printk-do-boot_delay_msec-inside-printk_delay.patch
+++ b/debian/patches-rt/0014-printk-do-boot_delay_msec-inside-printk_delay.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:52 +0100
Subject: [PATCH 14/25] printk: do boot_delay_msec inside printk_delay
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Both functions needed to be called one after the other, so just
integrate boot_delay_msec into printk_delay for simplification.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1497,6 +1497,21 @@ SYSCALL_DEFINE3(syslog, int, type, char
+@@ -1507,6 +1507,21 @@ SYSCALL_DEFINE3(syslog, int, type, char
return do_syslog(type, buf, len, SYSLOG_FROM_READER);
}
@@ -36,7 +36,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void print_console_dropped(struct console *con, u64 count)
{
char text[64];
-@@ -1578,20 +1593,6 @@ static void call_console_drivers(u64 seq
+@@ -1588,20 +1603,6 @@ static void call_console_drivers(u64 seq
}
}
@@ -57,7 +57,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline u32 printk_caller_id(void)
{
return in_task() ? task_pid_nr(current) :
-@@ -2565,10 +2566,8 @@ static int printk_kthread_func(void *dat
+@@ -2575,10 +2576,8 @@ static int printk_kthread_func(void *dat
console_lock();
call_console_drivers(master_seq, ext_text,
ext_len, text, len);
diff --git a/debian/patches-rt/0015-printk-print-history-for-new-consoles.patch b/debian/patches-rt/0015-printk-print-history-for-new-consoles.patch
index 68ca49ca8699..571091b71fcf 100644
--- a/debian/patches-rt/0015-printk-print-history-for-new-consoles.patch
+++ b/debian/patches-rt/0015-printk-print-history-for-new-consoles.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:53 +0100
Subject: [PATCH 15/25] printk: print history for new consoles
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
When new consoles register, they currently print how many messages
they have missed. However, many (or all) of those messages may still
@@ -28,7 +28,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
};
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1550,6 +1550,77 @@ static void format_text(struct printk_lo
+@@ -1560,6 +1560,77 @@ static void format_text(struct printk_lo
}
}
@@ -106,7 +106,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Call the console drivers, asking them to write out
* log_buf[start] to log_buf[end - 1].
-@@ -1568,6 +1639,10 @@ static void call_console_drivers(u64 seq
+@@ -1578,6 +1649,10 @@ static void call_console_drivers(u64 seq
for_each_console(con) {
if (!(con->flags & CON_ENABLED))
continue;
diff --git a/debian/patches-rt/0016-printk-implement-CON_PRINTBUFFER.patch b/debian/patches-rt/0016-printk-implement-CON_PRINTBUFFER.patch
index 1d026433a96e..bef26ad3f4e9 100644
--- a/debian/patches-rt/0016-printk-implement-CON_PRINTBUFFER.patch
+++ b/debian/patches-rt/0016-printk-implement-CON_PRINTBUFFER.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:54 +0100
Subject: [PATCH 16/25] printk: implement CON_PRINTBUFFER
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
If the CON_PRINTBUFFER flag is not set, do not replay the history
for that console.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -409,10 +409,6 @@ static u32 log_first_idx;
+@@ -419,10 +419,6 @@ static u32 log_first_idx;
static u64 log_next_seq;
static u32 log_next_idx;
@@ -25,7 +25,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
static u32 clear_idx;
-@@ -1640,8 +1636,12 @@ static void call_console_drivers(u64 seq
+@@ -1650,8 +1646,12 @@ static void call_console_drivers(u64 seq
if (!(con->flags & CON_ENABLED))
continue;
if (!con->wrote_history) {
@@ -40,7 +40,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
if (!con->write)
continue;
-@@ -1871,8 +1871,6 @@ EXPORT_SYMBOL(printk);
+@@ -1881,8 +1881,6 @@ EXPORT_SYMBOL(printk);
static u64 syslog_seq;
static u32 syslog_idx;
@@ -49,7 +49,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static u64 log_first_seq;
static u32 log_first_idx;
static u64 log_next_seq;
-@@ -2196,15 +2194,6 @@ void console_flush_on_panic(enum con_flu
+@@ -2206,15 +2204,6 @@ void console_flush_on_panic(enum con_flu
*/
console_trylock();
console_may_schedule = 0;
@@ -65,7 +65,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
console_unlock();
}
-@@ -2283,7 +2272,6 @@ early_param("keep_bootcon", keep_bootcon
+@@ -2293,7 +2282,6 @@ early_param("keep_bootcon", keep_bootcon
void register_console(struct console *newcon)
{
int i;
@@ -73,7 +73,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct console *bcon = NULL;
struct console_cmdline *c;
static bool has_preferred;
-@@ -2399,16 +2387,6 @@ void register_console(struct console *ne
+@@ -2409,16 +2397,6 @@ void register_console(struct console *ne
if (newcon->flags & CON_EXTENDED)
nr_ext_console_drivers++;
diff --git a/debian/patches-rt/0017-printk-add-processor-number-to-output.patch b/debian/patches-rt/0017-printk-add-processor-number-to-output.patch
index 1d9996f077a6..486c291fce99 100644
--- a/debian/patches-rt/0017-printk-add-processor-number-to-output.patch
+++ b/debian/patches-rt/0017-printk-add-processor-number-to-output.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:55 +0100
Subject: [PATCH 17/25] printk: add processor number to output
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
It can be difficult to sort printk out if multiple processors are
printing simultaneously. Add the processor number to the printk
@@ -15,7 +15,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -338,6 +338,7 @@ enum log_flags {
+@@ -348,6 +348,7 @@ enum log_flags {
struct printk_log {
u64 ts_nsec; /* timestamp in nanoseconds */
@@ -23,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
u16 len; /* length of entire record */
u16 text_len; /* length of text buffer */
u16 dict_len; /* length of dictionary buffer */
-@@ -489,7 +490,7 @@ static u32 log_next(u32 idx)
+@@ -499,7 +500,7 @@ static u32 log_next(u32 idx)
/* insert record into the buffer, discard old ones, update heads */
static int log_store(u32 caller_id, int facility, int level,
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
const char *dict, u16 dict_len,
const char *text, u16 text_len)
{
-@@ -523,6 +524,7 @@ static int log_store(u32 caller_id, int
+@@ -533,6 +534,7 @@ static int log_store(u32 caller_id, int
#ifdef CONFIG_PRINTK_CALLER
msg->caller_id = caller_id;
#endif
@@ -40,7 +40,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
msg->len = size;
/* insert message */
-@@ -596,9 +598,9 @@ static ssize_t msg_print_ext_header(char
+@@ -606,9 +608,9 @@ static ssize_t msg_print_ext_header(char
do_div(ts_usec, 1000);
@@ -52,7 +52,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static ssize_t msg_print_ext_body(char *buf, size_t size,
-@@ -1132,6 +1134,11 @@ static inline void boot_delay_msec(int l
+@@ -1142,6 +1144,11 @@ static inline void boot_delay_msec(int l
static bool printk_time = IS_ENABLED(CONFIG_PRINTK_TIME);
module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
@@ -64,7 +64,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static size_t print_syslog(unsigned int level, char *buf)
{
return sprintf(buf, "<%u>", level);
-@@ -1175,6 +1182,7 @@ static size_t print_prefix(const struct
+@@ -1185,6 +1192,7 @@ static size_t print_prefix(const struct
buf[len++] = ' ';
buf[len] = '\0';
}
@@ -72,7 +72,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return len;
}
-@@ -1750,6 +1758,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1760,6 +1768,7 @@ asmlinkage int vprintk_emit(int facility
u64 ts_nsec;
char *text;
char *rbuf;
@@ -80,7 +80,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
ts_nsec = local_clock();
-@@ -1759,6 +1768,8 @@ asmlinkage int vprintk_emit(int facility
+@@ -1769,6 +1778,8 @@ asmlinkage int vprintk_emit(int facility
return printed_len;
}
@@ -89,7 +89,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
text = rbuf;
text_len = vscnprintf(text, PRINTK_SPRINT_MAX, fmt, args);
-@@ -1793,7 +1804,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1803,7 +1814,7 @@ asmlinkage int vprintk_emit(int facility
if (dict)
lflags |= LOG_NEWLINE;
diff --git a/debian/patches-rt/0018-console-add-write_atomic-interface.patch b/debian/patches-rt/0018-console-add-write_atomic-interface.patch
index bdbaa69822e1..2757688a6ef9 100644
--- a/debian/patches-rt/0018-console-add-write_atomic-interface.patch
+++ b/debian/patches-rt/0018-console-add-write_atomic-interface.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:56 +0100
Subject: [PATCH 18/25] console: add write_atomic interface
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add a write_atomic callback to the console. This is an optional
function for console drivers. The function must be atomic (including
@@ -47,7 +47,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#endif /* _LINUX_CONSOLE_H */
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -3034,3 +3034,15 @@ void kmsg_dump_rewind(struct kmsg_dumper
+@@ -3044,3 +3044,15 @@ void kmsg_dump_rewind(struct kmsg_dumper
}
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
#endif
diff --git a/debian/patches-rt/0019-printk-introduce-emergency-messages.patch b/debian/patches-rt/0019-printk-introduce-emergency-messages.patch
index b7c0233bf6fb..114b7a993ee3 100644
--- a/debian/patches-rt/0019-printk-introduce-emergency-messages.patch
+++ b/debian/patches-rt/0019-printk-introduce-emergency-messages.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:57 +0100
Subject: [PATCH 19/25] printk: introduce emergency messages
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Console messages are generally either critical or non-critical.
Critical messages are messages such as crashes or sysrq output.
@@ -82,7 +82,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
};
EXPORT_SYMBOL_GPL(console_printk);
-@@ -488,6 +490,9 @@ static u32 log_next(u32 idx)
+@@ -498,6 +500,9 @@ static u32 log_next(u32 idx)
return idx + msg->len;
}
@@ -92,7 +92,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* insert record into the buffer, discard old ones, update heads */
static int log_store(u32 caller_id, int facility, int level,
enum log_flags flags, u64 ts_nsec, u16 cpu,
-@@ -1631,7 +1636,7 @@ static void printk_write_history(struct
+@@ -1641,7 +1646,7 @@ static void printk_write_history(struct
* The console_lock must be held.
*/
static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len,
@@ -101,7 +101,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
struct console *con;
-@@ -1651,6 +1656,18 @@ static void call_console_drivers(u64 seq
+@@ -1661,6 +1666,18 @@ static void call_console_drivers(u64 seq
con->wrote_history = 1;
con->printk_seq = seq - 1;
}
@@ -120,7 +120,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!con->write)
continue;
if (!cpu_online(raw_smp_processor_id()) &&
-@@ -1770,8 +1787,12 @@ asmlinkage int vprintk_emit(int facility
+@@ -1780,8 +1797,12 @@ asmlinkage int vprintk_emit(int facility
cpu = raw_smp_processor_id();
@@ -135,7 +135,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* strip and flag a trailing newline */
if (text_len && text[text_len-1] == '\n') {
-@@ -1804,6 +1825,14 @@ asmlinkage int vprintk_emit(int facility
+@@ -1814,6 +1835,14 @@ asmlinkage int vprintk_emit(int facility
if (dict)
lflags |= LOG_NEWLINE;
@@ -150,7 +150,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
printed_len = log_store(caller_id, facility, level, lflags, ts_nsec, cpu,
dict, dictlen, text, text_len);
-@@ -1896,7 +1925,7 @@ static ssize_t msg_print_ext_body(char *
+@@ -1906,7 +1935,7 @@ static ssize_t msg_print_ext_body(char *
char *dict, size_t dict_len,
char *text, size_t text_len) { return 0; }
static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len,
@@ -159,7 +159,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static size_t msg_print_text(const struct printk_log *msg, bool syslog,
bool time, char *buf, size_t size) { return 0; }
static bool suppress_message_printing(int level) { return false; }
-@@ -2629,7 +2658,7 @@ static int printk_kthread_func(void *dat
+@@ -2639,7 +2668,7 @@ static int printk_kthread_func(void *dat
console_lock();
call_console_drivers(master_seq, ext_text,
@@ -168,7 +168,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (len > 0 || ext_len > 0)
printk_delay(msg->level);
console_unlock();
-@@ -3033,6 +3062,76 @@ void kmsg_dump_rewind(struct kmsg_dumper
+@@ -3043,6 +3072,76 @@ void kmsg_dump_rewind(struct kmsg_dumper
logbuf_unlock_irqrestore(flags);
}
EXPORT_SYMBOL_GPL(kmsg_dump_rewind);
diff --git a/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch b/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch
index f4617e3a2e1f..1856f3582f35 100644
--- a/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch
+++ b/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:58 +0100
Subject: [PATCH 20/25] serial: 8250: implement write_atomic
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Implement a non-sleeping NMI-safe write_atomic console function in
order to support emergency printk messages.
@@ -16,26 +16,61 @@ preempted write_atomic.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- drivers/tty/serial/8250/8250.h | 4
+ drivers/tty/serial/8250/8250.h | 22 +++++
drivers/tty/serial/8250/8250_core.c | 19 +++-
- drivers/tty/serial/8250/8250_dma.c | 5 -
+ drivers/tty/serial/8250/8250_dma.c | 4
drivers/tty/serial/8250/8250_port.c | 154 ++++++++++++++++++++++++++----------
include/linux/serial_8250.h | 5 +
- 5 files changed, 139 insertions(+), 48 deletions(-)
+ 5 files changed, 157 insertions(+), 47 deletions(-)
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
-@@ -255,3 +255,7 @@ static inline int serial_index(struct ua
- {
- return port->minor - 64;
- }
-+
+@@ -96,6 +96,10 @@ struct serial8250_config {
+ #define SERIAL8250_SHARE_IRQS 0
+ #endif
+
+void set_ier(struct uart_8250_port *up, unsigned char ier);
+void clear_ier(struct uart_8250_port *up);
+void restore_ier(struct uart_8250_port *up);
++
+ #define SERIAL8250_PORT_FLAGS(_base, _irq, _flags) \
+ { \
+ .iobase = _base, \
+@@ -139,6 +143,15 @@ static inline bool serial8250_set_THRI(s
+ return true;
+ }
+
++static inline bool serial8250_set_THRI_sier(struct uart_8250_port *up)
++{
++ if (up->ier & UART_IER_THRI)
++ return false;
++ up->ier |= UART_IER_THRI;
++ set_ier(up, up->ier);
++ return true;
++}
++
+ static inline bool serial8250_clear_THRI(struct uart_8250_port *up)
+ {
+ if (!(up->ier & UART_IER_THRI))
+@@ -148,6 +161,15 @@ static inline bool serial8250_clear_THRI
+ return true;
+ }
+
++static inline bool serial8250_clear_THRI_sier(struct uart_8250_port *up)
++{
++ if (!(up->ier & UART_IER_THRI))
++ return false;
++ up->ier &= ~UART_IER_THRI;
++ set_ier(up, up->ier);
++ return true;
++}
++
+ struct uart_8250_port *serial8250_get_port(int line);
+
+ void serial8250_rpm_get(struct uart_8250_port *p);
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
-@@ -265,7 +265,7 @@ static void serial8250_timeout(struct ti
+@@ -266,7 +266,7 @@ static void serial8250_timeout(struct ti
static void serial8250_backup_timeout(struct timer_list *t)
{
struct uart_8250_port *up = from_timer(up, t, timer);
@@ -44,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned long flags;
spin_lock_irqsave(&up->port.lock, flags);
-@@ -274,10 +274,8 @@ static void serial8250_backup_timeout(st
+@@ -275,10 +275,8 @@ static void serial8250_backup_timeout(st
* Must disable interrupts or else we risk racing with the interrupt
* based handler.
*/
@@ -57,7 +92,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
iir = serial_in(up, UART_IIR);
-@@ -300,7 +298,7 @@ static void serial8250_backup_timeout(st
+@@ -301,7 +299,7 @@ static void serial8250_backup_timeout(st
serial8250_tx_chars(up);
if (up->port.irq)
@@ -66,7 +101,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
spin_unlock_irqrestore(&up->port.lock, flags);
-@@ -578,6 +576,14 @@ serial8250_register_ports(struct uart_dr
+@@ -579,6 +577,14 @@ serial8250_register_ports(struct uart_dr
#ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -81,7 +116,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void univ8250_console_write(struct console *co, const char *s,
unsigned int count)
{
-@@ -663,6 +669,7 @@ static int univ8250_console_match(struct
+@@ -664,6 +670,7 @@ static int univ8250_console_match(struct
static struct console univ8250_console = {
.name = "ttyS",
@@ -91,28 +126,27 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
.setup = univ8250_console_setup,
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
-@@ -36,7 +36,7 @@ static void __dma_tx_complete(void *para
+@@ -35,7 +35,7 @@ static void __dma_tx_complete(void *para
+
ret = serial8250_tx_dma(p);
- if (ret) {
- p->ier |= UART_IER_THRI;
-- serial_port_out(&p->port, UART_IER, p->ier);
-+ set_ier(p, p->ier);
- }
+ if (ret)
+- serial8250_set_THRI(p);
++ serial8250_set_THRI_sier(p);
spin_unlock_irqrestore(&p->port.lock, flags);
-@@ -101,8 +101,7 @@ int serial8250_tx_dma(struct uart_8250_p
+ }
+@@ -98,7 +98,7 @@ int serial8250_tx_dma(struct uart_8250_p
+ dma_async_issue_pending(dma->txchan);
if (dma->tx_err) {
dma->tx_err = 0;
- if (p->ier & UART_IER_THRI) {
-- p->ier &= ~UART_IER_THRI;
-- serial_out(p, UART_IER, p->ier);
-+ set_ier(p, p->ier);
- }
+- serial8250_clear_THRI(p);
++ serial8250_clear_THRI_sier(p);
}
return 0;
+ err:
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
-@@ -731,7 +731,7 @@ static void serial8250_set_sleep(struct
+@@ -721,7 +721,7 @@ static void serial8250_set_sleep(struct
serial_out(p, UART_EFR, UART_EFR_ECB);
serial_out(p, UART_LCR, 0);
}
@@ -121,7 +155,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (p->capabilities & UART_CAP_EFR) {
serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B);
serial_out(p, UART_EFR, efr);
-@@ -1433,7 +1433,7 @@ static void serial8250_stop_rx(struct ua
+@@ -1390,7 +1390,7 @@ static void serial8250_stop_rx(struct ua
up->ier &= ~(UART_IER_RLSI | UART_IER_RDI);
up->port.read_status_mask &= ~UART_LSR_DR;
@@ -130,7 +164,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
serial8250_rpm_put(up);
}
-@@ -1451,7 +1451,7 @@ static void __do_stop_tx_rs485(struct ua
+@@ -1408,7 +1408,7 @@ static void __do_stop_tx_rs485(struct ua
serial8250_clear_and_reinit_fifos(p);
p->ier |= UART_IER_RLSI | UART_IER_RDI;
@@ -139,26 +173,26 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
}
static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t)
-@@ -1504,7 +1504,7 @@ static inline void __do_stop_tx(struct u
+@@ -1459,7 +1459,7 @@ static void __stop_tx_rs485(struct uart_
+
+ static inline void __do_stop_tx(struct uart_8250_port *p)
{
- if (p->ier & UART_IER_THRI) {
- p->ier &= ~UART_IER_THRI;
-- serial_out(p, UART_IER, p->ier);
-+ set_ier(p, p->ier);
+- if (serial8250_clear_THRI(p))
++ if (serial8250_clear_THRI_sier(p))
serial8250_rpm_put_tx(p);
- }
}
-@@ -1557,7 +1557,7 @@ static inline void __start_tx(struct uar
- if (!(up->ier & UART_IER_THRI)) {
- up->ier |= UART_IER_THRI;
-- serial_port_out(port, UART_IER, up->ier);
-+ set_ier(up, up->ier);
+@@ -1509,7 +1509,7 @@ static inline void __start_tx(struct uar
+ if (up->dma && !up->dma->tx_dma(up))
+ return;
+- if (serial8250_set_THRI(up)) {
++ if (serial8250_set_THRI_sier(up)) {
if (up->bugs & UART_BUG_TXEN) {
unsigned char lsr;
-@@ -1663,7 +1663,7 @@ static void serial8250_disable_ms(struct
- return;
+
+@@ -1616,7 +1616,7 @@ static void serial8250_disable_ms(struct
+ mctrl_gpio_disable_ms(up->gpios);
up->ier &= ~UART_IER_MSI;
- serial_port_out(port, UART_IER, up->ier);
@@ -166,7 +200,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void serial8250_enable_ms(struct uart_port *port)
-@@ -1677,7 +1677,7 @@ static void serial8250_enable_ms(struct
+@@ -1632,7 +1632,7 @@ static void serial8250_enable_ms(struct
up->ier |= UART_IER_MSI;
serial8250_rpm_get(up);
@@ -175,7 +209,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
serial8250_rpm_put(up);
}
-@@ -2050,6 +2050,52 @@ static void wait_for_xmitr(struct uart_8
+@@ -1991,6 +1991,52 @@ static void wait_for_xmitr(struct uart_8
}
}
@@ -228,7 +262,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#ifdef CONFIG_CONSOLE_POLL
/*
* Console polling routines for writing and reading from the uart while
-@@ -2081,18 +2127,10 @@ static int serial8250_get_poll_char(stru
+@@ -2022,18 +2068,10 @@ static int serial8250_get_poll_char(stru
static void serial8250_put_poll_char(struct uart_port *port,
unsigned char c)
{
@@ -248,7 +282,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
wait_for_xmitr(up, BOTH_EMPTY);
/*
-@@ -2105,7 +2143,7 @@ static void serial8250_put_poll_char(str
+@@ -2046,7 +2084,7 @@ static void serial8250_put_poll_char(str
* and restore the IER
*/
wait_for_xmitr(up, BOTH_EMPTY);
@@ -257,7 +291,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
serial8250_rpm_put(up);
}
-@@ -2417,7 +2455,7 @@ void serial8250_do_shutdown(struct uart_
+@@ -2354,7 +2392,7 @@ void serial8250_do_shutdown(struct uart_
*/
spin_lock_irqsave(&port->lock, flags);
up->ier = 0;
@@ -266,7 +300,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
spin_unlock_irqrestore(&port->lock, flags);
synchronize_irq(port->irq);
-@@ -2728,7 +2766,7 @@ serial8250_do_set_termios(struct uart_po
+@@ -2639,7 +2677,7 @@ serial8250_do_set_termios(struct uart_po
if (up->capabilities & UART_CAP_RTOIE)
up->ier |= UART_IER_RTOIE;
@@ -275,7 +309,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (up->capabilities & UART_CAP_EFR) {
unsigned char efr = 0;
-@@ -3192,7 +3230,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_default
+@@ -3103,7 +3141,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_default
#ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -284,7 +318,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
struct uart_8250_port *up = up_to_u8250p(port);
-@@ -3200,6 +3238,18 @@ static void serial8250_console_putchar(s
+@@ -3111,6 +3149,18 @@ static void serial8250_console_putchar(s
serial_port_out(port, UART_TX, ch);
}
@@ -303,7 +337,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Restore serial console when h/w power-off detected
*/
-@@ -3221,6 +3271,42 @@ static void serial8250_console_restore(s
+@@ -3132,6 +3182,42 @@ static void serial8250_console_restore(s
serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS);
}
@@ -346,7 +380,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
-@@ -3232,27 +3318,13 @@ void serial8250_console_write(struct uar
+@@ -3143,27 +3229,13 @@ void serial8250_console_write(struct uar
{
struct uart_port *port = &up->port;
unsigned long flags;
@@ -376,7 +410,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* check scratch reg to see if port powered off during system sleep */
if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) {
-@@ -3260,14 +3332,16 @@ void serial8250_console_write(struct uar
+@@ -3171,14 +3243,16 @@ void serial8250_console_write(struct uar
up->canary = 0;
}
@@ -394,7 +428,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* The receive handling will happen properly because the
-@@ -3279,8 +3353,7 @@ void serial8250_console_write(struct uar
+@@ -3190,8 +3264,7 @@ void serial8250_console_write(struct uar
if (up->msr_saved_flags)
serial8250_modem_status(up);
@@ -404,7 +438,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
serial8250_rpm_put(up);
}
-@@ -3301,6 +3374,7 @@ static unsigned int probe_baud(struct ua
+@@ -3212,6 +3285,7 @@ static unsigned int probe_baud(struct ua
int serial8250_console_setup(struct uart_port *port, char *options, bool probe)
{
@@ -412,7 +446,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int baud = 9600;
int bits = 8;
int parity = 'n';
-@@ -3309,6 +3383,8 @@ int serial8250_console_setup(struct uart
+@@ -3220,6 +3294,8 @@ int serial8250_console_setup(struct uart
if (!port->iobase && !port->membase)
return -ENODEV;
@@ -431,7 +465,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/serial_core.h>
#include <linux/serial_reg.h>
#include <linux/platform_device.h>
-@@ -122,6 +123,8 @@ struct uart_8250_port {
+@@ -123,6 +124,8 @@ struct uart_8250_port {
#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
unsigned char msr_saved_flags;
@@ -440,7 +474,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct uart_8250_dma *dma;
const struct uart_8250_ops *ops;
-@@ -173,6 +176,8 @@ void serial8250_init_port(struct uart_82
+@@ -174,6 +177,8 @@ void serial8250_init_port(struct uart_82
void serial8250_set_defaults(struct uart_8250_port *up);
void serial8250_console_write(struct uart_8250_port *up, const char *s,
unsigned int count);
diff --git a/debian/patches-rt/0021-printk-implement-KERN_CONT.patch b/debian/patches-rt/0021-printk-implement-KERN_CONT.patch
index 02fc632e4a3b..d31f99c89f9a 100644
--- a/debian/patches-rt/0021-printk-implement-KERN_CONT.patch
+++ b/debian/patches-rt/0021-printk-implement-KERN_CONT.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:29:59 +0100
Subject: [PATCH 21/25] printk: implement KERN_CONT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Implement KERN_CONT based on the printing CPU rather than on the
printing task. As long as the KERN_CONT messages are coming from the
@@ -16,7 +16,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1699,8 +1699,6 @@ static inline u32 printk_caller_id(void)
+@@ -1709,8 +1709,6 @@ static inline u32 printk_caller_id(void)
0x80000000 + raw_smp_processor_id();
}
@@ -25,7 +25,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Continuation lines are buffered, and not committed to the record buffer
* until the line is complete, or a race forces it. The line fragments
-@@ -1711,52 +1709,55 @@ static struct cont {
+@@ -1721,52 +1719,55 @@ static struct cont {
char buf[LOG_LINE_MAX];
size_t len; /* length == 0 means unused buffer */
u32 caller_id; /* printk_caller_id() of first print */
@@ -105,7 +105,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* ring buffer used as memory allocator for temporary sprint buffers */
DECLARE_STATIC_PRINTKRB(sprint_rb,
-@@ -1768,6 +1769,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1778,6 +1779,7 @@ asmlinkage int vprintk_emit(int facility
const char *fmt, va_list args)
{
const u32 caller_id = printk_caller_id();
@@ -113,7 +113,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
enum log_flags lflags = 0;
int printed_len = 0;
struct prb_handle h;
-@@ -1833,8 +1835,15 @@ asmlinkage int vprintk_emit(int facility
+@@ -1843,8 +1845,15 @@ asmlinkage int vprintk_emit(int facility
*/
printk_emergency(rbuf, level, ts_nsec, cpu, text, text_len);
diff --git a/debian/patches-rt/0022-printk-implement-dev-kmsg.patch b/debian/patches-rt/0022-printk-implement-dev-kmsg.patch
index 44b6b2834271..afcf1dca07e4 100644
--- a/debian/patches-rt/0022-printk-implement-dev-kmsg.patch
+++ b/debian/patches-rt/0022-printk-implement-dev-kmsg.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:30:00 +0100
Subject: [PATCH 22/25] printk: implement /dev/kmsg
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Since printk messages are now logged to a new ring buffer, update
the /dev/kmsg functions to pull the messages from there.
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int vprintk(const char *s, va_list args)
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -663,10 +663,11 @@ static ssize_t msg_print_ext_body(char *
+@@ -673,10 +673,11 @@ static ssize_t msg_print_ext_body(char *
/* /dev/kmsg - userspace message inject/listen interface */
struct devkmsg_user {
u64 seq;
@@ -59,7 +59,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
};
static __printf(3, 4) __cold
-@@ -749,9 +750,11 @@ static ssize_t devkmsg_read(struct file
+@@ -759,9 +760,11 @@ static ssize_t devkmsg_read(struct file
size_t count, loff_t *ppos)
{
struct devkmsg_user *user = file->private_data;
@@ -72,7 +72,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!user)
return -EBADF;
-@@ -760,52 +763,67 @@ static ssize_t devkmsg_read(struct file
+@@ -770,52 +773,67 @@ static ssize_t devkmsg_read(struct file
if (ret)
return ret;
@@ -166,7 +166,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
out:
mutex_unlock(&user->lock);
return ret;
-@@ -814,19 +832,21 @@ static ssize_t devkmsg_read(struct file
+@@ -824,19 +842,21 @@ static ssize_t devkmsg_read(struct file
static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence)
{
struct devkmsg_user *user = file->private_data;
@@ -192,7 +192,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
break;
case SEEK_DATA:
/*
-@@ -834,40 +854,83 @@ static loff_t devkmsg_llseek(struct file
+@@ -844,40 +864,83 @@ static loff_t devkmsg_llseek(struct file
* like issued by 'dmesg -c'. Reading /dev/kmsg itself
* changes no global state, and does not clear anything.
*/
@@ -291,7 +291,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return ret;
}
-@@ -897,10 +960,7 @@ static int devkmsg_open(struct inode *in
+@@ -907,10 +970,7 @@ static int devkmsg_open(struct inode *in
mutex_init(&user->lock);
diff --git a/debian/patches-rt/0023-printk-implement-syslog.patch b/debian/patches-rt/0023-printk-implement-syslog.patch
index 898adc5d05ce..c5ee8d712b35 100644
--- a/debian/patches-rt/0023-printk-implement-syslog.patch
+++ b/debian/patches-rt/0023-printk-implement-syslog.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:30:01 +0100
Subject: [PATCH 23/25] printk: implement syslog
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Since printk messages are now logged to a new ring buffer, update
the syslog functions to pull the messages from there.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -397,10 +397,12 @@ DECLARE_STATIC_PRINTKRB_CPULOCK(printk_c
+@@ -407,10 +407,12 @@ DECLARE_STATIC_PRINTKRB_CPULOCK(printk_c
/* record buffer */
DECLARE_STATIC_PRINTKRB(printk_rb, CONFIG_LOG_BUF_SHIFT, &printk_cpulock);
@@ -28,7 +28,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static size_t syslog_partial;
static bool syslog_time;
-@@ -1293,30 +1295,42 @@ static size_t msg_print_text(const struc
+@@ -1303,30 +1305,42 @@ static size_t msg_print_text(const struc
return len;
}
@@ -85,7 +85,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -1326,131 +1340,212 @@ static int syslog_print(char __user *buf
+@@ -1336,131 +1350,212 @@ static int syslog_print(char __user *buf
if (!syslog_partial)
syslog_time = printk_time;
@@ -360,7 +360,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
error = check_syslog_permissions(type, source);
if (error)
-@@ -1468,11 +1563,49 @@ int do_syslog(int type, char __user *buf
+@@ -1478,11 +1573,49 @@ int do_syslog(int type, char __user *buf
return 0;
if (!access_ok(buf, len))
return -EFAULT;
@@ -414,7 +414,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
break;
/* Read/clear last kernel messages */
case SYSLOG_ACTION_READ_CLEAR:
-@@ -1517,47 +1650,45 @@ int do_syslog(int type, char __user *buf
+@@ -1527,47 +1660,45 @@ int do_syslog(int type, char __user *buf
break;
/* Number of chars in the log buffer */
case SYSLOG_ACTION_SIZE_UNREAD:
@@ -484,7 +484,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return error;
}
-@@ -1979,7 +2110,6 @@ EXPORT_SYMBOL(printk);
+@@ -1989,7 +2120,6 @@ EXPORT_SYMBOL(printk);
#define printk_time false
static u64 syslog_seq;
diff --git a/debian/patches-rt/0024-printk-implement-kmsg_dump.patch b/debian/patches-rt/0024-printk-implement-kmsg_dump.patch
index 17a5ac306767..87a3ba5bfd58 100644
--- a/debian/patches-rt/0024-printk-implement-kmsg_dump.patch
+++ b/debian/patches-rt/0024-printk-implement-kmsg_dump.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:30:02 +0100
Subject: [PATCH 24/25] printk: implement kmsg_dump
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Since printk messages are now logged to a new ring buffer, update
the kmsg_dump functions to pull the messages from there.
@@ -30,7 +30,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#ifdef CONFIG_PRINTK
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -407,13 +407,13 @@ static size_t syslog_partial;
+@@ -417,13 +417,13 @@ static size_t syslog_partial;
static bool syslog_time;
/* index and sequence number of the first record stored in the buffer */
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
static u32 clear_idx;
-@@ -460,38 +460,6 @@ static char *log_dict(const struct print
+@@ -470,38 +470,6 @@ static char *log_dict(const struct print
return (char *)msg + sizeof(struct printk_log) + msg->text_len;
}
@@ -85,7 +85,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void printk_emergency(char *buffer, int level, u64 ts_nsec, u16 cpu,
char *text, u16 text_len);
-@@ -2110,9 +2078,7 @@ EXPORT_SYMBOL(printk);
+@@ -2120,9 +2088,7 @@ EXPORT_SYMBOL(printk);
#define printk_time false
static u64 syslog_seq;
@@ -95,7 +95,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static char *log_text(const struct printk_log *msg) { return NULL; }
static char *log_dict(const struct printk_log *msg) { return NULL; }
static struct printk_log *log_from_idx(u32 idx) { return NULL; }
-@@ -3022,7 +2988,6 @@ module_param_named(always_kmsg_dump, alw
+@@ -3032,7 +2998,6 @@ module_param_named(always_kmsg_dump, alw
void kmsg_dump(enum kmsg_dump_reason reason)
{
struct kmsg_dumper *dumper;
@@ -103,7 +103,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
return;
-@@ -3035,12 +3000,7 @@ void kmsg_dump(enum kmsg_dump_reason rea
+@@ -3045,12 +3010,7 @@ void kmsg_dump(enum kmsg_dump_reason rea
/* initialize iterator with data about the stored records */
dumper->active = true;
@@ -117,7 +117,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* invoke dumper which will iterate over records */
dumper->dump(dumper, reason);
-@@ -3073,33 +3033,67 @@ void kmsg_dump(enum kmsg_dump_reason rea
+@@ -3083,33 +3043,67 @@ void kmsg_dump(enum kmsg_dump_reason rea
bool kmsg_dump_get_line_nolock(struct kmsg_dumper *dumper, bool syslog,
char *line, size_t size, size_t *len)
{
@@ -200,7 +200,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -3122,12 +3116,11 @@ bool kmsg_dump_get_line_nolock(struct km
+@@ -3132,12 +3126,11 @@ bool kmsg_dump_get_line_nolock(struct km
bool kmsg_dump_get_line(struct kmsg_dumper *dumper, bool syslog,
char *line, size_t size, size_t *len)
{
@@ -215,7 +215,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return ret;
}
-@@ -3155,74 +3148,101 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_line);
+@@ -3165,74 +3158,101 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_line);
bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
char *buf, size_t size, size_t *len)
{
@@ -293,7 +293,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- /* move first record forward until length fits into the buffer */
- seq = dumper->cur_seq;
- idx = dumper->cur_idx;
-- while (l > size && seq < dumper->next_seq) {
+- while (l >= size && seq < dumper->next_seq) {
- struct printk_log *msg = log_from_idx(idx);
+ /* count the total bytes after seq */
+ textlen = count_remaining(&iter, end_seq, msgbuf,
@@ -369,7 +369,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
-@@ -3238,10 +3258,8 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
+@@ -3248,10 +3268,8 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
*/
void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
{
@@ -382,7 +382,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -3254,11 +3272,9 @@ void kmsg_dump_rewind_nolock(struct kmsg
+@@ -3264,11 +3282,9 @@ void kmsg_dump_rewind_nolock(struct kmsg
*/
void kmsg_dump_rewind(struct kmsg_dumper *dumper)
{
diff --git a/debian/patches-rt/0025-printk-remove-unused-code.patch b/debian/patches-rt/0025-printk-remove-unused-code.patch
index c244b7d02a21..481fd315ee3f 100644
--- a/debian/patches-rt/0025-printk-remove-unused-code.patch
+++ b/debian/patches-rt/0025-printk-remove-unused-code.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Tue, 12 Feb 2019 15:30:03 +0100
Subject: [PATCH 25/25] printk: remove unused code
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Code relating to the safe context and anything dealing with the
previous log buffer implementation is no longer in use. Remove it.
@@ -69,7 +69,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int console_printk[5] = {
CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
-@@ -356,41 +355,6 @@ struct printk_log {
+@@ -366,41 +365,6 @@ struct printk_log {
#endif
;
@@ -111,7 +111,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
DECLARE_STATIC_PRINTKRB_CPULOCK(printk_cpulock);
#ifdef CONFIG_PRINTK
-@@ -400,23 +364,15 @@ DECLARE_STATIC_PRINTKRB(printk_rb, CONFI
+@@ -410,23 +374,15 @@ DECLARE_STATIC_PRINTKRB(printk_rb, CONFI
static DEFINE_MUTEX(syslog_lock);
DECLARE_STATIC_PRINTKRB_ITER(syslog_iter, &printk_rb);
@@ -136,7 +136,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#ifdef CONFIG_PRINTK_CALLER
#define PREFIX_MAX 48
-@@ -428,24 +384,16 @@ static u32 clear_idx;
+@@ -438,24 +394,16 @@ static u32 clear_idx;
#define LOG_LEVEL(v) ((v) & 0x07)
#define LOG_FACILITY(v) ((v) >> 3 & 0xff)
@@ -163,7 +163,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/* human readable text of the record */
-@@ -970,11 +918,6 @@ const struct file_operations kmsg_fops =
+@@ -980,11 +928,6 @@ const struct file_operations kmsg_fops =
*/
void log_buf_vmcoreinfo_setup(void)
{
@@ -175,7 +175,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Export struct printk_log size and field offsets. User space tools can
* parse it and detect any changes to structure down the line.
-@@ -990,6 +933,8 @@ void log_buf_vmcoreinfo_setup(void)
+@@ -1000,6 +943,8 @@ void log_buf_vmcoreinfo_setup(void)
}
#endif
@@ -184,7 +184,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* requested log_buf_len from kernel cmdline */
static unsigned long __initdata new_log_buf_len;
-@@ -1055,9 +1000,12 @@ static void __init log_buf_add_cpu(void)
+@@ -1065,9 +1010,12 @@ static void __init log_buf_add_cpu(void)
#else /* !CONFIG_SMP */
static inline void log_buf_add_cpu(void) {}
#endif /* CONFIG_SMP */
@@ -197,7 +197,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned long flags;
char *new_log_buf;
unsigned int free;
-@@ -1089,6 +1037,7 @@ void __init setup_log_buf(int early)
+@@ -1099,6 +1047,7 @@ void __init setup_log_buf(int early)
pr_info("log_buf_len: %u bytes\n", log_buf_len);
pr_info("early log buf free: %u(%u%%)\n",
free, (free * 100) / __LOG_BUF_LEN);
@@ -205,7 +205,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static bool __read_mostly ignore_loglevel;
-@@ -2009,7 +1958,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -2019,7 +1968,7 @@ asmlinkage int vprintk_emit(int facility
}
EXPORT_SYMBOL(vprintk_emit);
@@ -214,7 +214,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
return vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
}
-@@ -2070,31 +2019,6 @@ asmlinkage __visible int printk(const ch
+@@ -2080,31 +2029,6 @@ asmlinkage __visible int printk(const ch
return r;
}
EXPORT_SYMBOL(printk);
@@ -246,7 +246,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#endif /* CONFIG_PRINTK */
#ifdef CONFIG_EARLY_PRINTK
-@@ -2391,15 +2315,10 @@ void console_unblank(void)
+@@ -2401,15 +2325,10 @@ void console_unblank(void)
void console_flush_on_panic(enum con_flush_mode mode)
{
/*
@@ -265,7 +265,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -2748,43 +2667,6 @@ static int __init printk_late_init(void)
+@@ -2758,43 +2677,6 @@ static int __init printk_late_init(void)
late_initcall(printk_late_init);
#if defined CONFIG_PRINTK
@@ -309,7 +309,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static int printk_kthread_func(void *data)
{
struct prb_iterator iter;
-@@ -2850,22 +2732,9 @@ static int __init init_printk_kthread(vo
+@@ -2860,22 +2742,9 @@ static int __init init_printk_kthread(vo
}
late_initcall(init_printk_kthread);
diff --git a/debian/patches-rt/ARM-Allow-to-enable-RT.patch b/debian/patches-rt/ARM-Allow-to-enable-RT.patch
new file mode 100644
index 000000000000..7b4eedf7fded
--- /dev/null
+++ b/debian/patches-rt/ARM-Allow-to-enable-RT.patch
@@ -0,0 +1,22 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 11 Oct 2019 13:14:29 +0200
+Subject: [PATCH] ARM: Allow to enable RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Allow to select RT.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/arm/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm/Kconfig
++++ b/arch/arm/Kconfig
+@@ -32,6 +32,7 @@ config ARM
+ select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
+ select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7
+ select ARCH_SUPPORTS_ATOMIC_RMW
++ select ARCH_SUPPORTS_RT
+ select ARCH_USE_BUILTIN_BSWAP
+ select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
diff --git a/debian/patches-rt/ARM-enable-irq-in-translation-section-permission-fau.patch b/debian/patches-rt/ARM-enable-irq-in-translation-section-permission-fau.patch
index d3dfb44b4cce..886150767246 100644
--- a/debian/patches-rt/ARM-enable-irq-in-translation-section-permission-fau.patch
+++ b/debian/patches-rt/ARM-enable-irq-in-translation-section-permission-fau.patch
@@ -1,10 +1,10 @@
From: "Yadi.hu" <yadi.hu@windriver.com>
Date: Wed, 10 Dec 2014 10:32:09 +0800
Subject: ARM: enable irq in translation/section permission fault handlers
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Probably happens on all ARM, with
-CONFIG_PREEMPT_RT_FULL
+CONFIG_PREEMPT_RT
CONFIG_DEBUG_ATOMIC_SLEEP
This simple program....
@@ -64,7 +64,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
-@@ -434,6 +434,9 @@ do_translation_fault(unsigned long addr,
+@@ -414,6 +414,9 @@ do_translation_fault(unsigned long addr,
if (addr < TASK_SIZE)
return do_page_fault(addr, fsr, regs);
@@ -74,7 +74,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (user_mode(regs))
goto bad_area;
-@@ -501,6 +504,9 @@ do_translation_fault(unsigned long addr,
+@@ -481,6 +484,9 @@ do_translation_fault(unsigned long addr,
static int
do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
diff --git a/debian/patches-rt/ARM64-Allow-to-enable-RT.patch b/debian/patches-rt/ARM64-Allow-to-enable-RT.patch
new file mode 100644
index 000000000000..71a8e0a0ee4b
--- /dev/null
+++ b/debian/patches-rt/ARM64-Allow-to-enable-RT.patch
@@ -0,0 +1,22 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 11 Oct 2019 13:14:35 +0200
+Subject: [PATCH] ARM64: Allow to enable RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Allow to select RT.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/arm64/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/arm64/Kconfig
++++ b/arch/arm64/Kconfig
+@@ -69,6 +69,7 @@ config ARM64
+ select ARCH_SUPPORTS_ATOMIC_RMW
+ select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG
+ select ARCH_SUPPORTS_NUMA_BALANCING
++ select ARCH_SUPPORTS_RT
+ select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
+ select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
+ select ARCH_WANT_FRAME_POINTERS
diff --git a/debian/patches-rt/BPF-Disable-on-PREEMPT_RT.patch b/debian/patches-rt/BPF-Disable-on-PREEMPT_RT.patch
new file mode 100644
index 000000000000..8a11d4e78d87
--- /dev/null
+++ b/debian/patches-rt/BPF-Disable-on-PREEMPT_RT.patch
@@ -0,0 +1,36 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Thu, 10 Oct 2019 16:54:45 +0200
+Subject: [PATCH] BPF: Disable on PREEMPT_RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Disable BPF on PREEMPT_RT because
+- it allocates and frees memory in atomic context
+- it uses up_read_non_owner()
+- BPF_PROG_RUN() expects to be invoked in non-preemptible context
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ init/Kconfig | 1 +
+ net/kcm/Kconfig | 1 +
+ 2 files changed, 2 insertions(+)
+
+--- a/init/Kconfig
++++ b/init/Kconfig
+@@ -1629,6 +1629,7 @@ config KALLSYMS_BASE_RELATIVE
+ # syscall, maps, verifier
+ config BPF_SYSCALL
+ bool "Enable bpf() system call"
++ depends on !PREEMPT_RT
+ select BPF
+ select IRQ_WORK
+ default n
+--- a/net/kcm/Kconfig
++++ b/net/kcm/Kconfig
+@@ -3,6 +3,7 @@
+ config AF_KCM
+ tristate "KCM sockets"
+ depends on INET
++ depends on !PREEMPT_RT
+ select BPF_SYSCALL
+ select STREAM_PARSER
+ ---help---
diff --git a/debian/patches-rt/Drivers-hv-vmbus-include-header-for-get_irq_regs.patch b/debian/patches-rt/Drivers-hv-vmbus-include-header-for-get_irq_regs.patch
deleted file mode 100644
index d8ef4d85902b..000000000000
--- a/debian/patches-rt/Drivers-hv-vmbus-include-header-for-get_irq_regs.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 29 Aug 2018 21:59:04 +0200
-Subject: [PATCH] Drivers: hv: vmbus: include header for get_irq_regs()
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-On !RT the header file get_irq_regs() gets pulled in via other header files. On
-RT it does not and the build fails:
-
- drivers/hv/vmbus_drv.c:975 implicit declaration of function ‘get_irq_regs’ [-Werror=implicit-function-declaration]
- drivers/hv/hv.c:115 implicit declaration of function ‘get_irq_regs’ [-Werror=implicit-function-declaration]
-
-Add the header file for get_irq_regs() in a common header so it used by
-vmbus_drv.c by hv.c for their get_irq_regs() usage.
-
-Reported-by: Bernhard Landauer <oberon@manjaro.org>
-Reported-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- drivers/hv/hyperv_vmbus.h | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/drivers/hv/hyperv_vmbus.h
-+++ b/drivers/hv/hyperv_vmbus.h
-@@ -18,6 +18,7 @@
- #include <linux/atomic.h>
- #include <linux/hyperv.h>
- #include <linux/interrupt.h>
-+#include <linux/irq.h>
-
- #include "hv_trace.h"
-
diff --git a/debian/patches-rt/KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch b/debian/patches-rt/KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch
index b7063f5cbca7..25f8468e0b8c 100644
--- a/debian/patches-rt/KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch
+++ b/debian/patches-rt/KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch
@@ -2,7 +2,7 @@ From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 13 Aug 2019 14:29:41 +0200
Subject: [PATCH] KVM: arm/arm64: Let the timer expire in hardirq context
on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The timers are canceled from an preempt-notifier which is invoked with
disabled preemption which is not allowed on PREEMPT_RT.
diff --git a/debian/patches-rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch b/debian/patches-rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch
index 2446e55d8868..a0a2d452f209 100644
--- a/debian/patches-rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch
+++ b/debian/patches-rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch
@@ -1,7 +1,7 @@
From: Josh Cartwright <joshc@ni.com>
Date: Thu, 11 Feb 2016 11:54:01 -0600
Subject: KVM: arm/arm64: downgrade preempt_disable()d region to migrate_disable()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
kvm_arch_vcpu_ioctl_run() disables the use of preemption when updating
the vgic and timer states to prevent the calling task from migrating to
@@ -23,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/virt/kvm/arm/arm.c
+++ b/virt/kvm/arm/arm.c
-@@ -702,7 +702,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
+@@ -700,7 +700,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
* involves poking the GIC, which must be done in a
* non-preemptible context.
*/
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
kvm_pmu_flush_hwstate(vcpu);
-@@ -751,7 +751,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
+@@ -749,7 +749,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
kvm_timer_sync_hwstate(vcpu);
kvm_vgic_sync_hwstate(vcpu);
local_irq_enable();
@@ -41,7 +41,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
continue;
}
-@@ -829,7 +829,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
+@@ -827,7 +827,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_v
/* Exit types that need handling before we can be preempted */
handle_exit_early(vcpu, run, ret);
diff --git a/debian/patches-rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch b/debian/patches-rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
index e270b7b413e3..e476c36ee743 100644
--- a/debian/patches-rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
+++ b/debian/patches-rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
@@ -5,22 +5,23 @@ Cc: Anna Schumaker <anna.schumaker@netapp.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
tglx@linutronix.de
Subject: NFSv4: replace seqcount_t with a seqlock_t
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-The raw_write_seqcount_begin() in nfs4_reclaim_open_state() bugs me
-because it maps to preempt_disable() in -RT which I can't have at this
-point. So I took a look at the code.
-It the lockdep part was removed in commit abbec2da13f0 ("NFS: Use
-raw_write_seqcount_begin/end int nfs4_reclaim_open_state") because
-lockdep complained. The whole seqcount thing was introduced in commit
-c137afabe330 ("NFSv4: Allow the state manager to mark an open_owner as
-being recovered").
+The raw_write_seqcount_begin() in nfs4_reclaim_open_state() causes a
+preempt_disable() on -RT. The spin_lock()/spin_unlock() in that section does
+not work.
+The lockdep part was removed in commit
+ abbec2da13f0 ("NFS: Use raw_write_seqcount_begin/end int nfs4_reclaim_open_state")
+because lockdep complained.
+The whole seqcount thing was introduced in commit
+ c137afabe330 ("NFSv4: Allow the state manager to mark an open_owner as being recovered").
The recovery threads runs only once.
write_seqlock() does not work on !RT because it disables preemption and it the
writer side is preemptible (has to remain so despite the fact that it will
block readers).
Reported-by: kernel test robot <xiaolong.ye@intel.com>
+Link: https://lkml.kernel.org/r/20161021164727.24485-1-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
fs/nfs/delegation.c | 4 ++--
@@ -31,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
-@@ -152,11 +152,11 @@ static int nfs_delegation_claim_opens(st
+@@ -162,11 +162,11 @@ static int nfs_delegation_claim_opens(st
sp = state->owner;
/* Block nfs4_proc_unlck */
mutex_lock(&sp->so_delegreturn_mutex);
@@ -58,7 +59,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
-@@ -2926,7 +2926,7 @@ static int _nfs4_open_and_get_state(stru
+@@ -2956,7 +2956,7 @@ static int _nfs4_open_and_get_state(stru
unsigned int seq;
int ret;
@@ -67,7 +68,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
ret = _nfs4_proc_open(opendata, ctx);
if (ret != 0)
-@@ -2967,7 +2967,7 @@ static int _nfs4_open_and_get_state(stru
+@@ -2998,7 +2998,7 @@ static int _nfs4_open_and_get_state(stru
if (d_inode(dentry) == state->inode) {
nfs_inode_attach_open_context(ctx);
@@ -87,11 +88,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
mutex_init(&sp->so_delegreturn_mutex);
return sp;
}
-@@ -1633,8 +1633,12 @@ static int nfs4_reclaim_open_state(struc
+@@ -1618,8 +1618,12 @@ static int nfs4_reclaim_open_state(struc
* recovering after a network partition or a reboot from a
* server that doesn't support a grace period.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ write_seqlock(&sp->so_reclaim_seqlock);
+#else
+ write_seqcount_begin(&sp->so_reclaim_seqlock.seqcount);
@@ -101,13 +102,13 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
restart:
list_for_each_entry(state, &sp->so_states, open_states) {
if (!test_and_clear_bit(ops->state_flag_bit, &state->flags))
-@@ -1695,14 +1699,20 @@ static int nfs4_reclaim_open_state(struc
+@@ -1680,14 +1684,20 @@ static int nfs4_reclaim_open_state(struc
spin_lock(&sp->so_lock);
goto restart;
}
- raw_write_seqcount_end(&sp->so_reclaim_seqcount);
spin_unlock(&sp->so_lock);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ write_sequnlock(&sp->so_reclaim_seqlock);
+#else
+ write_seqcount_end(&sp->so_reclaim_seqlock.seqcount);
@@ -118,7 +119,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- spin_lock(&sp->so_lock);
- raw_write_seqcount_end(&sp->so_reclaim_seqcount);
- spin_unlock(&sp->so_lock);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ write_sequnlock(&sp->so_reclaim_seqlock);
+#else
+ write_seqcount_end(&sp->so_reclaim_seqlock.seqcount);
diff --git a/debian/patches-rt/POWERPC-Allow-to-enable-RT.patch b/debian/patches-rt/POWERPC-Allow-to-enable-RT.patch
new file mode 100644
index 000000000000..9da485c22ccd
--- /dev/null
+++ b/debian/patches-rt/POWERPC-Allow-to-enable-RT.patch
@@ -0,0 +1,22 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 11 Oct 2019 13:14:41 +0200
+Subject: [PATCH] POWERPC: Allow to enable RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Allow to select RT.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/powerpc/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/powerpc/Kconfig
++++ b/arch/powerpc/Kconfig
+@@ -144,6 +144,7 @@ config PPC
+ select ARCH_MIGHT_HAVE_PC_SERIO
+ select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
+ select ARCH_SUPPORTS_ATOMIC_RMW
++ select ARCH_SUPPORTS_RT
+ select ARCH_USE_BUILTIN_BSWAP
+ select ARCH_USE_CMPXCHG_LOCKREF if PPC64
+ select ARCH_WANT_IPC_PARSE_VERSION
diff --git a/debian/patches-rt/Use-CONFIG_PREEMPTION.patch b/debian/patches-rt/Use-CONFIG_PREEMPTION.patch
new file mode 100644
index 000000000000..ed9902f0edea
--- /dev/null
+++ b/debian/patches-rt/Use-CONFIG_PREEMPTION.patch
@@ -0,0 +1,1524 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 26 Jul 2019 11:30:49 +0200
+Subject: [PATCH] Use CONFIG_PREEMPTION
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Thisi is an all-in-one patch of the current `PREEMPTION' branch.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.html | 8 -
+ Documentation/RCU/Design/Requirements/Requirements.html | 24 ++--
+ Documentation/RCU/checklist.txt | 4
+ Documentation/RCU/rcubarrier.txt | 8 -
+ Documentation/RCU/stallwarn.txt | 4
+ Documentation/RCU/whatisRCU.txt | 7 -
+ Documentation/trace/ftrace-uses.rst | 2
+ arch/arc/kernel/entry.S | 6 -
+ arch/arm/include/asm/switch_to.h | 2
+ arch/arm/kernel/entry-armv.S | 4
+ arch/arm/kernel/traps.c | 2
+ arch/arm/mm/cache-v7.S | 4
+ arch/arm/mm/cache-v7m.S | 4
+ arch/arm64/Kconfig | 52 +++++-----
+ arch/arm64/crypto/sha256-glue.c | 2
+ arch/arm64/include/asm/assembler.h | 6 -
+ arch/arm64/include/asm/preempt.h | 4
+ arch/arm64/kernel/entry.S | 2
+ arch/arm64/kernel/traps.c | 3
+ arch/c6x/kernel/entry.S | 8 -
+ arch/csky/kernel/entry.S | 4
+ arch/h8300/kernel/entry.S | 6 -
+ arch/hexagon/kernel/vm_entry.S | 6 -
+ arch/ia64/kernel/entry.S | 12 +-
+ arch/ia64/kernel/kprobes.c | 2
+ arch/m68k/coldfire/entry.S | 2
+ arch/microblaze/kernel/entry.S | 2
+ arch/mips/include/asm/asmmacro.h | 4
+ arch/mips/kernel/entry.S | 6 -
+ arch/nds32/Kconfig | 2
+ arch/nds32/kernel/ex-exit.S | 4
+ arch/nios2/kernel/entry.S | 2
+ arch/parisc/Kconfig | 2
+ arch/parisc/kernel/entry.S | 10 -
+ arch/powerpc/Kconfig | 2
+ arch/powerpc/kernel/entry_32.S | 4
+ arch/powerpc/kernel/entry_64.S | 4
+ arch/powerpc/kernel/traps.c | 7 +
+ arch/riscv/kernel/entry.S | 4
+ arch/s390/Kconfig | 2
+ arch/s390/include/asm/preempt.h | 4
+ arch/s390/kernel/dumpstack.c | 2
+ arch/s390/kernel/entry.S | 2
+ arch/sh/Kconfig | 2
+ arch/sh/kernel/cpu/sh5/entry.S | 4
+ arch/sh/kernel/entry-common.S | 4
+ arch/sparc/Kconfig | 2
+ arch/sparc/kernel/rtrap_64.S | 2
+ arch/xtensa/kernel/entry.S | 2
+ arch/xtensa/kernel/traps.c | 7 -
+ drivers/gpu/drm/Kconfig | 2
+ drivers/media/platform/Kconfig | 2
+ drivers/video/backlight/Kconfig | 4
+ drivers/xen/preempt.c | 4
+ fs/btrfs/volumes.h | 2
+ fs/stack.c | 6 -
+ include/linux/fs.h | 4
+ include/linux/genhd.h | 6 -
+ include/linux/rcupdate.h | 4
+ include/xen/xen-ops.h | 4
+ kernel/Kconfig.locks | 12 +-
+ kernel/rcu/Kconfig | 4
+ kernel/rcu/rcutorture.c | 2
+ kernel/rcu/srcutiny.c | 2
+ kernel/rcu/tree.c | 4
+ kernel/rcu/tree_exp.h | 2
+ kernel/rcu/tree_plugin.h | 4
+ kernel/trace/trace.c | 2
+ kernel/workqueue.c | 2
+ lib/Kconfig.debug | 2
+ mm/memory.c | 2
+ mm/slub.c | 12 +-
+ net/core/dev.c | 2
+ 73 files changed, 191 insertions(+), 173 deletions(-)
+
+--- a/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.html
++++ b/Documentation/RCU/Design/Expedited-Grace-Periods/Expedited-Grace-Periods.html
+@@ -56,8 +56,8 @@ sections.
+ RCU-preempt Expedited Grace Periods</a></h2>
+
+ <p>
+-<tt>CONFIG_PREEMPT=y</tt> kernels implement RCU-preempt.
+-The overall flow of the handling of a given CPU by an RCU-preempt
++<tt>CONFIG_PREEMPT=y</tt> and <tt>CONFIG_PREEMPT_RT=y</tt> kernels implement
++RCU-preempt. The overall flow of the handling of a given CPU by an RCU-preempt
+ expedited grace period is shown in the following diagram:
+
+ <p><img src="ExpRCUFlow.svg" alt="ExpRCUFlow.svg" width="55%">
+@@ -140,8 +140,8 @@ or offline, among other things.
+ RCU-sched Expedited Grace Periods</a></h2>
+
+ <p>
+-<tt>CONFIG_PREEMPT=n</tt> kernels implement RCU-sched.
+-The overall flow of the handling of a given CPU by an RCU-sched
++<tt>CONFIG_PREEMPT=n</tt> and <tt>CONFIG_PREEMPT_RT=n</tt> kernels implement
++RCU-sched. The overall flow of the handling of a given CPU by an RCU-sched
+ expedited grace period is shown in the following diagram:
+
+ <p><img src="ExpSchedFlow.svg" alt="ExpSchedFlow.svg" width="55%">
+--- a/Documentation/RCU/Design/Requirements/Requirements.html
++++ b/Documentation/RCU/Design/Requirements/Requirements.html
+@@ -106,7 +106,7 @@ big RCU read-side critical section.
+ Production-quality implementations of <tt>rcu_read_lock()</tt> and
+ <tt>rcu_read_unlock()</tt> are extremely lightweight, and in
+ fact have exactly zero overhead in Linux kernels built for production
+-use with <tt>CONFIG_PREEMPT=n</tt>.
++use with <tt>CONFIG_PREEMPTION=n</tt>.
+
+ <p>
+ This guarantee allows ordering to be enforced with extremely low
+@@ -1499,7 +1499,7 @@ costs have plummeted.
+ However, as I learned from Matt Mackall's
+ <a href="http://elinux.org/Linux_Tiny-FAQ">bloatwatch</a>
+ efforts, memory footprint is critically important on single-CPU systems with
+-non-preemptible (<tt>CONFIG_PREEMPT=n</tt>) kernels, and thus
++non-preemptible (<tt>CONFIG_PREEMPTION=n</tt>) kernels, and thus
+ <a href="https://lkml.kernel.org/g/20090113221724.GA15307@linux.vnet.ibm.com">tiny RCU</a>
+ was born.
+ Josh Triplett has since taken over the small-memory banner with his
+@@ -1887,7 +1887,7 @@ constructs, there are limitations.
+ <p>
+ Implementations of RCU for which <tt>rcu_read_lock()</tt>
+ and <tt>rcu_read_unlock()</tt> generate no code, such as
+-Linux-kernel RCU when <tt>CONFIG_PREEMPT=n</tt>, can be
++Linux-kernel RCU when <tt>CONFIG_PREEMPTION=n</tt>, can be
+ nested arbitrarily deeply.
+ After all, there is no overhead.
+ Except that if all these instances of <tt>rcu_read_lock()</tt>
+@@ -2229,7 +2229,7 @@ be a no-op.
+ <p>
+ However, once the scheduler has spawned its first kthread, this early
+ boot trick fails for <tt>synchronize_rcu()</tt> (as well as for
+-<tt>synchronize_rcu_expedited()</tt>) in <tt>CONFIG_PREEMPT=y</tt>
++<tt>synchronize_rcu_expedited()</tt>) in <tt>CONFIG_PREEMPTION=y</tt>
+ kernels.
+ The reason is that an RCU read-side critical section might be preempted,
+ which means that a subsequent <tt>synchronize_rcu()</tt> really does have
+@@ -2568,7 +2568,7 @@ The compiler must not be permitted to tr
+
+ <p>
+ If the compiler did make this transformation in a
+-<tt>CONFIG_PREEMPT=n</tt> kernel build, and if <tt>get_user()</tt> did
++<tt>CONFIG_PREEMPTION=n</tt> kernel build, and if <tt>get_user()</tt> did
+ page fault, the result would be a quiescent state in the middle
+ of an RCU read-side critical section.
+ This misplaced quiescent state could result in line&nbsp;4 being
+@@ -2906,7 +2906,7 @@ in conjunction with the
+ The real-time-latency response requirements are such that the
+ traditional approach of disabling preemption across RCU
+ read-side critical sections is inappropriate.
+-Kernels built with <tt>CONFIG_PREEMPT=y</tt> therefore
++Kernels built with <tt>CONFIG_PREEMPTION=y</tt> therefore
+ use an RCU implementation that allows RCU read-side critical
+ sections to be preempted.
+ This requirement made its presence known after users made it
+@@ -3064,7 +3064,7 @@ includes
+ <tt>rcu_barrier_bh()</tt>, and
+ <tt>rcu_read_lock_bh_held()</tt>.
+ However, the update-side APIs are now simple wrappers for other RCU
+-flavors, namely RCU-sched in CONFIG_PREEMPT=n kernels and RCU-preempt
++flavors, namely RCU-sched in CONFIG_PREEMPTION=n kernels and RCU-preempt
+ otherwise.
+
+ <h3><a name="Sched Flavor">Sched Flavor (Historical)</a></h3>
+@@ -3088,12 +3088,12 @@ of an RCU read-side critical section can
+ Therefore, <i>RCU-sched</i> was created, which follows &ldquo;classic&rdquo;
+ RCU in that an RCU-sched grace period waits for for pre-existing
+ interrupt and NMI handlers.
+-In kernels built with <tt>CONFIG_PREEMPT=n</tt>, the RCU and RCU-sched
++In kernels built with <tt>CONFIG_PREEMPTION=n</tt>, the RCU and RCU-sched
+ APIs have identical implementations, while kernels built with
+-<tt>CONFIG_PREEMPT=y</tt> provide a separate implementation for each.
++<tt>CONFIG_PREEMPTION=y</tt> provide a separate implementation for each.
+
+ <p>
+-Note well that in <tt>CONFIG_PREEMPT=y</tt> kernels,
++Note well that in <tt>CONFIG_PREEMPTION=y</tt> kernels,
+ <tt>rcu_read_lock_sched()</tt> and <tt>rcu_read_unlock_sched()</tt>
+ disable and re-enable preemption, respectively.
+ This means that if there was a preemption attempt during the
+@@ -3302,12 +3302,12 @@ The tasks-RCU API is quite compact, cons
+ <tt>call_rcu_tasks()</tt>,
+ <tt>synchronize_rcu_tasks()</tt>, and
+ <tt>rcu_barrier_tasks()</tt>.
+-In <tt>CONFIG_PREEMPT=n</tt> kernels, trampolines cannot be preempted,
++In <tt>CONFIG_PREEMPTION=n</tt> kernels, trampolines cannot be preempted,
+ so these APIs map to
+ <tt>call_rcu()</tt>,
+ <tt>synchronize_rcu()</tt>, and
+ <tt>rcu_barrier()</tt>, respectively.
+-In <tt>CONFIG_PREEMPT=y</tt> kernels, trampolines can be preempted,
++In <tt>CONFIG_PREEMPTION=y</tt> kernels, trampolines can be preempted,
+ and these three APIs are therefore implemented by separate functions
+ that check for voluntary context switches.
+
+--- a/Documentation/RCU/checklist.txt
++++ b/Documentation/RCU/checklist.txt
+@@ -210,8 +210,8 @@ over a rather long period of time, but i
+ the rest of the system.
+
+ 7. As of v4.20, a given kernel implements only one RCU flavor,
+- which is RCU-sched for PREEMPT=n and RCU-preempt for PREEMPT=y.
+- If the updater uses call_rcu() or synchronize_rcu(),
++ which is RCU-sched for PREEMPTION=n and RCU-preempt for
++ PREEMPTION=y. If the updater uses call_rcu() or synchronize_rcu(),
+ then the corresponding readers my use rcu_read_lock() and
+ rcu_read_unlock(), rcu_read_lock_bh() and rcu_read_unlock_bh(),
+ or any pair of primitives that disables and re-enables preemption,
+--- a/Documentation/RCU/rcubarrier.txt
++++ b/Documentation/RCU/rcubarrier.txt
+@@ -6,8 +6,8 @@ RCU (read-copy update) is a synchronizat
+ of as a replacement for read-writer locking (among other things), but with
+ very low-overhead readers that are immune to deadlock, priority inversion,
+ and unbounded latency. RCU read-side critical sections are delimited
+-by rcu_read_lock() and rcu_read_unlock(), which, in non-CONFIG_PREEMPT
+-kernels, generate no code whatsoever.
++by rcu_read_lock() and rcu_read_unlock(), which, in
++non-CONFIG_PREEMPTION kernels, generate no code whatsoever.
+
+ This means that RCU writers are unaware of the presence of concurrent
+ readers, so that RCU updates to shared data must be undertaken quite
+@@ -303,10 +303,10 @@ Answer: This cannot happen. The reason i
+ to smp_call_function() and further to smp_call_function_on_cpu(),
+ causing this latter to spin until the cross-CPU invocation of
+ rcu_barrier_func() has completed. This by itself would prevent
+- a grace period from completing on non-CONFIG_PREEMPT kernels,
++ a grace period from completing on non-CONFIG_PREEMPTION kernels,
+ since each CPU must undergo a context switch (or other quiescent
+ state) before the grace period can complete. However, this is
+- of no use in CONFIG_PREEMPT kernels.
++ of no use in CONFIG_PREEMPTION kernels.
+
+ Therefore, on_each_cpu() disables preemption across its call
+ to smp_call_function() and also across the local call to
+--- a/Documentation/RCU/stallwarn.txt
++++ b/Documentation/RCU/stallwarn.txt
+@@ -20,7 +20,7 @@ o A CPU looping with preemption disabled
+
+ o A CPU looping with bottom halves disabled.
+
+-o For !CONFIG_PREEMPT kernels, a CPU looping anywhere in the kernel
++o For !CONFIG_PREEMPTION kernels, a CPU looping anywhere in the kernel
+ without invoking schedule(). If the looping in the kernel is
+ really expected and desirable behavior, you might need to add
+ some calls to cond_resched().
+@@ -39,7 +39,7 @@ o Anything that prevents RCU's grace-per
+ result in the "rcu_.*kthread starved for" console-log message,
+ which will include additional debugging information.
+
+-o A CPU-bound real-time task in a CONFIG_PREEMPT kernel, which might
++o A CPU-bound real-time task in a CONFIG_PREEMPTION kernel, which might
+ happen to preempt a low-priority task in the middle of an RCU
+ read-side critical section. This is especially damaging if
+ that low-priority task is not permitted to run on any other CPU,
+--- a/Documentation/RCU/whatisRCU.txt
++++ b/Documentation/RCU/whatisRCU.txt
+@@ -648,9 +648,10 @@ Quick Quiz #1: Why is this argument naiv
+
+ This section presents a "toy" RCU implementation that is based on
+ "classic RCU". It is also short on performance (but only for updates) and
+-on features such as hotplug CPU and the ability to run in CONFIG_PREEMPT
+-kernels. The definitions of rcu_dereference() and rcu_assign_pointer()
+-are the same as those shown in the preceding section, so they are omitted.
++on features such as hotplug CPU and the ability to run in
++CONFIG_PREEMPTION kernels. The definitions of rcu_dereference() and
++rcu_assign_pointer() are the same as those shown in the preceding
++section, so they are omitted.
+
+ void rcu_read_lock(void) { }
+
+--- a/Documentation/trace/ftrace-uses.rst
++++ b/Documentation/trace/ftrace-uses.rst
+@@ -146,7 +146,7 @@ FTRACE_OPS_FL_RECURSION_SAFE
+ itself or any nested functions that those functions call.
+
+ If this flag is set, it is possible that the callback will also
+- be called with preemption enabled (when CONFIG_PREEMPT is set),
++ be called with preemption enabled (when CONFIG_PREEMPTION is set),
+ but this is not guaranteed.
+
+ FTRACE_OPS_FL_IPMODIFY
+--- a/arch/arc/kernel/entry.S
++++ b/arch/arc/kernel/entry.S
+@@ -337,11 +337,11 @@ ENTRY(ret_from_exception)
+ resume_kernel_mode:
+
+ ; Disable Interrupts from this point on
+- ; CONFIG_PREEMPT: This is a must for preempt_schedule_irq()
+- ; !CONFIG_PREEMPT: To ensure restore_regs is intr safe
++ ; CONFIG_PREEMPTION: This is a must for preempt_schedule_irq()
++ ; !CONFIG_PREEMPTION: To ensure restore_regs is intr safe
+ IRQ_DISABLE r9
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+
+ ; Can't preempt if preemption disabled
+ GET_CURR_THR_INFO_FROM_SP r10
+--- a/arch/arm/include/asm/switch_to.h
++++ b/arch/arm/include/asm/switch_to.h
+@@ -10,7 +10,7 @@
+ * to ensure that the maintenance completes in case we migrate to another
+ * CPU.
+ */
+-#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) && defined(CONFIG_CPU_V7)
++#if defined(CONFIG_PREEMPTION) && defined(CONFIG_SMP) && defined(CONFIG_CPU_V7)
+ #define __complete_pending_tlbi() dsb(ish)
+ #else
+ #define __complete_pending_tlbi()
+--- a/arch/arm/kernel/entry-armv.S
++++ b/arch/arm/kernel/entry-armv.S
+@@ -211,7 +211,7 @@ ENDPROC(__dabt_svc)
+ svc_entry
+ irq_handler
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
+ ldr r0, [tsk, #TI_FLAGS] @ get flags
+ teq r8, #0 @ if preempt count != 0
+@@ -226,7 +226,7 @@ ENDPROC(__irq_svc)
+
+ .ltorg
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ svc_preempt:
+ mov r8, lr
+ 1: bl preempt_schedule_irq @ irq en/disable is done inside
+--- a/arch/arm/kernel/traps.c
++++ b/arch/arm/kernel/traps.c
+@@ -248,6 +248,8 @@ void show_stack(struct task_struct *tsk,
+
+ #ifdef CONFIG_PREEMPT
+ #define S_PREEMPT " PREEMPT"
++#elif defined(CONFIG_PREEMPT_RT)
++#define S_PREEMPT " PREEMPT_RT"
+ #else
+ #define S_PREEMPT ""
+ #endif
+--- a/arch/arm/mm/cache-v7.S
++++ b/arch/arm/mm/cache-v7.S
+@@ -135,13 +135,13 @@ ENTRY(v7_flush_dcache_all)
+ and r1, r1, #7 @ mask of the bits for current cache only
+ cmp r1, #2 @ see what cache we have at this level
+ blt skip @ skip if no cache, or just i-cache
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ save_and_disable_irqs_notrace r9 @ make cssr&csidr read atomic
+ #endif
+ mcr p15, 2, r10, c0, c0, 0 @ select current cache level in cssr
+ isb @ isb to sych the new cssr&csidr
+ mrc p15, 1, r1, c0, c0, 0 @ read the new csidr
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ restore_irqs_notrace r9
+ #endif
+ and r2, r1, #7 @ extract the length of the cache lines
+--- a/arch/arm/mm/cache-v7m.S
++++ b/arch/arm/mm/cache-v7m.S
+@@ -183,13 +183,13 @@ ENTRY(v7m_flush_dcache_all)
+ and r1, r1, #7 @ mask of the bits for current cache only
+ cmp r1, #2 @ see what cache we have at this level
+ blt skip @ skip if no cache, or just i-cache
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ save_and_disable_irqs_notrace r9 @ make cssr&csidr read atomic
+ #endif
+ write_csselr r10, r1 @ set current cache level
+ isb @ isb to sych the new cssr&csidr
+ read_ccsidr r1 @ read the new csidr
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ restore_irqs_notrace r9
+ #endif
+ and r2, r1, #7 @ extract the length of the cache lines
+--- a/arch/arm64/Kconfig
++++ b/arch/arm64/Kconfig
+@@ -35,32 +35,32 @@ config ARM64
+ select ARCH_HAS_TEARDOWN_DMA_OPS if IOMMU_SUPPORT
+ select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
+ select ARCH_HAVE_NMI_SAFE_CMPXCHG
+- select ARCH_INLINE_READ_LOCK if !PREEMPT
+- select ARCH_INLINE_READ_LOCK_BH if !PREEMPT
+- select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_READ_LOCK_IRQSAVE if !PREEMPT
+- select ARCH_INLINE_READ_UNLOCK if !PREEMPT
+- select ARCH_INLINE_READ_UNLOCK_BH if !PREEMPT
+- select ARCH_INLINE_READ_UNLOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_READ_UNLOCK_IRQRESTORE if !PREEMPT
+- select ARCH_INLINE_WRITE_LOCK if !PREEMPT
+- select ARCH_INLINE_WRITE_LOCK_BH if !PREEMPT
+- select ARCH_INLINE_WRITE_LOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_WRITE_LOCK_IRQSAVE if !PREEMPT
+- select ARCH_INLINE_WRITE_UNLOCK if !PREEMPT
+- select ARCH_INLINE_WRITE_UNLOCK_BH if !PREEMPT
+- select ARCH_INLINE_WRITE_UNLOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE if !PREEMPT
+- select ARCH_INLINE_SPIN_TRYLOCK if !PREEMPT
+- select ARCH_INLINE_SPIN_TRYLOCK_BH if !PREEMPT
+- select ARCH_INLINE_SPIN_LOCK if !PREEMPT
+- select ARCH_INLINE_SPIN_LOCK_BH if !PREEMPT
+- select ARCH_INLINE_SPIN_LOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_SPIN_LOCK_IRQSAVE if !PREEMPT
+- select ARCH_INLINE_SPIN_UNLOCK if !PREEMPT
+- select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPT
+- select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPT
+- select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPT
++ select ARCH_INLINE_READ_LOCK if !PREEMPTION
++ select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
++ select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_READ_LOCK_IRQSAVE if !PREEMPTION
++ select ARCH_INLINE_READ_UNLOCK if !PREEMPTION
++ select ARCH_INLINE_READ_UNLOCK_BH if !PREEMPTION
++ select ARCH_INLINE_READ_UNLOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_READ_UNLOCK_IRQRESTORE if !PREEMPTION
++ select ARCH_INLINE_WRITE_LOCK if !PREEMPTION
++ select ARCH_INLINE_WRITE_LOCK_BH if !PREEMPTION
++ select ARCH_INLINE_WRITE_LOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_WRITE_LOCK_IRQSAVE if !PREEMPTION
++ select ARCH_INLINE_WRITE_UNLOCK if !PREEMPTION
++ select ARCH_INLINE_WRITE_UNLOCK_BH if !PREEMPTION
++ select ARCH_INLINE_WRITE_UNLOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE if !PREEMPTION
++ select ARCH_INLINE_SPIN_TRYLOCK if !PREEMPTION
++ select ARCH_INLINE_SPIN_TRYLOCK_BH if !PREEMPTION
++ select ARCH_INLINE_SPIN_LOCK if !PREEMPTION
++ select ARCH_INLINE_SPIN_LOCK_BH if !PREEMPTION
++ select ARCH_INLINE_SPIN_LOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_SPIN_LOCK_IRQSAVE if !PREEMPTION
++ select ARCH_INLINE_SPIN_UNLOCK if !PREEMPTION
++ select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION
++ select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION
++ select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION
+ select ARCH_KEEP_MEMBLOCK
+ select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_USE_QUEUED_RWLOCKS
+--- a/arch/arm64/crypto/sha256-glue.c
++++ b/arch/arm64/crypto/sha256-glue.c
+@@ -97,7 +97,7 @@ static int sha256_update_neon(struct sha
+ * input when running on a preemptible kernel, but process the
+ * data block by block instead.
+ */
+- if (IS_ENABLED(CONFIG_PREEMPT) &&
++ if (IS_ENABLED(CONFIG_PREEMPTION) &&
+ chunk + sctx->count % SHA256_BLOCK_SIZE > SHA256_BLOCK_SIZE)
+ chunk = SHA256_BLOCK_SIZE -
+ sctx->count % SHA256_BLOCK_SIZE;
+--- a/arch/arm64/include/asm/assembler.h
++++ b/arch/arm64/include/asm/assembler.h
+@@ -699,8 +699,8 @@ USER(\label, ic ivau, \tmp2) // invali
+ * where <label> is optional, and marks the point where execution will resume
+ * after a yield has been performed. If omitted, execution resumes right after
+ * the endif_yield_neon invocation. Note that the entire sequence, including
+- * the provided patchup code, will be omitted from the image if CONFIG_PREEMPT
+- * is not defined.
++ * the provided patchup code, will be omitted from the image if
++ * CONFIG_PREEMPTION is not defined.
+ *
+ * As a convenience, in the case where no patchup code is required, the above
+ * sequence may be abbreviated to
+@@ -728,7 +728,7 @@ USER(\label, ic ivau, \tmp2) // invali
+ .endm
+
+ .macro if_will_cond_yield_neon
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ get_current_task x0
+ ldr x0, [x0, #TSK_TI_PREEMPT]
+ sub x0, x0, #PREEMPT_DISABLE_OFFSET
+--- a/arch/arm64/include/asm/preempt.h
++++ b/arch/arm64/include/asm/preempt.h
+@@ -79,11 +79,11 @@ static inline bool should_resched(int pr
+ return pc == preempt_offset;
+ }
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ void preempt_schedule(void);
+ #define __preempt_schedule() preempt_schedule()
+ void preempt_schedule_notrace(void);
+ #define __preempt_schedule_notrace() preempt_schedule_notrace()
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ #endif /* __ASM_PREEMPT_H */
+--- a/arch/arm64/kernel/entry.S
++++ b/arch/arm64/kernel/entry.S
+@@ -669,7 +669,7 @@ ENDPROC(el1_sync)
+
+ irq_handler
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ ldr x24, [tsk, #TSK_TI_PREEMPT] // get preempt count
+ alternative_if ARM64_HAS_IRQ_PRIO_MASKING
+ /*
+--- a/arch/arm64/kernel/traps.c
++++ b/arch/arm64/kernel/traps.c
+@@ -143,9 +143,12 @@ void show_stack(struct task_struct *tsk,
+
+ #ifdef CONFIG_PREEMPT
+ #define S_PREEMPT " PREEMPT"
++#elif defined(CONFIG_PREEMPT_RT)
++#define S_PREEMPT " PREEMPT_RT"
+ #else
+ #define S_PREEMPT ""
+ #endif
++
+ #define S_SMP " SMP"
+
+ static int __die(const char *str, int err, struct pt_regs *regs)
+--- a/arch/c6x/kernel/entry.S
++++ b/arch/c6x/kernel/entry.S
+@@ -18,7 +18,7 @@
+ #define DP B14
+ #define SP B15
+
+-#ifndef CONFIG_PREEMPT
++#ifndef CONFIG_PREEMPTION
+ #define resume_kernel restore_all
+ #endif
+
+@@ -287,7 +287,7 @@
+ ;; is a little bit different
+ ;;
+ ENTRY(ret_from_exception)
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ MASK_INT B2
+ #endif
+
+@@ -557,7 +557,7 @@ ENDPROC(_nmi_handler)
+ ;;
+ ;; Jump to schedule() then return to ret_from_isr
+ ;;
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ resume_kernel:
+ GET_THREAD_INFO A12
+ LDW .D1T1 *+A12(THREAD_INFO_PREEMPT_COUNT),A1
+@@ -582,7 +582,7 @@ ENDPROC(_nmi_handler)
+ B .S2 preempt_schedule_irq
+ #endif
+ ADDKPC .S2 preempt_schedule,B3,4
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ ENTRY(enable_exception)
+ DINT
+--- a/arch/csky/kernel/entry.S
++++ b/arch/csky/kernel/entry.S
+@@ -277,7 +277,7 @@ ENTRY(csky_irq)
+ zero_fp
+ psrset ee
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ mov r9, sp /* Get current stack pointer */
+ bmaski r10, THREAD_SHIFT
+ andn r9, r10 /* Get thread_info */
+@@ -294,7 +294,7 @@ ENTRY(csky_irq)
+ mov a0, sp
+ jbsr csky_do_IRQ
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ subi r12, 1
+ stw r12, (r9, TINFO_PREEMPT)
+ cmpnei r12, 0
+--- a/arch/h8300/kernel/entry.S
++++ b/arch/h8300/kernel/entry.S
+@@ -284,12 +284,12 @@ INTERRUPTS = 128
+ mov.l er0,@(LER0:16,sp)
+ bra resume_userspace
+
+-#if !defined(CONFIG_PREEMPT)
++#if !defined(CONFIG_PREEMPTION)
+ #define resume_kernel restore_all
+ #endif
+
+ ret_from_exception:
+-#if defined(CONFIG_PREEMPT)
++#if defined(CONFIG_PREEMPTION)
+ orc #0xc0,ccr
+ #endif
+ ret_from_interrupt:
+@@ -319,7 +319,7 @@ INTERRUPTS = 128
+ restore_all:
+ RESTORE_ALL /* Does RTE */
+
+-#if defined(CONFIG_PREEMPT)
++#if defined(CONFIG_PREEMPTION)
+ resume_kernel:
+ mov.l @(TI_PRE_COUNT:16,er4),er0
+ bne restore_all:8
+--- a/arch/hexagon/kernel/vm_entry.S
++++ b/arch/hexagon/kernel/vm_entry.S
+@@ -265,12 +265,12 @@
+ * should be in the designated register (usually R19)
+ *
+ * If we were in kernel mode, we don't need to check scheduler
+- * or signals if CONFIG_PREEMPT is not set. If set, then it has
++ * or signals if CONFIG_PREEMPTION is not set. If set, then it has
+ * to jump to a need_resched kind of block.
+- * BTW, CONFIG_PREEMPT is not supported yet.
++ * BTW, CONFIG_PREEMPTION is not supported yet.
+ */
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ R0 = #VM_INT_DISABLE
+ trap1(#HVM_TRAP1_VMSETIE)
+ #endif
+--- a/arch/ia64/kernel/entry.S
++++ b/arch/ia64/kernel/entry.S
+@@ -670,12 +670,12 @@ GLOBAL_ENTRY(ia64_leave_syscall)
+ *
+ * p6 controls whether current_thread_info()->flags needs to be check for
+ * extra work. We always check for extra work when returning to user-level.
+- * With CONFIG_PREEMPT, we also check for extra work when the preempt_count
++ * With CONFIG_PREEMPTION, we also check for extra work when the preempt_count
+ * is 0. After extra work processing has been completed, execution
+ * resumes at ia64_work_processed_syscall with p6 set to 1 if the extra-work-check
+ * needs to be redone.
+ */
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ RSM_PSR_I(p0, r2, r18) // disable interrupts
+ cmp.eq pLvSys,p0=r0,r0 // pLvSys=1: leave from syscall
+ (pKStk) adds r20=TI_PRE_COUNT+IA64_TASK_SIZE,r13
+@@ -685,7 +685,7 @@ GLOBAL_ENTRY(ia64_leave_syscall)
+ (pUStk) mov r21=0 // r21 <- 0
+ ;;
+ cmp.eq p6,p0=r21,r0 // p6 <- pUStk || (preempt_count == 0)
+-#else /* !CONFIG_PREEMPT */
++#else /* !CONFIG_PREEMPTION */
+ RSM_PSR_I(pUStk, r2, r18)
+ cmp.eq pLvSys,p0=r0,r0 // pLvSys=1: leave from syscall
+ (pUStk) cmp.eq.unc p6,p0=r0,r0 // p6 <- pUStk
+@@ -814,12 +814,12 @@ GLOBAL_ENTRY(ia64_leave_kernel)
+ *
+ * p6 controls whether current_thread_info()->flags needs to be check for
+ * extra work. We always check for extra work when returning to user-level.
+- * With CONFIG_PREEMPT, we also check for extra work when the preempt_count
++ * With CONFIG_PREEMPTION, we also check for extra work when the preempt_count
+ * is 0. After extra work processing has been completed, execution
+ * resumes at .work_processed_syscall with p6 set to 1 if the extra-work-check
+ * needs to be redone.
+ */
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ RSM_PSR_I(p0, r17, r31) // disable interrupts
+ cmp.eq p0,pLvSys=r0,r0 // pLvSys=0: leave from kernel
+ (pKStk) adds r20=TI_PRE_COUNT+IA64_TASK_SIZE,r13
+@@ -1120,7 +1120,7 @@ GLOBAL_ENTRY(ia64_leave_kernel)
+
+ /*
+ * On entry:
+- * r20 = &current->thread_info->pre_count (if CONFIG_PREEMPT)
++ * r20 = &current->thread_info->pre_count (if CONFIG_PREEMPTION)
+ * r31 = current->thread_info->flags
+ * On exit:
+ * p6 = TRUE if work-pending-check needs to be redone
+--- a/arch/ia64/kernel/kprobes.c
++++ b/arch/ia64/kernel/kprobes.c
+@@ -841,7 +841,7 @@ static int __kprobes pre_kprobes_handler
+ return 1;
+ }
+
+-#if !defined(CONFIG_PREEMPT)
++#if !defined(CONFIG_PREEMPTION)
+ if (p->ainsn.inst_flag == INST_FLAG_BOOSTABLE && !p->post_handler) {
+ /* Boost up -- we can execute copied instructions directly */
+ ia64_psr(regs)->ri = p->ainsn.slot;
+--- a/arch/m68k/coldfire/entry.S
++++ b/arch/m68k/coldfire/entry.S
+@@ -108,7 +108,7 @@ ENTRY(system_call)
+ btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel */
+ jeq Luser_return /* if so, skip resched, signals */
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ movel %sp,%d1 /* get thread_info pointer */
+ andl #-THREAD_SIZE,%d1 /* at base of kernel stack */
+ movel %d1,%a0
+--- a/arch/microblaze/kernel/entry.S
++++ b/arch/microblaze/kernel/entry.S
+@@ -728,7 +728,7 @@ irq_call:rtbd r0, do_IRQ;
+ bri 6f;
+ /* MS: Return to kernel state. */
+ 2:
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ lwi r11, CURRENT_TASK, TS_THREAD_INFO;
+ /* MS: get preempt_count from thread info */
+ lwi r5, r11, TI_PREEMPT_COUNT;
+--- a/arch/mips/include/asm/asmmacro.h
++++ b/arch/mips/include/asm/asmmacro.h
+@@ -63,7 +63,7 @@
+ .endm
+
+ .macro local_irq_disable reg=t0
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ lw \reg, TI_PRE_COUNT($28)
+ addi \reg, \reg, 1
+ sw \reg, TI_PRE_COUNT($28)
+@@ -73,7 +73,7 @@
+ xori \reg, \reg, 1
+ mtc0 \reg, CP0_STATUS
+ irq_disable_hazard
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ lw \reg, TI_PRE_COUNT($28)
+ addi \reg, \reg, -1
+ sw \reg, TI_PRE_COUNT($28)
+--- a/arch/mips/kernel/entry.S
++++ b/arch/mips/kernel/entry.S
+@@ -19,7 +19,7 @@
+ #include <asm/thread_info.h>
+ #include <asm/war.h>
+
+-#ifndef CONFIG_PREEMPT
++#ifndef CONFIG_PREEMPTION
+ #define resume_kernel restore_all
+ #else
+ #define __ret_from_irq ret_from_exception
+@@ -27,7 +27,7 @@
+
+ .text
+ .align 5
+-#ifndef CONFIG_PREEMPT
++#ifndef CONFIG_PREEMPTION
+ FEXPORT(ret_from_exception)
+ local_irq_disable # preempt stop
+ b __ret_from_irq
+@@ -53,7 +53,7 @@ FEXPORT(__ret_from_irq)
+ bnez t0, work_pending
+ j restore_all
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ resume_kernel:
+ local_irq_disable
+ lw t0, TI_PRE_COUNT($28)
+--- a/arch/nds32/Kconfig
++++ b/arch/nds32/Kconfig
+@@ -61,7 +61,7 @@ config GENERIC_HWEIGHT
+
+ config GENERIC_LOCKBREAK
+ def_bool y
+- depends on PREEMPT
++ depends on PREEMPTION
+
+ config TRACE_IRQFLAGS_SUPPORT
+ def_bool y
+--- a/arch/nds32/kernel/ex-exit.S
++++ b/arch/nds32/kernel/ex-exit.S
+@@ -72,7 +72,7 @@
+ restore_user_regs_last
+ .endm
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ .macro preempt_stop
+ .endm
+ #else
+@@ -158,7 +158,7 @@ ENTRY(ret_slow_syscall)
+ /*
+ * preemptive kernel
+ */
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ resume_kernel:
+ gie_disable
+ lwi $t0, [tsk+#TSK_TI_PREEMPT]
+--- a/arch/nios2/kernel/entry.S
++++ b/arch/nios2/kernel/entry.S
+@@ -365,7 +365,7 @@ ENTRY(ret_from_interrupt)
+ ldw r1, PT_ESTATUS(sp) /* check if returning to kernel */
+ TSTBNZ r1, r1, ESTATUS_EU, Luser_return
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ GET_THREAD_INFO r1
+ ldw r4, TI_PREEMPT_COUNT(r1)
+ bne r4, r0, restore_all
+--- a/arch/parisc/Kconfig
++++ b/arch/parisc/Kconfig
+@@ -81,7 +81,7 @@ config STACK_GROWSUP
+ config GENERIC_LOCKBREAK
+ bool
+ default y
+- depends on SMP && PREEMPT
++ depends on SMP && PREEMPTION
+
+ config ARCH_HAS_ILOG2_U32
+ bool
+--- a/arch/parisc/kernel/entry.S
++++ b/arch/parisc/kernel/entry.S
+@@ -940,14 +940,14 @@ ENTRY(intr_return)
+ rfi
+ nop
+
+-#ifndef CONFIG_PREEMPT
++#ifndef CONFIG_PREEMPTION
+ # define intr_do_preempt intr_restore
+-#endif /* !CONFIG_PREEMPT */
++#endif /* !CONFIG_PREEMPTION */
+
+ .import schedule,code
+ intr_do_resched:
+ /* Only call schedule on return to userspace. If we're returning
+- * to kernel space, we may schedule if CONFIG_PREEMPT, otherwise
++ * to kernel space, we may schedule if CONFIG_PREEMPTION, otherwise
+ * we jump back to intr_restore.
+ */
+ LDREG PT_IASQ0(%r16), %r20
+@@ -979,7 +979,7 @@ ENTRY(intr_return)
+ * and preempt_count is 0. otherwise, we continue on
+ * our merry way back to the current running task.
+ */
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ .import preempt_schedule_irq,code
+ intr_do_preempt:
+ rsm PSW_SM_I, %r0 /* disable interrupts */
+@@ -999,7 +999,7 @@ ENTRY(intr_return)
+ nop
+
+ b,n intr_restore /* ssm PSW_SM_I done by intr_restore */
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ /*
+ * External interrupts.
+--- a/arch/powerpc/Kconfig
++++ b/arch/powerpc/Kconfig
+@@ -106,7 +106,7 @@ config LOCKDEP_SUPPORT
+ config GENERIC_LOCKBREAK
+ bool
+ default y
+- depends on SMP && PREEMPT
++ depends on SMP && PREEMPTION
+
+ config GENERIC_HWEIGHT
+ bool
+--- a/arch/powerpc/kernel/entry_32.S
++++ b/arch/powerpc/kernel/entry_32.S
+@@ -897,7 +897,7 @@ user_exc_return: /* r10 contains MSR_KE
+ bne- 0b
+ 1:
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ /* check current_thread_info->preempt_count */
+ lwz r0,TI_PREEMPT(r2)
+ cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
+@@ -921,7 +921,7 @@ user_exc_return: /* r10 contains MSR_KE
+ */
+ bl trace_hardirqs_on
+ #endif
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+ restore_kuap:
+ kuap_restore r1, r2, r9, r10, r0
+
+--- a/arch/powerpc/kernel/entry_64.S
++++ b/arch/powerpc/kernel/entry_64.S
+@@ -846,7 +846,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
+ bne- 0b
+ 1:
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ /* Check if we need to preempt */
+ andi. r0,r4,_TIF_NEED_RESCHED
+ beq+ restore
+@@ -877,7 +877,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
+ li r10,MSR_RI
+ mtmsrd r10,1 /* Update machine state */
+ #endif /* CONFIG_PPC_BOOK3E */
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ .globl fast_exc_return_irq
+ fast_exc_return_irq:
+--- a/arch/powerpc/kernel/traps.c
++++ b/arch/powerpc/kernel/traps.c
+@@ -251,14 +251,19 @@ NOKPROBE_SYMBOL(oops_end);
+
+ static int __die(const char *str, struct pt_regs *regs, long err)
+ {
++ const char *pr = "";
++
+ printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
+
++ if (IS_ENABLED(CONFIG_PREEMPTION))
++ pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
++
+ printk("%s PAGE_SIZE=%luK%s%s%s%s%s%s%s %s\n",
+ IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN) ? "LE" : "BE",
+ PAGE_SIZE / 1024,
+ early_radix_enabled() ? " MMU=Radix" : "",
+ early_mmu_has_feature(MMU_FTR_HPTE_TABLE) ? " MMU=Hash" : "",
+- IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
++ pr,
+ IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
+ IS_ENABLED(CONFIG_SMP) ? (" NR_CPUS=" __stringify(NR_CPUS)) : "",
+ debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
+--- a/arch/riscv/kernel/entry.S
++++ b/arch/riscv/kernel/entry.S
+@@ -155,7 +155,7 @@
+ REG_L x2, PT_SP(sp)
+ .endm
+
+-#if !IS_ENABLED(CONFIG_PREEMPT)
++#if !IS_ENABLED(CONFIG_PREEMPTION)
+ .set resume_kernel, restore_all
+ #endif
+
+@@ -269,7 +269,7 @@ ENTRY(handle_exception)
+ RESTORE_ALL
+ sret
+
+-#if IS_ENABLED(CONFIG_PREEMPT)
++#if IS_ENABLED(CONFIG_PREEMPTION)
+ resume_kernel:
+ REG_L s0, TASK_TI_PREEMPT_COUNT(tp)
+ bnez s0, restore_all
+--- a/arch/s390/Kconfig
++++ b/arch/s390/Kconfig
+@@ -30,7 +30,7 @@ config GENERIC_BUG_RELATIVE_POINTERS
+ def_bool y
+
+ config GENERIC_LOCKBREAK
+- def_bool y if PREEMPT
++ def_bool y if PREEMPTTION
+
+ config PGSTE
+ def_bool y if KVM
+--- a/arch/s390/include/asm/preempt.h
++++ b/arch/s390/include/asm/preempt.h
+@@ -130,11 +130,11 @@ static inline bool should_resched(int pr
+
+ #endif /* CONFIG_HAVE_MARCH_Z196_FEATURES */
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ extern asmlinkage void preempt_schedule(void);
+ #define __preempt_schedule() preempt_schedule()
+ extern asmlinkage void preempt_schedule_notrace(void);
+ #define __preempt_schedule_notrace() preempt_schedule_notrace()
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ #endif /* __ASM_PREEMPT_H */
+--- a/arch/s390/kernel/dumpstack.c
++++ b/arch/s390/kernel/dumpstack.c
+@@ -194,6 +194,8 @@ void die(struct pt_regs *regs, const cha
+ regs->int_code >> 17, ++die_counter);
+ #ifdef CONFIG_PREEMPT
+ pr_cont("PREEMPT ");
++#elif defined(CONFIG_PREEMPT_RT)
++ pr_cont("PREEMPT_RT ");
+ #endif
+ pr_cont("SMP ");
+ if (debug_pagealloc_enabled())
+--- a/arch/s390/kernel/entry.S
++++ b/arch/s390/kernel/entry.S
+@@ -790,7 +790,7 @@ ENTRY(io_int_handler)
+ .Lio_work:
+ tm __PT_PSW+1(%r11),0x01 # returning to user ?
+ jo .Lio_work_user # yes -> do resched & signal
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ # check for preemptive scheduling
+ icm %r0,15,__LC_PREEMPT_COUNT
+ jnz .Lio_restore # preemption is disabled
+--- a/arch/sh/Kconfig
++++ b/arch/sh/Kconfig
+@@ -108,7 +108,7 @@ config GENERIC_CALIBRATE_DELAY
+
+ config GENERIC_LOCKBREAK
+ def_bool y
+- depends on SMP && PREEMPT
++ depends on SMP && PREEMPTION
+
+ config ARCH_SUSPEND_POSSIBLE
+ def_bool n
+--- a/arch/sh/kernel/cpu/sh5/entry.S
++++ b/arch/sh/kernel/cpu/sh5/entry.S
+@@ -86,7 +86,7 @@
+ andi r6, ~0xf0, r6; \
+ putcon r6, SR;
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ # define preempt_stop() CLI()
+ #else
+ # define preempt_stop()
+@@ -884,7 +884,7 @@ LRESVEC_block_end: /* Marker. Unused.
+
+ /* Check softirqs */
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ pta ret_from_syscall, tr0
+ blink tr0, ZERO
+
+--- a/arch/sh/kernel/entry-common.S
++++ b/arch/sh/kernel/entry-common.S
+@@ -41,7 +41,7 @@
+ */
+ #include <asm/dwarf.h>
+
+-#if defined(CONFIG_PREEMPT)
++#if defined(CONFIG_PREEMPTION)
+ # define preempt_stop() cli ; TRACE_IRQS_OFF
+ #else
+ # define preempt_stop()
+@@ -84,7 +84,7 @@ ENTRY(ret_from_irq)
+ get_current_thread_info r8, r0
+ bt resume_kernel ! Yes, it's from kernel, go back soon
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ bra resume_userspace
+ nop
+ ENTRY(resume_kernel)
+--- a/arch/sparc/Kconfig
++++ b/arch/sparc/Kconfig
+@@ -277,7 +277,7 @@ config US3_MC
+ config GENERIC_LOCKBREAK
+ bool
+ default y
+- depends on SPARC64 && SMP && PREEMPT
++ depends on SPARC64 && SMP && PREEMPTION
+
+ config NUMA
+ bool "NUMA support"
+--- a/arch/sparc/kernel/rtrap_64.S
++++ b/arch/sparc/kernel/rtrap_64.S
+@@ -310,7 +310,7 @@ kern_rtt: rdpr %canrestore, %g1
+ retry
+
+ to_kernel:
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ ldsw [%g6 + TI_PRE_COUNT], %l5
+ brnz %l5, kern_fpucheck
+ ldx [%g6 + TI_FLAGS], %l5
+--- a/arch/xtensa/kernel/entry.S
++++ b/arch/xtensa/kernel/entry.S
+@@ -520,7 +520,7 @@ ENTRY(kernel_exception)
+ call4 schedule # void schedule (void)
+ j 1b
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ 6:
+ _bbci.l a4, TIF_NEED_RESCHED, 4f
+
+--- a/arch/xtensa/kernel/traps.c
++++ b/arch/xtensa/kernel/traps.c
+@@ -524,12 +524,15 @@ DEFINE_SPINLOCK(die_lock);
+ void die(const char * str, struct pt_regs * regs, long err)
+ {
+ static int die_counter;
++ const char *pr = "";
++
++ if (IS_ENABLED(CONFIG_PREEMPTION))
++ pr = IS_ENABLED(CONFIG_PREEMPT_RT) ? " PREEMPT_RT" : " PREEMPT";
+
+ console_verbose();
+ spin_lock_irq(&die_lock);
+
+- pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter,
+- IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "");
++ pr_info("%s: sig: %ld [#%d]%s\n", str, err, ++die_counter, pr);
+ show_regs(regs);
+ if (!user_mode(regs))
+ show_stack(NULL, (unsigned long*)regs->areg[1]);
+--- a/drivers/gpu/drm/Kconfig
++++ b/drivers/gpu/drm/Kconfig
+@@ -397,7 +397,7 @@ config DRM_R128
+
+ config DRM_I810
+ tristate "Intel I810"
+- # !PREEMPT because of missing ioctl locking
++ # !PREEMPTION because of missing ioctl locking
+ depends on DRM && AGP && AGP_INTEL && (!PREEMPTION || BROKEN)
+ help
+ Choose this option if you have an Intel I810 graphics card. If M is
+--- a/drivers/media/platform/Kconfig
++++ b/drivers/media/platform/Kconfig
+@@ -585,7 +585,7 @@ config VIDEO_MESON_G12A_AO_CEC
+
+ config CEC_GPIO
+ tristate "Generic GPIO-based CEC driver"
+- depends on PREEMPT || COMPILE_TEST
++ depends on PREEMPTION || COMPILE_TEST
+ select CEC_CORE
+ select CEC_PIN
+ select GPIOLIB
+--- a/drivers/video/backlight/Kconfig
++++ b/drivers/video/backlight/Kconfig
+@@ -99,7 +99,7 @@ config LCD_TOSA
+
+ config LCD_HP700
+ tristate "HP Jornada 700 series LCD Driver"
+- depends on SA1100_JORNADA720_SSP && !PREEMPT
++ depends on SA1100_JORNADA720_SSP && !PREEMPTION
+ default y
+ help
+ If you have an HP Jornada 700 series handheld (710/720/728)
+@@ -228,7 +228,7 @@ config BACKLIGHT_HP680
+
+ config BACKLIGHT_HP700
+ tristate "HP Jornada 700 series Backlight Driver"
+- depends on SA1100_JORNADA720_SSP && !PREEMPT
++ depends on SA1100_JORNADA720_SSP && !PREEMPTION
+ default y
+ help
+ If you have an HP Jornada 700 series,
+--- a/drivers/xen/preempt.c
++++ b/drivers/xen/preempt.c
+@@ -8,7 +8,7 @@
+ #include <linux/sched.h>
+ #include <xen/xen-ops.h>
+
+-#ifndef CONFIG_PREEMPT
++#ifndef CONFIG_PREEMPTION
+
+ /*
+ * Some hypercalls issued by the toolstack can take many 10s of
+@@ -37,4 +37,4 @@ asmlinkage __visible void xen_maybe_pree
+ __this_cpu_write(xen_in_preemptible_hcall, true);
+ }
+ }
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+--- a/fs/btrfs/volumes.h
++++ b/fs/btrfs/volumes.h
+@@ -179,7 +179,7 @@ btrfs_device_set_##name(struct btrfs_dev
+ write_seqcount_end(&dev->data_seqcount); \
+ preempt_enable(); \
+ }
+-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
++#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
+ #define BTRFS_DEVICE_GETSET_FUNCS(name) \
+ static inline u64 \
+ btrfs_device_get_##name(const struct btrfs_device *dev) \
+--- a/fs/stack.c
++++ b/fs/stack.c
+@@ -23,7 +23,7 @@ void fsstack_copy_inode_size(struct inod
+
+ /*
+ * But on 32-bit, we ought to make an effort to keep the two halves of
+- * i_blocks in sync despite SMP or PREEMPT - though stat's
++ * i_blocks in sync despite SMP or PREEMPTION - though stat's
+ * generic_fillattr() doesn't bother, and we won't be applying quotas
+ * (where i_blocks does become important) at the upper level.
+ *
+@@ -38,14 +38,14 @@ void fsstack_copy_inode_size(struct inod
+ spin_unlock(&src->i_lock);
+
+ /*
+- * If CONFIG_SMP or CONFIG_PREEMPT on 32-bit, it's vital for
++ * If CONFIG_SMP or CONFIG_PREEMPTION on 32-bit, it's vital for
+ * fsstack_copy_inode_size() to hold some lock around
+ * i_size_write(), otherwise i_size_read() may spin forever (see
+ * include/linux/fs.h). We don't necessarily hold i_mutex when this
+ * is called, so take i_lock for that case.
+ *
+ * And if on 32-bit, continue our effort to keep the two halves of
+- * i_blocks in sync despite SMP or PREEMPT: use i_lock for that case
++ * i_blocks in sync despite SMP or PREEMPTION: use i_lock for that case
+ * too, and do both at once by combining the tests.
+ *
+ * There is none of this locking overhead in the 64-bit case.
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -855,7 +855,7 @@ static inline loff_t i_size_read(const s
+ i_size = inode->i_size;
+ } while (read_seqcount_retry(&inode->i_size_seqcount, seq));
+ return i_size;
+-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
++#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
+ loff_t i_size;
+
+ preempt_disable();
+@@ -880,7 +880,7 @@ static inline void i_size_write(struct i
+ inode->i_size = i_size;
+ write_seqcount_end(&inode->i_size_seqcount);
+ preempt_enable();
+-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
++#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
+ preempt_disable();
+ inode->i_size = i_size;
+ preempt_enable();
+--- a/include/linux/genhd.h
++++ b/include/linux/genhd.h
+@@ -717,7 +717,7 @@ static inline void hd_free_part(struct h
+ * accessor function.
+ *
+ * Code written along the lines of i_size_read() and i_size_write().
+- * CONFIG_PREEMPT case optimizes the case of UP kernel with preemption
++ * CONFIG_PREEMPTION case optimizes the case of UP kernel with preemption
+ * on.
+ */
+ static inline sector_t part_nr_sects_read(struct hd_struct *part)
+@@ -730,7 +730,7 @@ static inline sector_t part_nr_sects_rea
+ nr_sects = part->nr_sects;
+ } while (read_seqcount_retry(&part->nr_sects_seq, seq));
+ return nr_sects;
+-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
++#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
+ sector_t nr_sects;
+
+ preempt_disable();
+@@ -753,7 +753,7 @@ static inline void part_nr_sects_write(s
+ write_seqcount_begin(&part->nr_sects_seq);
+ part->nr_sects = size;
+ write_seqcount_end(&part->nr_sects_seq);
+-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
++#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
+ preempt_disable();
+ part->nr_sects = size;
+ preempt_enable();
+--- a/include/linux/rcupdate.h
++++ b/include/linux/rcupdate.h
+@@ -154,7 +154,7 @@ static inline void exit_tasks_rcu_finish
+ *
+ * This macro resembles cond_resched(), except that it is defined to
+ * report potential quiescent states to RCU-tasks even if the cond_resched()
+- * machinery were to be shut off, as some advocate for PREEMPT kernels.
++ * machinery were to be shut off, as some advocate for PREEMPTION kernels.
+ */
+ #define cond_resched_tasks_rcu_qs() \
+ do { \
+@@ -580,7 +580,7 @@ do { \
+ *
+ * You can avoid reading and understanding the next paragraph by
+ * following this rule: don't put anything in an rcu_read_lock() RCU
+- * read-side critical section that would block in a !PREEMPT kernel.
++ * read-side critical section that would block in a !PREEMPTION kernel.
+ * But if you want the full story, read on!
+ *
+ * In non-preemptible RCU implementations (TREE_RCU and TINY_RCU),
+--- a/include/xen/xen-ops.h
++++ b/include/xen/xen-ops.h
+@@ -215,7 +215,7 @@ bool xen_running_on_version_or_later(uns
+ void xen_efi_runtime_setup(void);
+
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+
+ static inline void xen_preemptible_hcall_begin(void)
+ {
+@@ -239,6 +239,6 @@ static inline void xen_preemptible_hcall
+ __this_cpu_write(xen_in_preemptible_hcall, false);
+ }
+
+-#endif /* CONFIG_PREEMPT */
++#endif /* CONFIG_PREEMPTION */
+
+ #endif /* INCLUDE_XEN_OPS_H */
+--- a/kernel/Kconfig.locks
++++ b/kernel/Kconfig.locks
+@@ -101,7 +101,7 @@ config UNINLINE_SPIN_UNLOCK
+ # unlock and unlock_irq functions are inlined when:
+ # - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
+ # or
+-# - DEBUG_SPINLOCK=n and PREEMPT=n
++# - DEBUG_SPINLOCK=n and PREEMPTION=n
+ #
+ # unlock_bh and unlock_irqrestore functions are inlined when:
+ # - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
+@@ -139,7 +139,7 @@ config INLINE_SPIN_UNLOCK_BH
+
+ config INLINE_SPIN_UNLOCK_IRQ
+ def_bool y
+- depends on !PREEMPT || ARCH_INLINE_SPIN_UNLOCK_IRQ
++ depends on !PREEMPTION || ARCH_INLINE_SPIN_UNLOCK_IRQ
+
+ config INLINE_SPIN_UNLOCK_IRQRESTORE
+ def_bool y
+@@ -168,7 +168,7 @@ config INLINE_READ_LOCK_IRQSAVE
+
+ config INLINE_READ_UNLOCK
+ def_bool y
+- depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK
++ depends on !PREEMPTION || ARCH_INLINE_READ_UNLOCK
+
+ config INLINE_READ_UNLOCK_BH
+ def_bool y
+@@ -176,7 +176,7 @@ config INLINE_READ_UNLOCK_BH
+
+ config INLINE_READ_UNLOCK_IRQ
+ def_bool y
+- depends on !PREEMPT || ARCH_INLINE_READ_UNLOCK_IRQ
++ depends on !PREEMPTION || ARCH_INLINE_READ_UNLOCK_IRQ
+
+ config INLINE_READ_UNLOCK_IRQRESTORE
+ def_bool y
+@@ -205,7 +205,7 @@ config INLINE_WRITE_LOCK_IRQSAVE
+
+ config INLINE_WRITE_UNLOCK
+ def_bool y
+- depends on !PREEMPT || ARCH_INLINE_WRITE_UNLOCK
++ depends on !PREEMPTION || ARCH_INLINE_WRITE_UNLOCK
+
+ config INLINE_WRITE_UNLOCK_BH
+ def_bool y
+@@ -213,7 +213,7 @@ config INLINE_WRITE_UNLOCK_BH
+
+ config INLINE_WRITE_UNLOCK_IRQ
+ def_bool y
+- depends on !PREEMPT || ARCH_INLINE_WRITE_UNLOCK_IRQ
++ depends on !PREEMPTION || ARCH_INLINE_WRITE_UNLOCK_IRQ
+
+ config INLINE_WRITE_UNLOCK_IRQRESTORE
+ def_bool y
+--- a/kernel/rcu/Kconfig
++++ b/kernel/rcu/Kconfig
+@@ -200,8 +200,8 @@ config RCU_NOCB_CPU
+ specified at boot time by the rcu_nocbs parameter. For each
+ such CPU, a kthread ("rcuox/N") will be created to invoke
+ callbacks, where the "N" is the CPU being offloaded, and where
+- the "p" for RCU-preempt (PREEMPT kernels) and "s" for RCU-sched
+- (!PREEMPT kernels). Nothing prevents this kthread from running
++ the "p" for RCU-preempt (PREEMPTION kernels) and "s" for RCU-sched
++ (!PREEMPTION kernels). Nothing prevents this kthread from running
+ on the specified CPUs, but (1) the kthreads may be preempted
+ between each callback, and (2) affinity or cgroups can be used
+ to force the kthreads to run on whatever set of CPUs is desired.
+--- a/kernel/rcu/rcutorture.c
++++ b/kernel/rcu/rcutorture.c
+@@ -1725,7 +1725,7 @@ static void rcu_torture_fwd_cb_cr(struct
+ // Give the scheduler a chance, even on nohz_full CPUs.
+ static void rcu_torture_fwd_prog_cond_resched(unsigned long iter)
+ {
+- if (IS_ENABLED(CONFIG_PREEMPT) && IS_ENABLED(CONFIG_NO_HZ_FULL)) {
++ if (IS_ENABLED(CONFIG_PREEMPTION) && IS_ENABLED(CONFIG_NO_HZ_FULL)) {
+ // Real call_rcu() floods hit userspace, so emulate that.
+ if (need_resched() || (iter & 0xfff))
+ schedule();
+--- a/kernel/rcu/srcutiny.c
++++ b/kernel/rcu/srcutiny.c
+@@ -103,7 +103,7 @@ EXPORT_SYMBOL_GPL(__srcu_read_unlock);
+
+ /*
+ * Workqueue handler to drive one grace period and invoke any callbacks
+- * that become ready as a result. Single-CPU and !PREEMPT operation
++ * that become ready as a result. Single-CPU and !PREEMPTION operation
+ * means that we get away with murder on synchronization. ;-)
+ */
+ void srcu_drive_gp(struct work_struct *wp)
+--- a/kernel/rcu/tree.c
++++ b/kernel/rcu/tree.c
+@@ -2667,9 +2667,9 @@ EXPORT_SYMBOL_GPL(kfree_call_rcu);
+
+ /*
+ * During early boot, any blocking grace-period wait automatically
+- * implies a grace period. Later on, this is never the case for PREEMPT.
++ * implies a grace period. Later on, this is never the case for PREEMPTION.
+ *
+- * Howevr, because a context switch is a grace period for !PREEMPT, any
++ * Howevr, because a context switch is a grace period for !PREEMPTION, any
+ * blocking grace-period wait automatically implies a grace period if
+ * there is only one CPU online at any point time during execution of
+ * either synchronize_rcu() or synchronize_rcu_expedited(). It is OK to
+--- a/kernel/rcu/tree_exp.h
++++ b/kernel/rcu/tree_exp.h
+@@ -670,7 +670,7 @@ static void rcu_exp_handler(void *unused
+ }
+ }
+
+-/* PREEMPT=y, so no PREEMPT=n expedited grace period to clean up after. */
++/* PREEMPTION=y, so no PREEMPTION=n expedited grace period to clean up after. */
+ static void sync_sched_exp_online_cleanup(int cpu)
+ {
+ }
+--- a/kernel/rcu/tree_plugin.h
++++ b/kernel/rcu/tree_plugin.h
+@@ -788,7 +788,7 @@ static void __init rcu_bootup_announce(v
+ }
+
+ /*
+- * Note a quiescent state for PREEMPT=n. Because we do not need to know
++ * Note a quiescent state for PREEMPTION=n. Because we do not need to know
+ * how many quiescent states passed, just if there was at least one since
+ * the start of the grace period, this just sets a flag. The caller must
+ * have disabled preemption.
+@@ -838,7 +838,7 @@ void rcu_all_qs(void)
+ EXPORT_SYMBOL_GPL(rcu_all_qs);
+
+ /*
+- * Note a PREEMPT=n context switch. The caller must have disabled interrupts.
++ * Note a PREEMPTION=n context switch. The caller must have disabled interrupts.
+ */
+ void rcu_note_context_switch(bool preempt)
+ {
+--- a/kernel/trace/trace.c
++++ b/kernel/trace/trace.c
+@@ -3654,6 +3654,8 @@ print_trace_header(struct seq_file *m, s
+ "desktop",
+ #elif defined(CONFIG_PREEMPT)
+ "preempt",
++#elif defined(CONFIG_PREEMPT_RT)
++ "preempt_rt",
+ #else
+ "unknown",
+ #endif
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -2279,7 +2279,7 @@ static void process_one_work(struct work
+ }
+
+ /*
+- * The following prevents a kworker from hogging CPU on !PREEMPT
++ * The following prevents a kworker from hogging CPU on !PREEMPTION
+ * kernels, where a requeueing work item waiting for something to
+ * happen could deadlock with stop_machine as such work item could
+ * indefinitely requeue itself while all other CPUs are trapped in
+--- a/lib/Kconfig.debug
++++ b/lib/Kconfig.debug
+@@ -1070,7 +1070,7 @@ config DEBUG_TIMEKEEPING
+
+ config DEBUG_PREEMPT
+ bool "Debug preemptible kernel"
+- depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT
++ depends on DEBUG_KERNEL && PREEMPTION && TRACE_IRQFLAGS_SUPPORT
+ default y
+ help
+ If you say Y here then the kernel will use a debug variant of the
+--- a/mm/memory.c
++++ b/mm/memory.c
+@@ -2133,7 +2133,7 @@ static inline int pte_unmap_same(struct
+ pte_t *page_table, pte_t orig_pte)
+ {
+ int same = 1;
+-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)
++#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPTION)
+ if (sizeof(pte_t) > sizeof(unsigned long)) {
+ spinlock_t *ptl = pte_lockptr(mm, pmd);
+ spin_lock(ptl);
+--- a/mm/slub.c
++++ b/mm/slub.c
+@@ -1963,7 +1963,7 @@ static void *get_partial(struct kmem_cac
+ return get_any_partial(s, flags, c);
+ }
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ /*
+ * Calculate the next globally unique transaction for disambiguiation
+ * during cmpxchg. The transactions start with the cpu number and are then
+@@ -2008,7 +2008,7 @@ static inline void note_cmpxchg_failure(
+
+ pr_info("%s %s: cmpxchg redo ", n, s->name);
+
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ if (tid_to_cpu(tid) != tid_to_cpu(actual_tid))
+ pr_warn("due to cpu change %d -> %d\n",
+ tid_to_cpu(tid), tid_to_cpu(actual_tid));
+@@ -2636,7 +2636,7 @@ static void *__slab_alloc(struct kmem_ca
+ unsigned long flags;
+
+ local_irq_save(flags);
+-#ifdef CONFIG_PREEMPT
++#ifdef CONFIG_PREEMPTION
+ /*
+ * We may have been preempted and rescheduled on a different
+ * cpu before disabling interrupts. Need to reload cpu area
+@@ -2690,13 +2690,13 @@ static __always_inline void *slab_alloc_
+ * as we end up on the original cpu again when doing the cmpxchg.
+ *
+ * We should guarantee that tid and kmem_cache are retrieved on
+- * the same cpu. It could be different if CONFIG_PREEMPT so we need
++ * the same cpu. It could be different if CONFIG_PREEMPTION so we need
+ * to check if it is matched or not.
+ */
+ do {
+ tid = this_cpu_read(s->cpu_slab->tid);
+ c = raw_cpu_ptr(s->cpu_slab);
+- } while (IS_ENABLED(CONFIG_PREEMPT) &&
++ } while (IS_ENABLED(CONFIG_PREEMPTION) &&
+ unlikely(tid != READ_ONCE(c->tid)));
+
+ /*
+@@ -2970,7 +2970,7 @@ static __always_inline void do_slab_free
+ do {
+ tid = this_cpu_read(s->cpu_slab->tid);
+ c = raw_cpu_ptr(s->cpu_slab);
+- } while (IS_ENABLED(CONFIG_PREEMPT) &&
++ } while (IS_ENABLED(CONFIG_PREEMPTION) &&
+ unlikely(tid != READ_ONCE(c->tid)));
+
+ /* Same with comment on barrier() in slab_alloc_node() */
+--- a/net/core/dev.c
++++ b/net/core/dev.c
+@@ -820,7 +820,7 @@ EXPORT_SYMBOL(dev_get_by_napi_id);
+ *
+ * The use of raw_seqcount_begin() and cond_resched() before
+ * retrying is required as we want to give the writers a chance
+- * to complete when CONFIG_PREEMPT is not set.
++ * to complete when CONFIG_PREEMPTION is not set.
+ */
+ int netdev_get_name(struct net *net, char *name, int ifindex)
+ {
diff --git a/debian/patches-rt/add_migrate_disable.patch b/debian/patches-rt/add_migrate_disable.patch
index 6f618be9c88c..0020fc176a5e 100644
--- a/debian/patches-rt/add_migrate_disable.patch
+++ b/debian/patches-rt/add_migrate_disable.patch
@@ -1,43 +1,67 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat, 27 May 2017 19:02:06 +0200
Subject: kernel/sched/core: add migrate_disable()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+[bristot@redhat.com: rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration
+ Link: https://lkml.kernel.org/r/e981d271cbeca975bca710e2fbcc6078c09741b0.1498482127.git.bristot@redhat.com
+]
+[swood@redhat.com: fixups and optimisations
+ Link:https://lkml.kernel.org/r/20190727055638.20443-1-swood@redhat.com
+ Link:https://lkml.kernel.org/r/20191012065214.28109-1-swood@redhat.com
+]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- include/linux/preempt.h | 23 ++++++++
- include/linux/sched.h | 7 ++
- include/linux/smp.h | 3 +
- kernel/sched/core.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++-
- kernel/sched/debug.c | 4 +
- 5 files changed, 164 insertions(+), 2 deletions(-)
+ include/linux/preempt.h | 32 +++++++
+ include/linux/sched.h | 35 ++++++++
+ include/linux/smp.h | 3
+ init/init_task.c | 4
+ kernel/cpu.c | 42 ++++++++++
+ kernel/locking/rtmutex.c | 12 ++
+ kernel/locking/rwlock-rt.c | 18 +++-
+ kernel/rcu/tree_plugin.h | 6 +
+ kernel/sched/core.c | 181 ++++++++++++++++++++++++++++++++++++++++++++-
+ kernel/sched/debug.c | 4
+ kernel/sched/sched.h | 4
+ lib/smp_processor_id.c | 5 +
+ 12 files changed, 336 insertions(+), 10 deletions(-)
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
-@@ -191,6 +191,22 @@ do { \
+@@ -201,6 +201,31 @@ do { \
#define preemptible() (preempt_count() == 0 && !irqs_disabled())
-+#ifdef CONFIG_SMP
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
+
+extern void migrate_disable(void);
+extern void migrate_enable(void);
+
+int __migrate_disabled(struct task_struct *p);
+
++#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
++
++extern void migrate_disable(void);
++extern void migrate_enable(void);
++static inline int __migrate_disabled(struct task_struct *p)
++{
++ return 0;
++}
++
+#else
-+#define migrate_disable() barrier()
-+#define migrate_enable() barrier()
++#define migrate_disable() preempt_disable()
++#define migrate_enable() preempt_enable()
+static inline int __migrate_disabled(struct task_struct *p)
+{
+ return 0;
+}
+#endif
+
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
#define preempt_enable() \
do { \
-@@ -259,6 +275,13 @@ do { \
- #define preempt_enable_notrace() barrier()
+@@ -270,6 +295,13 @@ do { \
+ #define preempt_check_resched_rt() barrier()
#define preemptible() 0
+#define migrate_disable() barrier()
@@ -52,140 +76,455 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.
#ifdef MODULE
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -653,6 +653,13 @@ struct task_struct {
+@@ -233,6 +233,8 @@ extern void io_schedule_finish(int token
+ extern long io_schedule_timeout(long timeout);
+ extern void io_schedule(void);
+
++int cpu_nr_pinned(int cpu);
++
+ /**
+ * struct prev_cputime - snapshot of system and user cputime
+ * @utime: time spent in user mode
+@@ -705,6 +707,20 @@ struct task_struct {
int nr_cpus_allowed;
const cpumask_t *cpus_ptr;
cpumask_t cpus_mask;
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
+ int migrate_disable;
-+ int migrate_disable_update;
++ bool migrate_disable_scheduled;
+# ifdef CONFIG_SCHED_DEBUG
-+ int migrate_disable_atomic;
++ int pinned_on_cpu;
++# endif
++#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
++# ifdef CONFIG_SCHED_DEBUG
++ int migrate_disable;
+# endif
+#endif
++#ifdef CONFIG_PREEMPT_RT
++ int sleeping_lock;
++#endif
#ifdef CONFIG_PREEMPT_RCU
int rcu_read_lock_nesting;
+@@ -1865,6 +1881,23 @@ static __always_inline bool need_resched
+ return unlikely(tif_need_resched());
+ }
+
++#ifdef CONFIG_PREEMPT_RT
++static inline void sleeping_lock_inc(void)
++{
++ current->sleeping_lock++;
++}
++
++static inline void sleeping_lock_dec(void)
++{
++ current->sleeping_lock--;
++}
++
++#else
++
++static inline void sleeping_lock_inc(void) { }
++static inline void sleeping_lock_dec(void) { }
++#endif
++
+ /*
+ * Wrappers for p->thread_info->cpu access. No-op on UP.
+ */
+@@ -2056,4 +2089,6 @@ int sched_trace_rq_cpu(struct rq *rq);
+
+ const struct cpumask *sched_trace_rd_span(struct root_domain *rd);
+
++extern struct task_struct *takedown_cpu_task;
++
+ #endif
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
-@@ -206,6 +206,9 @@ static inline int get_boot_cpu_id(void)
- #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
+@@ -222,6 +222,9 @@ static inline int get_boot_cpu_id(void)
+ #define get_cpu() ({ preempt_disable(); __smp_processor_id(); })
#define put_cpu() preempt_enable()
-+#define get_cpu_light() ({ migrate_disable(); smp_processor_id(); })
++#define get_cpu_light() ({ migrate_disable(); __smp_processor_id(); })
+#define put_cpu_light() migrate_enable()
+
/*
* Callback to arch code if there's nosmp or maxcpus=0 on the
* boot command line:
+--- a/init/init_task.c
++++ b/init/init_task.c
+@@ -73,6 +73,10 @@ struct task_struct init_task
+ .cpus_ptr = &init_task.cpus_mask,
+ .cpus_mask = CPU_MASK_ALL,
+ .nr_cpus_allowed= NR_CPUS,
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT) && \
++ defined(CONFIG_SCHED_DEBUG)
++ .pinned_on_cpu = -1,
++#endif
+ .mm = NULL,
+ .active_mm = &init_mm,
+ .restart_block = {
+--- a/kernel/cpu.c
++++ b/kernel/cpu.c
+@@ -849,6 +849,15 @@ static int take_cpu_down(void *_param)
+ int err, cpu = smp_processor_id();
+ int ret;
+
++#ifdef CONFIG_PREEMPT_RT
++ /*
++ * If any tasks disabled migration before we got here,
++ * go back and sleep again.
++ */
++ if (cpu_nr_pinned(cpu))
++ return -EAGAIN;
++#endif
++
+ /* Ensure this CPU doesn't handle any more interrupts. */
+ err = __cpu_disable();
+ if (err < 0)
+@@ -878,6 +887,8 @@ static int take_cpu_down(void *_param)
+ return 0;
+ }
+
++struct task_struct *takedown_cpu_task;
++
+ static int takedown_cpu(unsigned int cpu)
+ {
+ struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
+@@ -892,11 +903,39 @@ static int takedown_cpu(unsigned int cpu
+ */
+ irq_lock_sparse();
+
++#ifdef CONFIG_PREEMPT_RT
++ WARN_ON_ONCE(takedown_cpu_task);
++ takedown_cpu_task = current;
++
++again:
++ /*
++ * If a task pins this CPU after we pass this check, take_cpu_down
++ * will return -EAGAIN.
++ */
++ for (;;) {
++ int nr_pinned;
++
++ set_current_state(TASK_UNINTERRUPTIBLE);
++ nr_pinned = cpu_nr_pinned(cpu);
++ if (nr_pinned == 0)
++ break;
++ schedule();
++ }
++ set_current_state(TASK_RUNNING);
++#endif
++
+ /*
+ * So now all preempt/rcu users must observe !cpu_active().
+ */
+ err = stop_machine_cpuslocked(take_cpu_down, NULL, cpumask_of(cpu));
++#ifdef CONFIG_PREEMPT_RT
++ if (err == -EAGAIN)
++ goto again;
++#endif
+ if (err) {
++#ifdef CONFIG_PREEMPT_RT
++ takedown_cpu_task = NULL;
++#endif
+ /* CPU refused to die */
+ irq_unlock_sparse();
+ /* Unpark the hotplug thread so we can rollback there */
+@@ -915,6 +954,9 @@ static int takedown_cpu(unsigned int cpu
+ wait_for_ap_thread(st, false);
+ BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
+
++#ifdef CONFIG_PREEMPT_RT
++ takedown_cpu_task = NULL;
++#endif
+ /* Interrupts are moved away from the dying cpu, reenable alloc/free */
+ irq_unlock_sparse();
+
+--- a/kernel/locking/rtmutex.c
++++ b/kernel/locking/rtmutex.c
+@@ -1140,6 +1140,7 @@ void __sched rt_spin_lock_slowunlock(str
+
+ void __lockfunc rt_spin_lock(spinlock_t *lock)
+ {
++ sleeping_lock_inc();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+ rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
+@@ -1154,6 +1155,7 @@ void __lockfunc __rt_spin_lock(struct rt
+ #ifdef CONFIG_DEBUG_LOCK_ALLOC
+ void __lockfunc rt_spin_lock_nested(spinlock_t *lock, int subclass)
+ {
++ sleeping_lock_inc();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
+ rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
+@@ -1167,6 +1169,7 @@ void __lockfunc rt_spin_unlock(spinlock_
+ spin_release(&lock->dep_map, 1, _RET_IP_);
+ rt_spin_lock_fastunlock(&lock->lock, rt_spin_lock_slowunlock);
+ migrate_enable();
++ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_spin_unlock);
+
+@@ -1192,12 +1195,15 @@ int __lockfunc rt_spin_trylock(spinlock_
+ {
+ int ret;
+
++ sleeping_lock_inc();
+ migrate_disable();
+ ret = __rt_mutex_trylock(&lock->lock);
+- if (ret)
++ if (ret) {
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+- else
++ } else {
+ migrate_enable();
++ sleeping_lock_dec();
++ }
+ return ret;
+ }
+ EXPORT_SYMBOL(rt_spin_trylock);
+@@ -1209,6 +1215,7 @@ int __lockfunc rt_spin_trylock_bh(spinlo
+ local_bh_disable();
+ ret = __rt_mutex_trylock(&lock->lock);
+ if (ret) {
++ sleeping_lock_inc();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+ } else
+@@ -1224,6 +1231,7 @@ int __lockfunc rt_spin_trylock_irqsave(s
+ *flags = 0;
+ ret = __rt_mutex_trylock(&lock->lock);
+ if (ret) {
++ sleeping_lock_inc();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+ }
+--- a/kernel/locking/rwlock-rt.c
++++ b/kernel/locking/rwlock-rt.c
+@@ -305,12 +305,15 @@ int __lockfunc rt_read_trylock(rwlock_t
+ {
+ int ret;
+
++ sleeping_lock_inc();
+ migrate_disable();
+ ret = do_read_rt_trylock(rwlock);
+- if (ret)
++ if (ret) {
+ rwlock_acquire_read(&rwlock->dep_map, 0, 1, _RET_IP_);
+- else
++ } else {
+ migrate_enable();
++ sleeping_lock_dec();
++ }
+ return ret;
+ }
+ EXPORT_SYMBOL(rt_read_trylock);
+@@ -319,18 +322,22 @@ int __lockfunc rt_write_trylock(rwlock_t
+ {
+ int ret;
+
++ sleeping_lock_inc();
+ migrate_disable();
+ ret = do_write_rt_trylock(rwlock);
+- if (ret)
++ if (ret) {
+ rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_);
+- else
++ } else {
+ migrate_enable();
++ sleeping_lock_dec();
++ }
+ return ret;
+ }
+ EXPORT_SYMBOL(rt_write_trylock);
+
+ void __lockfunc rt_read_lock(rwlock_t *rwlock)
+ {
++ sleeping_lock_inc();
+ migrate_disable();
+ rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_);
+ do_read_rt_lock(rwlock);
+@@ -339,6 +346,7 @@ EXPORT_SYMBOL(rt_read_lock);
+
+ void __lockfunc rt_write_lock(rwlock_t *rwlock)
+ {
++ sleeping_lock_inc();
+ migrate_disable();
+ rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_);
+ do_write_rt_lock(rwlock);
+@@ -350,6 +358,7 @@ void __lockfunc rt_read_unlock(rwlock_t
+ rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
+ do_read_rt_unlock(rwlock);
+ migrate_enable();
++ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_read_unlock);
+
+@@ -358,6 +367,7 @@ void __lockfunc rt_write_unlock(rwlock_t
+ rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
+ do_write_rt_unlock(rwlock);
+ migrate_enable();
++ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_write_unlock);
+
+--- a/kernel/rcu/tree_plugin.h
++++ b/kernel/rcu/tree_plugin.h
+@@ -287,10 +287,14 @@ void rcu_note_context_switch(bool preemp
+ struct task_struct *t = current;
+ struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
+ struct rcu_node *rnp;
++ int sleeping_l = 0;
+
+ trace_rcu_utilization(TPS("Start context switch"));
+ lockdep_assert_irqs_disabled();
+- WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0);
++#if defined(CONFIG_PREEMPT_RT)
++ sleeping_l = t->sleeping_lock;
++#endif
++ WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0 && !sleeping_l);
+ if (t->rcu_read_lock_nesting > 0 &&
+ !t->rcu_read_unlock_special.b.blocked) {
+
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -1060,7 +1060,15 @@ void set_cpus_allowed_common(struct task
- p->nr_cpus_allowed = cpumask_weight(new_mask);
+@@ -1487,7 +1487,7 @@ static inline bool is_cpu_allowed(struct
+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
+ return false;
+
+- if (is_per_cpu_kthread(p))
++ if (is_per_cpu_kthread(p) || __migrate_disabled(p))
+ return cpu_online(cpu);
+
+ return cpu_active(cpu);
+@@ -1611,9 +1611,18 @@ static int migration_cpu_stop(void *data
+ void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask)
+ {
+ cpumask_copy(&p->cpus_mask, new_mask);
+- p->nr_cpus_allowed = cpumask_weight(new_mask);
++ if (p->cpus_ptr == &p->cpus_mask)
++ p->nr_cpus_allowed = cpumask_weight(new_mask);
}
--void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
+int __migrate_disabled(struct task_struct *p)
+{
+ return p->migrate_disable;
+}
++EXPORT_SYMBOL_GPL(__migrate_disabled);
+#endif
+
-+static void __do_set_cpus_allowed_tail(struct task_struct *p,
-+ const struct cpumask *new_mask)
+ void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
{
struct rq *rq = task_rq(p);
- bool queued, running;
-@@ -1089,6 +1097,20 @@ void do_set_cpus_allowed(struct task_str
- set_curr_task(rq, p);
- }
-
-+void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
-+{
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+ if (__migrate_disabled(p)) {
-+ lockdep_assert_held(&p->pi_lock);
-+
-+ cpumask_copy(&p->cpus_mask, new_mask);
-+ p->migrate_disable_update = 1;
-+ return;
-+ }
-+#endif
-+ __do_set_cpus_allowed_tail(p, new_mask);
-+}
-+
- /*
- * Change a given task's CPU affinity. Migrate the thread to a
- * proper CPU and schedule it away if the CPU it's executing on
-@@ -1147,9 +1169,16 @@ static int __set_cpus_allowed_ptr(struct
+@@ -1702,7 +1711,8 @@ static int __set_cpus_allowed_ptr(struct
}
/* Can the task run on the task's current CPU? If so, we're done */
- if (cpumask_test_cpu(task_cpu(p), new_mask))
-+ if (cpumask_test_cpu(task_cpu(p), new_mask) || __migrate_disabled(p))
++ if (cpumask_test_cpu(task_cpu(p), new_mask) ||
++ p->cpus_ptr != &p->cpus_mask)
goto out;
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+ if (__migrate_disabled(p)) {
-+ p->migrate_disable_update = 1;
-+ goto out;
-+ }
-+#endif
-+
- dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
if (task_running(rq, p) || p->state == TASK_WAKING) {
- struct migration_arg arg = { p, dest_cpu };
-@@ -7086,3 +7115,99 @@ const u32 sched_prio_to_wmult[40] = {
+@@ -4027,6 +4037,8 @@ pick_next_task(struct rq *rq, struct tas
+ BUG();
+ }
+
++static void migrate_disabled_sched(struct task_struct *p);
++
+ /*
+ * __schedule() is the main scheduler function.
+ *
+@@ -4097,6 +4109,9 @@ static void __sched notrace __schedule(b
+ rq_lock(rq, &rf);
+ smp_mb__after_spinlock();
+
++ if (__migrate_disabled(prev))
++ migrate_disabled_sched(prev);
++
+ /* Promote REQ to ACT */
+ rq->clock_update_flags <<= 1;
+ update_rq_clock(rq);
+@@ -6339,6 +6354,7 @@ static void migrate_tasks(struct rq *dea
+ break;
+
+ next = __pick_migrate_task(rq);
++ WARN_ON_ONCE(__migrate_disabled(next));
+
+ /*
+ * Rules for changing task_struct::cpus_mask are holding
+@@ -8028,3 +8044,162 @@ const u32 sched_prio_to_wmult[40] = {
};
#undef CREATE_TRACE_POINTS
+
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
+
-+void migrate_disable(void)
++static inline void
++update_nr_migratory(struct task_struct *p, long delta)
+{
-+ struct task_struct *p = current;
-+
-+ if (in_atomic() || irqs_disabled()) {
-+#ifdef CONFIG_SCHED_DEBUG
-+ p->migrate_disable_atomic++;
-+#endif
-+ return;
++ if (unlikely((p->sched_class == &rt_sched_class ||
++ p->sched_class == &dl_sched_class) &&
++ p->nr_cpus_allowed > 1)) {
++ if (p->sched_class == &rt_sched_class)
++ task_rq(p)->rt.rt_nr_migratory += delta;
++ else
++ task_rq(p)->dl.dl_nr_migratory += delta;
+ }
-+#ifdef CONFIG_SCHED_DEBUG
-+ WARN_ON_ONCE(p->migrate_disable_atomic);
-+#endif
-+
-+ if (p->migrate_disable) {
-+ p->migrate_disable++;
-+ return;
-+ }
-+
-+ preempt_disable();
-+ p->migrate_disable = 1;
++}
+
++static inline void
++migrate_disable_update_cpus_allowed(struct task_struct *p)
++{
+ p->cpus_ptr = cpumask_of(smp_processor_id());
++ update_nr_migratory(p, -1);
+ p->nr_cpus_allowed = 1;
++}
+
-+ preempt_enable();
++static inline void
++migrate_enable_update_cpus_allowed(struct task_struct *p)
++{
++ struct rq *rq;
++ struct rq_flags rf;
++
++ rq = task_rq_lock(p, &rf);
++ p->cpus_ptr = &p->cpus_mask;
++ p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
++ update_nr_migratory(p, 1);
++ task_rq_unlock(rq, p, &rf);
+}
-+EXPORT_SYMBOL(migrate_disable);
+
-+void migrate_enable(void)
++void migrate_disable(void)
+{
-+ struct task_struct *p = current;
++ preempt_disable();
+
-+ if (in_atomic() || irqs_disabled()) {
++ if (++current->migrate_disable == 1) {
++ this_rq()->nr_pinned++;
+#ifdef CONFIG_SCHED_DEBUG
-+ p->migrate_disable_atomic--;
++ WARN_ON_ONCE(current->pinned_on_cpu >= 0);
++ current->pinned_on_cpu = smp_processor_id();
+#endif
-+ return;
+ }
+
-+#ifdef CONFIG_SCHED_DEBUG
-+ WARN_ON_ONCE(p->migrate_disable_atomic);
-+#endif
++ preempt_enable();
++}
++EXPORT_SYMBOL(migrate_disable);
++
++static void migrate_disabled_sched(struct task_struct *p)
++{
++ if (p->migrate_disable_scheduled)
++ return;
++
++ migrate_disable_update_cpus_allowed(p);
++ p->migrate_disable_scheduled = 1;
++}
++
++void migrate_enable(void)
++{
++ struct task_struct *p = current;
++ struct rq *rq = this_rq();
++ int cpu = task_cpu(p);
+
+ WARN_ON_ONCE(p->migrate_disable <= 0);
+ if (p->migrate_disable > 1) {
@@ -195,57 +534,126 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.
+
+ preempt_disable();
+
-+ p->cpus_ptr = &p->cpus_mask;
-+ p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
++#ifdef CONFIG_SCHED_DEBUG
++ WARN_ON_ONCE(current->pinned_on_cpu != cpu);
++ current->pinned_on_cpu = -1;
++#endif
++
++ WARN_ON_ONCE(rq->nr_pinned < 1);
++
+ p->migrate_disable = 0;
++ rq->nr_pinned--;
++ if (rq->nr_pinned == 0 && unlikely(!cpu_active(cpu)) &&
++ takedown_cpu_task)
++ wake_up_process(takedown_cpu_task);
++
++ if (!p->migrate_disable_scheduled)
++ goto out;
+
-+ if (p->migrate_disable_update) {
-+ struct rq *rq;
++ p->migrate_disable_scheduled = 0;
++
++ migrate_enable_update_cpus_allowed(p);
++
++ WARN_ON(smp_processor_id() != cpu);
++ if (!is_cpu_allowed(p, cpu)) {
++ struct migration_arg arg = { p };
+ struct rq_flags rf;
+
+ rq = task_rq_lock(p, &rf);
+ update_rq_clock(rq);
-+
-+ __do_set_cpus_allowed_tail(p, &p->cpus_mask);
++ arg.dest_cpu = select_fallback_rq(cpu, p);
+ task_rq_unlock(rq, p, &rf);
+
-+ p->migrate_disable_update = 0;
-+
-+ WARN_ON(smp_processor_id() != task_cpu(p));
-+ if (!cpumask_test_cpu(task_cpu(p), &p->cpus_mask)) {
-+ const struct cpumask *cpu_valid_mask = cpu_active_mask;
-+ struct migration_arg arg;
-+ unsigned int dest_cpu;
-+
-+ if (p->flags & PF_KTHREAD) {
-+ /*
-+ * Kernel threads are allowed on online && !active CPUs
-+ */
-+ cpu_valid_mask = cpu_online_mask;
-+ }
-+ dest_cpu = cpumask_any_and(cpu_valid_mask, &p->cpus_mask);
-+ arg.task = p;
-+ arg.dest_cpu = dest_cpu;
-+
-+ preempt_enable();
-+ stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
-+ return;
-+ }
++ preempt_enable();
++
++ sleeping_lock_inc();
++ stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
++ sleeping_lock_dec();
++ return;
++
+ }
++
++out:
+ preempt_enable();
+}
+EXPORT_SYMBOL(migrate_enable);
++
++int cpu_nr_pinned(int cpu)
++{
++ struct rq *rq = cpu_rq(cpu);
++
++ return rq->nr_pinned;
++}
++
++#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
++static void migrate_disabled_sched(struct task_struct *p)
++{
++}
++
++void migrate_disable(void)
++{
++#ifdef CONFIG_SCHED_DEBUG
++ current->migrate_disable++;
++#endif
++ barrier();
++}
++EXPORT_SYMBOL(migrate_disable);
++
++void migrate_enable(void)
++{
++#ifdef CONFIG_SCHED_DEBUG
++ struct task_struct *p = current;
++
++ WARN_ON_ONCE(p->migrate_disable <= 0);
++ p->migrate_disable--;
++#endif
++ barrier();
++}
++EXPORT_SYMBOL(migrate_enable);
++
++#else
++static void migrate_disabled_sched(struct task_struct *p)
++{
++}
++
+#endif
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
-@@ -979,6 +979,10 @@ void proc_sched_show_task(struct task_st
+@@ -958,6 +958,10 @@ void proc_sched_show_task(struct task_st
P(dl.runtime);
P(dl.deadline);
}
-+#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
++#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT)
+ P(migrate_disable);
+#endif
+ P(nr_cpus_allowed);
#undef PN_SCHEDSTAT
#undef PN
#undef __PN
+--- a/kernel/sched/sched.h
++++ b/kernel/sched/sched.h
+@@ -999,6 +999,10 @@ struct rq {
+ /* Must be inspected within a rcu lock section */
+ struct cpuidle_state *idle_state;
+ #endif
++
++#if defined(CONFIG_PREEMPT_RT) && defined(CONFIG_SMP)
++ int nr_pinned;
++#endif
+ };
+
+ #ifdef CONFIG_FAIR_GROUP_SCHED
+--- a/lib/smp_processor_id.c
++++ b/lib/smp_processor_id.c
+@@ -23,6 +23,11 @@ unsigned int check_preemption_disabled(c
+ * Kernel threads bound to a single CPU can safely use
+ * smp_processor_id():
+ */
++#if defined(CONFIG_PREEMPT_RT) && (defined(CONFIG_SMP) || defined(CONFIG_SCHED_DEBUG))
++ if (current->migrate_disable)
++ goto out;
++#endif
++
+ if (current->nr_cpus_allowed == 1)
+ goto out;
+
diff --git a/debian/patches-rt/apparmor-use-a-locallock-instead-preempt_disable.patch b/debian/patches-rt/apparmor-use-a-locallock-instead-preempt_disable.patch
index 17e306fdb058..53a69f3f5b6d 100644
--- a/debian/patches-rt/apparmor-use-a-locallock-instead-preempt_disable.patch
+++ b/debian/patches-rt/apparmor-use-a-locallock-instead-preempt_disable.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 11 Oct 2017 17:43:49 +0200
Subject: apparmor: use a locallock instead preempt_disable()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
get_buffers() disables preemption which acts as a lock for the per-CPU
variable. Since we can't disable preemption here on RT, a local_lock is
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define for_each_cpu_buffer(I) for ((I) = 0; (I) < MAX_PATH_BUFFERS; (I)++)
-#ifdef CONFIG_DEBUG_PREEMPT
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+static inline void AA_BUG_PREEMPT_ENABLED(const char *s)
+{
+ struct local_irq_lock *lv;
diff --git a/debian/patches-rt/arch-arm64-Add-lazy-preempt-support.patch b/debian/patches-rt/arch-arm64-Add-lazy-preempt-support.patch
index 70a94e1365f7..2b2fee304971 100644
--- a/debian/patches-rt/arch-arm64-Add-lazy-preempt-support.patch
+++ b/debian/patches-rt/arch-arm64-Add-lazy-preempt-support.patch
@@ -1,7 +1,7 @@
From: Anders Roxell <anders.roxell@linaro.org>
Date: Thu, 14 May 2015 17:52:17 +0200
Subject: arch/arm64: Add lazy preempt support
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
arm64 is missing support for PREEMPT_RT. The main feature which is
lacking is support for lazy preemption. The arch-specific entry code,
@@ -13,16 +13,16 @@ indicate that support for full RT preemption is now available.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
arch/arm64/Kconfig | 1 +
- arch/arm64/include/asm/preempt.h | 23 ++++++++++++++++++++++-
+ arch/arm64/include/asm/preempt.h | 25 ++++++++++++++++++++++++-
arch/arm64/include/asm/thread_info.h | 6 +++++-
arch/arm64/kernel/asm-offsets.c | 1 +
- arch/arm64/kernel/entry.S | 12 ++++++++++--
+ arch/arm64/kernel/entry.S | 13 +++++++++++--
arch/arm64/kernel/signal.c | 2 +-
- 6 files changed, 40 insertions(+), 5 deletions(-)
+ 6 files changed, 43 insertions(+), 5 deletions(-)
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
-@@ -152,6 +152,7 @@ config ARM64
+@@ -158,6 +158,7 @@ config ARM64
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
@@ -32,7 +32,7 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
select HAVE_RCU_TABLE_FREE
--- a/arch/arm64/include/asm/preempt.h
+++ b/arch/arm64/include/asm/preempt.h
-@@ -70,13 +70,34 @@ static inline bool __preempt_count_dec_a
+@@ -70,13 +70,36 @@ static inline bool __preempt_count_dec_a
* interrupt occurring between the non-atomic READ_ONCE/WRITE_ONCE
* pair.
*/
@@ -40,6 +40,8 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
+ if (!pc || !READ_ONCE(ti->preempt_count))
+ return true;
+#ifdef CONFIG_PREEMPT_LAZY
++ if ((pc & ~PREEMPT_NEED_RESCHED))
++ return false;
+ if (current_thread_info()->preempt_lazy_count)
+ return false;
+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
@@ -67,10 +69,10 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
+#endif
}
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
-@@ -31,6 +31,7 @@ struct thread_info {
+@@ -29,6 +29,7 @@ struct thread_info {
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
u64 ttbr0; /* saved TTBR0_EL1 */
#endif
@@ -78,15 +80,15 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
union {
u64 preempt_count; /* 0 => preemptible, <0 => bug */
struct {
-@@ -75,6 +76,7 @@ void arch_release_task_struct(struct tas
+@@ -63,6 +64,7 @@ void arch_release_task_struct(struct tas
#define TIF_FOREIGN_FPSTATE 3 /* CPU's FP state is not current's */
#define TIF_UPROBE 4 /* uprobe breakpoint or singlestep */
#define TIF_FSCHECK 5 /* Check FS is USER_DS on return */
+#define TIF_NEED_RESCHED_LAZY 6
#define TIF_NOHZ 7
- #define TIF_SYSCALL_TRACE 8
- #define TIF_SYSCALL_AUDIT 9
-@@ -93,6 +95,7 @@ void arch_release_task_struct(struct tas
+ #define TIF_SYSCALL_TRACE 8 /* syscall trace active */
+ #define TIF_SYSCALL_AUDIT 9 /* syscall auditing */
+@@ -83,6 +85,7 @@ void arch_release_task_struct(struct tas
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_FOREIGN_FPSTATE (1 << TIF_FOREIGN_FPSTATE)
@@ -94,7 +96,7 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
#define _TIF_NOHZ (1 << TIF_NOHZ)
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
-@@ -105,8 +108,9 @@ void arch_release_task_struct(struct tas
+@@ -96,8 +99,9 @@ void arch_release_task_struct(struct tas
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
_TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
@@ -104,7 +106,7 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
+#define _TIF_NEED_RESCHED_MASK (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
_TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
- _TIF_NOHZ)
+ _TIF_NOHZ | _TIF_SYSCALL_EMU)
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -30,6 +30,7 @@ int main(void)
@@ -117,14 +119,15 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
DEFINE(TSK_TI_TTBR0, offsetof(struct task_struct, thread_info.ttbr0));
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
-@@ -679,9 +679,17 @@ alternative_if ARM64_HAS_IRQ_PRIO_MASKIN
+@@ -679,9 +679,18 @@ alternative_if ARM64_HAS_IRQ_PRIO_MASKIN
mrs x0, daif
orr x24, x24, x0
alternative_else_nop_endif
- cbnz x24, 1f // preempt count != 0 || NMI return path
-- bl preempt_schedule_irq // irq en/disable is done inside
+- bl arm64_preempt_schedule_irq // irq en/disable is done inside
+
-+ cbnz x24, 2f // preempt count != 0
++ cbz x24, 1f // (need_resched + count) == 0
++ cbnz w24, 2f // count != 0
+
+ ldr w24, [tsk, #TSK_TI_PREEMPT_LAZY] // get preempt lazy count
+ cbnz w24, 2f // preempt lazy count != 0
@@ -132,7 +135,7 @@ Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
+ ldr x0, [tsk, #TSK_TI_FLAGS] // get flags
+ tbz x0, #TIF_NEED_RESCHED_LAZY, 2f // needs rescheduling?
1:
-+ bl preempt_schedule_irq // irq en/disable is done inside
++ bl arm64_preempt_schedule_irq // irq en/disable is done inside
+2:
#endif
diff --git a/debian/patches-rt/arm-disable-NEON-in-kernel-mode.patch b/debian/patches-rt/arm-disable-NEON-in-kernel-mode.patch
index 56c08e0f982d..4862eff05600 100644
--- a/debian/patches-rt/arm-disable-NEON-in-kernel-mode.patch
+++ b/debian/patches-rt/arm-disable-NEON-in-kernel-mode.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 1 Dec 2017 10:42:03 +0100
Subject: [PATCH] arm*: disable NEON in kernel mode
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
NEON in kernel mode is used by the crypto algorithms and raid6 code.
While the raid6 code looks okay, the crypto algorithms do not: NEON
@@ -20,130 +20,129 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
-@@ -2135,7 +2135,7 @@ config NEON
+@@ -2062,7 +2062,7 @@ config NEON
config KERNEL_MODE_NEON
bool "Support for NEON in kernel mode"
- depends on NEON && AEABI
-+ depends on NEON && AEABI && !PREEMPT_RT_BASE
++ depends on NEON && AEABI && !PREEMPT_RT
help
Say Y to include support for NEON in kernel mode.
--- a/arch/arm64/crypto/Kconfig
+++ b/arch/arm64/crypto/Kconfig
-@@ -19,43 +19,43 @@ config CRYPTO_SHA512_ARM64
+@@ -19,50 +19,50 @@ config CRYPTO_SHA512_ARM64
config CRYPTO_SHA1_ARM64_CE
tristate "SHA-1 digest algorithm (ARMv8 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_SHA1
config CRYPTO_SHA2_ARM64_CE
tristate "SHA-224/SHA-256 digest algorithm (ARMv8 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_SHA256_ARM64
config CRYPTO_SHA512_ARM64_CE
tristate "SHA-384/SHA-512 digest algorithm (ARMv8 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_SHA512_ARM64
config CRYPTO_SHA3_ARM64
tristate "SHA3 digest algorithm (ARMv8.2 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_SHA3
config CRYPTO_SM3_ARM64_CE
tristate "SM3 digest algorithm (ARMv8.2 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_SM3
config CRYPTO_SM4_ARM64_CE
tristate "SM4 symmetric cipher (ARMv8.2 Crypto Extensions)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_ALGAPI
select CRYPTO_SM4
config CRYPTO_GHASH_ARM64_CE
tristate "GHASH/AES-GCM using ARMv8 Crypto Extensions"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_HASH
select CRYPTO_GF128MUL
- select CRYPTO_AES
-@@ -63,7 +63,7 @@ config CRYPTO_GHASH_ARM64_CE
+ select CRYPTO_LIB_AES
config CRYPTO_CRCT10DIF_ARM64_CE
tristate "CRCT10DIF digest algorithm using PMULL instructions"
- depends on KERNEL_MODE_NEON && CRC_T10DIF
-+ depends on KERNEL_MODE_NEON && CRC_T10DIF && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && CRC_T10DIF && !PREEMPT_RT
select CRYPTO_HASH
config CRYPTO_AES_ARM64
-@@ -72,13 +72,13 @@ config CRYPTO_AES_ARM64
+@@ -71,13 +71,13 @@ config CRYPTO_AES_ARM64
config CRYPTO_AES_ARM64_CE
tristate "AES core cipher using ARMv8 Crypto Extensions"
- depends on ARM64 && KERNEL_MODE_NEON
-+ depends on ARM64 && KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on ARM64 && KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_ALGAPI
- select CRYPTO_AES_ARM64
+ select CRYPTO_LIB_AES
config CRYPTO_AES_ARM64_CE_CCM
tristate "AES in CCM mode using ARMv8 Crypto Extensions"
- depends on ARM64 && KERNEL_MODE_NEON
-+ depends on ARM64 && KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on ARM64 && KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_ALGAPI
select CRYPTO_AES_ARM64_CE
- select CRYPTO_AES_ARM64
-@@ -86,7 +86,7 @@ config CRYPTO_AES_ARM64_CE_CCM
+ select CRYPTO_AEAD
+@@ -85,7 +85,7 @@ config CRYPTO_AES_ARM64_CE_CCM
config CRYPTO_AES_ARM64_CE_BLK
tristate "AES in ECB/CBC/CTR/XTS modes using ARMv8 Crypto Extensions"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && !PREEMPT_RT
select CRYPTO_BLKCIPHER
select CRYPTO_AES_ARM64_CE
select CRYPTO_AES_ARM64
-@@ -94,7 +94,7 @@ config CRYPTO_AES_ARM64_CE_BLK
+@@ -93,7 +93,7 @@ config CRYPTO_AES_ARM64_CE_BLK
config CRYPTO_AES_ARM64_NEON_BLK
tristate "AES in ECB/CBC/CTR/XTS modes using NEON instructions"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && PREEMPT_RT
select CRYPTO_BLKCIPHER
select CRYPTO_AES_ARM64
- select CRYPTO_AES
-@@ -102,18 +102,18 @@ config CRYPTO_AES_ARM64_NEON_BLK
+ select CRYPTO_LIB_AES
+@@ -101,18 +101,18 @@ config CRYPTO_AES_ARM64_NEON_BLK
config CRYPTO_CHACHA20_NEON
tristate "ChaCha20, XChaCha20, and XChaCha12 stream ciphers using NEON instructions"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && !PREEMPT_RT
select CRYPTO_BLKCIPHER
select CRYPTO_CHACHA20
config CRYPTO_NHPOLY1305_NEON
tristate "NHPoly1305 hash function using NEON instructions (for Adiantum)"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && !PREEMPT_RT
select CRYPTO_NHPOLY1305
config CRYPTO_AES_ARM64_BS
tristate "AES in ECB/CBC/CTR/XTS modes using bit-sliced NEON algorithm"
- depends on KERNEL_MODE_NEON
-+ depends on KERNEL_MODE_NEON && !PREEMPT_RT_BASE
++ depends on KERNEL_MODE_NEON && !PREEMPT_RT
select CRYPTO_BLKCIPHER
select CRYPTO_AES_ARM64_NEON_BLK
select CRYPTO_AES_ARM64
diff --git a/debian/patches-rt/arm-enable-highmem-for-rt.patch b/debian/patches-rt/arm-enable-highmem-for-rt.patch
index 99a2d388f4df..6f1d25c2b323 100644
--- a/debian/patches-rt/arm-enable-highmem-for-rt.patch
+++ b/debian/patches-rt/arm-enable-highmem-for-rt.patch
@@ -1,7 +1,7 @@
Subject: arm: Enable highmem for rt
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 13 Feb 2013 11:03:11 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
fixup highmem for ARM.
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include <linux/thread_info.h>
-+#if defined CONFIG_PREEMPT_RT_FULL && defined CONFIG_HIGHMEM
++#if defined CONFIG_PREEMPT_RT && defined CONFIG_HIGHMEM
+void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p);
+#else
+static inline void
@@ -79,7 +79,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* with the new mapping.
*/
- set_fixmap_pte(idx, mk_pte(page, kmap_prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = pte;
+#endif
+ set_fixmap_pte(idx, pte);
@@ -95,7 +95,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (cache_is_vivt())
__cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = __pte(0);
+#endif
#ifdef CONFIG_DEBUG_HIGHMEM
@@ -131,14 +131,14 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
BUG_ON(!pte_none(get_fixmap_pte(vaddr)));
#endif
- set_fixmap_pte(idx, pfn_pte(pfn, kmap_prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = pte;
+#endif
+ set_fixmap_pte(idx, pte);
return (void *)vaddr;
}
-+#if defined CONFIG_PREEMPT_RT_FULL
++#if defined CONFIG_PREEMPT_RT
+void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p)
+{
+ int i;
diff --git a/debian/patches-rt/arm-highmem-flush-tlb-on-unmap.patch b/debian/patches-rt/arm-highmem-flush-tlb-on-unmap.patch
index 97afe0eeb63c..698e25c43ade 100644
--- a/debian/patches-rt/arm-highmem-flush-tlb-on-unmap.patch
+++ b/debian/patches-rt/arm-highmem-flush-tlb-on-unmap.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 11 Mar 2013 21:37:27 +0100
Subject: arm/highmem: Flush tlb on unmap
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The tlb should be flushed on unmap and thus make the mapping entry
invalid. This is only done in the non-debug case which does not look
diff --git a/debian/patches-rt/arm-imx6-cpuidle-Use-raw_spinlock_t.patch b/debian/patches-rt/arm-imx6-cpuidle-Use-raw_spinlock_t.patch
deleted file mode 100644
index fd14557cf0ce..000000000000
--- a/debian/patches-rt/arm-imx6-cpuidle-Use-raw_spinlock_t.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 14 May 2019 17:07:44 +0200
-Subject: [PATCH] arm: imx6: cpuidle: Use raw_spinlock_t
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The idle call back is invoked with disabled interrupts and requires
-raw_spinlock_t locks to work.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/arm/mach-imx/cpuidle-imx6q.c | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
---- a/arch/arm/mach-imx/cpuidle-imx6q.c
-+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
-@@ -14,22 +14,22 @@
- #include "hardware.h"
-
- static int num_idle_cpus = 0;
--static DEFINE_SPINLOCK(cpuidle_lock);
-+static DEFINE_RAW_SPINLOCK(cpuidle_lock);
-
- static int imx6q_enter_wait(struct cpuidle_device *dev,
- struct cpuidle_driver *drv, int index)
- {
-- spin_lock(&cpuidle_lock);
-+ raw_spin_lock(&cpuidle_lock);
- if (++num_idle_cpus == num_online_cpus())
- imx6_set_lpm(WAIT_UNCLOCKED);
-- spin_unlock(&cpuidle_lock);
-+ raw_spin_unlock(&cpuidle_lock);
-
- cpu_do_idle();
-
-- spin_lock(&cpuidle_lock);
-+ raw_spin_lock(&cpuidle_lock);
- if (num_idle_cpus-- == num_online_cpus())
- imx6_set_lpm(WAIT_CLOCKED);
-- spin_unlock(&cpuidle_lock);
-+ raw_spin_unlock(&cpuidle_lock);
-
- return index;
- }
diff --git a/debian/patches-rt/arm-include-definition-for-cpumask_t.patch b/debian/patches-rt/arm-include-definition-for-cpumask_t.patch
index 3929976ae611..e92bc38e44a2 100644
--- a/debian/patches-rt/arm-include-definition-for-cpumask_t.patch
+++ b/debian/patches-rt/arm-include-definition-for-cpumask_t.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 22 Dec 2016 17:28:33 +0100
Subject: [PATCH] arm: include definition for cpumask_t
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This definition gets pulled in by other files. With the (later) split of
RCU and spinlock.h it won't compile anymore.
diff --git a/debian/patches-rt/arm-preempt-lazy-support.patch b/debian/patches-rt/arm-preempt-lazy-support.patch
index f5a764c8ab87..0824e21a5e2d 100644
--- a/debian/patches-rt/arm-preempt-lazy-support.patch
+++ b/debian/patches-rt/arm-preempt-lazy-support.patch
@@ -1,7 +1,7 @@
Subject: arm: Add support for lazy preemption
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 31 Oct 2012 12:04:11 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Implement the arm pieces for lazy preempt.
@@ -17,7 +17,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
-@@ -94,6 +94,7 @@ config ARM
+@@ -102,6 +102,7 @@ config ARM
select HAVE_PERF_EVENTS
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
@@ -77,7 +77,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+++ b/arch/arm/kernel/entry-armv.S
@@ -213,11 +213,18 @@ ENDPROC(__dabt_svc)
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
- ldr r0, [tsk, #TI_FLAGS] @ get flags
teq r8, #0 @ if preempt count != 0
@@ -140,7 +140,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
-@@ -648,7 +648,8 @@ do_work_pending(struct pt_regs *regs, un
+@@ -649,7 +649,8 @@ do_work_pending(struct pt_regs *regs, un
*/
trace_hardirqs_off();
do {
diff --git a/debian/patches-rt/arm-remove-printk_nmi_.patch b/debian/patches-rt/arm-remove-printk_nmi_.patch
index 580977a5fce9..2a7b94713b52 100644
--- a/debian/patches-rt/arm-remove-printk_nmi_.patch
+++ b/debian/patches-rt/arm-remove-printk_nmi_.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 15 Feb 2019 14:34:20 +0100
Subject: [PATCH] arm: remove printk_nmi_.*()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
It is no longer provided by the printk core code.
@@ -12,7 +12,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
-@@ -679,11 +679,9 @@ void handle_IPI(int ipinr, struct pt_reg
+@@ -678,11 +678,9 @@ void handle_IPI(int ipinr, struct pt_reg
break;
case IPI_CPU_BACKTRACE:
diff --git a/debian/patches-rt/arm64-KVM-compute_layout-before-altenates-are-applie.patch b/debian/patches-rt/arm64-KVM-compute_layout-before-altenates-are-applie.patch
index 2f50fa1f3db9..e896f4cad086 100644
--- a/debian/patches-rt/arm64-KVM-compute_layout-before-altenates-are-applie.patch
+++ b/debian/patches-rt/arm64-KVM-compute_layout-before-altenates-are-applie.patch
@@ -1,45 +1,62 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 26 Jul 2018 09:13:42 +0200
-Subject: [PATCH] arm64: KVM: compute_layout before altenates are applied
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: [PATCH] arm64: KVM: Invoke compute_layout() before alternatives are
+ applied
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
compute_layout() is invoked as part of an alternative fixup under
-stop_machine() and needs a sleeping lock as part of get_random_long().
+stop_machine(). This function invokes get_random_long() which acquires a
+sleeping lock on -RT which can not be acquired in this context.
-Invoke compute_layout() before the alternatives are applied.
+Rename compute_layout() to kvm_compute_layout() and invoke it before
+stop_machine() applies the alternatives. Add a __init prefix to
+kvm_compute_layout() because the caller has it, too (and so the code can be
+discarded after boot).
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- arch/arm64/include/asm/alternative.h | 6 ++++++
- arch/arm64/kernel/alternative.c | 1 +
- arch/arm64/kvm/va_layout.c | 7 +------
- 3 files changed, 8 insertions(+), 6 deletions(-)
+ arch/arm64/include/asm/kvm_mmu.h | 1 +
+ arch/arm64/kernel/smp.c | 4 ++++
+ arch/arm64/kvm/va_layout.c | 8 +-------
+ 3 files changed, 6 insertions(+), 7 deletions(-)
---- a/arch/arm64/include/asm/alternative.h
-+++ b/arch/arm64/include/asm/alternative.h
-@@ -35,6 +35,12 @@ void apply_alternatives_module(void *sta
- static inline void apply_alternatives_module(void *start, size_t length) { }
- #endif
+--- a/arch/arm64/include/asm/kvm_mmu.h
++++ b/arch/arm64/include/asm/kvm_mmu.h
+@@ -91,6 +91,7 @@ alternative_cb_end
-+#ifdef CONFIG_KVM_ARM_HOST
+ void kvm_update_va_mask(struct alt_instr *alt,
+ __le32 *origptr, __le32 *updptr, int nr_inst);
+void kvm_compute_layout(void);
-+#else
-+static inline void kvm_compute_layout(void) { }
-+#endif
-+
- #define ALTINSTR_ENTRY(feature,cb) \
- " .word 661b - .\n" /* label */ \
- " .if " __stringify(cb) " == 0\n" \
---- a/arch/arm64/kernel/alternative.c
-+++ b/arch/arm64/kernel/alternative.c
-@@ -238,6 +238,7 @@ static int __apply_alternatives_multi_st
- void __init apply_alternatives_all(void)
+
+ static inline unsigned long __kern_hyp_va(unsigned long v)
{
- /* better not try code patching on a live SMP system */
-+ kvm_compute_layout();
- stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask);
+--- a/arch/arm64/kernel/smp.c
++++ b/arch/arm64/kernel/smp.c
+@@ -31,6 +31,7 @@
+ #include <linux/of.h>
+ #include <linux/irq_work.h>
+ #include <linux/kexec.h>
++#include <linux/kvm_host.h>
+
+ #include <asm/alternative.h>
+ #include <asm/atomic.h>
+@@ -39,6 +40,7 @@
+ #include <asm/cputype.h>
+ #include <asm/cpu_ops.h>
+ #include <asm/daifflags.h>
++#include <asm/kvm_mmu.h>
+ #include <asm/mmu_context.h>
+ #include <asm/numa.h>
+ #include <asm/pgtable.h>
+@@ -408,6 +410,8 @@ static void __init hyp_mode_check(void)
+ "CPU: CPUs started in inconsistent modes");
+ else
+ pr_info("CPU: All CPU(s) started at EL1\n");
++ if (IS_ENABLED(CONFIG_KVM_ARM_HOST))
++ kvm_compute_layout();
}
+ void __init smp_cpus_done(unsigned int max_cpus)
--- a/arch/arm64/kvm/va_layout.c
+++ b/arch/arm64/kvm/va_layout.c
@@ -22,7 +22,7 @@ static u8 tag_lsb;
@@ -51,16 +68,17 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
u64 hyp_va_msb;
-@@ -110,8 +110,6 @@ void __init kvm_update_va_mask(struct al
+@@ -110,9 +110,6 @@ void __init kvm_update_va_mask(struct al
BUG_ON(nr_inst != 5);
- if (!has_vhe() && !va_mask)
- compute_layout();
-
+-
for (i = 0; i < nr_inst; i++) {
u32 rd, rn, insn, oinsn;
-@@ -156,9 +154,6 @@ void kvm_patch_vector_branch(struct alt_
+
+@@ -156,9 +153,6 @@ void kvm_patch_vector_branch(struct alt_
return;
}
diff --git a/debian/patches-rt/arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch b/debian/patches-rt/arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch
index fc914a91bf07..bc7ef382b076 100644
--- a/debian/patches-rt/arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch
+++ b/debian/patches-rt/arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch
@@ -1,25 +1,21 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 25 Jul 2018 14:02:38 +0200
-Subject: [PATCH] arm64: fpsimd: use preemp_disable in addition to
- local_bh_disable()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: [PATCH] arm64: fpsimd: Delay freeing memory in fpsimd_flush_thread()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-In v4.16-RT I noticed a number of warnings from task_fpsimd_load(). The
-code disables BH and expects that it is not preemptible. On -RT the
-task remains preemptible but remains the same CPU. This may corrupt the
-content of the SIMD registers if the task is preempted during
-saving/restoring those registers.
+fpsimd_flush_thread() invokes kfree() via sve_free() within a preempt disabled
+section which is not working on -RT.
-Add preempt_disable()/enable() to enfore the required semantic on -RT.
+Delay freeing of memory until preemption is enabled again.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- arch/arm64/kernel/fpsimd.c | 31 +++++++++++++++++++++++++++++--
- 1 file changed, 29 insertions(+), 2 deletions(-)
+ arch/arm64/kernel/fpsimd.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
-@@ -162,6 +162,16 @@ static void sve_free(struct task_struct
+@@ -213,6 +213,16 @@ static void sve_free(struct task_struct
__sve_free(task);
}
@@ -36,43 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* TIF_SVE controls whether a task can use SVE without trapping while
* in userspace, and also the way a task's FPSIMD/SVE state is stored
-@@ -557,6 +567,7 @@ int sve_set_vector_length(struct task_st
- * non-SVE thread.
- */
- if (task == current) {
-+ preempt_disable();
- local_bh_disable();
-
- fpsimd_save();
-@@ -566,8 +577,10 @@ int sve_set_vector_length(struct task_st
- if (test_and_clear_tsk_thread_flag(task, TIF_SVE))
- sve_to_fpsimd(task);
-
-- if (task == current)
-+ if (task == current) {
- local_bh_enable();
-+ preempt_enable();
-+ }
-
- /*
- * Force reallocation of task SVE state to the correct size
-@@ -880,6 +893,7 @@ asmlinkage void do_sve_acc(unsigned int
-
- sve_alloc(current);
-
-+ preempt_disable();
- local_bh_disable();
-
- fpsimd_save();
-@@ -892,6 +906,7 @@ asmlinkage void do_sve_acc(unsigned int
- WARN_ON(1); /* SVE access shouldn't have trapped */
-
- local_bh_enable();
-+ preempt_enable();
- }
-
- /*
-@@ -954,10 +969,12 @@ void fpsimd_thread_switch(struct task_st
+@@ -1008,6 +1018,7 @@ void fpsimd_thread_switch(struct task_st
void fpsimd_flush_thread(void)
{
int vl, supported_vl;
@@ -80,12 +40,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!system_supports_fpsimd())
return;
-
-+ preempt_disable();
- local_bh_disable();
-
- fpsimd_flush_task_state(current);
-@@ -966,7 +983,7 @@ void fpsimd_flush_thread(void)
+@@ -1020,7 +1031,7 @@ void fpsimd_flush_thread(void)
if (system_supports_sve()) {
clear_thread_flag(TIF_SVE);
@@ -94,72 +49,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Reset the task vector length as required.
-@@ -1000,6 +1017,8 @@ void fpsimd_flush_thread(void)
+@@ -1054,6 +1065,7 @@ void fpsimd_flush_thread(void)
}
- local_bh_enable();
-+ preempt_enable();
+ put_cpu_fpsimd_context();
+ kfree(mem);
}
/*
-@@ -1011,9 +1030,11 @@ void fpsimd_preserve_current_state(void)
- if (!system_supports_fpsimd())
- return;
-
-+ preempt_disable();
- local_bh_disable();
- fpsimd_save();
- local_bh_enable();
-+ preempt_enable();
- }
-
- /*
-@@ -1076,6 +1097,7 @@ void fpsimd_restore_current_state(void)
- if (!system_supports_fpsimd())
- return;
-
-+ preempt_disable();
- local_bh_disable();
-
- if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
-@@ -1084,6 +1106,7 @@ void fpsimd_restore_current_state(void)
- }
-
- local_bh_enable();
-+ preempt_enable();
- }
-
- /*
-@@ -1096,6 +1119,7 @@ void fpsimd_update_current_state(struct
- if (!system_supports_fpsimd())
- return;
-
-+ preempt_disable();
- local_bh_disable();
-
- current->thread.uw.fpsimd_state = *state;
-@@ -1108,6 +1132,7 @@ void fpsimd_update_current_state(struct
- clear_thread_flag(TIF_FOREIGN_FPSTATE);
-
- local_bh_enable();
-+ preempt_enable();
- }
-
- /*
-@@ -1170,6 +1195,7 @@ void kernel_neon_begin(void)
-
- BUG_ON(!may_use_simd());
-
-+ preempt_disable();
- local_bh_disable();
-
- __this_cpu_write(kernel_neon_busy, true);
-@@ -1183,6 +1209,7 @@ void kernel_neon_begin(void)
- preempt_disable();
-
- local_bh_enable();
-+ preempt_enable();
- }
- EXPORT_SYMBOL(kernel_neon_begin);
-
diff --git a/debian/patches-rt/arm64-preempt-Check-preemption-level-before-looking-.patch b/debian/patches-rt/arm64-preempt-Check-preemption-level-before-looking-.patch
deleted file mode 100644
index 19e6bb2deec8..000000000000
--- a/debian/patches-rt/arm64-preempt-Check-preemption-level-before-looking-.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 14 Aug 2019 17:08:58 +0200
-Subject: [PATCH] arm64: preempt: Check preemption level before looking at
- lazy-preempt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Before evaluating the lazy-preempt state it must be ensure that the
-preempt-count is zero.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/arm64/include/asm/preempt.h | 2 ++
- 1 file changed, 2 insertions(+)
-
---- a/arch/arm64/include/asm/preempt.h
-+++ b/arch/arm64/include/asm/preempt.h
-@@ -73,6 +73,8 @@ static inline bool __preempt_count_dec_a
- if (!pc || !READ_ONCE(ti->preempt_count))
- return true;
- #ifdef CONFIG_PREEMPT_LAZY
-+ if ((pc & ~PREEMPT_NEED_RESCHED))
-+ return false;
- if (current_thread_info()->preempt_lazy_count)
- return false;
- return test_thread_flag(TIF_NEED_RESCHED_LAZY);
diff --git a/debian/patches-rt/arm64-preempt-Fixup-lazy-preempt.patch b/debian/patches-rt/arm64-preempt-Fixup-lazy-preempt.patch
deleted file mode 100644
index cf1dceb0a9b8..000000000000
--- a/debian/patches-rt/arm64-preempt-Fixup-lazy-preempt.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 13 Aug 2019 11:53:23 +0200
-Subject: [PATCH] arm64: preempt: Fixup lazy preempt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The irq-exit assmebly checks preempt count and need-resched flag
-followed by lazy-preempt status. This is a bug. It should schedule if
-preempt-count is zero _and_ need_resched is set _or_ preempt-count is
-zero and check the lazy-preempt status.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/arm64/kernel/entry.S | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/arch/arm64/kernel/entry.S
-+++ b/arch/arm64/kernel/entry.S
-@@ -680,7 +680,8 @@ alternative_if ARM64_HAS_IRQ_PRIO_MASKIN
- orr x24, x24, x0
- alternative_else_nop_endif
-
-- cbnz x24, 2f // preempt count != 0
-+ cbz x24, 1f // (need_resched + count) == 0
-+ cbnz w24, 2f // count != 0
-
- ldr w24, [tsk, #TSK_TI_PREEMPT_LAZY] // get preempt lazy count
- cbnz w24, 2f // preempt lazy count != 0
diff --git a/debian/patches-rt/at91_dont_enable_disable_clock.patch b/debian/patches-rt/at91_dont_enable_disable_clock.patch
index 1b24e75d2c85..3cc25f0ccaf3 100644
--- a/debian/patches-rt/at91_dont_enable_disable_clock.patch
+++ b/debian/patches-rt/at91_dont_enable_disable_clock.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 09 Mar 2016 10:51:06 +0100
Subject: arm: at91: do not disable/enable clocks in a row
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Currently the driver will disable the clock and enable it one line later
if it is switching from periodic mode into one shot.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/clocksource/timer-atmel-tcb.c
+++ b/drivers/clocksource/timer-atmel-tcb.c
-@@ -130,6 +130,7 @@ static u64 notrace tc_sched_clock_read32
+@@ -143,6 +143,7 @@ static unsigned long notrace tc_delay_ti
struct tc_clkevt_device {
struct clock_event_device clkevt;
struct clk *clk;
@@ -22,7 +22,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
void __iomem *regs;
};
-@@ -147,6 +148,24 @@ static struct tc_clkevt_device *to_tc_cl
+@@ -160,6 +161,24 @@ static struct tc_clkevt_device *to_tc_cl
*/
static u32 timer_clock;
@@ -47,7 +47,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static int tc_shutdown(struct clock_event_device *d)
{
struct tc_clkevt_device *tcd = to_tc_clkevt(d);
-@@ -154,8 +173,14 @@ static int tc_shutdown(struct clock_even
+@@ -167,8 +186,14 @@ static int tc_shutdown(struct clock_even
writel(0xff, regs + ATMEL_TC_REG(2, IDR));
writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
@@ -63,7 +63,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 0;
}
-@@ -168,7 +193,7 @@ static int tc_set_oneshot(struct clock_e
+@@ -181,7 +206,7 @@ static int tc_set_oneshot(struct clock_e
if (clockevent_state_oneshot(d) || clockevent_state_periodic(d))
tc_shutdown(d);
@@ -72,7 +72,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* slow clock, count up to RC, then irq and stop */
writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE |
-@@ -190,7 +215,7 @@ static int tc_set_periodic(struct clock_
+@@ -203,7 +228,7 @@ static int tc_set_periodic(struct clock_
/* By not making the gentime core emulate periodic mode on top
* of oneshot, we get lower overhead and improved accuracy.
*/
@@ -81,7 +81,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* slow clock, count up to RC, then irq and restart */
writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO,
-@@ -223,7 +248,7 @@ static struct tc_clkevt_device clkevt =
+@@ -236,7 +261,7 @@ static struct tc_clkevt_device clkevt =
/* Should be lower than at91rm9200's system timer */
.rating = 125,
.set_next_event = tc_next_event,
diff --git a/debian/patches-rt/block-Don-t-disable-interrupts-in-trigger_softirq.patch b/debian/patches-rt/block-Don-t-disable-interrupts-in-trigger_softirq.patch
new file mode 100644
index 000000000000..96d516fb1f9b
--- /dev/null
+++ b/debian/patches-rt/block-Don-t-disable-interrupts-in-trigger_softirq.patch
@@ -0,0 +1,36 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 15 Nov 2019 21:37:22 +0100
+Subject: [PATCH] block: Don't disable interrupts in trigger_softirq()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+trigger_softirq() is always invoked as a SMP-function call which is
+always invoked with disables interrupts.
+
+Don't disable interrupt in trigger_softirq() because interrupts are
+already disabled.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ block/blk-softirq.c | 4 ----
+ 1 file changed, 4 deletions(-)
+
+--- a/block/blk-softirq.c
++++ b/block/blk-softirq.c
+@@ -42,17 +42,13 @@ static __latent_entropy void blk_done_so
+ static void trigger_softirq(void *data)
+ {
+ struct request *rq = data;
+- unsigned long flags;
+ struct list_head *list;
+
+- local_irq_save(flags);
+ list = this_cpu_ptr(&blk_cpu_done);
+ list_add_tail(&rq->ipi_list, list);
+
+ if (list->next == &rq->ipi_list)
+ raise_softirq_irqoff(BLOCK_SOFTIRQ);
+-
+- local_irq_restore(flags);
+ }
+
+ /*
diff --git a/debian/patches-rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch b/debian/patches-rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch
deleted file mode 100644
index 9705f2fc7994..000000000000
--- a/debian/patches-rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 13 Mar 2018 13:49:16 +0100
-Subject: [PATCH] block: blk-mq: move blk_queue_usage_counter_release()
- into process context
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-| BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:914
-| in_atomic(): 1, irqs_disabled(): 0, pid: 255, name: kworker/u257:6
-| 5 locks held by kworker/u257:6/255:
-| #0: ("events_unbound"){.+.+.+}, at: [<ffffffff8108edf1>] process_one_work+0x171/0x5e0
-| #1: ((&entry->work)){+.+.+.}, at: [<ffffffff8108edf1>] process_one_work+0x171/0x5e0
-| #2: (&shost->scan_mutex){+.+.+.}, at: [<ffffffffa000faa3>] __scsi_add_device+0xa3/0x130 [scsi_mod]
-| #3: (&set->tag_list_lock){+.+...}, at: [<ffffffff812f09fa>] blk_mq_init_queue+0x96a/0xa50
-| #4: (rcu_read_lock_sched){......}, at: [<ffffffff8132887d>] percpu_ref_kill_and_confirm+0x1d/0x120
-| Preemption disabled at:[<ffffffff812eff76>] blk_mq_freeze_queue_start+0x56/0x70
-|
-| CPU: 2 PID: 255 Comm: kworker/u257:6 Not tainted 3.18.7-rt0+ #1
-| Workqueue: events_unbound async_run_entry_fn
-| 0000000000000003 ffff8800bc29f998 ffffffff815b3a12 0000000000000000
-| 0000000000000000 ffff8800bc29f9b8 ffffffff8109aa16 ffff8800bc29fa28
-| ffff8800bc5d1bc8 ffff8800bc29f9e8 ffffffff815b8dd4 ffff880000000000
-| Call Trace:
-| [<ffffffff815b3a12>] dump_stack+0x4f/0x7c
-| [<ffffffff8109aa16>] __might_sleep+0x116/0x190
-| [<ffffffff815b8dd4>] rt_spin_lock+0x24/0x60
-| [<ffffffff810b6089>] __wake_up+0x29/0x60
-| [<ffffffff812ee06e>] blk_mq_usage_counter_release+0x1e/0x20
-| [<ffffffff81328966>] percpu_ref_kill_and_confirm+0x106/0x120
-| [<ffffffff812eff76>] blk_mq_freeze_queue_start+0x56/0x70
-| [<ffffffff812f0000>] blk_mq_update_tag_set_depth+0x40/0xd0
-| [<ffffffff812f0a1c>] blk_mq_init_queue+0x98c/0xa50
-| [<ffffffffa000dcf0>] scsi_mq_alloc_queue+0x20/0x60 [scsi_mod]
-| [<ffffffffa000ea35>] scsi_alloc_sdev+0x2f5/0x370 [scsi_mod]
-| [<ffffffffa000f494>] scsi_probe_and_add_lun+0x9e4/0xdd0 [scsi_mod]
-| [<ffffffffa000fb26>] __scsi_add_device+0x126/0x130 [scsi_mod]
-| [<ffffffffa013033f>] ata_scsi_scan_host+0xaf/0x200 [libata]
-| [<ffffffffa012b5b6>] async_port_probe+0x46/0x60 [libata]
-| [<ffffffff810978fb>] async_run_entry_fn+0x3b/0xf0
-| [<ffffffff8108ee81>] process_one_work+0x201/0x5e0
-
-percpu_ref_kill_and_confirm() invokes blk_mq_usage_counter_release() in
-a rcu-sched region. swait based wake queue can't be used due to
-wake_up_all() usage and disabled interrupts in !RT configs (as reported
-by Corey Minyard).
-The wq_has_sleeper() check has been suggested by Peter Zijlstra.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- block/blk-core.c | 12 +++++++++++-
- include/linux/blkdev.h | 2 ++
- 2 files changed, 13 insertions(+), 1 deletion(-)
-
---- a/block/blk-core.c
-+++ b/block/blk-core.c
-@@ -404,12 +404,21 @@ void blk_queue_exit(struct request_queue
- percpu_ref_put(&q->q_usage_counter);
- }
-
-+static void blk_queue_usage_counter_release_wrk(struct work_struct *work)
-+{
-+ struct request_queue *q =
-+ container_of(work, struct request_queue, mq_pcpu_wake);
-+
-+ wake_up_all(&q->mq_freeze_wq);
-+}
-+
- static void blk_queue_usage_counter_release(struct percpu_ref *ref)
- {
- struct request_queue *q =
- container_of(ref, struct request_queue, q_usage_counter);
-
-- wake_up_all(&q->mq_freeze_wq);
-+ if (wq_has_sleeper(&q->mq_freeze_wq))
-+ schedule_work(&q->mq_pcpu_wake);
- }
-
- static void blk_rq_timed_out_timer(struct timer_list *t)
-@@ -480,6 +489,7 @@ struct request_queue *blk_alloc_queue_no
- spin_lock_init(&q->queue_lock);
-
- init_waitqueue_head(&q->mq_freeze_wq);
-+ INIT_WORK(&q->mq_pcpu_wake, blk_queue_usage_counter_release_wrk);
- mutex_init(&q->mq_freeze_lock);
-
- /*
---- a/include/linux/blkdev.h
-+++ b/include/linux/blkdev.h
-@@ -13,6 +13,7 @@
- #include <linux/llist.h>
- #include <linux/timer.h>
- #include <linux/workqueue.h>
-+#include <linux/kthread.h>
- #include <linux/pagemap.h>
- #include <linux/backing-dev-defs.h>
- #include <linux/wait.h>
-@@ -559,6 +560,7 @@ struct request_queue {
- #endif
- struct rcu_head rcu_head;
- wait_queue_head_t mq_freeze_wq;
-+ struct work_struct mq_pcpu_wake;
- /*
- * Protect concurrent access to q_usage_counter by
- * percpu_ref_kill() and percpu_ref_reinit().
diff --git a/debian/patches-rt/block-mq-don-t-complete-requests-via-IPI.patch b/debian/patches-rt/block-mq-don-t-complete-requests-via-IPI.patch
index da39325ce9ec..93e02438dc4d 100644
--- a/debian/patches-rt/block-mq-don-t-complete-requests-via-IPI.patch
+++ b/debian/patches-rt/block-mq-don-t-complete-requests-via-IPI.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 29 Jan 2015 15:10:08 +0100
Subject: block/mq: don't complete requests via IPI
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The IPI runs in hardirq context and there are sleeping locks. Assume caches are
shared and complete them on the local CPU.
@@ -13,7 +13,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
-@@ -605,8 +605,16 @@ static void __blk_mq_complete_request(st
+@@ -612,8 +612,16 @@ static void __blk_mq_complete_request(st
}
cpu = get_cpu_light();
@@ -21,7 +21,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ * Avoid SMP function calls for completions because they acquire
+ * sleeping spinlocks on RT.
+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ shared = true;
+#else
if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags))
diff --git a/debian/patches-rt/block-mq-drop-preempt-disable.patch b/debian/patches-rt/block-mq-drop-preempt-disable.patch
index 401459684286..0930ac9e8047 100644
--- a/debian/patches-rt/block-mq-drop-preempt-disable.patch
+++ b/debian/patches-rt/block-mq-drop-preempt-disable.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 14 Jul 2015 14:26:34 +0200
Subject: block/mq: do not invoke preempt_disable()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
preempt_disable() and get_cpu() don't play well together with the sleeping
locks it tries to allocate later.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
-@@ -604,7 +604,7 @@ static void __blk_mq_complete_request(st
+@@ -611,7 +611,7 @@ static void __blk_mq_complete_request(st
return;
}
@@ -23,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags))
shared = cpus_share_cache(cpu, ctx->cpu);
-@@ -616,7 +616,7 @@ static void __blk_mq_complete_request(st
+@@ -623,7 +623,7 @@ static void __blk_mq_complete_request(st
} else {
q->mq_ops->complete(rq);
}
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void hctx_unlock(struct blk_mq_hw_ctx *hctx, int srcu_idx)
-@@ -1456,14 +1456,14 @@ static void __blk_mq_delay_run_hw_queue(
+@@ -1466,14 +1466,14 @@ static void __blk_mq_delay_run_hw_queue(
return;
if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
diff --git a/debian/patches-rt/block-mq-use-cpu_light.patch b/debian/patches-rt/block-mq-use-cpu_light.patch
deleted file mode 100644
index 990a13788152..000000000000
--- a/debian/patches-rt/block-mq-use-cpu_light.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 9 Apr 2014 10:37:23 +0200
-Subject: block: mq: use cpu_light()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-there is a might sleep splat because get_cpu() disables preemption and
-later we grab a lock. As a workaround for this we use get_cpu_light().
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- block/blk-mq.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/block/blk-mq.h
-+++ b/block/blk-mq.h
-@@ -151,12 +151,12 @@ static inline struct blk_mq_ctx *__blk_m
- */
- static inline struct blk_mq_ctx *blk_mq_get_ctx(struct request_queue *q)
- {
-- return __blk_mq_get_ctx(q, get_cpu());
-+ return __blk_mq_get_ctx(q, get_cpu_light());
- }
-
- static inline void blk_mq_put_ctx(struct blk_mq_ctx *ctx)
- {
-- put_cpu();
-+ put_cpu_light();
- }
-
- struct blk_mq_alloc_data {
diff --git a/debian/patches-rt/block-use-cpu-chill.patch b/debian/patches-rt/block-use-cpu-chill.patch
index 467e427fdc8c..1413bfefe1ca 100644
--- a/debian/patches-rt/block-use-cpu-chill.patch
+++ b/debian/patches-rt/block-use-cpu-chill.patch
@@ -1,7 +1,7 @@
Subject: block: Use cpu_chill() for retry loops
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 20 Dec 2012 18:28:26 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Retry loops on RT might loop forever when the modifying side was
preempted. Steven also observed a live lock when there was a
@@ -10,6 +10,8 @@ concurrent priority boosting going on.
Use cpu_chill() instead of cpu_relax() to let the system
make progress.
+[bigeasy: After all those changes that occured over the years, this one hunk is
+left and should not cause any starvation on -RT anymore]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
diff --git a/debian/patches-rt/cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch b/debian/patches-rt/cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch
deleted file mode 100644
index 67a433009ad6..000000000000
--- a/debian/patches-rt/cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 3 Jul 2018 18:19:48 +0200
-Subject: [PATCH] cgroup: use irqsave in cgroup_rstat_flush_locked()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-All callers of cgroup_rstat_flush_locked() acquire cgroup_rstat_lock
-either with spin_lock_irq() or spin_lock_irqsave().
-cgroup_rstat_flush_locked() itself acquires cgroup_rstat_cpu_lock which
-is a raw_spin_lock. This lock is also acquired in cgroup_rstat_updated()
-in IRQ context and therefore requires _irqsave() locking suffix in
-cgroup_rstat_flush_locked().
-Since there is no difference between spin_lock_t and raw_spin_lock_t
-on !RT lockdep does not complain here. On RT lockdep complains because
-the interrupts were not disabled here and a deadlock is possible.
-
-Acquire the raw_spin_lock_t with disabled interrupts.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/cgroup/rstat.c | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
---- a/kernel/cgroup/rstat.c
-+++ b/kernel/cgroup/rstat.c
-@@ -160,8 +160,9 @@ static void cgroup_rstat_flush_locked(st
- raw_spinlock_t *cpu_lock = per_cpu_ptr(&cgroup_rstat_cpu_lock,
- cpu);
- struct cgroup *pos = NULL;
-+ unsigned long flags;
-
-- raw_spin_lock(cpu_lock);
-+ raw_spin_lock_irqsave(cpu_lock, flags);
- while ((pos = cgroup_rstat_cpu_pop_updated(pos, cgrp, cpu))) {
- struct cgroup_subsys_state *css;
-
-@@ -173,7 +174,7 @@ static void cgroup_rstat_flush_locked(st
- css->ss->css_rstat_flush(css, cpu);
- rcu_read_unlock();
- }
-- raw_spin_unlock(cpu_lock);
-+ raw_spin_unlock_irqrestore(cpu_lock, flags);
-
- /* if @may_sleep, play nice and yield if necessary */
- if (may_sleep && (need_resched() ||
diff --git a/debian/patches-rt/clocksource-tclib-allow-higher-clockrates.patch b/debian/patches-rt/clocksource-tclib-allow-higher-clockrates.patch
index 09d07f8ef760..5b8e21240749 100644
--- a/debian/patches-rt/clocksource-tclib-allow-higher-clockrates.patch
+++ b/debian/patches-rt/clocksource-tclib-allow-higher-clockrates.patch
@@ -1,7 +1,7 @@
From: Benedikt Spranger <b.spranger@linutronix.de>
Date: Mon, 8 Mar 2010 18:57:04 +0100
Subject: clocksource: TCLIB: Allow higher clock rates for clock events
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
As default the TCLIB uses the 32KiHz base clock rate for clock events.
Add a compile time selection to allow higher clock resulution.
@@ -17,7 +17,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
-@@ -429,6 +429,13 @@ config ATMEL_TCB_CLKSRC
+@@ -434,6 +434,13 @@ config ATMEL_TCB_CLKSRC
help
Support for Timer Counter Blocks on Atmel SoCs.
@@ -33,7 +33,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
depends on ARM || ARM64
--- a/drivers/clocksource/timer-atmel-tcb.c
+++ b/drivers/clocksource/timer-atmel-tcb.c
-@@ -27,8 +27,7 @@
+@@ -28,8 +28,7 @@
* this 32 bit free-running counter. the second channel is not used.
*
* - The third channel may be used to provide a 16-bit clockevent
@@ -43,7 +43,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
*
* REVISIT behavior during system suspend states... we should disable
* all clocks and save the power. Easily done for clockevent devices,
-@@ -131,6 +130,7 @@ struct tc_clkevt_device {
+@@ -144,6 +143,7 @@ struct tc_clkevt_device {
struct clock_event_device clkevt;
struct clk *clk;
bool clk_enabled;
@@ -51,7 +51,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void __iomem *regs;
};
-@@ -139,13 +139,6 @@ static struct tc_clkevt_device *to_tc_cl
+@@ -152,13 +152,6 @@ static struct tc_clkevt_device *to_tc_cl
return container_of(clkevt, struct tc_clkevt_device, clkevt);
}
@@ -65,7 +65,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static u32 timer_clock;
static void tc_clk_disable(struct clock_event_device *d)
-@@ -195,7 +188,7 @@ static int tc_set_oneshot(struct clock_e
+@@ -208,7 +201,7 @@ static int tc_set_oneshot(struct clock_e
tc_clk_enable(d);
@@ -74,7 +74,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE |
ATMEL_TC_WAVESEL_UP_AUTO, regs + ATMEL_TC_REG(2, CMR));
writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-@@ -217,10 +210,10 @@ static int tc_set_periodic(struct clock_
+@@ -230,10 +223,10 @@ static int tc_set_periodic(struct clock_
*/
tc_clk_enable(d);
@@ -87,7 +87,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/* Enable clock and interrupts on RC compare */
writel(ATMEL_TC_CPCS, regs + ATMEL_TC_REG(2, IER));
-@@ -246,7 +239,11 @@ static struct tc_clkevt_device clkevt =
+@@ -259,7 +252,11 @@ static struct tc_clkevt_device clkevt =
.features = CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_ONESHOT,
/* Should be lower than at91rm9200's system timer */
@@ -99,7 +99,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
.set_next_event = tc_next_event,
.set_state_shutdown = tc_shutdown_clk_off,
.set_state_periodic = tc_set_periodic,
-@@ -268,8 +265,11 @@ static irqreturn_t ch2_irq(int irq, void
+@@ -281,8 +278,11 @@ static irqreturn_t ch2_irq(int irq, void
return IRQ_NONE;
}
@@ -112,7 +112,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
int ret;
struct clk *t2_clk = tc->clk[2];
int irq = tc->irq[2];
-@@ -290,7 +290,11 @@ static int __init setup_clkevents(struct
+@@ -303,7 +303,11 @@ static int __init setup_clkevents(struct
clkevt.regs = tc->regs;
clkevt.clk = t2_clk;
@@ -125,7 +125,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
clkevt.clkevt.cpumask = cpumask_of(0);
-@@ -301,7 +305,7 @@ static int __init setup_clkevents(struct
+@@ -314,7 +318,7 @@ static int __init setup_clkevents(struct
return ret;
}
@@ -134,7 +134,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return ret;
}
-@@ -358,8 +362,6 @@ static void __init tcb_setup_single_chan
+@@ -371,8 +375,6 @@ static void __init tcb_setup_single_chan
writel(ATMEL_TC_SYNC, tcaddr + ATMEL_TC_BCR);
}
@@ -143,7 +143,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static const struct of_device_id atmel_tcb_of_match[] = {
{ .compatible = "atmel,at91rm9200-tcb", .data = (void *)16, },
{ .compatible = "atmel,at91sam9x5-tcb", .data = (void *)32, },
-@@ -477,7 +479,11 @@ static int __init tcb_clksrc_init(struct
+@@ -492,7 +494,11 @@ static int __init tcb_clksrc_init(struct
goto err_disable_t1;
/* channel 2: periodic and oneshot timer support */
diff --git a/debian/patches-rt/completion-use-simple-wait-queues.patch b/debian/patches-rt/completion-use-simple-wait-queues.patch
index b7e55778ed47..49a7cb2779af 100644
--- a/debian/patches-rt/completion-use-simple-wait-queues.patch
+++ b/debian/patches-rt/completion-use-simple-wait-queues.patch
@@ -1,13 +1,17 @@
Subject: completion: Use simple wait queues
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 11 Jan 2013 11:23:51 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Completions have no long lasting callbacks and therefor do not need
the complex waitqueue variant. Use simple waitqueues which reduces the
contention on the waitqueue lock.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+[cminyard@mvista.com: Move __prepare_to_swait() into the do loop because
+ swake_up_locked() removes the waiter on wake from the queue while in the
+ original code it is not the case]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/powerpc/platforms/ps3/device-init.c | 4 +-
drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 4 +-
@@ -19,9 +23,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/power/hibernate.c | 7 ++++
kernel/power/suspend.c | 4 ++
kernel/sched/completion.c | 34 ++++++++++----------
- kernel/sched/core.c | 10 ++++-
kernel/sched/swait.c | 21 +++++++++++-
- 12 files changed, 75 insertions(+), 31 deletions(-)
+ 11 files changed, 67 insertions(+), 29 deletions(-)
--- a/arch/powerpc/platforms/ps3/device-init.c
+++ b/arch/powerpc/platforms/ps3/device-init.c
@@ -51,7 +54,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
default:
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
-@@ -1708,7 +1708,7 @@ static void ffs_data_put(struct ffs_data
+@@ -1715,7 +1715,7 @@ static void ffs_data_put(struct ffs_data
pr_info("%s(): freeing\n", __func__);
ffs_data_clear(ffs);
BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
@@ -62,7 +65,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kfree(ffs->dev_name);
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
-@@ -343,7 +343,7 @@ ep_io (struct ep_data *epdata, void *buf
+@@ -344,7 +344,7 @@ ep_io (struct ep_data *epdata, void *buf
spin_unlock_irq (&epdata->dev->lock);
if (likely (value == 0)) {
@@ -71,7 +74,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (value != 0) {
spin_lock_irq (&epdata->dev->lock);
if (likely (epdata->ep != NULL)) {
-@@ -352,7 +352,7 @@ ep_io (struct ep_data *epdata, void *buf
+@@ -353,7 +353,7 @@ ep_io (struct ep_data *epdata, void *buf
usb_ep_dequeue (epdata->ep, epdata->req);
spin_unlock_irq (&epdata->dev->lock);
@@ -120,7 +123,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/**
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
-@@ -196,6 +196,12 @@ struct platform_s2idle_ops {
+@@ -197,6 +197,12 @@ struct platform_s2idle_ops {
void (*end)(void);
};
@@ -147,7 +150,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
-@@ -688,6 +688,10 @@ static int load_image_and_restore(void)
+@@ -689,6 +689,10 @@ static int load_image_and_restore(void)
return error;
}
@@ -158,7 +161,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/**
* hibernate - Carry out system hibernation, including saving the image.
*/
-@@ -701,6 +705,8 @@ int hibernate(void)
+@@ -702,6 +706,8 @@ int hibernate(void)
return -EPERM;
}
@@ -167,7 +170,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
lock_system_sleep();
/* The snapshot device should not be opened while we're running */
if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
-@@ -777,6 +783,7 @@ int hibernate(void)
+@@ -778,6 +784,7 @@ int hibernate(void)
atomic_inc(&snapshot_device_available);
Unlock:
unlock_system_sleep();
@@ -177,7 +180,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return error;
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
-@@ -605,6 +605,8 @@ static int enter_state(suspend_state_t s
+@@ -594,6 +594,8 @@ static int enter_state(suspend_state_t s
return error;
}
@@ -186,7 +189,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/**
* pm_suspend - Externally visible function for suspending the system.
* @state: System sleep state to enter.
-@@ -619,6 +621,7 @@ int pm_suspend(suspend_state_t state)
+@@ -608,6 +610,7 @@ int pm_suspend(suspend_state_t state)
if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
return -EINVAL;
@@ -194,7 +197,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
pr_info("suspend entry (%s)\n", mem_sleep_labels[state]);
error = enter_state(state);
if (error) {
-@@ -628,6 +631,7 @@ int pm_suspend(suspend_state_t state)
+@@ -617,6 +620,7 @@ int pm_suspend(suspend_state_t state)
suspend_stats.success++;
}
pr_info("suspend exit\n");
@@ -242,12 +245,12 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ DECLARE_SWAITQUEUE(wait);
- __add_wait_queue_entry_tail_exclusive(&x->wait, &wait);
-+ __prepare_to_swait(&x->wait, &wait);
do {
if (signal_pending_state(state, current)) {
timeout = -ERESTARTSYS;
break;
}
++ __prepare_to_swait(&x->wait, &wait);
__set_current_state(state);
- spin_unlock_irq(&x->wait.lock);
+ raw_spin_unlock_irq(&x->wait.lock);
@@ -298,32 +301,6 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return true;
}
EXPORT_SYMBOL(completion_done);
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7123,7 +7123,10 @@ void migrate_disable(void)
- return;
- }
- #ifdef CONFIG_SCHED_DEBUG
-- WARN_ON_ONCE(p->migrate_disable_atomic);
-+ if (unlikely(p->migrate_disable_atomic)) {
-+ tracing_off();
-+ WARN_ON_ONCE(1);
-+ }
- #endif
-
- if (p->migrate_disable) {
-@@ -7153,7 +7156,10 @@ void migrate_enable(void)
- }
-
- #ifdef CONFIG_SCHED_DEBUG
-- WARN_ON_ONCE(p->migrate_disable_atomic);
-+ if (unlikely(p->migrate_disable_atomic)) {
-+ tracing_off();
-+ WARN_ON_ONCE(1);
-+ }
- #endif
-
- WARN_ON_ONCE(p->migrate_disable <= 0);
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
@@ -32,6 +32,25 @@ void swake_up_locked(struct swait_queue_
@@ -352,7 +329,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void swake_up_one(struct swait_queue_head *q)
{
unsigned long flags;
-@@ -69,7 +88,7 @@ void swake_up_all(struct swait_queue_hea
+@@ -70,7 +89,7 @@ void swake_up_all(struct swait_queue_hea
}
EXPORT_SYMBOL(swake_up_all);
diff --git a/debian/patches-rt/cond-resched-lock-rt-tweak.patch b/debian/patches-rt/cond-resched-lock-rt-tweak.patch
index fe86949a0aab..4d9fd940fffa 100644
--- a/debian/patches-rt/cond-resched-lock-rt-tweak.patch
+++ b/debian/patches-rt/cond-resched-lock-rt-tweak.patch
@@ -1,7 +1,7 @@
Subject: sched: Use the proper LOCK_OFFSET for cond_resched()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 17 Jul 2011 22:51:33 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
RT does not increment preempt count when a 'sleeping' spinlock is
locked. Update PREEMPT_LOCK_OFFSET for that case.
@@ -17,7 +17,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* The preempt_count offset after spin_lock()
*/
-+#if !defined(CONFIG_PREEMPT_RT_FULL)
++#if !defined(CONFIG_PREEMPT_RT)
#define PREEMPT_LOCK_OFFSET PREEMPT_DISABLE_OFFSET
+#else
+#define PREEMPT_LOCK_OFFSET 0
diff --git a/debian/patches-rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch b/debian/patches-rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
index 71a730f2d6d9..cb938b8216f6 100644
--- a/debian/patches-rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
+++ b/debian/patches-rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
@@ -2,7 +2,7 @@ From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Sun, 16 Oct 2016 05:11:54 +0200
Subject: [PATCH] connector/cn_proc: Protect send_msg() with a local lock
on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931
|in_atomic(): 1, irqs_disabled(): 0, pid: 31807, name: sleep
diff --git a/debian/patches-rt/cpu-hotplug--Implement-CPU-pinning.patch b/debian/patches-rt/cpu-hotplug--Implement-CPU-pinning.patch
deleted file mode 100644
index 49230a771ce2..000000000000
--- a/debian/patches-rt/cpu-hotplug--Implement-CPU-pinning.patch
+++ /dev/null
@@ -1,109 +0,0 @@
-Subject: cpu/hotplug: Implement CPU pinning
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Wed, 19 Jul 2017 17:31:20 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- include/linux/sched.h | 1 +
- kernel/cpu.c | 38 ++++++++++++++++++++++++++++++++++++++
- 2 files changed, 39 insertions(+)
-
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -662,6 +662,7 @@ struct task_struct {
- #if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- int migrate_disable;
- int migrate_disable_update;
-+ int pinned_on_cpu;
- # ifdef CONFIG_SCHED_DEBUG
- int migrate_disable_atomic;
- # endif
---- a/kernel/cpu.c
-+++ b/kernel/cpu.c
-@@ -76,6 +76,11 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_s
- .fail = CPUHP_INVALID,
- };
-
-+#ifdef CONFIG_HOTPLUG_CPU
-+static DEFINE_PER_CPU(struct rt_rw_lock, cpuhp_pin_lock) = \
-+ __RWLOCK_RT_INITIALIZER(cpuhp_pin_lock);
-+#endif
-+
- #if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP)
- static struct lockdep_map cpuhp_state_up_map =
- STATIC_LOCKDEP_MAP_INIT("cpuhp_state-up", &cpuhp_state_up_map);
-@@ -287,7 +292,28 @@ static int cpu_hotplug_disabled;
- */
- void pin_current_cpu(void)
- {
-+ struct rt_rw_lock *cpuhp_pin;
-+ unsigned int cpu;
-+ int ret;
-+
-+again:
-+ cpuhp_pin = this_cpu_ptr(&cpuhp_pin_lock);
-+ ret = __read_rt_trylock(cpuhp_pin);
-+ if (ret) {
-+ current->pinned_on_cpu = smp_processor_id();
-+ return;
-+ }
-+ cpu = smp_processor_id();
-+ preempt_enable();
-+
-+ __read_rt_lock(cpuhp_pin);
-
-+ preempt_disable();
-+ if (cpu != smp_processor_id()) {
-+ __read_rt_unlock(cpuhp_pin);
-+ goto again;
-+ }
-+ current->pinned_on_cpu = cpu;
- }
-
- /**
-@@ -295,6 +321,13 @@ void pin_current_cpu(void)
- */
- void unpin_current_cpu(void)
- {
-+ struct rt_rw_lock *cpuhp_pin = this_cpu_ptr(&cpuhp_pin_lock);
-+
-+ if (WARN_ON(current->pinned_on_cpu != smp_processor_id()))
-+ cpuhp_pin = per_cpu_ptr(&cpuhp_pin_lock, current->pinned_on_cpu);
-+
-+ current->pinned_on_cpu = -1;
-+ __read_rt_unlock(cpuhp_pin);
- }
-
- DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock);
-@@ -885,6 +918,7 @@ static int take_cpu_down(void *_param)
-
- static int takedown_cpu(unsigned int cpu)
- {
-+ struct rt_rw_lock *cpuhp_pin = per_cpu_ptr(&cpuhp_pin_lock, cpu);
- struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
- int err;
-
-@@ -897,11 +931,14 @@ static int takedown_cpu(unsigned int cpu
- */
- irq_lock_sparse();
-
-+ __write_rt_lock(cpuhp_pin);
-+
- /*
- * So now all preempt/rcu users must observe !cpu_active().
- */
- err = stop_machine_cpuslocked(take_cpu_down, NULL, cpumask_of(cpu));
- if (err) {
-+ __write_rt_unlock(cpuhp_pin);
- /* CPU refused to die */
- irq_unlock_sparse();
- /* Unpark the hotplug thread so we can rollback there */
-@@ -920,6 +957,7 @@ static int takedown_cpu(unsigned int cpu
- wait_for_ap_thread(st, false);
- BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
-
-+ __write_rt_unlock(cpuhp_pin);
- /* Interrupts are moved away from the dying cpu, reenable alloc/free */
- irq_unlock_sparse();
-
diff --git a/debian/patches-rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch b/debian/patches-rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch
deleted file mode 100644
index b85ad5cf5d0c..000000000000
--- a/debian/patches-rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Thu, 9 Apr 2015 15:23:01 +0200
-Subject: cpufreq: drop K8's driver from beeing selected
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Ralf posted a picture of a backtrace from
-
-| powernowk8_target_fn() -> transition_frequency_fidvid() and then at the
-| end:
-| 932 policy = cpufreq_cpu_get(smp_processor_id());
-| 933 cpufreq_cpu_put(policy);
-
-crashing the system on -RT. I assumed that policy was a NULL pointer but
-was rulled out. Since Ralf can't do any more investigations on this and
-I have no machine with this, I simply switch it off.
-
-Reported-by: Ralf Mardorf <ralf.mardorf@alice-dsl.net>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- drivers/cpufreq/Kconfig.x86 | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/drivers/cpufreq/Kconfig.x86
-+++ b/drivers/cpufreq/Kconfig.x86
-@@ -126,7 +126,7 @@ config X86_POWERNOW_K7_ACPI
-
- config X86_POWERNOW_K8
- tristate "AMD Opteron/Athlon64 PowerNow!"
-- depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ
-+ depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ && !PREEMPT_RT_BASE
- help
- This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.
- Support for K10 and newer processors is now in acpi-cpufreq.
diff --git a/debian/patches-rt/cpumask-disable-offstack-on-rt.patch b/debian/patches-rt/cpumask-disable-offstack-on-rt.patch
index e2edc5470f4d..544ec233fb75 100644
--- a/debian/patches-rt/cpumask-disable-offstack-on-rt.patch
+++ b/debian/patches-rt/cpumask-disable-offstack-on-rt.patch
@@ -1,7 +1,7 @@
Subject: cpumask: Disable CONFIG_CPUMASK_OFFSTACK for RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 14 Dec 2011 01:03:49 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
There are "valid" GFP_ATOMIC allocations such as
@@ -47,22 +47,22 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
-@@ -938,7 +938,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
+@@ -965,7 +965,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
config MAXSMP
bool "Enable Maximum number of SMP Processors and NUMA Nodes"
depends on X86_64 && SMP && DEBUG_KERNEL
- select CPUMASK_OFFSTACK
-+ select CPUMASK_OFFSTACK if !PREEMPT_RT_FULL
++ select CPUMASK_OFFSTACK if !PREEMPT_RT
---help---
Enable maximum number of CPUS and NUMA Nodes for this architecture.
If unsure, say N.
--- a/lib/Kconfig
+++ b/lib/Kconfig
-@@ -469,6 +469,7 @@ config CHECK_SIGNATURE
+@@ -468,6 +468,7 @@ config CHECK_SIGNATURE
config CPUMASK_OFFSTACK
bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
help
Use dynamic allocation for cpumask_var_t, instead of putting
them on the stack. This is a bit more expensive, but avoids
diff --git a/debian/patches-rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch b/debian/patches-rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch
index 5cf67afda117..550aa679e3b8 100644
--- a/debian/patches-rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch
+++ b/debian/patches-rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch
@@ -1,7 +1,7 @@
From: Mike Galbraith <efault@gmx.de>
Date: Sun, 8 Jan 2017 09:32:25 +0100
Subject: [PATCH] cpuset: Convert callback_lock to raw_spinlock_t
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The two commits below add up to a cpuset might_sleep() splat for RT:
@@ -51,16 +51,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
-@@ -333,7 +333,7 @@ static struct cpuset top_cpuset = {
- */
+@@ -345,7 +345,7 @@ void cpuset_read_unlock(void)
+ percpu_up_read(&cpuset_rwsem);
+ }
- static DEFINE_MUTEX(cpuset_mutex);
-static DEFINE_SPINLOCK(callback_lock);
+static DEFINE_RAW_SPINLOCK(callback_lock);
static struct workqueue_struct *cpuset_migrate_mm_wq;
-@@ -1234,7 +1234,7 @@ static int update_parent_subparts_cpumas
+@@ -1255,7 +1255,7 @@ static int update_parent_subparts_cpumas
* Newly added CPUs will be removed from effective_cpus and
* newly deleted ones will be added back to effective_cpus.
*/
@@ -69,7 +69,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (adding) {
cpumask_or(parent->subparts_cpus,
parent->subparts_cpus, tmp->addmask);
-@@ -1253,7 +1253,7 @@ static int update_parent_subparts_cpumas
+@@ -1274,7 +1274,7 @@ static int update_parent_subparts_cpumas
}
parent->nr_subparts_cpus = cpumask_weight(parent->subparts_cpus);
@@ -78,7 +78,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return cmd == partcmd_update;
}
-@@ -1358,7 +1358,7 @@ static void update_cpumasks_hier(struct
+@@ -1379,7 +1379,7 @@ static void update_cpumasks_hier(struct
continue;
rcu_read_unlock();
@@ -87,7 +87,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
cpumask_copy(cp->effective_cpus, tmp->new_cpus);
if (cp->nr_subparts_cpus &&
-@@ -1389,7 +1389,7 @@ static void update_cpumasks_hier(struct
+@@ -1410,7 +1410,7 @@ static void update_cpumasks_hier(struct
= cpumask_weight(cp->subparts_cpus);
}
}
@@ -96,7 +96,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
WARN_ON(!is_in_v2_mode() &&
!cpumask_equal(cp->cpus_allowed, cp->effective_cpus));
-@@ -1507,7 +1507,7 @@ static int update_cpumask(struct cpuset
+@@ -1528,7 +1528,7 @@ static int update_cpumask(struct cpuset
return -EINVAL;
}
@@ -105,7 +105,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
cpumask_copy(cs->cpus_allowed, trialcs->cpus_allowed);
/*
-@@ -1518,7 +1518,7 @@ static int update_cpumask(struct cpuset
+@@ -1539,7 +1539,7 @@ static int update_cpumask(struct cpuset
cs->cpus_allowed);
cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus);
}
@@ -114,7 +114,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
update_cpumasks_hier(cs, &tmp);
-@@ -1712,9 +1712,9 @@ static void update_nodemasks_hier(struct
+@@ -1733,9 +1733,9 @@ static void update_nodemasks_hier(struct
continue;
rcu_read_unlock();
@@ -126,7 +126,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
WARN_ON(!is_in_v2_mode() &&
!nodes_equal(cp->mems_allowed, cp->effective_mems));
-@@ -1782,9 +1782,9 @@ static int update_nodemask(struct cpuset
+@@ -1803,9 +1803,9 @@ static int update_nodemask(struct cpuset
if (retval < 0)
goto done;
@@ -138,7 +138,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* use trialcs->mems_allowed as a temp variable */
update_nodemasks_hier(cs, &trialcs->mems_allowed);
-@@ -1875,9 +1875,9 @@ static int update_flag(cpuset_flagbits_t
+@@ -1896,9 +1896,9 @@ static int update_flag(cpuset_flagbits_t
spread_flag_changed = ((is_spread_slab(cs) != is_spread_slab(trialcs))
|| (is_spread_page(cs) != is_spread_page(trialcs)));
@@ -150,7 +150,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!cpumask_empty(trialcs->cpus_allowed) && balance_flag_changed)
rebuild_sched_domains_locked();
-@@ -2380,7 +2380,7 @@ static int cpuset_common_seq_show(struct
+@@ -2407,7 +2407,7 @@ static int cpuset_common_seq_show(struct
cpuset_filetype_t type = seq_cft(sf)->private;
int ret = 0;
@@ -159,7 +159,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
switch (type) {
case FILE_CPULIST:
-@@ -2402,7 +2402,7 @@ static int cpuset_common_seq_show(struct
+@@ -2429,7 +2429,7 @@ static int cpuset_common_seq_show(struct
ret = -EINVAL;
}
@@ -168,7 +168,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return ret;
}
-@@ -2712,14 +2712,14 @@ static int cpuset_css_online(struct cgro
+@@ -2742,14 +2742,14 @@ static int cpuset_css_online(struct cgro
cpuset_inc();
@@ -185,7 +185,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!test_bit(CGRP_CPUSET_CLONE_CHILDREN, &css->cgroup->flags))
goto out_unlock;
-@@ -2746,12 +2746,12 @@ static int cpuset_css_online(struct cgro
+@@ -2776,12 +2776,12 @@ static int cpuset_css_online(struct cgro
}
rcu_read_unlock();
@@ -198,27 +198,27 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- spin_unlock_irq(&callback_lock);
+ raw_spin_unlock_irq(&callback_lock);
out_unlock:
- mutex_unlock(&cpuset_mutex);
- return 0;
-@@ -2804,7 +2804,7 @@ static void cpuset_css_free(struct cgrou
+ percpu_up_write(&cpuset_rwsem);
+ put_online_cpus();
+@@ -2837,7 +2837,7 @@ static void cpuset_css_free(struct cgrou
static void cpuset_bind(struct cgroup_subsys_state *root_css)
{
- mutex_lock(&cpuset_mutex);
+ percpu_down_write(&cpuset_rwsem);
- spin_lock_irq(&callback_lock);
+ raw_spin_lock_irq(&callback_lock);
if (is_in_v2_mode()) {
cpumask_copy(top_cpuset.cpus_allowed, cpu_possible_mask);
-@@ -2815,7 +2815,7 @@ static void cpuset_bind(struct cgroup_su
+@@ -2848,7 +2848,7 @@ static void cpuset_bind(struct cgroup_su
top_cpuset.mems_allowed = top_cpuset.effective_mems;
}
- spin_unlock_irq(&callback_lock);
+ raw_spin_unlock_irq(&callback_lock);
- mutex_unlock(&cpuset_mutex);
+ percpu_up_write(&cpuset_rwsem);
}
-@@ -2916,12 +2916,12 @@ hotplug_update_tasks_legacy(struct cpuse
+@@ -2945,12 +2945,12 @@ hotplug_update_tasks_legacy(struct cpuse
{
bool is_empty;
@@ -233,7 +233,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Don't call update_tasks_cpumask() if the cpuset becomes empty,
-@@ -2958,10 +2958,10 @@ hotplug_update_tasks(struct cpuset *cs,
+@@ -2987,10 +2987,10 @@ hotplug_update_tasks(struct cpuset *cs,
if (nodes_empty(*new_mems))
*new_mems = parent_cs(cs)->effective_mems;
@@ -246,7 +246,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (cpus_updated)
update_tasks_cpumask(cs);
-@@ -3116,7 +3116,7 @@ static void cpuset_hotplug_workfn(struct
+@@ -3145,7 +3145,7 @@ static void cpuset_hotplug_workfn(struct
/* synchronize cpus_allowed to cpu_active_mask */
if (cpus_updated) {
@@ -255,7 +255,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!on_dfl)
cpumask_copy(top_cpuset.cpus_allowed, &new_cpus);
/*
-@@ -3136,17 +3136,17 @@ static void cpuset_hotplug_workfn(struct
+@@ -3165,17 +3165,17 @@ static void cpuset_hotplug_workfn(struct
}
}
cpumask_copy(top_cpuset.effective_cpus, &new_cpus);
@@ -276,7 +276,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
update_tasks_nodemask(&top_cpuset);
}
-@@ -3247,11 +3247,11 @@ void cpuset_cpus_allowed(struct task_str
+@@ -3276,11 +3276,11 @@ void cpuset_cpus_allowed(struct task_str
{
unsigned long flags;
@@ -290,7 +290,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -3312,11 +3312,11 @@ nodemask_t cpuset_mems_allowed(struct ta
+@@ -3341,11 +3341,11 @@ nodemask_t cpuset_mems_allowed(struct ta
nodemask_t mask;
unsigned long flags;
@@ -304,7 +304,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return mask;
}
-@@ -3408,14 +3408,14 @@ bool __cpuset_node_allowed(int node, gfp
+@@ -3437,14 +3437,14 @@ bool __cpuset_node_allowed(int node, gfp
return true;
/* Not hardwall and node outside mems_allowed: scan up cpusets */
diff --git a/debian/patches-rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch b/debian/patches-rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch
index 43cd09b7b08f..03505afd6bea 100644
--- a/debian/patches-rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch
+++ b/debian/patches-rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 21 Feb 2014 17:24:04 +0100
Subject: crypto: Reduce preempt disabled regions, more algos
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Don Estabrook reported
| kernel: WARNING: CPU: 2 PID: 858 at kernel/sched/core.c:2428 migrate_disable+0xed/0x100()
@@ -39,8 +39,8 @@ Reported-by: Don Estabrook <don.estabrook@gmail.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/x86/crypto/cast5_avx_glue.c | 21 +++++++++------------
- arch/x86/crypto/glue_helper.c | 31 ++++++++++++++++---------------
- 2 files changed, 25 insertions(+), 27 deletions(-)
+ arch/x86/crypto/glue_helper.c | 26 +++++++++++++++-----------
+ 2 files changed, 24 insertions(+), 23 deletions(-)
--- a/arch/x86/crypto/cast5_avx_glue.c
+++ b/arch/x86/crypto/cast5_avx_glue.c
@@ -125,7 +125,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
err = skcipher_walk_done(&walk, 0);
--- a/arch/x86/crypto/glue_helper.c
+++ b/arch/x86/crypto/glue_helper.c
-@@ -23,7 +23,7 @@ int glue_ecb_req_128bit(const struct com
+@@ -24,7 +24,7 @@ int glue_ecb_req_128bit(const struct com
void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
const unsigned int bsize = 128 / 8;
struct skcipher_walk walk;
@@ -134,7 +134,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned int nbytes;
int err;
-@@ -36,7 +36,7 @@ int glue_ecb_req_128bit(const struct com
+@@ -37,7 +37,7 @@ int glue_ecb_req_128bit(const struct com
unsigned int i;
fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
@@ -143,7 +143,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
for (i = 0; i < gctx->num_funcs; i++) {
func_bytes = bsize * gctx->funcs[i].num_blocks;
-@@ -54,10 +54,9 @@ int glue_ecb_req_128bit(const struct com
+@@ -55,10 +55,9 @@ int glue_ecb_req_128bit(const struct com
if (nbytes < bsize)
break;
}
@@ -155,7 +155,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return err;
}
EXPORT_SYMBOL_GPL(glue_ecb_req_128bit);
-@@ -100,7 +99,7 @@ int glue_cbc_decrypt_req_128bit(const st
+@@ -101,7 +100,7 @@ int glue_cbc_decrypt_req_128bit(const st
void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
const unsigned int bsize = 128 / 8;
struct skcipher_walk walk;
@@ -164,7 +164,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned int nbytes;
int err;
-@@ -114,7 +113,7 @@ int glue_cbc_decrypt_req_128bit(const st
+@@ -115,7 +114,7 @@ int glue_cbc_decrypt_req_128bit(const st
u128 last_iv;
fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
@@ -173,7 +173,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Start of the last block. */
src += nbytes / bsize - 1;
dst += nbytes / bsize - 1;
-@@ -146,10 +145,10 @@ int glue_cbc_decrypt_req_128bit(const st
+@@ -147,10 +146,10 @@ int glue_cbc_decrypt_req_128bit(const st
done:
u128_xor(dst, dst, (u128 *)walk.iv);
*(u128 *)walk.iv = last_iv;
@@ -185,7 +185,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return err;
}
EXPORT_SYMBOL_GPL(glue_cbc_decrypt_req_128bit);
-@@ -160,7 +159,7 @@ int glue_ctr_req_128bit(const struct com
+@@ -161,7 +160,7 @@ int glue_ctr_req_128bit(const struct com
void *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
const unsigned int bsize = 128 / 8;
struct skcipher_walk walk;
@@ -194,7 +194,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned int nbytes;
int err;
-@@ -174,7 +173,7 @@ int glue_ctr_req_128bit(const struct com
+@@ -175,7 +174,7 @@ int glue_ctr_req_128bit(const struct com
le128 ctrblk;
fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
@@ -203,7 +203,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
be128_to_le128(&ctrblk, (be128 *)walk.iv);
-@@ -198,11 +197,10 @@ int glue_ctr_req_128bit(const struct com
+@@ -199,11 +198,10 @@ int glue_ctr_req_128bit(const struct com
}
le128_to_be128((be128 *)walk.iv, &ctrblk);
@@ -216,24 +216,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (nbytes) {
le128 ctrblk;
u128 tmp;
-@@ -263,7 +261,7 @@ int glue_xts_req_128bit(const struct com
- {
- const unsigned int bsize = 128 / 8;
- struct skcipher_walk walk;
-- bool fpu_enabled = false;
-+ bool fpu_enabled;
- unsigned int nbytes;
- int err;
-
-@@ -274,21 +272,24 @@ int glue_xts_req_128bit(const struct com
-
- /* set minimum length to bsize, for tweak_fn */
- fpu_enabled = glue_fpu_begin(bsize, gctx->fpu_blocks_limit,
-- &walk, fpu_enabled,
-+ &walk, false,
- nbytes < bsize ? bsize : nbytes);
-
- /* calculate first value of T */
+@@ -301,8 +299,14 @@ int glue_xts_req_128bit(const struct com
tweak_fn(tweak_ctx, walk.iv, walk.iv);
while (nbytes) {
@@ -244,12 +227,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ glue_fpu_end(fpu_enabled);
+ fpu_enabled = false;
++
err = skcipher_walk_done(&walk, nbytes);
nbytes = walk.nbytes;
}
-
-- glue_fpu_end(fpu_enabled);
--
- return err;
- }
- EXPORT_SYMBOL_GPL(glue_xts_req_128bit);
diff --git a/debian/patches-rt/crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch b/debian/patches-rt/crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch
index bbd5e26f16e6..9b4fc7f4f973 100644
--- a/debian/patches-rt/crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch
+++ b/debian/patches-rt/crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 26 Jul 2018 18:52:00 +0200
Subject: [PATCH] crypto: cryptd - add a lock instead
preempt_disable/local_bh_disable
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
cryptd has a per-CPU lock which protected with local_bh_disable() and
preempt_disable().
@@ -20,7 +20,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
-@@ -34,6 +34,7 @@ MODULE_PARM_DESC(cryptd_max_cpu_qlen, "S
+@@ -36,6 +36,7 @@ static struct workqueue_struct *cryptd_w
struct cryptd_cpu_queue {
struct crypto_queue queue;
struct work_struct work;
@@ -28,7 +28,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
};
struct cryptd_queue {
-@@ -103,6 +104,7 @@ static int cryptd_init_queue(struct cryp
+@@ -105,6 +106,7 @@ static int cryptd_init_queue(struct cryp
cpu_queue = per_cpu_ptr(queue->cpu_queue, cpu);
crypto_init_queue(&cpu_queue->queue, max_cpu_qlen);
INIT_WORK(&cpu_queue->work, cryptd_queue_worker);
@@ -36,9 +36,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
pr_info("cryptd: max_cpu_qlen set to %d\n", max_cpu_qlen);
return 0;
-@@ -127,8 +129,10 @@ static int cryptd_enqueue_request(struct
+@@ -129,8 +131,10 @@ static int cryptd_enqueue_request(struct
struct cryptd_cpu_queue *cpu_queue;
- atomic_t *refcnt;
+ refcount_t *refcnt;
- cpu = get_cpu();
- cpu_queue = this_cpu_ptr(queue->cpu_queue);
@@ -49,8 +49,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
err = crypto_enqueue_request(&cpu_queue->queue, request);
refcnt = crypto_tfm_ctx(request->tfm);
-@@ -144,7 +148,7 @@ static int cryptd_enqueue_request(struct
- atomic_inc(refcnt);
+@@ -146,7 +150,7 @@ static int cryptd_enqueue_request(struct
+ refcount_inc(refcnt);
out_put_cpu:
- put_cpu();
@@ -58,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return err;
}
-@@ -160,16 +164,11 @@ static void cryptd_queue_worker(struct w
+@@ -162,16 +166,11 @@ static void cryptd_queue_worker(struct w
cpu_queue = container_of(work, struct cryptd_cpu_queue, work);
/*
* Only handle one request at a time to avoid hogging crypto workqueue.
diff --git a/debian/patches-rt/crypto-limit-more-FPU-enabled-sections.patch b/debian/patches-rt/crypto-limit-more-FPU-enabled-sections.patch
index 935833ce8c75..247df895a819 100644
--- a/debian/patches-rt/crypto-limit-more-FPU-enabled-sections.patch
+++ b/debian/patches-rt/crypto-limit-more-FPU-enabled-sections.patch
@@ -4,7 +4,7 @@ Subject: [PATCH] crypto: limit more FPU-enabled sections
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Those crypto drivers use SSE/AVX/… for their crypto work and in order to
do so in kernel they need to enable the "FPU" in kernel mode which
@@ -37,7 +37,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/x86/crypto/chacha_glue.c
+++ b/arch/x86/crypto/chacha_glue.c
@@ -127,7 +127,6 @@ static int chacha_simd_stream_xor(struct
- struct chacha_ctx *ctx, u8 *iv)
+ const struct chacha_ctx *ctx, const u8 *iv)
{
u32 *state, state_buf[16 + 2] __aligned(8);
- int next_yield = 4096; /* bytes until next FPU yield */
@@ -79,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Use fpregs_lock() while editing CPU's FPU registers or fpu->state.
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
-@@ -134,6 +134,18 @@ void kernel_fpu_end(void)
+@@ -113,6 +113,18 @@ void kernel_fpu_end(void)
}
EXPORT_SYMBOL_GPL(kernel_fpu_end);
diff --git a/debian/patches-rt/debugobjects-rt.patch b/debian/patches-rt/debugobjects-rt.patch
index 1658d88e183f..4833d67daee0 100644
--- a/debian/patches-rt/debugobjects-rt.patch
+++ b/debian/patches-rt/debugobjects-rt.patch
@@ -1,7 +1,7 @@
Subject: debugobjects: Make RT aware
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 17 Jul 2011 21:41:35 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Avoid filling the pool / allocating memory with irqs off().
@@ -12,12 +12,12 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
-@@ -376,7 +376,10 @@ static void
+@@ -533,7 +533,10 @@ static void
struct debug_obj *obj;
unsigned long flags;
- fill_pool();
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (preempt_count() == 0 && !irqs_disabled())
+#endif
+ fill_pool();
diff --git a/debian/patches-rt/dma-buf-Use-seqlock_t-instread-disabling-preemption.patch b/debian/patches-rt/dma-buf-Use-seqlock_t-instread-disabling-preemption.patch
index ef03b75ac0d4..a6f2aa3267ab 100644
--- a/debian/patches-rt/dma-buf-Use-seqlock_t-instread-disabling-preemption.patch
+++ b/debian/patches-rt/dma-buf-Use-seqlock_t-instread-disabling-preemption.patch
@@ -1,10 +1,10 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 14 Aug 2019 16:38:43 +0200
Subject: [PATCH] dma-buf: Use seqlock_t instread disabling preemption
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
"dma reservation" disables preemption while acquiring the write access
-for "seqcount" and then may acquire a spinlock_t.
+for "seqcount".
Replace the seqcount with a seqlock_t which provides seqcount like
semantic and lock for writer.
@@ -13,15 +13,15 @@ Link: https://lkml.kernel.org/r/f410b429-db86-f81c-7c67-f563fa808b62@free.fr
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/dma-buf/dma-buf.c | 8 ++--
- drivers/dma-buf/reservation.c | 40 ++++++++---------------
+ drivers/dma-buf/dma-resv.c | 45 ++++++++---------------
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 6 +--
- drivers/gpu/drm/i915/i915_gem.c | 10 ++---
- include/linux/reservation.h | 4 +-
- 5 files changed, 28 insertions(+), 40 deletions(-)
+ drivers/gpu/drm/i915/gem/i915_gem_busy.c | 6 +--
+ include/linux/dma-resv.h | 4 +-
+ 5 files changed, 27 insertions(+), 42 deletions(-)
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
-@@ -168,7 +168,7 @@ static __poll_t dma_buf_poll(struct file
+@@ -214,7 +214,7 @@ static __poll_t dma_buf_poll(struct file
return 0;
retry:
@@ -30,7 +30,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rcu_read_lock();
fobj = rcu_dereference(resv->fence);
-@@ -177,7 +177,7 @@ static __poll_t dma_buf_poll(struct file
+@@ -223,7 +223,7 @@ static __poll_t dma_buf_poll(struct file
else
shared_count = 0;
fence_excl = rcu_dereference(resv->fence_excl);
@@ -39,7 +39,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rcu_read_unlock();
goto retry;
}
-@@ -1034,12 +1034,12 @@ static int dma_buf_debug_show(struct seq
+@@ -1189,12 +1189,12 @@ static int dma_buf_debug_show(struct seq
robj = buf_obj->resv;
while (true) {
@@ -54,28 +54,33 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
break;
rcu_read_unlock();
}
---- a/drivers/dma-buf/reservation.c
-+++ b/drivers/dma-buf/reservation.c
-@@ -110,15 +110,13 @@ int reservation_object_reserve_shared(st
- new->shared_count = j;
- new->shared_max = max;
+--- a/drivers/dma-buf/dma-resv.c
++++ b/drivers/dma-buf/dma-resv.c
+@@ -49,12 +49,6 @@
+ DEFINE_WD_CLASS(reservation_ww_class);
+ EXPORT_SYMBOL(reservation_ww_class);
-- preempt_disable();
-- write_seqcount_begin(&obj->seq);
-+ write_seqlock(&obj->seq);
- /*
- * RCU_INIT_POINTER can be used here,
- * seqcount provides the necessary barriers
- */
- RCU_INIT_POINTER(obj->fence, new);
-- write_seqcount_end(&obj->seq);
-- preempt_enable();
-+ write_sequnlock(&obj->seq);
+-struct lock_class_key reservation_seqcount_class;
+-EXPORT_SYMBOL(reservation_seqcount_class);
+-
+-const char reservation_seqcount_string[] = "reservation_seqcount";
+-EXPORT_SYMBOL(reservation_seqcount_string);
+-
+ /**
+ * dma_resv_list_alloc - allocate fence list
+ * @shared_max: number of fences we need space for
+@@ -103,8 +97,7 @@ void dma_resv_init(struct dma_resv *obj)
+ {
+ ww_mutex_init(&obj->lock, &reservation_ww_class);
- if (!old)
- return 0;
-@@ -158,8 +156,7 @@ void reservation_object_add_shared_fence
- fobj = reservation_object_get_list(obj);
+- __seqcount_init(&obj->seq, reservation_seqcount_string,
+- &reservation_seqcount_class);
++ seqlock_init(&obj->seq);
+ RCU_INIT_POINTER(obj->fence, NULL);
+ RCU_INIT_POINTER(obj->fence_excl, NULL);
+ }
+@@ -234,8 +227,7 @@ void dma_resv_add_shared_fence(struct dm
+ fobj = dma_resv_get_list(obj);
count = fobj->shared_count;
- preempt_disable();
@@ -83,18 +88,18 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ write_seqlock(&obj->seq);
for (i = 0; i < count; ++i) {
- struct dma_fence *old_fence;
-@@ -181,8 +178,7 @@ void reservation_object_add_shared_fence
+
+@@ -255,8 +247,7 @@ void dma_resv_add_shared_fence(struct dm
/* pointer update must be visible before we extend the shared_count */
smp_store_mb(fobj->shared_count, count);
- write_seqcount_end(&obj->seq);
- preempt_enable();
+ write_sequnlock(&obj->seq);
+ dma_fence_put(old);
}
- EXPORT_SYMBOL(reservation_object_add_shared_fence);
-
-@@ -209,14 +205,11 @@ void reservation_object_add_excl_fence(s
+ EXPORT_SYMBOL(dma_resv_add_shared_fence);
+@@ -283,14 +274,12 @@ void dma_resv_add_excl_fence(struct dma_
if (fence)
dma_fence_get(fence);
@@ -102,6 +107,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- write_seqcount_begin(&obj->seq);
- /* write_seqcount_begin provides the necessary memory barrier */
+ write_seqlock(&obj->seq);
++ /* write_seqlock provides the necessary memory barrier */
RCU_INIT_POINTER(obj->fence_excl, fence);
if (old)
old->shared_count = 0;
@@ -111,23 +117,24 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* inplace update, no shared fences */
while (i--)
-@@ -298,13 +291,10 @@ int reservation_object_copy_fences(struc
- src_list = reservation_object_get_list(dst);
- old = reservation_object_get_excl(dst);
+@@ -368,13 +357,11 @@ int dma_resv_copy_fences(struct dma_resv
+ src_list = dma_resv_get_list(dst);
+ old = dma_resv_get_excl(dst);
- preempt_disable();
- write_seqcount_begin(&dst->seq);
- /* write_seqcount_begin provides the necessary memory barrier */
+ write_seqlock(&dst->seq);
++ /* write_seqlock provides the necessary memory barrier */
RCU_INIT_POINTER(dst->fence_excl, new);
RCU_INIT_POINTER(dst->fence, dst_list);
- write_seqcount_end(&dst->seq);
- preempt_enable();
+ write_sequnlock(&dst->seq);
- if (src_list)
- kfree_rcu(src_list, rcu);
-@@ -345,7 +335,7 @@ int reservation_object_get_fences_rcu(st
+ dma_resv_list_free(src_list);
+ dma_fence_put(old);
+@@ -414,7 +401,7 @@ int dma_resv_get_fences_rcu(struct dma_r
shared_count = i = 0;
rcu_read_lock();
@@ -136,7 +143,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
fence_excl = rcu_dereference(obj->fence_excl);
if (fence_excl && !dma_fence_get_rcu(fence_excl))
-@@ -394,7 +384,7 @@ int reservation_object_get_fences_rcu(st
+@@ -456,7 +443,7 @@ int dma_resv_get_fences_rcu(struct dma_r
}
}
@@ -145,7 +152,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
while (i--)
dma_fence_put(shared[i]);
dma_fence_put(fence_excl);
-@@ -443,7 +433,7 @@ long reservation_object_wait_timeout_rcu
+@@ -507,7 +494,7 @@ long dma_resv_wait_timeout_rcu(struct dm
retry:
shared_count = 0;
@@ -154,7 +161,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rcu_read_lock();
i = -1;
-@@ -490,7 +480,7 @@ long reservation_object_wait_timeout_rcu
+@@ -553,7 +540,7 @@ long dma_resv_wait_timeout_rcu(struct dm
rcu_read_unlock();
if (fence) {
@@ -163,7 +170,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
dma_fence_put(fence);
goto retry;
}
-@@ -546,7 +536,7 @@ bool reservation_object_test_signaled_rc
+@@ -607,7 +594,7 @@ bool dma_resv_test_signaled_rcu(struct d
retry:
ret = true;
shared_count = 0;
@@ -172,7 +179,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (test_all) {
unsigned i;
-@@ -567,7 +557,7 @@ bool reservation_object_test_signaled_rc
+@@ -627,7 +614,7 @@ bool dma_resv_test_signaled_rcu(struct d
break;
}
@@ -181,7 +188,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
goto retry;
}
-@@ -580,7 +570,7 @@ bool reservation_object_test_signaled_rc
+@@ -639,7 +626,7 @@ bool dma_resv_test_signaled_rcu(struct d
if (ret < 0)
goto retry;
@@ -192,7 +199,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
-@@ -250,11 +250,9 @@ static int amdgpu_amdkfd_remove_eviction
+@@ -252,11 +252,9 @@ static int amdgpu_amdkfd_remove_eviction
new->shared_count = k;
/* Install the new fence list, seqcount provides the barriers */
@@ -206,64 +213,50 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Drop the references to the removed fences or move them to ef_list */
for (i = j, k = 0; i < old->shared_count; ++i) {
---- a/drivers/gpu/drm/i915/i915_gem.c
-+++ b/drivers/gpu/drm/i915/i915_gem.c
-@@ -449,7 +449,7 @@ i915_gem_object_wait_reservation(struct
- unsigned int flags,
- long timeout)
- {
-- unsigned int seq = __read_seqcount_begin(&resv->seq);
-+ unsigned int seq = read_seqbegin(&resv->seq);
- struct dma_fence *excl;
- bool prune_fences = false;
+--- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c
++++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c
+@@ -75,7 +75,6 @@ busy_check_writer(const struct dma_fence
-@@ -500,9 +500,9 @@ i915_gem_object_wait_reservation(struct
- * signaled and that the reservation object has not been changed (i.e.
- * no new fences have been added).
- */
-- if (prune_fences && !__read_seqcount_retry(&resv->seq, seq)) {
-+ if (prune_fences && !read_seqretry(&resv->seq, seq)) {
- if (reservation_object_trylock(resv)) {
-- if (!__read_seqcount_retry(&resv->seq, seq))
-+ if (!read_seqretry(&resv->seq, seq))
- reservation_object_add_excl_fence(resv, NULL);
- reservation_object_unlock(resv);
- }
-@@ -3943,7 +3943,7 @@ i915_gem_busy_ioctl(struct drm_device *d
+ return __busy_set_if_active(fence, __busy_write_id);
+ }
+-
+ int
+ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
+ struct drm_file *file)
+@@ -110,7 +109,8 @@ i915_gem_busy_ioctl(struct drm_device *d
*
*/
retry:
-- seq = raw_read_seqcount(&obj->resv->seq);
-+ seq = read_seqbegin(&obj->resv->seq);
+- seq = raw_read_seqcount(&obj->base.resv->seq);
++ /* XXX raw_read_seqcount() does not wait for the WRTIE to finish */
++ seq = read_seqbegin(&obj->base.resv->seq);
/* Translate the exclusive fence to the READ *and* WRITE engine */
- args->busy = busy_check_writer(rcu_dereference(obj->resv->fence_excl));
-@@ -3961,7 +3961,7 @@ i915_gem_busy_ioctl(struct drm_device *d
+ args->busy =
+@@ -129,7 +129,7 @@ i915_gem_busy_ioctl(struct drm_device *d
}
}
-- if (args->busy && read_seqcount_retry(&obj->resv->seq, seq))
-+ if (args->busy && read_seqretry(&obj->resv->seq, seq))
+- if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq))
++ if (args->busy && read_seqretry(&obj->base.resv->seq, seq))
goto retry;
err = 0;
---- a/include/linux/reservation.h
-+++ b/include/linux/reservation.h
-@@ -71,7 +71,7 @@ struct reservation_object_list {
+--- a/include/linux/dma-resv.h
++++ b/include/linux/dma-resv.h
+@@ -65,13 +65,13 @@ struct dma_resv_list {
+ /**
+ * struct dma_resv - a reservation object manages fences for a buffer
+ * @lock: update side lock
+- * @seq: sequence count for managing RCU read-side synchronization
++ * @seq: sequence lock for managing RCU read-side synchronization
+ * @fence_excl: the exclusive fence, if there is one currently
+ * @fence: list of current shared fences
*/
- struct reservation_object {
+ struct dma_resv {
struct ww_mutex lock;
- seqcount_t seq;
+ seqlock_t seq;
struct dma_fence __rcu *fence_excl;
- struct reservation_object_list __rcu *fence;
-@@ -90,7 +90,7 @@ reservation_object_init(struct reservati
- {
- ww_mutex_init(&obj->lock, &reservation_ww_class);
-
-- __seqcount_init(&obj->seq, reservation_seqcount_string, &reservation_seqcount_class);
-+ seqlock_init(&obj->seq);
- RCU_INIT_POINTER(obj->fence, NULL);
- RCU_INIT_POINTER(obj->fence_excl, NULL);
- }
+ struct dma_resv_list __rcu *fence;
diff --git a/debian/patches-rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch b/debian/patches-rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
index f29c915f3886..2514420d294f 100644
--- a/debian/patches-rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
+++ b/debian/patches-rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
@@ -2,7 +2,7 @@ From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Thu, 31 Mar 2016 04:08:28 +0200
Subject: [PATCH] drivers/block/zram: Replace bit spinlocks with rtmutex
for -rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
They're nondeterministic, and lead to ___might_sleep() splats in -rt.
OTOH, they're a lot less wasteful than an rtmutex per page.
@@ -20,7 +20,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
u32 index, int offset, struct bio *bio);
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+static void zram_meta_init_table_locks(struct zram *zram, size_t num_pages)
+{
+ size_t index;
@@ -65,7 +65,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline bool init_done(struct zram *zram)
{
-@@ -1154,6 +1189,7 @@ static bool zram_meta_alloc(struct zram
+@@ -1155,6 +1190,7 @@ static bool zram_meta_alloc(struct zram
if (!huge_class_size)
huge_class_size = zs_huge_class_size(zram->mem_pool);
diff --git a/debian/patches-rt/drivers-tty-fix-omap-lock-crap.patch b/debian/patches-rt/drivers-tty-fix-omap-lock-crap.patch
index 8841f827ba7a..791eef14a089 100644
--- a/debian/patches-rt/drivers-tty-fix-omap-lock-crap.patch
+++ b/debian/patches-rt/drivers-tty-fix-omap-lock-crap.patch
@@ -1,7 +1,7 @@
Subject: tty/serial/omap: Make the locking RT aware
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 28 Jul 2011 13:32:57 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The lock is a sleeping lock and local_irq_save() is not the
optimsation we are looking for. Redo it to make it work on -RT and
diff --git a/debian/patches-rt/drivers-tty-pl011-irq-disable-madness.patch b/debian/patches-rt/drivers-tty-pl011-irq-disable-madness.patch
index 0a45ead46550..c32cfba70e65 100644
--- a/debian/patches-rt/drivers-tty-pl011-irq-disable-madness.patch
+++ b/debian/patches-rt/drivers-tty-pl011-irq-disable-madness.patch
@@ -1,7 +1,7 @@
Subject: tty/serial/pl011: Make the locking work on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 08 Jan 2013 21:36:51 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The lock is a sleeping lock and local_irq_save() is not the optimsation
we are looking for. Redo it to make it work on -RT and non-RT.
@@ -13,7 +13,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
-@@ -2216,13 +2216,19 @@ pl011_console_write(struct console *co,
+@@ -2214,13 +2214,19 @@ pl011_console_write(struct console *co,
clk_enable(uap->clk);
@@ -36,7 +36,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* First save the CR then disable the interrupts
-@@ -2248,8 +2254,7 @@ pl011_console_write(struct console *co,
+@@ -2246,8 +2252,7 @@ pl011_console_write(struct console *co,
pl011_write(old_cr, uap, REG_CR);
if (locked)
diff --git a/debian/patches-rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch b/debian/patches-rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch
index 2b6aadcfb896..9387dccc7bc4 100644
--- a/debian/patches-rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch
+++ b/debian/patches-rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch
@@ -2,7 +2,7 @@ From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Thu, 20 Oct 2016 11:15:22 +0200
Subject: [PATCH] drivers/zram: Don't disable preemption in
zcomp_stream_get/put()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
In v4.7, the driver switched to percpu compression streams, disabling
preemption via get/put_cpu_ptr(). Use a per-zcomp_strm lock here. We
@@ -64,7 +64,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* dynamic per-device compression frontend */
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
-@@ -1252,6 +1252,7 @@ static int __zram_bvec_read(struct zram
+@@ -1253,6 +1253,7 @@ static int __zram_bvec_read(struct zram
unsigned long handle;
unsigned int size;
void *src, *dst;
@@ -72,7 +72,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
zram_slot_lock(zram, index);
if (zram_test_flag(zram, index, ZRAM_WB)) {
-@@ -1282,6 +1283,7 @@ static int __zram_bvec_read(struct zram
+@@ -1283,6 +1284,7 @@ static int __zram_bvec_read(struct zram
size = zram_get_obj_size(zram, index);
@@ -80,7 +80,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
src = zs_map_object(zram->mem_pool, handle, ZS_MM_RO);
if (size == PAGE_SIZE) {
dst = kmap_atomic(page);
-@@ -1289,14 +1291,13 @@ static int __zram_bvec_read(struct zram
+@@ -1290,14 +1292,13 @@ static int __zram_bvec_read(struct zram
kunmap_atomic(dst);
ret = 0;
} else {
diff --git a/debian/patches-rt/drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch b/debian/patches-rt/drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch
index a54bf1710f99..2dd57b8e136a 100644
--- a/debian/patches-rt/drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch
+++ b/debian/patches-rt/drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch
@@ -1,8 +1,8 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 25 Sep 2019 16:04:11 +0200
+Date: Thu, 26 Sep 2019 12:29:05 +0200
Subject: [PATCH] drm/i915: Don't disable interrupts for
intel_engine_breadcrumbs_irq()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The function intel_engine_breadcrumbs_irq() is always invoked from an interrupt
handler and for that reason it invokes (as an optimisation) only spin_lock()
@@ -12,7 +12,7 @@ interrupts while the former function is invoked so that assumption is
also true for callers from preemptible context.
On PREEMPT_RT local_irq_disable() really disables interrupts and this
-forbids to acquire spin_lock() which becomes a sleeping spinlock.
+forbids to invoke spin_lock() which becomes a sleeping spinlock.
This is also problematic with `threadirqs' in conjunction with
irq_work. With force threading the interrupt handler, the handler is
@@ -29,26 +29,15 @@ directly instead using intel_engine_signal_breadcrumbs().
Reported-by: Clark Williams <williams@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- drivers/gpu/drm/i915/i915_reset.c | 2 +-
- drivers/gpu/drm/i915/intel_breadcrumbs.c | 16 +++++-----------
- drivers/gpu/drm/i915/intel_hangcheck.c | 2 +-
- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 -
+ drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 16 +++++-----------
+ drivers/gpu/drm/i915/gt/intel_engine.h | 1 -
+ drivers/gpu/drm/i915/gt/intel_hangcheck.c | 2 +-
+ drivers/gpu/drm/i915/gt/intel_reset.c | 2 +-
4 files changed, 7 insertions(+), 14 deletions(-)
---- a/drivers/gpu/drm/i915/i915_reset.c
-+++ b/drivers/gpu/drm/i915/i915_reset.c
-@@ -804,7 +804,7 @@ static void reset_finish(struct drm_i915
-
- for_each_engine(engine, i915, id) {
- reset_finish_engine(engine);
-- intel_engine_signal_breadcrumbs(engine);
-+ intel_engine_breadcrumbs_irq(engine);
- }
- }
-
---- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
-+++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
-@@ -116,9 +116,10 @@ void intel_engine_breadcrumbs_irq(struct
+--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
++++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+@@ -134,9 +134,10 @@ void intel_engine_breadcrumbs_irq(struct
const ktime_t timestamp = ktime_get();
struct intel_context *ce, *cn;
struct list_head *pos, *next;
@@ -60,7 +49,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (b->irq_armed && list_empty(&b->signalers))
__intel_breadcrumbs_disarm_irq(b);
-@@ -162,7 +163,7 @@ void intel_engine_breadcrumbs_irq(struct
+@@ -182,30 +183,23 @@ void intel_engine_breadcrumbs_irq(struct
}
}
@@ -69,13 +58,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_for_each_safe(pos, next, &signal) {
struct i915_request *rq =
-@@ -170,21 +171,14 @@ void intel_engine_breadcrumbs_irq(struct
-
- __dma_fence_signal__timestamp(&rq->fence, timestamp);
+ list_entry(pos, typeof(*rq), signal_link);
+ struct list_head cb_list;
- spin_lock(&rq->lock);
+ spin_lock_irqsave(&rq->lock, flags);
- __dma_fence_signal__notify(&rq->fence);
+ list_replace(&rq->fence.cb_list, &cb_list);
+ __dma_fence_signal__timestamp(&rq->fence, timestamp);
+ __dma_fence_signal__notify(&rq->fence, &cb_list);
- spin_unlock(&rq->lock);
+ spin_unlock_irqrestore(&rq->lock, flags);
@@ -93,10 +83,20 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void signal_irq_work(struct irq_work *work)
{
struct intel_engine_cs *engine =
---- a/drivers/gpu/drm/i915/intel_hangcheck.c
-+++ b/drivers/gpu/drm/i915/intel_hangcheck.c
-@@ -275,7 +275,7 @@ static void i915_hangcheck_elapsed(struc
- for_each_engine(engine, dev_priv, id) {
+--- a/drivers/gpu/drm/i915/gt/intel_engine.h
++++ b/drivers/gpu/drm/i915/gt/intel_engine.h
+@@ -349,7 +349,6 @@ void intel_engine_init_execlists(struct
+ void intel_engine_init_breadcrumbs(struct intel_engine_cs *engine);
+ void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
+
+-void intel_engine_signal_breadcrumbs(struct intel_engine_cs *engine);
+ void intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine);
+
+ static inline void
+--- a/drivers/gpu/drm/i915/gt/intel_hangcheck.c
++++ b/drivers/gpu/drm/i915/gt/intel_hangcheck.c
+@@ -283,7 +283,7 @@ static void hangcheck_elapsed(struct wor
+ for_each_engine(engine, gt->i915, id) {
struct hangcheck hc;
- intel_engine_signal_breadcrumbs(engine);
@@ -104,13 +104,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
hangcheck_load_sample(engine, &hc);
hangcheck_accumulate_sample(engine, &hc);
---- a/drivers/gpu/drm/i915/intel_ringbuffer.h
-+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
-@@ -388,7 +388,6 @@ void intel_engine_fini_breadcrumbs(struc
- void intel_engine_pin_breadcrumbs_irq(struct intel_engine_cs *engine);
- void intel_engine_unpin_breadcrumbs_irq(struct intel_engine_cs *engine);
+--- a/drivers/gpu/drm/i915/gt/intel_reset.c
++++ b/drivers/gpu/drm/i915/gt/intel_reset.c
+@@ -695,7 +695,7 @@ static void reset_finish_engine(struct i
+ engine->reset.finish(engine);
+ intel_uncore_forcewake_put(engine->uncore, FORCEWAKE_ALL);
--void intel_engine_signal_breadcrumbs(struct intel_engine_cs *engine);
- void intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine);
+- intel_engine_signal_breadcrumbs(engine);
++ intel_engine_breadcrumbs_irq(engine);
+ }
- static inline void
+ static void reset_finish(struct intel_gt *gt, intel_engine_mask_t awake)
diff --git a/debian/patches-rt/drm-i915-Don-t-disable-interrupts-independently-of-t.patch b/debian/patches-rt/drm-i915-Don-t-disable-interrupts-independently-of-t.patch
index d03217e4d454..c61307a9ff9d 100644
--- a/debian/patches-rt/drm-i915-Don-t-disable-interrupts-independently-of-t.patch
+++ b/debian/patches-rt/drm-i915-Don-t-disable-interrupts-independently-of-t.patch
@@ -2,43 +2,70 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 10 Apr 2019 11:01:37 +0200
Subject: [PATCH] drm/i915: Don't disable interrupts independently of the
lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-The locks (timeline->lock and rq->lock) need to be taken with disabled
-interrupts. This is done in __retire_engine_request() by disabling the
+The locks (active.lock and rq->lock) need to be taken with disabled
+interrupts. This is done in i915_request_retire() by disabling the
interrupts independently of the locks itself.
While local_irq_disable()+spin_lock() equals spin_lock_irq() on vanilla
-it does not on RT. Also, it is not obvious if there is a special reason
-to why the interrupts are disabled independently of the lock.
+it does not on PREEMPT_RT.
+Chris Wilson confirmed that local_irq_disable() was just introduced as
+an optimisation to avoid enabling/disabling interrupts during
+lock/unlock combo.
Enable/disable interrupts as part of the locking instruction.
+Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- drivers/gpu/drm/i915/i915_request.c | 8 ++------
- 1 file changed, 2 insertions(+), 6 deletions(-)
+ drivers/gpu/drm/i915/i915_request.c | 12 ++++--------
+ 1 file changed, 4 insertions(+), 8 deletions(-)
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
-@@ -202,9 +202,7 @@ static void __retire_engine_request(stru
+@@ -205,14 +205,14 @@ static void remove_from_engine(struct i9
+ * check that the rq still belongs to the newly locked engine.
+ */
+ locked = READ_ONCE(rq->engine);
+- spin_lock(&locked->active.lock);
++ spin_lock_irq(&locked->active.lock);
+ while (unlikely(locked != (engine = READ_ONCE(rq->engine)))) {
+ spin_unlock(&locked->active.lock);
+ spin_lock(&engine->active.lock);
+ locked = engine;
+ }
+ list_del(&rq->sched.link);
+- spin_unlock(&locked->active.lock);
++ spin_unlock_irq(&locked->active.lock);
+ }
- GEM_BUG_ON(!i915_request_completed(rq));
+ static bool i915_request_retire(struct i915_request *rq)
+@@ -272,8 +272,6 @@ static bool i915_request_retire(struct i
+ active->retire(active, rq);
+ }
- local_irq_disable();
-
-- spin_lock(&engine->timeline.lock);
-+ spin_lock_irq(&engine->timeline.lock);
- GEM_BUG_ON(!list_is_first(&rq->link, &engine->timeline.requests));
- list_del_init(&rq->link);
- spin_unlock(&engine->timeline.lock);
-@@ -219,9 +217,7 @@ static void __retire_engine_request(stru
- GEM_BUG_ON(!atomic_read(&rq->i915->gt_pm.rps.num_waiters));
- atomic_dec(&rq->i915->gt_pm.rps.num_waiters);
+ /*
+ * We only loosely track inflight requests across preemption,
+ * and so we may find ourselves attempting to retire a _completed_
+@@ -282,7 +280,7 @@ static bool i915_request_retire(struct i
+ */
+ remove_from_engine(rq);
+
+- spin_lock(&rq->lock);
++ spin_lock_irq(&rq->lock);
+ i915_request_mark_complete(rq);
+ if (!i915_request_signaled(rq))
+ dma_fence_signal_locked(&rq->fence);
+@@ -297,9 +295,7 @@ static bool i915_request_retire(struct i
+ __notify_execute_cb(rq);
}
+ GEM_BUG_ON(!list_empty(&rq->execute_cb));
- spin_unlock(&rq->lock);
-
- local_irq_enable();
+ spin_unlock_irq(&rq->lock);
- /*
- * The backing object for the context is done after switching to the
+ remove_from_client(rq);
+ list_del(&rq->link);
diff --git a/debian/patches-rt/drm-i915-Drop-the-IRQ-off-asserts.patch b/debian/patches-rt/drm-i915-Drop-the-IRQ-off-asserts.patch
index 17af1141947b..2ce13a4d54f1 100644
--- a/debian/patches-rt/drm-i915-Drop-the-IRQ-off-asserts.patch
+++ b/debian/patches-rt/drm-i915-Drop-the-IRQ-off-asserts.patch
@@ -1,12 +1,12 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Thu, 26 Sep 2019 09:31:06 +0200
+Date: Thu, 26 Sep 2019 12:30:21 +0200
Subject: [PATCH] drm/i915: Drop the IRQ-off asserts
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The lockdep_assert_irqs_disabled() check is needless. The previous
-lockdep_assert_held() check ensures that the lock is acquired and that
-time lockdep also prints a warning if the interrupts are not disabled if
-they have to be.
+lockdep_assert_held() check ensures that the lock is acquired and while
+the lock is acquired lockdep also prints a warning if the interrupts are
+not disabled if they have to be.
These IRQ-off asserts trigger on PREEMPT_RT because the locks become
sleeping locks and do not really disable interrupts.
@@ -15,20 +15,20 @@ Remove lockdep_assert_irqs_disabled().
Reported-by: Clark Williams <williams@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- drivers/gpu/drm/i915/intel_breadcrumbs.c | 3 ---
+ drivers/gpu/drm/i915/gt/intel_breadcrumbs.c | 3 ---
1 file changed, 3 deletions(-)
---- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
-+++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
-@@ -101,7 +101,6 @@ static void
+--- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
++++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
+@@ -120,7 +120,6 @@ static void
struct dma_fence_cb *cur, *tmp;
lockdep_assert_held(fence->lock);
- lockdep_assert_irqs_disabled();
- list_for_each_entry_safe(cur, tmp, &fence->cb_list, node) {
+ list_for_each_entry_safe(cur, tmp, list, node) {
INIT_LIST_HEAD(&cur->node);
-@@ -270,7 +269,6 @@ void intel_engine_fini_breadcrumbs(struc
+@@ -269,7 +268,6 @@ void intel_engine_fini_breadcrumbs(struc
bool i915_request_enable_breadcrumb(struct i915_request *rq)
{
lockdep_assert_held(&rq->lock);
diff --git a/debian/patches-rt/drm-i915-disable-tracing-on-RT.patch b/debian/patches-rt/drm-i915-disable-tracing-on-RT.patch
index fc788947a161..f931fc50b303 100644
--- a/debian/patches-rt/drm-i915-disable-tracing-on-RT.patch
+++ b/debian/patches-rt/drm-i915-disable-tracing-on-RT.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 6 Dec 2018 09:52:20 +0100
Subject: [PATCH] drm/i915: disable tracing on -RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Luca Abeni reported this:
| BUG: scheduling while atomic: kworker/u8:2/15203/0x00000003
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#if !defined(_I915_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _I915_TRACE_H_
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+#define NOTRACE
+#endif
+
diff --git a/debian/patches-rt/drm-i915-skip-DRM_I915_LOW_LEVEL_TRACEPOINTS-with-NO.patch b/debian/patches-rt/drm-i915-skip-DRM_I915_LOW_LEVEL_TRACEPOINTS-with-NO.patch
index b0eda8903e79..d287154d8d03 100644
--- a/debian/patches-rt/drm-i915-skip-DRM_I915_LOW_LEVEL_TRACEPOINTS-with-NO.patch
+++ b/debian/patches-rt/drm-i915-skip-DRM_I915_LOW_LEVEL_TRACEPOINTS-with-NO.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 19 Dec 2018 10:47:02 +0100
Subject: [PATCH] drm/i915: skip DRM_I915_LOW_LEVEL_TRACEPOINTS with NOTRACE
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The order of the header files is important. If this header file is
included after tracepoint.h was included then the NOTRACE here becomes a
@@ -15,7 +15,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
-@@ -733,7 +733,7 @@ DEFINE_EVENT(i915_request, i915_request_
+@@ -725,7 +725,7 @@ DEFINE_EVENT(i915_request, i915_request_
TP_ARGS(rq)
);
diff --git a/debian/patches-rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch b/debian/patches-rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch
index 73cbfb2567c1..932bc67d59c2 100644
--- a/debian/patches-rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch
+++ b/debian/patches-rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch
@@ -1,7 +1,7 @@
Subject: drm,i915: Use local_lock/unlock_irq() in intel_pipe_update_start/end()
From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Sat, 27 Feb 2016 09:01:42 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
[ 8.014039] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:918
@@ -57,11 +57,11 @@ Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- drivers/gpu/drm/i915/intel_sprite.c | 13 ++++++++-----
+ drivers/gpu/drm/i915/display/intel_sprite.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
---- a/drivers/gpu/drm/i915/intel_sprite.c
-+++ b/drivers/gpu/drm/i915/intel_sprite.c
+--- a/drivers/gpu/drm/i915/display/intel_sprite.c
++++ b/drivers/gpu/drm/i915/display/intel_sprite.c
@@ -38,6 +38,7 @@
#include <drm/drm_plane_helper.h>
#include <drm/drm_rect.h>
@@ -69,8 +69,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+#include <linux/locallock.h>
#include "i915_drv.h"
- #include "intel_atomic_plane.h"
-@@ -79,6 +80,8 @@ int intel_usecs_to_scanlines(const struc
+ #include "i915_trace.h"
+@@ -80,6 +81,8 @@ int intel_usecs_to_scanlines(const struc
#define VBLANK_EVASION_TIME_US 100
#endif
@@ -79,7 +79,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/**
* intel_pipe_update_start() - start update of a set of display registers
* @new_crtc_state: the new crtc state
-@@ -128,7 +131,7 @@ void intel_pipe_update_start(const struc
+@@ -129,7 +132,7 @@ void intel_pipe_update_start(const struc
DRM_ERROR("PSR idle timed out 0x%x, atomic update may fail\n",
psr_status);
@@ -88,7 +88,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
crtc->debug.min_vbl = min;
crtc->debug.max_vbl = max;
-@@ -152,11 +155,11 @@ void intel_pipe_update_start(const struc
+@@ -153,11 +156,11 @@ void intel_pipe_update_start(const struc
break;
}
@@ -102,7 +102,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
finish_wait(wq, &wait);
-@@ -189,7 +192,7 @@ void intel_pipe_update_start(const struc
+@@ -190,7 +193,7 @@ void intel_pipe_update_start(const struc
return;
irq_disable:
@@ -111,7 +111,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
/**
-@@ -225,7 +228,7 @@ void intel_pipe_update_end(struct intel_
+@@ -226,7 +229,7 @@ void intel_pipe_update_end(struct intel_
new_crtc_state->base.event = NULL;
}
diff --git a/debian/patches-rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch b/debian/patches-rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch
index 0978a960ffd3..cf35af44c836 100644
--- a/debian/patches-rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch
+++ b/debian/patches-rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch
@@ -1,7 +1,7 @@
Subject: drm,radeon,i915: Use preempt_disable/enable_rt() where recommended
From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Sat, 27 Feb 2016 08:09:11 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
DRM folks identified the spots, so use them.
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
-@@ -1100,6 +1100,7 @@ static bool i915_get_crtc_scanoutpos(str
+@@ -983,6 +983,7 @@ bool i915_get_crtc_scanoutpos(struct drm
spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/* Get optional system timestamp before query. */
if (stime)
-@@ -1151,6 +1152,7 @@ static bool i915_get_crtc_scanoutpos(str
+@@ -1034,6 +1035,7 @@ bool i915_get_crtc_scanoutpos(struct drm
*etime = ktime_get();
/* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
@@ -34,7 +34,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
-@@ -1814,6 +1814,7 @@ int radeon_get_crtc_scanoutpos(struct dr
+@@ -1819,6 +1819,7 @@ int radeon_get_crtc_scanoutpos(struct dr
struct radeon_device *rdev = dev->dev_private;
/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
@@ -42,7 +42,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/* Get optional system timestamp before query. */
if (stime)
-@@ -1906,6 +1907,7 @@ int radeon_get_crtc_scanoutpos(struct dr
+@@ -1911,6 +1912,7 @@ int radeon_get_crtc_scanoutpos(struct dr
*etime = ktime_get();
/* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */
diff --git a/debian/patches-rt/efi-Allow-efi-runtime.patch b/debian/patches-rt/efi-Allow-efi-runtime.patch
index cd14028f6a6f..83bb2643e5b7 100644
--- a/debian/patches-rt/efi-Allow-efi-runtime.patch
+++ b/debian/patches-rt/efi-Allow-efi-runtime.patch
@@ -1,10 +1,10 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 26 Jul 2018 15:06:10 +0200
Subject: [PATCH] efi: Allow efi=runtime
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-In case the option "efi=noruntime" is default at built-time, the user
-could overwrite its sate by `efi=runtime' and allow it again.
+In case the command line option "efi=noruntime" is default at built-time, the user
+could overwrite its state by `efi=runtime' and allow it again.
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
-@@ -113,6 +113,9 @@ static int __init parse_efi_cmdline(char
+@@ -94,6 +94,9 @@ static int __init parse_efi_cmdline(char
if (parse_option_str(str, "noruntime"))
disable_runtime = true;
diff --git a/debian/patches-rt/efi-Disable-runtime-services-on-RT.patch b/debian/patches-rt/efi-Disable-runtime-services-on-RT.patch
index 1b2e9574ff53..a01cfbe45bfd 100644
--- a/debian/patches-rt/efi-Disable-runtime-services-on-RT.patch
+++ b/debian/patches-rt/efi-Disable-runtime-services-on-RT.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 26 Jul 2018 15:03:16 +0200
Subject: [PATCH] efi: Disable runtime services on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Based on meassurements the EFI functions get_variable /
get_next_variable take up to 2us which looks okay.
@@ -29,12 +29,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
-@@ -87,7 +87,7 @@ struct mm_struct efi_mm = {
+@@ -68,7 +68,7 @@ struct mm_struct efi_mm = {
struct workqueue_struct *efi_rts_wq;
-static bool disable_runtime;
-+static bool disable_runtime = IS_ENABLED(CONFIG_PREEMPT_RT_BASE);
++static bool disable_runtime = IS_ENABLED(CONFIG_PREEMPT_RT);
static int __init setup_noefi(char *arg)
{
disable_runtime = true;
diff --git a/debian/patches-rt/epoll-use-get-cpu-light.patch b/debian/patches-rt/epoll-use-get-cpu-light.patch
index d9595c8fc046..d7ef7803c748 100644
--- a/debian/patches-rt/epoll-use-get-cpu-light.patch
+++ b/debian/patches-rt/epoll-use-get-cpu-light.patch
@@ -1,7 +1,7 @@
Subject: fs/epoll: Do not disable preemption on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 08 Jul 2011 16:35:35 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
ep_call_nested() takes a sleeping lock so we can't disable preemption.
The light version is enough since ep_call_nested() doesn't mind beeing
diff --git a/debian/patches-rt/fs-aio-simple-simple-work.patch b/debian/patches-rt/fs-aio-simple-simple-work.patch
deleted file mode 100644
index 379a19c54051..000000000000
--- a/debian/patches-rt/fs-aio-simple-simple-work.patch
+++ /dev/null
@@ -1,67 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Mon, 16 Feb 2015 18:49:10 +0100
-Subject: fs/aio: simple simple work
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:768
-|in_atomic(): 1, irqs_disabled(): 0, pid: 26, name: rcuos/2
-|2 locks held by rcuos/2/26:
-| #0: (rcu_callback){.+.+..}, at: [<ffffffff810b1a12>] rcu_nocb_kthread+0x1e2/0x380
-| #1: (rcu_read_lock_sched){.+.+..}, at: [<ffffffff812acd26>] percpu_ref_kill_rcu+0xa6/0x1c0
-|Preemption disabled at:[<ffffffff810b1a93>] rcu_nocb_kthread+0x263/0x380
-|Call Trace:
-| [<ffffffff81582e9e>] dump_stack+0x4e/0x9c
-| [<ffffffff81077aeb>] __might_sleep+0xfb/0x170
-| [<ffffffff81589304>] rt_spin_lock+0x24/0x70
-| [<ffffffff811c5790>] free_ioctx_users+0x30/0x130
-| [<ffffffff812ace34>] percpu_ref_kill_rcu+0x1b4/0x1c0
-| [<ffffffff810b1a93>] rcu_nocb_kthread+0x263/0x380
-| [<ffffffff8106e046>] kthread+0xd6/0xf0
-| [<ffffffff81591eec>] ret_from_fork+0x7c/0xb0
-
-replace this preempt_disable() friendly swork.
-
-Reported-By: Mike Galbraith <umgwanakikbuti@gmail.com>
-Suggested-by: Benjamin LaHaise <bcrl@kvack.org>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- fs/aio.c | 13 +++++++++++--
- 1 file changed, 11 insertions(+), 2 deletions(-)
-
---- a/fs/aio.c
-+++ b/fs/aio.c
-@@ -127,6 +127,7 @@ struct kioctx {
- long nr_pages;
-
- struct rcu_work free_rwork; /* see free_ioctx() */
-+ struct work_struct free_work; /* see free_ioctx() */
-
- /*
- * signals when all in-flight requests are done
-@@ -612,9 +613,9 @@ static void free_ioctx_reqs(struct percp
- * and ctx->users has dropped to 0, so we know no more kiocbs can be submitted -
- * now it's safe to cancel any that need to be.
- */
--static void free_ioctx_users(struct percpu_ref *ref)
-+static void free_ioctx_users_work(struct work_struct *work)
- {
-- struct kioctx *ctx = container_of(ref, struct kioctx, users);
-+ struct kioctx *ctx = container_of(work, struct kioctx, free_work);
- struct aio_kiocb *req;
-
- spin_lock_irq(&ctx->ctx_lock);
-@@ -632,6 +633,14 @@ static void free_ioctx_users(struct perc
- percpu_ref_put(&ctx->reqs);
- }
-
-+static void free_ioctx_users(struct percpu_ref *ref)
-+{
-+ struct kioctx *ctx = container_of(ref, struct kioctx, users);
-+
-+ INIT_WORK(&ctx->free_work, free_ioctx_users_work);
-+ schedule_work(&ctx->free_work);
-+}
-+
- static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm)
- {
- unsigned i, new_nr;
diff --git a/debian/patches-rt/fs-buffer-Make-BH_Uptodate_Lock-bit_spin_lock-a-regu.patch b/debian/patches-rt/fs-buffer-Make-BH_Uptodate_Lock-bit_spin_lock-a-regu.patch
new file mode 100644
index 000000000000..3669e87b26ff
--- /dev/null
+++ b/debian/patches-rt/fs-buffer-Make-BH_Uptodate_Lock-bit_spin_lock-a-regu.patch
@@ -0,0 +1,193 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 15 Nov 2019 18:54:20 +0100
+Subject: [PATCH] fs/buffer: Make BH_Uptodate_Lock bit_spin_lock a regular
+ spinlock_t
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Bit spinlocks are problematic if PREEMPT_RT is enabled, because they
+disable preemption, which is undesired for latency reasons and breaks when
+regular spinlocks are taken within the bit_spinlock locked region because
+regular spinlocks are converted to 'sleeping spinlocks' on RT. So RT
+replaces the bit spinlocks with regular spinlocks to avoid this problem.
+Bit spinlocks are also not covered by lock debugging, e.g. lockdep.
+
+Substitute the BH_Uptodate_Lock bit spinlock with a regular spinlock.
+
+Reviewed-by: Jan Kara <jack@suse.cz>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+[bigeasy: remove the wrapper and use always spinlock_t and move it into
+ the padding hole]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+v2…v3: rename uptodate_lock to b_uptodate_lock.
+
+v1…v2: Move the spinlock_t to the padding hole as per Jan Kara. pahole says
+its total size remained unchanged, before
+
+| atomic_t b_count; /* 96 4 */
+|
+| /* size: 104, cachelines: 2, members: 12 */
+| /* padding: 4 */
+| /* last cacheline: 40 bytes */
+
+after
+
+| atomic_t b_count; /* 96 4 */
+| spinlock_t uptodate_lock; /* 100 4 */
+|
+| /* size: 104, cachelines: 2, members: 13 */
+| /* last cacheline: 40 bytes */
+
+ fs/buffer.c | 19 +++++++------------
+ fs/ext4/page-io.c | 8 +++-----
+ fs/ntfs/aops.c | 9 +++------
+ include/linux/buffer_head.h | 6 +++---
+ 4 files changed, 16 insertions(+), 26 deletions(-)
+
+--- a/fs/buffer.c
++++ b/fs/buffer.c
+@@ -275,8 +275,7 @@ static void end_buffer_async_read(struct
+ * decide that the page is now completely done.
+ */
+ first = page_buffers(page);
+- local_irq_save(flags);
+- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
++ spin_lock_irqsave(&first->b_uptodate_lock, flags);
+ clear_buffer_async_read(bh);
+ unlock_buffer(bh);
+ tmp = bh;
+@@ -289,8 +288,7 @@ static void end_buffer_async_read(struct
+ }
+ tmp = tmp->b_this_page;
+ } while (tmp != bh);
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+
+ /*
+ * If none of the buffers had errors and they are all
+@@ -302,8 +300,7 @@ static void end_buffer_async_read(struct
+ return;
+
+ still_busy:
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+ return;
+ }
+
+@@ -331,8 +328,7 @@ void end_buffer_async_write(struct buffe
+ }
+
+ first = page_buffers(page);
+- local_irq_save(flags);
+- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
++ spin_lock_irqsave(&first->b_uptodate_lock, flags);
+
+ clear_buffer_async_write(bh);
+ unlock_buffer(bh);
+@@ -344,14 +340,12 @@ void end_buffer_async_write(struct buffe
+ }
+ tmp = tmp->b_this_page;
+ }
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+ end_page_writeback(page);
+ return;
+
+ still_busy:
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+ return;
+ }
+ EXPORT_SYMBOL(end_buffer_async_write);
+@@ -3368,6 +3362,7 @@ struct buffer_head *alloc_buffer_head(gf
+ struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
+ if (ret) {
+ INIT_LIST_HEAD(&ret->b_assoc_buffers);
++ spin_lock_init(&ret->b_uptodate_lock);
+ preempt_disable();
+ __this_cpu_inc(bh_accounting.nr);
+ recalc_bh_state();
+--- a/fs/ext4/page-io.c
++++ b/fs/ext4/page-io.c
+@@ -87,11 +87,10 @@ static void ext4_finish_bio(struct bio *
+ }
+ bh = head = page_buffers(page);
+ /*
+- * We check all buffers in the page under BH_Uptodate_Lock
++ * We check all buffers in the page under b_uptodate_lock
+ * to avoid races with other end io clearing async_write flags
+ */
+- local_irq_save(flags);
+- bit_spin_lock(BH_Uptodate_Lock, &head->b_state);
++ spin_lock_irqsave(&head->b_uptodate_lock, flags);
+ do {
+ if (bh_offset(bh) < bio_start ||
+ bh_offset(bh) + bh->b_size > bio_end) {
+@@ -103,8 +102,7 @@ static void ext4_finish_bio(struct bio *
+ if (bio->bi_status)
+ buffer_io_error(bh);
+ } while ((bh = bh->b_this_page) != head);
+- bit_spin_unlock(BH_Uptodate_Lock, &head->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&head->b_uptodate_lock, flags);
+ if (!under_io) {
+ fscrypt_free_bounce_page(bounce_page);
+ end_page_writeback(page);
+--- a/fs/ntfs/aops.c
++++ b/fs/ntfs/aops.c
+@@ -92,8 +92,7 @@ static void ntfs_end_buffer_async_read(s
+ "0x%llx.", (unsigned long long)bh->b_blocknr);
+ }
+ first = page_buffers(page);
+- local_irq_save(flags);
+- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
++ spin_lock_irqsave(&first->b_uptodate_lock, flags);
+ clear_buffer_async_read(bh);
+ unlock_buffer(bh);
+ tmp = bh;
+@@ -108,8 +107,7 @@ static void ntfs_end_buffer_async_read(s
+ }
+ tmp = tmp->b_this_page;
+ } while (tmp != bh);
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+ /*
+ * If none of the buffers had errors then we can set the page uptodate,
+ * but we first have to perform the post read mst fixups, if the
+@@ -142,8 +140,7 @@ static void ntfs_end_buffer_async_read(s
+ unlock_page(page);
+ return;
+ still_busy:
+- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
+- local_irq_restore(flags);
++ spin_unlock_irqrestore(&first->b_uptodate_lock, flags);
+ return;
+ }
+
+--- a/include/linux/buffer_head.h
++++ b/include/linux/buffer_head.h
+@@ -22,9 +22,6 @@ enum bh_state_bits {
+ BH_Dirty, /* Is dirty */
+ BH_Lock, /* Is locked */
+ BH_Req, /* Has been submitted for I/O */
+- BH_Uptodate_Lock,/* Used by the first bh in a page, to serialise
+- * IO completion of other buffers in the page
+- */
+
+ BH_Mapped, /* Has a disk mapping */
+ BH_New, /* Disk mapping was newly created by get_block */
+@@ -76,6 +73,9 @@ struct buffer_head {
+ struct address_space *b_assoc_map; /* mapping this buffer is
+ associated with */
+ atomic_t b_count; /* users using this buffer_head */
++ spinlock_t b_uptodate_lock; /* Used by the first bh in a page, to
++ * serialise IO completion of other
++ * buffers in the page */
+ };
+
+ /*
diff --git a/debian/patches-rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch b/debian/patches-rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch
index bd18fb8be918..698d4282871b 100644
--- a/debian/patches-rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch
+++ b/debian/patches-rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 13 Sep 2017 12:32:34 +0200
Subject: [PATCH] fs/dcache: bring back explicit INIT_HLIST_BL_HEAD init
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Commit 3d375d78593c ("mm: update callers to use HASH_ZERO flag") removed
INIT_HLIST_BL_HEAD and uses the ZERO flag instead for the init. However
@@ -15,7 +15,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/dcache.c
+++ b/fs/dcache.c
-@@ -3075,6 +3075,8 @@ static int __init set_dhash_entries(char
+@@ -3141,6 +3141,8 @@ static int __init set_dhash_entries(char
static void __init dcache_init_early(void)
{
@@ -24,7 +24,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* If hashes are distributed across NUMA nodes, defer
* hash allocation until vmalloc space is available.
*/
-@@ -3091,11 +3093,16 @@ static void __init dcache_init_early(voi
+@@ -3157,11 +3159,16 @@ static void __init dcache_init_early(voi
NULL,
0,
0);
@@ -41,7 +41,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* A constructor could be added for stable state like the lists,
* but it is probably not worth it because of the cache nature
-@@ -3119,6 +3126,10 @@ static void __init dcache_init(void)
+@@ -3185,6 +3192,10 @@ static void __init dcache_init(void)
NULL,
0,
0);
diff --git a/debian/patches-rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch b/debian/patches-rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch
index 1201ce1f7476..67f0727af2a0 100644
--- a/debian/patches-rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch
+++ b/debian/patches-rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 20 Oct 2017 11:29:53 +0200
Subject: [PATCH] fs/dcache: disable preemption on i_dir_seq's write side
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
i_dir_seq is an opencoded seqcounter. Based on the code it looks like we
could have two writers in parallel despite the fact that the d_lock is
@@ -18,13 +18,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
fs/dcache.c | 12 +++++++-----
fs/inode.c | 2 +-
- fs/libfs.c | 6 ++++--
include/linux/fs.h | 2 +-
- 4 files changed, 13 insertions(+), 9 deletions(-)
+ 3 files changed, 9 insertions(+), 7 deletions(-)
--- a/fs/dcache.c
+++ b/fs/dcache.c
-@@ -2418,9 +2418,10 @@ EXPORT_SYMBOL(d_rehash);
+@@ -2482,9 +2482,10 @@ EXPORT_SYMBOL(d_rehash);
static inline unsigned start_dir_add(struct inode *dir)
{
@@ -37,7 +36,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return n;
cpu_relax();
}
-@@ -2428,7 +2429,8 @@ static inline unsigned start_dir_add(str
+@@ -2492,7 +2493,8 @@ static inline unsigned start_dir_add(str
static inline void end_dir_add(struct inode *dir, unsigned n)
{
@@ -47,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void d_wait_lookup(struct dentry *dentry)
-@@ -2461,7 +2463,7 @@ struct dentry *d_alloc_parallel(struct d
+@@ -2525,7 +2527,7 @@ struct dentry *d_alloc_parallel(struct d
retry:
rcu_read_lock();
@@ -56,7 +55,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
r_seq = read_seqbegin(&rename_lock);
dentry = __d_lookup_rcu(parent, name, &d_seq);
if (unlikely(dentry)) {
-@@ -2489,7 +2491,7 @@ struct dentry *d_alloc_parallel(struct d
+@@ -2553,7 +2555,7 @@ struct dentry *d_alloc_parallel(struct d
}
hlist_bl_lock(b);
@@ -76,39 +75,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
inode->i_rdev = 0;
inode->dirtied_when = 0;
---- a/fs/libfs.c
-+++ b/fs/libfs.c
-@@ -91,7 +91,7 @@ static struct dentry *next_positive(stru
- struct list_head *from,
- int count)
- {
-- unsigned *seq = &parent->d_inode->i_dir_seq, n;
-+ unsigned *seq = &parent->d_inode->__i_dir_seq, n;
- struct dentry *res;
- struct list_head *p;
- bool skipped;
-@@ -124,8 +124,9 @@ static struct dentry *next_positive(stru
- static void move_cursor(struct dentry *cursor, struct list_head *after)
- {
- struct dentry *parent = cursor->d_parent;
-- unsigned n, *seq = &parent->d_inode->i_dir_seq;
-+ unsigned n, *seq = &parent->d_inode->__i_dir_seq;
- spin_lock(&parent->d_lock);
-+ preempt_disable_rt();
- for (;;) {
- n = *seq;
- if (!(n & 1) && cmpxchg(seq, n, n + 1) == n)
-@@ -138,6 +139,7 @@ static void move_cursor(struct dentry *c
- else
- list_add_tail(&cursor->d_child, &parent->d_subdirs);
- smp_store_release(seq, n + 2);
-+ preempt_enable_rt();
- spin_unlock(&parent->d_lock);
- }
-
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
-@@ -709,7 +709,7 @@ struct inode {
+@@ -716,7 +716,7 @@ struct inode {
struct block_device *i_bdev;
struct cdev *i_cdev;
char *i_link;
diff --git a/debian/patches-rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch b/debian/patches-rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch
index 498032a37fa0..571007636b98 100644
--- a/debian/patches-rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch
+++ b/debian/patches-rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 14 Sep 2016 14:35:49 +0200
Subject: [PATCH] fs/dcache: use swait_queue instead of waitqueue
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
__d_lookup_done() invokes wake_up_all() while holding a hlist_bl_lock()
which disables preemption. As a workaround convert it to swait.
@@ -24,7 +24,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/afs/dir_silly.c
+++ b/fs/afs/dir_silly.c
-@@ -207,7 +207,7 @@ int afs_silly_iput(struct dentry *dentry
+@@ -202,7 +202,7 @@ int afs_silly_iput(struct dentry *dentry
struct dentry *alias;
int ret;
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/dcache.c
+++ b/fs/dcache.c
-@@ -2435,21 +2435,24 @@ static inline void end_dir_add(struct in
+@@ -2499,21 +2499,24 @@ static inline void end_dir_add(struct in
static void d_wait_lookup(struct dentry *dentry)
{
@@ -82,7 +82,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
unsigned int hash = name->hash;
struct hlist_bl_head *b = in_lookup_hash(parent, hash);
-@@ -2564,7 +2567,7 @@ void __d_lookup_done(struct dentry *dent
+@@ -2628,7 +2631,7 @@ void __d_lookup_done(struct dentry *dent
hlist_bl_lock(b);
dentry->d_flags &= ~DCACHE_PAR_LOOKUP;
__hlist_bl_del(&dentry->d_u.d_in_lookup_hash);
@@ -104,7 +104,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
--- a/fs/namei.c
+++ b/fs/namei.c
-@@ -1643,7 +1643,7 @@ static struct dentry *__lookup_slow(cons
+@@ -1637,7 +1637,7 @@ static struct dentry *__lookup_slow(cons
{
struct dentry *dentry, *old;
struct inode *inode = dir->d_inode;
@@ -113,7 +113,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Don't go there if it's already dead */
if (unlikely(IS_DEADDIR(inode)))
-@@ -3133,7 +3133,7 @@ static int lookup_open(struct nameidata
+@@ -3125,7 +3125,7 @@ static int lookup_open(struct nameidata
struct dentry *dentry;
int error, create_error = 0;
umode_t mode = op->mode;
@@ -124,7 +124,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return -ENOENT;
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
-@@ -441,7 +441,7 @@ static
+@@ -445,7 +445,7 @@ static
void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
{
struct qstr filename = QSTR_INIT(entry->name, entry->len);
@@ -133,7 +133,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct dentry *dentry;
struct dentry *alias;
struct inode *dir = d_inode(parent);
-@@ -1492,7 +1492,7 @@ int nfs_atomic_open(struct inode *dir, s
+@@ -1496,7 +1496,7 @@ int nfs_atomic_open(struct inode *dir, s
struct file *file, unsigned open_flags,
umode_t mode)
{
@@ -164,7 +164,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
spin_lock(&dentry->d_lock);
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
-@@ -1892,7 +1892,7 @@ bool proc_fill_cache(struct file *file,
+@@ -1891,7 +1891,7 @@ bool proc_fill_cache(struct file *file,
child = d_hash_and_lookup(dir, &qname);
if (!child) {
@@ -175,7 +175,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
goto end_instantiate;
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
-@@ -698,7 +698,7 @@ static bool proc_sys_fill_cache(struct f
+@@ -702,7 +702,7 @@ static bool proc_sys_fill_cache(struct f
child = d_lookup(dir, &qname);
if (!child) {
@@ -217,7 +217,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
long timeout;
--- a/kernel/sched/swait.c
+++ b/kernel/sched/swait.c
-@@ -70,6 +70,7 @@ void swake_up_all(struct swait_queue_hea
+@@ -51,6 +51,7 @@ void swake_up_all(struct swait_queue_hea
struct swait_queue *curr;
LIST_HEAD(tmp);
diff --git a/debian/patches-rt/fs-jbd-replace-bh_state-lock.patch b/debian/patches-rt/fs-jbd-replace-bh_state-lock.patch
deleted file mode 100644
index 117b3d7cafd2..000000000000
--- a/debian/patches-rt/fs-jbd-replace-bh_state-lock.patch
+++ /dev/null
@@ -1,97 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Fri, 18 Mar 2011 10:11:25 +0100
-Subject: fs: jbd/jbd2: Make state lock and journal head lock rt safe
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-bit_spin_locks break under RT.
-
-Based on a previous patch from Steven Rostedt <rostedt@goodmis.org>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- include/linux/buffer_head.h | 8 ++++++++
- include/linux/jbd2.h | 24 ++++++++++++++++++++++++
- 2 files changed, 32 insertions(+)
-
---- a/include/linux/buffer_head.h
-+++ b/include/linux/buffer_head.h
-@@ -78,6 +78,10 @@ struct buffer_head {
- atomic_t b_count; /* users using this buffer_head */
- #ifdef CONFIG_PREEMPT_RT_BASE
- spinlock_t b_uptodate_lock;
-+#if IS_ENABLED(CONFIG_JBD2)
-+ spinlock_t b_state_lock;
-+ spinlock_t b_journal_head_lock;
-+#endif
- #endif
- };
-
-@@ -109,6 +113,10 @@ static inline void buffer_head_init_lock
- {
- #ifdef CONFIG_PREEMPT_RT_BASE
- spin_lock_init(&bh->b_uptodate_lock);
-+#if IS_ENABLED(CONFIG_JBD2)
-+ spin_lock_init(&bh->b_state_lock);
-+ spin_lock_init(&bh->b_journal_head_lock);
-+#endif
- #endif
- }
-
---- a/include/linux/jbd2.h
-+++ b/include/linux/jbd2.h
-@@ -344,32 +344,56 @@ static inline struct journal_head *bh2jh
-
- static inline void jbd_lock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_lock(BH_State, &bh->b_state);
-+#else
-+ spin_lock(&bh->b_state_lock);
-+#endif
- }
-
- static inline int jbd_trylock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- return bit_spin_trylock(BH_State, &bh->b_state);
-+#else
-+ return spin_trylock(&bh->b_state_lock);
-+#endif
- }
-
- static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- return bit_spin_is_locked(BH_State, &bh->b_state);
-+#else
-+ return spin_is_locked(&bh->b_state_lock);
-+#endif
- }
-
- static inline void jbd_unlock_bh_state(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_unlock(BH_State, &bh->b_state);
-+#else
-+ spin_unlock(&bh->b_state_lock);
-+#endif
- }
-
- static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_lock(BH_JournalHead, &bh->b_state);
-+#else
-+ spin_lock(&bh->b_journal_head_lock);
-+#endif
- }
-
- static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
- {
-+#ifndef CONFIG_PREEMPT_RT_BASE
- bit_spin_unlock(BH_JournalHead, &bh->b_state);
-+#else
-+ spin_unlock(&bh->b_journal_head_lock);
-+#endif
- }
-
- #define J_ASSERT(assert) BUG_ON(!(assert))
diff --git a/debian/patches-rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch b/debian/patches-rt/fs-namespace-use-cpu-chill-in-trylock-loops.patch
index 011e31f1e670..f1bce903b8ee 100644
--- a/debian/patches-rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch
+++ b/debian/patches-rt/fs-namespace-use-cpu-chill-in-trylock-loops.patch
@@ -1,7 +1,7 @@
-Subject: fs: dcache: Use cpu_chill() in trylock loops
+Subject: fs: namespace: Use cpu_chill() in trylock loops
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 07 Mar 2012 21:00:34 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Retry loops on RT might loop forever when the modifying side was
preempted. Use cpu_chill() instead of cpu_relax() to let the system
@@ -10,29 +10,9 @@ make progress.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- fs/autofs/expire.c | 3 ++-
- fs/namespace.c | 8 ++++++--
- 2 files changed, 8 insertions(+), 3 deletions(-)
+ fs/namespace.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
---- a/fs/autofs/expire.c
-+++ b/fs/autofs/expire.c
-@@ -5,6 +5,7 @@
- * Copyright 2001-2006 Ian Kent <raven@themaw.net>
- */
-
-+#include <linux/delay.h>
- #include "autofs_i.h"
-
- /* Check if a dentry can be expired */
-@@ -150,7 +151,7 @@ static struct dentry *get_next_positive_
- parent = p->d_parent;
- if (!spin_trylock(&parent->d_lock)) {
- spin_unlock(&p->d_lock);
-- cpu_relax();
-+ cpu_chill();
- goto relock;
- }
- spin_unlock(&p->d_lock);
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -14,6 +14,7 @@
@@ -43,7 +23,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include <linux/security.h>
#include <linux/cred.h>
#include <linux/idr.h>
-@@ -326,8 +327,11 @@ int __mnt_want_write(struct vfsmount *m)
+@@ -321,8 +322,11 @@ int __mnt_want_write(struct vfsmount *m)
* incremented count after it has set MNT_WRITE_HOLD.
*/
smp_mb();
diff --git a/debian/patches-rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch b/debian/patches-rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch
index dc780fb77a5a..676751f93bd5 100644
--- a/debian/patches-rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch
+++ b/debian/patches-rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 15 Sep 2016 10:51:27 +0200
Subject: [PATCH] fs/nfs: turn rmdir_sem into a semaphore
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The RW semaphore had a reader side which used the _non_owner version
because it most likely took the reader lock in one thread and released it
@@ -22,11 +22,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
-@@ -1812,7 +1812,11 @@ int nfs_rmdir(struct inode *dir, struct
+@@ -1825,7 +1825,11 @@ int nfs_rmdir(struct inode *dir, struct
trace_nfs_rmdir_enter(dir, dentry);
if (d_really_is_positive(dentry)) {
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ down(&NFS_I(d_inode(dentry))->rmdir_sem);
+#else
down_write(&NFS_I(d_inode(dentry))->rmdir_sem);
@@ -34,11 +34,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name);
/* Ensure the VFS deletes this inode */
switch (error) {
-@@ -1822,7 +1826,11 @@ int nfs_rmdir(struct inode *dir, struct
+@@ -1835,7 +1839,11 @@ int nfs_rmdir(struct inode *dir, struct
case -ENOENT:
nfs_dentry_handle_enoent(dentry);
}
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ up(&NFS_I(d_inode(dentry))->rmdir_sem);
+#else
up_write(&NFS_I(d_inode(dentry))->rmdir_sem);
@@ -48,11 +48,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
trace_nfs_rmdir_exit(dir, dentry, error);
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
-@@ -2090,7 +2090,11 @@ static void init_once(void *foo)
+@@ -2105,7 +2105,11 @@ static void init_once(void *foo)
atomic_long_set(&nfsi->nrequests, 0);
atomic_long_set(&nfsi->commit_info.ncommit, 0);
atomic_set(&nfsi->commit_info.rpcs_out, 0);
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ sema_init(&nfsi->rmdir_sem, 1);
+#else
init_rwsem(&nfsi->rmdir_sem);
@@ -66,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rpc_restart_call_prepare(task);
}
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+static void nfs_down_anon(struct semaphore *sema)
+{
+ down(sema);
@@ -129,7 +129,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Readers: in-flight sillydelete RPC calls */
/* Writers: rmdir */
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ struct semaphore rmdir_sem;
+#else
struct rw_semaphore rmdir_sem;
diff --git a/debian/patches-rt/fs-replace-bh_uptodate_lock-for-rt.patch b/debian/patches-rt/fs-replace-bh_uptodate_lock-for-rt.patch
deleted file mode 100644
index d641875b9494..000000000000
--- a/debian/patches-rt/fs-replace-bh_uptodate_lock-for-rt.patch
+++ /dev/null
@@ -1,185 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Fri, 18 Mar 2011 09:18:52 +0100
-Subject: buffer_head: Replace bh_uptodate_lock for -rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Wrap the bit_spin_lock calls into a separate inline and add the RT
-replacements with a real spinlock.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- fs/buffer.c | 21 +++++++--------------
- fs/ext4/page-io.c | 6 ++----
- fs/ntfs/aops.c | 10 +++-------
- include/linux/buffer_head.h | 34 ++++++++++++++++++++++++++++++++++
- 4 files changed, 46 insertions(+), 25 deletions(-)
-
---- a/fs/buffer.c
-+++ b/fs/buffer.c
-@@ -275,8 +275,7 @@ static void end_buffer_async_read(struct
- * decide that the page is now completely done.
- */
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
- clear_buffer_async_read(bh);
- unlock_buffer(bh);
- tmp = bh;
-@@ -289,8 +288,7 @@ static void end_buffer_async_read(struct
- }
- tmp = tmp->b_this_page;
- } while (tmp != bh);
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
-
- /*
- * If none of the buffers had errors and they are all
-@@ -302,9 +300,7 @@ static void end_buffer_async_read(struct
- return;
-
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
-
- /*
-@@ -331,8 +327,7 @@ void end_buffer_async_write(struct buffe
- }
-
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
-
- clear_buffer_async_write(bh);
- unlock_buffer(bh);
-@@ -344,15 +339,12 @@ void end_buffer_async_write(struct buffe
- }
- tmp = tmp->b_this_page;
- }
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
- end_page_writeback(page);
- return;
-
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
- EXPORT_SYMBOL(end_buffer_async_write);
-
-@@ -3372,6 +3364,7 @@ struct buffer_head *alloc_buffer_head(gf
- struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
- if (ret) {
- INIT_LIST_HEAD(&ret->b_assoc_buffers);
-+ buffer_head_init_locks(ret);
- preempt_disable();
- __this_cpu_inc(bh_accounting.nr);
- recalc_bh_state();
---- a/fs/ext4/page-io.c
-+++ b/fs/ext4/page-io.c
-@@ -95,8 +95,7 @@ static void ext4_finish_bio(struct bio *
- * We check all buffers in the page under BH_Uptodate_Lock
- * to avoid races with other end io clearing async_write flags
- */
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &head->b_state);
-+ flags = bh_uptodate_lock_irqsave(head);
- do {
- if (bh_offset(bh) < bio_start ||
- bh_offset(bh) + bh->b_size > bio_end) {
-@@ -108,8 +107,7 @@ static void ext4_finish_bio(struct bio *
- if (bio->bi_status)
- buffer_io_error(bh);
- } while ((bh = bh->b_this_page) != head);
-- bit_spin_unlock(BH_Uptodate_Lock, &head->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(head, flags);
- if (!under_io) {
- #ifdef CONFIG_FS_ENCRYPTION
- if (data_page)
---- a/fs/ntfs/aops.c
-+++ b/fs/ntfs/aops.c
-@@ -92,8 +92,7 @@ static void ntfs_end_buffer_async_read(s
- "0x%llx.", (unsigned long long)bh->b_blocknr);
- }
- first = page_buffers(page);
-- local_irq_save(flags);
-- bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
-+ flags = bh_uptodate_lock_irqsave(first);
- clear_buffer_async_read(bh);
- unlock_buffer(bh);
- tmp = bh;
-@@ -108,8 +107,7 @@ static void ntfs_end_buffer_async_read(s
- }
- tmp = tmp->b_this_page;
- } while (tmp != bh);
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-+ bh_uptodate_unlock_irqrestore(first, flags);
- /*
- * If none of the buffers had errors then we can set the page uptodate,
- * but we first have to perform the post read mst fixups, if the
-@@ -142,9 +140,7 @@ static void ntfs_end_buffer_async_read(s
- unlock_page(page);
- return;
- still_busy:
-- bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
-- local_irq_restore(flags);
-- return;
-+ bh_uptodate_unlock_irqrestore(first, flags);
- }
-
- /**
---- a/include/linux/buffer_head.h
-+++ b/include/linux/buffer_head.h
-@@ -76,8 +76,42 @@ struct buffer_head {
- struct address_space *b_assoc_map; /* mapping this buffer is
- associated with */
- atomic_t b_count; /* users using this buffer_head */
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ spinlock_t b_uptodate_lock;
-+#endif
- };
-
-+static inline unsigned long bh_uptodate_lock_irqsave(struct buffer_head *bh)
-+{
-+ unsigned long flags;
-+
-+#ifndef CONFIG_PREEMPT_RT_BASE
-+ local_irq_save(flags);
-+ bit_spin_lock(BH_Uptodate_Lock, &bh->b_state);
-+#else
-+ spin_lock_irqsave(&bh->b_uptodate_lock, flags);
-+#endif
-+ return flags;
-+}
-+
-+static inline void
-+bh_uptodate_unlock_irqrestore(struct buffer_head *bh, unsigned long flags)
-+{
-+#ifndef CONFIG_PREEMPT_RT_BASE
-+ bit_spin_unlock(BH_Uptodate_Lock, &bh->b_state);
-+ local_irq_restore(flags);
-+#else
-+ spin_unlock_irqrestore(&bh->b_uptodate_lock, flags);
-+#endif
-+}
-+
-+static inline void buffer_head_init_locks(struct buffer_head *bh)
-+{
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ spin_lock_init(&bh->b_uptodate_lock);
-+#endif
-+}
-+
- /*
- * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
- * and buffer_foo() functions.
diff --git a/debian/patches-rt/fscache-initialize-cookie-hash-table-raw-spinlocks.patch b/debian/patches-rt/fscache-initialize-cookie-hash-table-raw-spinlocks.patch
index 8288facd4808..96dce314b465 100644
--- a/debian/patches-rt/fscache-initialize-cookie-hash-table-raw-spinlocks.patch
+++ b/debian/patches-rt/fscache-initialize-cookie-hash-table-raw-spinlocks.patch
@@ -1,7 +1,7 @@
From: Clark Williams <williams@redhat.com>
Date: Tue, 3 Jul 2018 13:34:30 -0500
Subject: [PATCH] fscache: initialize cookie hash table raw spinlocks
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The fscache cookie mechanism uses a hash table of hlist_bl_head structures. The
PREEMPT_RT patcheset adds a raw spinlock to this structure and so on PREEMPT_RT
diff --git a/debian/patches-rt/ftrace-Fix-trace-header-alignment.patch b/debian/patches-rt/ftrace-Fix-trace-header-alignment.patch
deleted file mode 100644
index 9a8156d613ba..000000000000
--- a/debian/patches-rt/ftrace-Fix-trace-header-alignment.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From: Mike Galbraith <umgwanakikbuti@gmail.com>
-Date: Sun, 16 Oct 2016 05:08:30 +0200
-Subject: [PATCH] ftrace: Fix trace header alignment
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Line up helper arrows to the right column.
-
-Cc: stable-rt@vger.kernel.org
-Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
-[bigeasy: fixup function tracer header]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/trace/trace.c | 22 +++++++++++-----------
- 1 file changed, 11 insertions(+), 11 deletions(-)
-
---- a/kernel/trace/trace.c
-+++ b/kernel/trace/trace.c
-@@ -3557,17 +3557,17 @@ unsigned long trace_total_entries(struct
-
- static void print_lat_help_header(struct seq_file *m)
- {
-- seq_puts(m, "# _--------=> CPU# \n"
-- "# / _-------=> irqs-off \n"
-- "# | / _------=> need-resched \n"
-- "# || / _-----=> need-resched_lazy \n"
-- "# ||| / _----=> hardirq/softirq \n"
-- "# |||| / _---=> preempt-depth \n"
-- "# ||||| / _--=> preempt-lazy-depth\n"
-- "# |||||| / _-=> migrate-disable \n"
-- "# ||||||| / delay \n"
-- "# cmd pid |||||||| time | caller \n"
-- "# \\ / |||||||| \\ | / \n");
-+ seq_puts(m, "# _--------=> CPU# \n"
-+ "# / _-------=> irqs-off \n"
-+ "# | / _------=> need-resched \n"
-+ "# || / _-----=> need-resched_lazy \n"
-+ "# ||| / _----=> hardirq/softirq \n"
-+ "# |||| / _---=> preempt-depth \n"
-+ "# ||||| / _--=> preempt-lazy-depth\n"
-+ "# |||||| / _-=> migrate-disable \n"
-+ "# ||||||| / delay \n"
-+ "# cmd pid |||||||| time | caller \n"
-+ "# \\ / |||||||| \\ | / \n");
- }
-
- static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
diff --git a/debian/patches-rt/ftrace-migrate-disable-tracing.patch b/debian/patches-rt/ftrace-migrate-disable-tracing.patch
index 5c286f99db18..280f26c09d83 100644
--- a/debian/patches-rt/ftrace-migrate-disable-tracing.patch
+++ b/debian/patches-rt/ftrace-migrate-disable-tracing.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 17 Jul 2011 21:56:42 +0200
Subject: trace: Add migrate-disabled counter to tracing output
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#define TRACE_EVENT_TYPE_MAX \
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
-@@ -2330,6 +2330,8 @@ tracing_generic_entry_update(struct trac
+@@ -2348,6 +2348,8 @@ tracing_generic_entry_update(struct trac
((pc & SOFTIRQ_OFFSET) ? TRACE_FLAG_SOFTIRQ : 0) |
(tif_need_resched() ? TRACE_FLAG_NEED_RESCHED : 0) |
(test_preempt_need_resched() ? TRACE_FLAG_PREEMPT_RESCHED : 0);
@@ -33,7 +33,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
EXPORT_SYMBOL_GPL(tracing_generic_entry_update);
-@@ -3558,9 +3560,10 @@ static void print_lat_help_header(struct
+@@ -3578,9 +3580,10 @@ static void print_lat_help_header(struct
"# | / _----=> need-resched \n"
"# || / _---=> hardirq/softirq \n"
"# ||| / _--=> preempt-depth \n"
@@ -49,7 +49,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
-@@ -188,6 +188,8 @@ static int trace_define_common_fields(vo
+@@ -181,6 +181,8 @@ static int trace_define_common_fields(vo
__common_field(unsigned char, flags);
__common_field(unsigned char, preempt_count);
__common_field(int, pid);
diff --git a/debian/patches-rt/futex-Delay-deallocation-of-pi_state.patch b/debian/patches-rt/futex-Delay-deallocation-of-pi_state.patch
deleted file mode 100644
index 507a015a3452..000000000000
--- a/debian/patches-rt/futex-Delay-deallocation-of-pi_state.patch
+++ /dev/null
@@ -1,174 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Wed, 26 Jun 2019 13:35:36 +0200
-Subject: [PATCH] futex: Delay deallocation of pi_state
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-On -RT we can't invoke kfree() in a non-preemptible context.
-
-Defer the deallocation of pi_state to preemptible context.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/futex.c | 55 ++++++++++++++++++++++++++++++++++++++++++++-----------
- 1 file changed, 44 insertions(+), 11 deletions(-)
-
---- a/kernel/futex.c
-+++ b/kernel/futex.c
-@@ -814,13 +814,13 @@ static void get_pi_state(struct futex_pi
- * Drops a reference to the pi_state object and frees or caches it
- * when the last reference is gone.
- */
--static void put_pi_state(struct futex_pi_state *pi_state)
-+static struct futex_pi_state *__put_pi_state(struct futex_pi_state *pi_state)
- {
- if (!pi_state)
-- return;
-+ return NULL;
-
- if (!refcount_dec_and_test(&pi_state->refcount))
-- return;
-+ return NULL;
-
- /*
- * If pi_state->owner is NULL, the owner is most probably dying
-@@ -840,9 +840,7 @@ static void put_pi_state(struct futex_pi
- raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
- }
-
-- if (current->pi_state_cache) {
-- kfree(pi_state);
-- } else {
-+ if (!current->pi_state_cache) {
- /*
- * pi_state->list is already empty.
- * clear pi_state->owner.
-@@ -851,6 +849,30 @@ static void put_pi_state(struct futex_pi
- pi_state->owner = NULL;
- refcount_set(&pi_state->refcount, 1);
- current->pi_state_cache = pi_state;
-+ pi_state = NULL;
-+ }
-+ return pi_state;
-+}
-+
-+static void put_pi_state(struct futex_pi_state *pi_state)
-+{
-+ kfree(__put_pi_state(pi_state));
-+}
-+
-+static void put_pi_state_atomic(struct futex_pi_state *pi_state,
-+ struct list_head *to_free)
-+{
-+ if (__put_pi_state(pi_state))
-+ list_add(&pi_state->list, to_free);
-+}
-+
-+static void free_pi_state_list(struct list_head *to_free)
-+{
-+ struct futex_pi_state *p, *next;
-+
-+ list_for_each_entry_safe(p, next, to_free, list) {
-+ list_del(&p->list);
-+ kfree(p);
- }
- }
-
-@@ -867,6 +889,7 @@ void exit_pi_state_list(struct task_stru
- struct futex_pi_state *pi_state;
- struct futex_hash_bucket *hb;
- union futex_key key = FUTEX_KEY_INIT;
-+ LIST_HEAD(to_free);
-
- if (!futex_cmpxchg_enabled)
- return;
-@@ -911,7 +934,7 @@ void exit_pi_state_list(struct task_stru
- /* retain curr->pi_lock for the loop invariant */
- raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
- raw_spin_unlock(&hb->lock);
-- put_pi_state(pi_state);
-+ put_pi_state_atomic(pi_state, &to_free);
- continue;
- }
-
-@@ -930,6 +953,8 @@ void exit_pi_state_list(struct task_stru
- raw_spin_lock_irq(&curr->pi_lock);
- }
- raw_spin_unlock_irq(&curr->pi_lock);
-+
-+ free_pi_state_list(&to_free);
- }
-
- #endif
-@@ -1910,6 +1935,7 @@ static int futex_requeue(u32 __user *uad
- struct futex_hash_bucket *hb1, *hb2;
- struct futex_q *this, *next;
- DEFINE_WAKE_Q(wake_q);
-+ LIST_HEAD(to_free);
-
- if (nr_wake < 0 || nr_requeue < 0)
- return -EINVAL;
-@@ -2147,7 +2173,7 @@ static int futex_requeue(u32 __user *uad
- * object.
- */
- this->pi_state = NULL;
-- put_pi_state(pi_state);
-+ put_pi_state_atomic(pi_state, &to_free);
- /*
- * We stop queueing more waiters and let user
- * space deal with the mess.
-@@ -2164,7 +2190,7 @@ static int futex_requeue(u32 __user *uad
- * in futex_proxy_trylock_atomic() or in lookup_pi_state(). We
- * need to drop it here again.
- */
-- put_pi_state(pi_state);
-+ put_pi_state_atomic(pi_state, &to_free);
-
- out_unlock:
- double_unlock_hb(hb1, hb2);
-@@ -2185,6 +2211,7 @@ static int futex_requeue(u32 __user *uad
- out_put_key1:
- put_futex_key(&key1);
- out:
-+ free_pi_state_list(&to_free);
- return ret ? ret : task_count;
- }
-
-@@ -2321,13 +2348,16 @@ static int unqueue_me(struct futex_q *q)
- static void unqueue_me_pi(struct futex_q *q)
- __releases(q->lock_ptr)
- {
-+ struct futex_pi_state *ps;
-+
- __unqueue_futex(q);
-
- BUG_ON(!q->pi_state);
-- put_pi_state(q->pi_state);
-+ ps = __put_pi_state(q->pi_state);
- q->pi_state = NULL;
-
- raw_spin_unlock(q->lock_ptr);
-+ kfree(ps);
- }
-
- static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
-@@ -3279,6 +3309,8 @@ static int futex_wait_requeue_pi(u32 __u
- * did a lock-steal - fix up the PI-state in that case.
- */
- if (q.pi_state && (q.pi_state->owner != current)) {
-+ struct futex_pi_state *ps_free;
-+
- raw_spin_lock(q.lock_ptr);
- ret = fixup_pi_state_owner(uaddr2, &q, current);
- if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == current) {
-@@ -3289,8 +3321,9 @@ static int futex_wait_requeue_pi(u32 __u
- * Drop the reference to the pi state which
- * the requeue_pi() code acquired for us.
- */
-- put_pi_state(q.pi_state);
-+ ps_free = __put_pi_state(q.pi_state);
- raw_spin_unlock(q.lock_ptr);
-+ kfree(ps_free);
- }
- } else {
- struct rt_mutex *pi_mutex;
diff --git a/debian/patches-rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch b/debian/patches-rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch
new file mode 100644
index 000000000000..d4d8871a0af6
--- /dev/null
+++ b/debian/patches-rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch
@@ -0,0 +1,43 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 1 Mar 2013 11:17:42 +0100
+Subject: futex: Ensure lock/unlock symetry versus pi_lock and hash bucket lock
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+In exit_pi_state_list() we have the following locking construct:
+
+ spin_lock(&hb->lock);
+ raw_spin_lock_irq(&curr->pi_lock);
+
+ ...
+ spin_unlock(&hb->lock);
+
+In !RT this works, but on RT the migrate_enable() function which is
+called from spin_unlock() sees atomic context due to the held pi_lock
+and just decrements the migrate_disable_atomic counter of the
+task. Now the next call to migrate_disable() sees the counter being
+negative and issues a warning. That check should be in
+migrate_enable() already.
+
+Fix this by dropping pi_lock before unlocking hb->lock and reaquire
+pi_lock after that again. This is safe as the loop code reevaluates
+head again under the pi_lock.
+
+Reported-by: Yong Zhang <yong.zhang@windriver.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/futex.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/kernel/futex.c
++++ b/kernel/futex.c
+@@ -945,7 +945,9 @@ static void exit_pi_state_list(struct ta
+ if (head->next != next) {
+ /* retain curr->pi_lock for the loop invariant */
+ raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
++ raw_spin_unlock_irq(&curr->pi_lock);
+ spin_unlock(&hb->lock);
++ raw_spin_lock_irq(&curr->pi_lock);
+ put_pi_state(pi_state);
+ continue;
+ }
diff --git a/debian/patches-rt/futex-Make-the-futex_hash_bucket-lock-raw.patch b/debian/patches-rt/futex-Make-the-futex_hash_bucket-lock-raw.patch
deleted file mode 100644
index 9a9dd403ae77..000000000000
--- a/debian/patches-rt/futex-Make-the-futex_hash_bucket-lock-raw.patch
+++ /dev/null
@@ -1,331 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 26 Jun 2019 11:59:44 +0200
-Subject: [PATCH] futex: Make the futex_hash_bucket lock raw
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Since commit 1a1fb985f2e2b ("futex: Handle early deadlock return
-correctly") we can deadlock while we attempt to acquire the HB lock if
-we fail to acquire the lock.
-The RT waiter (for the futex lock) is still enqueued and acquiring the
-HB lock may build up a lock chain which leads to a deadlock if the owner
-of the lock futex-lock holds the HB lock.
-
-Make the hash bucket lock raw so it does not participate in the
-lockchain.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/futex.c | 86 ++++++++++++++++++++++++++++-----------------------------
- 1 file changed, 43 insertions(+), 43 deletions(-)
-
---- a/kernel/futex.c
-+++ b/kernel/futex.c
-@@ -231,7 +231,7 @@ struct futex_q {
- struct plist_node list;
-
- struct task_struct *task;
-- spinlock_t *lock_ptr;
-+ raw_spinlock_t *lock_ptr;
- union futex_key key;
- struct futex_pi_state *pi_state;
- struct rt_mutex_waiter *rt_waiter;
-@@ -252,7 +252,7 @@ static const struct futex_q futex_q_init
- */
- struct futex_hash_bucket {
- atomic_t waiters;
-- spinlock_t lock;
-+ raw_spinlock_t lock;
- struct plist_head chain;
- } ____cacheline_aligned_in_smp;
-
-@@ -900,7 +900,7 @@ void exit_pi_state_list(struct task_stru
- }
- raw_spin_unlock_irq(&curr->pi_lock);
-
-- spin_lock(&hb->lock);
-+ raw_spin_lock(&hb->lock);
- raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
- raw_spin_lock(&curr->pi_lock);
- /*
-@@ -910,7 +910,7 @@ void exit_pi_state_list(struct task_stru
- if (head->next != next) {
- /* retain curr->pi_lock for the loop invariant */
- raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- put_pi_state(pi_state);
- continue;
- }
-@@ -922,7 +922,7 @@ void exit_pi_state_list(struct task_stru
-
- raw_spin_unlock(&curr->pi_lock);
- raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
-
- rt_mutex_futex_unlock(&pi_state->pi_mutex);
- put_pi_state(pi_state);
-@@ -1542,21 +1542,21 @@ static inline void
- double_lock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
- {
- if (hb1 <= hb2) {
-- spin_lock(&hb1->lock);
-+ raw_spin_lock(&hb1->lock);
- if (hb1 < hb2)
-- spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
-+ raw_spin_lock_nested(&hb2->lock, SINGLE_DEPTH_NESTING);
- } else { /* hb1 > hb2 */
-- spin_lock(&hb2->lock);
-- spin_lock_nested(&hb1->lock, SINGLE_DEPTH_NESTING);
-+ raw_spin_lock(&hb2->lock);
-+ raw_spin_lock_nested(&hb1->lock, SINGLE_DEPTH_NESTING);
- }
- }
-
- static inline void
- double_unlock_hb(struct futex_hash_bucket *hb1, struct futex_hash_bucket *hb2)
- {
-- spin_unlock(&hb1->lock);
-+ raw_spin_unlock(&hb1->lock);
- if (hb1 != hb2)
-- spin_unlock(&hb2->lock);
-+ raw_spin_unlock(&hb2->lock);
- }
-
- /*
-@@ -1584,7 +1584,7 @@ futex_wake(u32 __user *uaddr, unsigned i
- if (!hb_waiters_pending(hb))
- goto out_put_key;
-
-- spin_lock(&hb->lock);
-+ raw_spin_lock(&hb->lock);
-
- plist_for_each_entry_safe(this, next, &hb->chain, list) {
- if (match_futex (&this->key, &key)) {
-@@ -1603,7 +1603,7 @@ futex_wake(u32 __user *uaddr, unsigned i
- }
- }
-
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- wake_up_q(&wake_q);
- out_put_key:
- put_futex_key(&key);
-@@ -2208,7 +2208,7 @@ static inline struct futex_hash_bucket *
-
- q->lock_ptr = &hb->lock;
-
-- spin_lock(&hb->lock);
-+ raw_spin_lock(&hb->lock);
- return hb;
- }
-
-@@ -2216,7 +2216,7 @@ static inline void
- queue_unlock(struct futex_hash_bucket *hb)
- __releases(&hb->lock)
- {
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- hb_waiters_dec(hb);
- }
-
-@@ -2255,7 +2255,7 @@ static inline void queue_me(struct futex
- __releases(&hb->lock)
- {
- __queue_me(q, hb);
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- }
-
- /**
-@@ -2271,41 +2271,41 @@ static inline void queue_me(struct futex
- */
- static int unqueue_me(struct futex_q *q)
- {
-- spinlock_t *lock_ptr;
-+ raw_spinlock_t *lock_ptr;
- int ret = 0;
-
- /* In the common case we don't take the spinlock, which is nice. */
- retry:
- /*
-- * q->lock_ptr can change between this read and the following spin_lock.
-- * Use READ_ONCE to forbid the compiler from reloading q->lock_ptr and
-- * optimizing lock_ptr out of the logic below.
-+ * q->lock_ptr can change between this read and the following
-+ * raw_spin_lock. Use READ_ONCE to forbid the compiler from reloading
-+ * q->lock_ptr and optimizing lock_ptr out of the logic below.
- */
- lock_ptr = READ_ONCE(q->lock_ptr);
- if (lock_ptr != NULL) {
-- spin_lock(lock_ptr);
-+ raw_spin_lock(lock_ptr);
- /*
- * q->lock_ptr can change between reading it and
-- * spin_lock(), causing us to take the wrong lock. This
-+ * raw_spin_lock(), causing us to take the wrong lock. This
- * corrects the race condition.
- *
- * Reasoning goes like this: if we have the wrong lock,
- * q->lock_ptr must have changed (maybe several times)
-- * between reading it and the spin_lock(). It can
-- * change again after the spin_lock() but only if it was
-- * already changed before the spin_lock(). It cannot,
-+ * between reading it and the raw_spin_lock(). It can
-+ * change again after the raw_spin_lock() but only if it was
-+ * already changed before the raw_spin_lock(). It cannot,
- * however, change back to the original value. Therefore
- * we can detect whether we acquired the correct lock.
- */
- if (unlikely(lock_ptr != q->lock_ptr)) {
-- spin_unlock(lock_ptr);
-+ raw_spin_unlock(lock_ptr);
- goto retry;
- }
- __unqueue_futex(q);
-
- BUG_ON(q->pi_state);
-
-- spin_unlock(lock_ptr);
-+ raw_spin_unlock(lock_ptr);
- ret = 1;
- }
-
-@@ -2327,7 +2327,7 @@ static void unqueue_me_pi(struct futex_q
- put_pi_state(q->pi_state);
- q->pi_state = NULL;
-
-- spin_unlock(q->lock_ptr);
-+ raw_spin_unlock(q->lock_ptr);
- }
-
- static int fixup_pi_state_owner(u32 __user *uaddr, struct futex_q *q,
-@@ -2460,7 +2460,7 @@ static int fixup_pi_state_owner(u32 __us
- */
- handle_err:
- raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
-- spin_unlock(q->lock_ptr);
-+ raw_spin_unlock(q->lock_ptr);
-
- switch (err) {
- case -EFAULT:
-@@ -2478,7 +2478,7 @@ static int fixup_pi_state_owner(u32 __us
- break;
- }
-
-- spin_lock(q->lock_ptr);
-+ raw_spin_lock(q->lock_ptr);
- raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
-
- /*
-@@ -2574,7 +2574,7 @@ static void futex_wait_queue_me(struct f
- /*
- * The task state is guaranteed to be set before another task can
- * wake it. set_current_state() is implemented using smp_store_mb() and
-- * queue_me() calls spin_unlock() upon completion, both serializing
-+ * queue_me() calls raw_spin_unlock() upon completion, both serializing
- * access to the hash list and forcing another memory barrier.
- */
- set_current_state(TASK_INTERRUPTIBLE);
-@@ -2867,7 +2867,7 @@ static int futex_lock_pi(u32 __user *uad
- * before __rt_mutex_start_proxy_lock() is done.
- */
- raw_spin_lock_irq(&q.pi_state->pi_mutex.wait_lock);
-- spin_unlock(q.lock_ptr);
-+ raw_spin_unlock(q.lock_ptr);
- /*
- * __rt_mutex_start_proxy_lock() unconditionally enqueues the @rt_waiter
- * such that futex_unlock_pi() is guaranteed to observe the waiter when
-@@ -2888,7 +2888,7 @@ static int futex_lock_pi(u32 __user *uad
- ret = rt_mutex_wait_proxy_lock(&q.pi_state->pi_mutex, to, &rt_waiter);
-
- cleanup:
-- spin_lock(q.lock_ptr);
-+ raw_spin_lock(q.lock_ptr);
- /*
- * If we failed to acquire the lock (deadlock/signal/timeout), we must
- * first acquire the hb->lock before removing the lock from the
-@@ -2989,7 +2989,7 @@ static int futex_unlock_pi(u32 __user *u
- return ret;
-
- hb = hash_futex(&key);
-- spin_lock(&hb->lock);
-+ raw_spin_lock(&hb->lock);
-
- /*
- * Check waiters first. We do not trust user space values at
-@@ -3023,7 +3023,7 @@ static int futex_unlock_pi(u32 __user *u
- * rt_waiter. Also see the WARN in wake_futex_pi().
- */
- raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
-
- /* drops pi_state->pi_mutex.wait_lock */
- ret = wake_futex_pi(uaddr, uval, pi_state);
-@@ -3062,7 +3062,7 @@ static int futex_unlock_pi(u32 __user *u
- * owner.
- */
- if ((ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, 0))) {
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- switch (ret) {
- case -EFAULT:
- goto pi_faulted;
-@@ -3082,7 +3082,7 @@ static int futex_unlock_pi(u32 __user *u
- ret = (curval == uval) ? 0 : -EAGAIN;
-
- out_unlock:
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- out_putkey:
- put_futex_key(&key);
- return ret;
-@@ -3257,9 +3257,9 @@ static int futex_wait_requeue_pi(u32 __u
- /* Queue the futex_q, drop the hb lock, wait for wakeup. */
- futex_wait_queue_me(hb, &q, to);
-
-- spin_lock(&hb->lock);
-+ raw_spin_lock(&hb->lock);
- ret = handle_early_requeue_pi_wakeup(hb, &q, &key2, to);
-- spin_unlock(&hb->lock);
-+ raw_spin_unlock(&hb->lock);
- if (ret)
- goto out_put_keys;
-
-@@ -3279,7 +3279,7 @@ static int futex_wait_requeue_pi(u32 __u
- * did a lock-steal - fix up the PI-state in that case.
- */
- if (q.pi_state && (q.pi_state->owner != current)) {
-- spin_lock(q.lock_ptr);
-+ raw_spin_lock(q.lock_ptr);
- ret = fixup_pi_state_owner(uaddr2, &q, current);
- if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == current) {
- pi_state = q.pi_state;
-@@ -3290,7 +3290,7 @@ static int futex_wait_requeue_pi(u32 __u
- * the requeue_pi() code acquired for us.
- */
- put_pi_state(q.pi_state);
-- spin_unlock(q.lock_ptr);
-+ raw_spin_unlock(q.lock_ptr);
- }
- } else {
- struct rt_mutex *pi_mutex;
-@@ -3304,7 +3304,7 @@ static int futex_wait_requeue_pi(u32 __u
- pi_mutex = &q.pi_state->pi_mutex;
- ret = rt_mutex_wait_proxy_lock(pi_mutex, to, &rt_waiter);
-
-- spin_lock(q.lock_ptr);
-+ raw_spin_lock(q.lock_ptr);
- if (ret && !rt_mutex_cleanup_proxy_lock(pi_mutex, &rt_waiter))
- ret = 0;
-
-@@ -3929,7 +3929,7 @@ static int __init futex_init(void)
- for (i = 0; i < futex_hashsize; i++) {
- atomic_set(&futex_queues[i].waiters, 0);
- plist_head_init(&futex_queues[i].chain);
-- spin_lock_init(&futex_queues[i].lock);
-+ raw_spin_lock_init(&futex_queues[i].lock);
- }
-
- return 0;
diff --git a/debian/patches-rt/futex-requeue-pi-fix.patch b/debian/patches-rt/futex-requeue-pi-fix.patch
new file mode 100644
index 000000000000..921ce1a0cd13
--- /dev/null
+++ b/debian/patches-rt/futex-requeue-pi-fix.patch
@@ -0,0 +1,113 @@
+From: Steven Rostedt <rostedt@goodmis.org>
+Date: Tue, 14 Jul 2015 14:26:34 +0200
+Subject: futex: Fix bug on when a requeued RT task times out
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Requeue with timeout causes a bug with PREEMPT_RT.
+
+The bug comes from a timed out condition.
+
+
+ TASK 1 TASK 2
+ ------ ------
+ futex_wait_requeue_pi()
+ futex_wait_queue_me()
+ <timed out>
+
+ double_lock_hb();
+
+ raw_spin_lock(pi_lock);
+ if (current->pi_blocked_on) {
+ } else {
+ current->pi_blocked_on = PI_WAKE_INPROGRESS;
+ run_spin_unlock(pi_lock);
+ spin_lock(hb->lock); <-- blocked!
+
+
+ plist_for_each_entry_safe(this) {
+ rt_mutex_start_proxy_lock();
+ task_blocks_on_rt_mutex();
+ BUG_ON(task->pi_blocked_on)!!!!
+
+The BUG_ON() actually has a check for PI_WAKE_INPROGRESS, but the
+problem is that, after TASK 1 sets PI_WAKE_INPROGRESS, it then tries to
+grab the hb->lock, which it fails to do so. As the hb->lock is a mutex,
+it will block and set the "pi_blocked_on" to the hb->lock.
+
+When TASK 2 goes to requeue it, the check for PI_WAKE_INPROGESS fails
+because the task1's pi_blocked_on is no longer set to that, but instead,
+set to the hb->lock.
+
+The fix:
+
+When calling rt_mutex_start_proxy_lock() a check is made to see
+if the proxy tasks pi_blocked_on is set. If so, exit out early.
+Otherwise set it to a new flag PI_REQUEUE_INPROGRESS, which notifies
+the proxy task that it is being requeued, and will handle things
+appropriately.
+
+
+Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+---
+ kernel/locking/rtmutex.c | 31 ++++++++++++++++++++++++++++++-
+ kernel/locking/rtmutex_common.h | 1 +
+ 2 files changed, 31 insertions(+), 1 deletion(-)
+
+--- a/kernel/locking/rtmutex.c
++++ b/kernel/locking/rtmutex.c
+@@ -138,7 +138,8 @@ static void fixup_rt_mutex_waiters(struc
+
+ static int rt_mutex_real_waiter(struct rt_mutex_waiter *waiter)
+ {
+- return waiter && waiter != PI_WAKEUP_INPROGRESS;
++ return waiter && waiter != PI_WAKEUP_INPROGRESS &&
++ waiter != PI_REQUEUE_INPROGRESS;
+ }
+
+ /*
+@@ -1779,6 +1780,34 @@ int __rt_mutex_start_proxy_lock(struct r
+ if (try_to_take_rt_mutex(lock, task, NULL))
+ return 1;
+
++#ifdef CONFIG_PREEMPT_RT
++ /*
++ * In PREEMPT_RT there's an added race.
++ * If the task, that we are about to requeue, times out,
++ * it can set the PI_WAKEUP_INPROGRESS. This tells the requeue
++ * to skip this task. But right after the task sets
++ * its pi_blocked_on to PI_WAKEUP_INPROGRESS it can then
++ * block on the spin_lock(&hb->lock), which in RT is an rtmutex.
++ * This will replace the PI_WAKEUP_INPROGRESS with the actual
++ * lock that it blocks on. We *must not* place this task
++ * on this proxy lock in that case.
++ *
++ * To prevent this race, we first take the task's pi_lock
++ * and check if it has updated its pi_blocked_on. If it has,
++ * we assume that it woke up and we return -EAGAIN.
++ * Otherwise, we set the task's pi_blocked_on to
++ * PI_REQUEUE_INPROGRESS, so that if the task is waking up
++ * it will know that we are in the process of requeuing it.
++ */
++ raw_spin_lock(&task->pi_lock);
++ if (task->pi_blocked_on) {
++ raw_spin_unlock(&task->pi_lock);
++ return -EAGAIN;
++ }
++ task->pi_blocked_on = PI_REQUEUE_INPROGRESS;
++ raw_spin_unlock(&task->pi_lock);
++#endif
++
+ /* We enforce deadlock detection for futexes */
+ ret = task_blocks_on_rt_mutex(lock, waiter, task,
+ RT_MUTEX_FULL_CHAINWALK);
+--- a/kernel/locking/rtmutex_common.h
++++ b/kernel/locking/rtmutex_common.h
+@@ -131,6 +131,7 @@ enum rtmutex_chainwalk {
+ * PI-futex support (proxy locking functions, etc.):
+ */
+ #define PI_WAKEUP_INPROGRESS ((struct rt_mutex_waiter *) 1)
++#define PI_REQUEUE_INPROGRESS ((struct rt_mutex_waiter *) 2)
+
+ extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
+ extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
diff --git a/debian/patches-rt/futex-workaround-migrate_disable-enable-in-different.patch b/debian/patches-rt/futex-workaround-migrate_disable-enable-in-different.patch
new file mode 100644
index 000000000000..7d89fbcbf493
--- /dev/null
+++ b/debian/patches-rt/futex-workaround-migrate_disable-enable-in-different.patch
@@ -0,0 +1,67 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Wed, 8 Mar 2017 14:23:35 +0100
+Subject: [PATCH] futex: workaround migrate_disable/enable in different context
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+migrate_enable() invokes __schedule() and it expects a preempt count of one.
+Holding a raw_spinlock_t with disabled interrupts should not allow scheduling.
+
+These little hacks ensure that we don't schedule while we lock the hb lockwith
+interrupts enabled and unlock it with interrupts disabled.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+[XXX: As per PeterZ suggesstion
+ set_thread_flag(TIF_NEED_RESCHED); preempt_fold_need_resched()
+ would trigger a scheduler invocation on the last preempt_enable() which in
+ turn would allow to drop this.
+]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/futex.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+--- a/kernel/futex.c
++++ b/kernel/futex.c
+@@ -2980,6 +2980,14 @@ static int futex_lock_pi(u32 __user *uad
+ * before __rt_mutex_start_proxy_lock() is done.
+ */
+ raw_spin_lock_irq(&q.pi_state->pi_mutex.wait_lock);
++ /*
++ * the migrate_disable() here disables migration in the in_atomic() fast
++ * path which is enabled again in the following spin_unlock(). We have
++ * one migrate_disable() pending in the slow-path which is reversed
++ * after the raw_spin_unlock_irq() where we leave the atomic context.
++ */
++ migrate_disable();
++
+ spin_unlock(q.lock_ptr);
+ /*
+ * __rt_mutex_start_proxy_lock() unconditionally enqueues the @rt_waiter
+@@ -2988,6 +2996,7 @@ static int futex_lock_pi(u32 __user *uad
+ */
+ ret = __rt_mutex_start_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter, current);
+ raw_spin_unlock_irq(&q.pi_state->pi_mutex.wait_lock);
++ migrate_enable();
+
+ if (ret) {
+ if (ret == 1)
+@@ -3136,10 +3145,19 @@ static int futex_unlock_pi(u32 __user *u
+ * rt_waiter. Also see the WARN in wake_futex_pi().
+ */
+ raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
++ /*
++ * Magic trickery for now to make the RT migrate disable
++ * logic happy. The following spin_unlock() happens with
++ * interrupts disabled so the internal migrate_enable()
++ * won't undo the migrate_disable() which was issued when
++ * locking hb->lock.
++ */
++ migrate_disable();
+ spin_unlock(&hb->lock);
+
+ /* drops pi_state->pi_mutex.wait_lock */
+ ret = wake_futex_pi(uaddr, uval, pi_state);
++ migrate_enable();
+
+ put_pi_state(pi_state);
+
diff --git a/debian/patches-rt/genirq-disable-irqpoll-on-rt.patch b/debian/patches-rt/genirq-disable-irqpoll-on-rt.patch
index 30db096a3a76..62740a22756d 100644
--- a/debian/patches-rt/genirq-disable-irqpoll-on-rt.patch
+++ b/debian/patches-rt/genirq-disable-irqpoll-on-rt.patch
@@ -1,7 +1,7 @@
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:29:57 -0500
Subject: genirq: Disable irqpoll on -rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Creates long latencies for no value
@@ -18,8 +18,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static int __init irqfixup_setup(char *str)
{
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ pr_warn("irqfixup boot option not supported w/ CONFIG_PREEMPT_RT_BASE\n");
++#ifdef CONFIG_PREEMPT_RT
++ pr_warn("irqfixup boot option not supported w/ CONFIG_PREEMPT_RT\n");
+ return 1;
+#endif
irqfixup = 1;
@@ -29,8 +29,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static int __init irqpoll_setup(char *str)
{
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ pr_warn("irqpoll boot option not supported w/ CONFIG_PREEMPT_RT_BASE\n");
++#ifdef CONFIG_PREEMPT_RT
++ pr_warn("irqpoll boot option not supported w/ CONFIG_PREEMPT_RT\n");
+ return 1;
+#endif
irqfixup = 2;
diff --git a/debian/patches-rt/genirq-force-threading.patch b/debian/patches-rt/genirq-force-threading.patch
deleted file mode 100644
index f692e5c9262e..000000000000
--- a/debian/patches-rt/genirq-force-threading.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-Subject: genirq: Force interrupt thread on RT
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Sun, 03 Apr 2011 11:57:29 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Force threaded_irqs and optimize the code (force_irqthreads) in regard
-to this.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- include/linux/interrupt.h | 4 ++++
- kernel/irq/manage.c | 2 ++
- 2 files changed, 6 insertions(+)
-
---- a/include/linux/interrupt.h
-+++ b/include/linux/interrupt.h
-@@ -472,7 +472,11 @@ extern int irq_set_irqchip_state(unsigne
- bool state);
-
- #ifdef CONFIG_IRQ_FORCED_THREADING
-+# ifdef CONFIG_PREEMPT_RT_BASE
-+# define force_irqthreads (true)
-+# else
- extern bool force_irqthreads;
-+# endif
- #else
- #define force_irqthreads (0)
- #endif
---- a/kernel/irq/manage.c
-+++ b/kernel/irq/manage.c
-@@ -24,6 +24,7 @@
- #include "internals.h"
-
- #ifdef CONFIG_IRQ_FORCED_THREADING
-+# ifndef CONFIG_PREEMPT_RT_BASE
- __read_mostly bool force_irqthreads;
- EXPORT_SYMBOL_GPL(force_irqthreads);
-
-@@ -33,6 +34,7 @@ static int __init setup_forced_irqthread
- return 0;
- }
- early_param("threadirqs", setup_forced_irqthreads);
-+# endif
- #endif
-
- static void __synchronize_hardirq(struct irq_desc *desc, bool sync_chip)
diff --git a/debian/patches-rt/genirq-update-irq_set_irqchip_state-documentation.patch b/debian/patches-rt/genirq-update-irq_set_irqchip_state-documentation.patch
index b02cb536a0ce..d94b8097c97f 100644
--- a/debian/patches-rt/genirq-update-irq_set_irqchip_state-documentation.patch
+++ b/debian/patches-rt/genirq-update-irq_set_irqchip_state-documentation.patch
@@ -1,7 +1,7 @@
From: Josh Cartwright <joshc@ni.com>
Date: Thu, 11 Feb 2016 11:54:00 -0600
Subject: genirq: update irq_set_irqchip_state documentation
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
On -rt kernels, the use of migrate_disable()/migrate_enable() is
sufficient to guarantee a task isn't moved to another CPU. Update the
@@ -15,7 +15,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
-@@ -2684,7 +2684,7 @@ EXPORT_SYMBOL_GPL(irq_get_irqchip_state)
+@@ -2687,7 +2687,7 @@ EXPORT_SYMBOL_GPL(irq_get_irqchip_state)
* This call sets the internal irqchip state of an interrupt,
* depending on the value of @which.
*
diff --git a/debian/patches-rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch b/debian/patches-rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch
deleted file mode 100644
index 2b023a452157..000000000000
--- a/debian/patches-rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Fri, 4 Aug 2017 18:31:00 +0200
-Subject: [PATCH] hotplug: duct-tape RT-rwlock usage for non-RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-This type is only available on -RT. We need to craft something for
-non-RT. Since the only migrate_disable() user is -RT only, there is no
-damage.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/cpu.c | 14 +++++++++++++-
- 1 file changed, 13 insertions(+), 1 deletion(-)
-
---- a/kernel/cpu.c
-+++ b/kernel/cpu.c
-@@ -76,7 +76,7 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_s
- .fail = CPUHP_INVALID,
- };
-
--#ifdef CONFIG_HOTPLUG_CPU
-+#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PREEMPT_RT_FULL)
- static DEFINE_PER_CPU(struct rt_rw_lock, cpuhp_pin_lock) = \
- __RWLOCK_RT_INITIALIZER(cpuhp_pin_lock);
- #endif
-@@ -292,6 +292,7 @@ static int cpu_hotplug_disabled;
- */
- void pin_current_cpu(void)
- {
-+#ifdef CONFIG_PREEMPT_RT_FULL
- struct rt_rw_lock *cpuhp_pin;
- unsigned int cpu;
- int ret;
-@@ -314,6 +315,7 @@ void pin_current_cpu(void)
- goto again;
- }
- current->pinned_on_cpu = cpu;
-+#endif
- }
-
- /**
-@@ -321,6 +323,7 @@ void pin_current_cpu(void)
- */
- void unpin_current_cpu(void)
- {
-+#ifdef CONFIG_PREEMPT_RT_FULL
- struct rt_rw_lock *cpuhp_pin = this_cpu_ptr(&cpuhp_pin_lock);
-
- if (WARN_ON(current->pinned_on_cpu != smp_processor_id()))
-@@ -328,6 +331,7 @@ void unpin_current_cpu(void)
-
- current->pinned_on_cpu = -1;
- __read_rt_unlock(cpuhp_pin);
-+#endif
- }
-
- DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock);
-@@ -918,7 +922,9 @@ static int take_cpu_down(void *_param)
-
- static int takedown_cpu(unsigned int cpu)
- {
-+#ifdef CONFIG_PREEMPT_RT_FULL
- struct rt_rw_lock *cpuhp_pin = per_cpu_ptr(&cpuhp_pin_lock, cpu);
-+#endif
- struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
- int err;
-
-@@ -931,14 +937,18 @@ static int takedown_cpu(unsigned int cpu
- */
- irq_lock_sparse();
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
- __write_rt_lock(cpuhp_pin);
-+#endif
-
- /*
- * So now all preempt/rcu users must observe !cpu_active().
- */
- err = stop_machine_cpuslocked(take_cpu_down, NULL, cpumask_of(cpu));
- if (err) {
-+#ifdef CONFIG_PREEMPT_RT_FULL
- __write_rt_unlock(cpuhp_pin);
-+#endif
- /* CPU refused to die */
- irq_unlock_sparse();
- /* Unpark the hotplug thread so we can rollback there */
-@@ -957,7 +967,9 @@ static int takedown_cpu(unsigned int cpu
- wait_for_ap_thread(st, false);
- BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
- __write_rt_unlock(cpuhp_pin);
-+#endif
- /* Interrupts are moved away from the dying cpu, reenable alloc/free */
- irq_unlock_sparse();
-
diff --git a/debian/patches-rt/hotplug-light-get-online-cpus.patch b/debian/patches-rt/hotplug-light-get-online-cpus.patch
deleted file mode 100644
index 71ad8e5eba36..000000000000
--- a/debian/patches-rt/hotplug-light-get-online-cpus.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-Subject: hotplug: Lightweight get online cpus
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Wed, 15 Jun 2011 12:36:06 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-get_online_cpus() is a heavy weight function which involves a global
-mutex. migrate_disable() wants a simpler construct which prevents only
-a CPU from going doing while a task is in a migrate disabled section.
-
-Implement a per cpu lockless mechanism, which serializes only in the
-real unplug case on a global mutex. That serialization affects only
-tasks on the cpu which should be brought down.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- include/linux/cpu.h | 5 +++++
- kernel/cpu.c | 15 +++++++++++++++
- kernel/sched/core.c | 3 +++
- 3 files changed, 23 insertions(+)
-
---- a/include/linux/cpu.h
-+++ b/include/linux/cpu.h
-@@ -113,6 +113,8 @@ extern void cpu_hotplug_disable(void);
- extern void cpu_hotplug_enable(void);
- void clear_tasks_mm_cpumask(int cpu);
- int cpu_down(unsigned int cpu);
-+extern void pin_current_cpu(void);
-+extern void unpin_current_cpu(void);
-
- #else /* CONFIG_HOTPLUG_CPU */
-
-@@ -124,6 +126,9 @@ static inline int cpus_read_trylock(voi
- static inline void lockdep_assert_cpus_held(void) { }
- static inline void cpu_hotplug_disable(void) { }
- static inline void cpu_hotplug_enable(void) { }
-+static inline void pin_current_cpu(void) { }
-+static inline void unpin_current_cpu(void) { }
-+
- #endif /* !CONFIG_HOTPLUG_CPU */
-
- /* Wrappers which go away once all code is converted */
---- a/kernel/cpu.c
-+++ b/kernel/cpu.c
-@@ -282,6 +282,21 @@ static int cpu_hotplug_disabled;
-
- #ifdef CONFIG_HOTPLUG_CPU
-
-+/**
-+ * pin_current_cpu - Prevent the current cpu from being unplugged
-+ */
-+void pin_current_cpu(void)
-+{
-+
-+}
-+
-+/**
-+ * unpin_current_cpu - Allow unplug of current cpu
-+ */
-+void unpin_current_cpu(void)
-+{
-+}
-+
- DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock);
-
- void cpus_read_lock(void)
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7214,6 +7214,7 @@ void migrate_disable(void)
- }
-
- preempt_disable();
-+ pin_current_cpu();
-
- migrate_disable_update_cpus_allowed(p);
- p->migrate_disable = 1;
-@@ -7279,11 +7280,13 @@ void migrate_enable(void)
- arg.task = p;
- arg.dest_cpu = dest_cpu;
-
-+ unpin_current_cpu();
- preempt_enable();
- stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
- return;
- }
- }
-+ unpin_current_cpu();
- preempt_enable();
- }
- EXPORT_SYMBOL(migrate_enable);
diff --git a/debian/patches-rt/hrtimer-Add-a-missing-bracket-and-hide-migration_bas.patch b/debian/patches-rt/hrtimer-Add-a-missing-bracket-and-hide-migration_bas.patch
deleted file mode 100644
index 37a918c00757..000000000000
--- a/debian/patches-rt/hrtimer-Add-a-missing-bracket-and-hide-migration_bas.patch
+++ /dev/null
@@ -1,66 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 4 Sep 2019 16:55:27 +0200
-Subject: [PATCH] hrtimer: Add a missing bracket and hide `migration_base' on
- !SMP
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-[ Upstream commit 5d2295f3a93b04986d069ebeaf5b07725f9096c1 ]
-
-The recent change to avoid taking the expiry lock when a timer is currently
-migrated missed to add a bracket at the end of the if statement leading to
-compile errors. Since that commit the variable `migration_base' is always
-used but it is only available on SMP configuration thus leading to another
-compile error. The changelog says "The timer base and base->cpu_base
-cannot be NULL in the code path", so it is safe to limit this check to SMP
-configurations only.
-
-Add the missing bracket to the if statement and hide `migration_base'
-behind CONFIG_SMP bars.
-
-[ tglx: Mark the functions inline ... ]
-
-Fixes: 68b2c8c1e4210 ("hrtimer: Don't take expiry_lock when timer is currently migrated")
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Link: https://lkml.kernel.org/r/20190904145527.eah7z56ntwobqm6j@linutronix.de
-[bigeasy: port back to RT]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/hrtimer.c | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
-
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -141,6 +141,11 @@ static struct hrtimer_cpu_base migration
-
- #define migration_base migration_cpu_base.clock_base[0]
-
-+static inline bool is_migration_base(struct hrtimer_clock_base *base)
-+{
-+ return base == &migration_base;
-+}
-+
- /*
- * We are using hashed locking: holding per_cpu(hrtimer_bases)[n].lock
- * means that all timers which are tied to this base via timer->base are
-@@ -265,6 +270,11 @@ switch_hrtimer_base(struct hrtimer *time
-
- #else /* CONFIG_SMP */
-
-+static inline bool is_migration_base(struct hrtimer_clock_base *base)
-+{
-+ return false;
-+}
-+
- static inline struct hrtimer_clock_base *
- lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
- {
-@@ -934,7 +944,7 @@ void hrtimer_grab_expiry_lock(const stru
- {
- struct hrtimer_clock_base *base = READ_ONCE(timer->base);
-
-- if (timer->is_soft && base != &migration_base) {
-+ if (timer->is_soft && is_migration_base(base)) {
- spin_lock(&base->cpu_base->softirq_expiry_lock);
- spin_unlock(&base->cpu_base->softirq_expiry_lock);
- }
diff --git a/debian/patches-rt/hrtimer-Allow-raw-wakeups-during-boot.patch b/debian/patches-rt/hrtimer-Allow-raw-wakeups-during-boot.patch
new file mode 100644
index 000000000000..29760ba4cc56
--- /dev/null
+++ b/debian/patches-rt/hrtimer-Allow-raw-wakeups-during-boot.patch
@@ -0,0 +1,34 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 9 Aug 2019 15:25:21 +0200
+Subject: [PATCH] hrtimer: Allow raw wakeups during boot
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+There are a few wake-up timers during the early boot which are essencial for
+the system to make progress. At this stage there are no softirq spawn for the
+softirq processing so there is no timer processing in softirq.
+The wakeup in question:
+
+smpboot_create_thread()
+ -> kthread_create_on_cpu()
+ -> kthread_bind()
+ -> wait_task_inactive()
+ -> schedule_hrtimeout()
+
+Let the timer fire in hardirq context during the system boot.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/time/hrtimer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/kernel/time/hrtimer.c
++++ b/kernel/time/hrtimer.c
+@@ -1816,7 +1816,7 @@ static void __hrtimer_init_sleeper(struc
+ * expiry.
+ */
+ if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
+- if (task_is_realtime(current) && !(mode & HRTIMER_MODE_SOFT))
++ if ((task_is_realtime(current) && !(mode & HRTIMER_MODE_SOFT)) || system_state != SYSTEM_RUNNING)
+ mode |= HRTIMER_MODE_HARD;
+ }
+
diff --git a/debian/patches-rt/hrtimer-Introduce-expiry-spin-lock.patch b/debian/patches-rt/hrtimer-Introduce-expiry-spin-lock.patch
deleted file mode 100644
index f33cfe91852c..000000000000
--- a/debian/patches-rt/hrtimer-Introduce-expiry-spin-lock.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-From: Anna-Maria Gleixner <anna-maria@linutronix.de>
-Date: Mon, 27 May 2019 16:54:04 +0200
-Subject: [PATCH] hrtimer: Introduce expiry spin lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-When deleting a hrtimer, it is possible, that the CPU has to spin, because the
-hrtimer is marked as running. This is done via cpu_relax() and repeating trying to
-delete the timer. When doing this in a virtual machine, the CPU wastes vcpu time
-because of spinning as long as the timer is no longer running.
-
-The spinning and time wasting, could be prevented by using PARAVIRT_SPINLOCKS
-and introducing a per timer base spin lock for expiry. The lock is hold during
-expiring the timers of a base. When the deletion of a timer wasn't successful,
-because the timer is running at the moment, the expiry lock is trying to
-accessed instead of cpu_realax(). The lock is already held by the CPU expring
-the timers, so the CPU could be scheduled out instead of spinning until the lock
-is released, because of the PARAVIRT_SPINLOCKS code. Thereby wasting time
-spinning around is prevented.
-
-The code isn't done conditionally on PARAVIRT_SPINLOCKS. The lock is taken only
-at two places. In one of them the lock is directly dropped after accessing
-it. So the probability for a slowpath when taking the lock is very low. But this
-keeps the code cleaner than introducing several CONFIG_PARAVIRT_SPINLOCKS
-dependend code paths and struct members.
-
-Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/hrtimer.h | 3 +++
- kernel/time/hrtimer.c | 15 ++++++++++++++-
- 2 files changed, 17 insertions(+), 1 deletion(-)
-
---- a/include/linux/hrtimer.h
-+++ b/include/linux/hrtimer.h
-@@ -183,6 +183,8 @@ enum hrtimer_base_type {
- * @nr_retries: Total number of hrtimer interrupt retries
- * @nr_hangs: Total number of hrtimer interrupt hangs
- * @max_hang_time: Maximum time spent in hrtimer_interrupt
-+ * @softirq_expiry_lock: Lock which is taken while softirq based hrtimer are
-+ * expired
- * @expires_next: absolute time of the next event, is required for remote
- * hrtimer enqueue; it is the total first expiry time (hard
- * and soft hrtimer are taken into account)
-@@ -210,6 +212,7 @@ struct hrtimer_cpu_base {
- unsigned short nr_hangs;
- unsigned int max_hang_time;
- #endif
-+ spinlock_t softirq_expiry_lock;
- ktime_t expires_next;
- struct hrtimer *next_timer;
- ktime_t softirq_expires_next;
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -930,6 +930,16 @@ u64 hrtimer_forward(struct hrtimer *time
- }
- EXPORT_SYMBOL_GPL(hrtimer_forward);
-
-+static void hrtimer_grab_expiry_lock(const struct hrtimer *timer)
-+{
-+ struct hrtimer_clock_base *base = timer->base;
-+
-+ if (base && base->cpu_base) {
-+ spin_lock(&base->cpu_base->softirq_expiry_lock);
-+ spin_unlock(&base->cpu_base->softirq_expiry_lock);
-+ }
-+}
-+
- /*
- * enqueue_hrtimer - internal function to (re)start a timer
- *
-@@ -1162,7 +1172,7 @@ int hrtimer_cancel(struct hrtimer *timer
-
- if (ret >= 0)
- return ret;
-- cpu_relax();
-+ hrtimer_grab_expiry_lock(timer);
- }
- }
- EXPORT_SYMBOL_GPL(hrtimer_cancel);
-@@ -1459,6 +1469,7 @@ static __latent_entropy void hrtimer_run
- unsigned long flags;
- ktime_t now;
-
-+ spin_lock(&cpu_base->softirq_expiry_lock);
- raw_spin_lock_irqsave(&cpu_base->lock, flags);
-
- now = hrtimer_update_base(cpu_base);
-@@ -1468,6 +1479,7 @@ static __latent_entropy void hrtimer_run
- hrtimer_update_softirq_timer(cpu_base, true);
-
- raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
-+ spin_unlock(&cpu_base->softirq_expiry_lock);
- }
-
- #ifdef CONFIG_HIGH_RES_TIMERS
-@@ -1809,6 +1821,7 @@ int hrtimers_prepare_cpu(unsigned int cp
- cpu_base->softirq_next_timer = NULL;
- cpu_base->expires_next = KTIME_MAX;
- cpu_base->softirq_expires_next = KTIME_MAX;
-+ spin_lock_init(&cpu_base->softirq_expiry_lock);
- return 0;
- }
-
diff --git a/debian/patches-rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch b/debian/patches-rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch
deleted file mode 100644
index cddacda2c689..000000000000
--- a/debian/patches-rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch
+++ /dev/null
@@ -1,210 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Fri, 3 Jul 2009 08:44:31 -0500
-Subject: hrtimer: by timers by default into the softirq context
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-We can't have hrtimers callbacks running in hardirq context on RT. Therefore
-the timers are deferred to the softirq context by default.
-There are few timers which expect to be run in hardirq context even on RT.
-Those are:
-- very short running where low latency is critical (kvm lapic)
-- timers which take raw locks and need run in hard-irq context (perf, sched)
-- wake up related timer (kernel side of clock_nanosleep() and so on)
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/x86/kvm/lapic.c | 2 +-
- include/linux/hrtimer.h | 6 ++++++
- kernel/events/core.c | 4 ++--
- kernel/sched/core.c | 2 +-
- kernel/sched/deadline.c | 2 +-
- kernel/sched/fair.c | 4 ++--
- kernel/sched/rt.c | 4 ++--
- kernel/time/hrtimer.c | 21 +++++++++++++++++++--
- kernel/time/tick-broadcast-hrtimer.c | 2 +-
- kernel/time/tick-sched.c | 2 +-
- kernel/watchdog.c | 2 +-
- 11 files changed, 37 insertions(+), 14 deletions(-)
-
---- a/arch/x86/kvm/lapic.c
-+++ b/arch/x86/kvm/lapic.c
-@@ -2313,7 +2313,7 @@ int kvm_create_lapic(struct kvm_vcpu *vc
- apic->vcpu = vcpu;
-
- hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC,
-- HRTIMER_MODE_ABS_PINNED);
-+ HRTIMER_MODE_ABS_PINNED_HARD);
- apic->lapic_timer.timer.function = apic_timer_fn;
- if (timer_advance_ns == -1) {
- apic->lapic_timer.timer_advance_ns = 1000;
---- a/include/linux/hrtimer.h
-+++ b/include/linux/hrtimer.h
-@@ -38,6 +38,7 @@ enum hrtimer_mode {
- HRTIMER_MODE_REL = 0x01,
- HRTIMER_MODE_PINNED = 0x02,
- HRTIMER_MODE_SOFT = 0x04,
-+ HRTIMER_MODE_HARD = 0x08,
-
- HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED,
- HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED,
-@@ -48,6 +49,11 @@ enum hrtimer_mode {
- HRTIMER_MODE_ABS_PINNED_SOFT = HRTIMER_MODE_ABS_PINNED | HRTIMER_MODE_SOFT,
- HRTIMER_MODE_REL_PINNED_SOFT = HRTIMER_MODE_REL_PINNED | HRTIMER_MODE_SOFT,
-
-+ HRTIMER_MODE_ABS_HARD = HRTIMER_MODE_ABS | HRTIMER_MODE_HARD,
-+ HRTIMER_MODE_REL_HARD = HRTIMER_MODE_REL | HRTIMER_MODE_HARD,
-+
-+ HRTIMER_MODE_ABS_PINNED_HARD = HRTIMER_MODE_ABS_PINNED | HRTIMER_MODE_HARD,
-+ HRTIMER_MODE_REL_PINNED_HARD = HRTIMER_MODE_REL_PINNED | HRTIMER_MODE_HARD,
- };
-
- /*
---- a/kernel/events/core.c
-+++ b/kernel/events/core.c
-@@ -1103,7 +1103,7 @@ static void __perf_mux_hrtimer_init(stru
- cpuctx->hrtimer_interval = ns_to_ktime(NSEC_PER_MSEC * interval);
-
- raw_spin_lock_init(&cpuctx->hrtimer_lock);
-- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
-+ hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- timer->function = perf_mux_hrtimer_handler;
- }
-
-@@ -9511,7 +9511,7 @@ static void perf_swevent_init_hrtimer(st
- if (!is_sampling_event(event))
- return;
-
-- hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- hwc->hrtimer.function = perf_swevent_hrtimer;
-
- /*
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -317,7 +317,7 @@ static void hrtick_rq_init(struct rq *rq
- rq->hrtick_csd.info = rq;
- #endif
-
-- hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- rq->hrtick_timer.function = hrtick;
- }
- #else /* CONFIG_SCHED_HRTICK */
---- a/kernel/sched/deadline.c
-+++ b/kernel/sched/deadline.c
-@@ -1053,7 +1053,7 @@ void init_dl_task_timer(struct sched_dl_
- {
- struct hrtimer *timer = &dl_se->dl_timer;
-
-- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- timer->function = dl_task_timer;
- }
-
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -5004,9 +5004,9 @@ void init_cfs_bandwidth(struct cfs_bandw
- cfs_b->period = ns_to_ktime(default_cfs_period());
-
- INIT_LIST_HEAD(&cfs_b->throttled_cfs_rq);
-- hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
-+ hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
- cfs_b->period_timer.function = sched_cfs_period_timer;
-- hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- cfs_b->slack_timer.function = sched_cfs_slack_timer;
- cfs_b->distribute_running = 0;
- }
---- a/kernel/sched/rt.c
-+++ b/kernel/sched/rt.c
-@@ -45,8 +45,8 @@ void init_rt_bandwidth(struct rt_bandwid
-
- raw_spin_lock_init(&rt_b->rt_runtime_lock);
-
-- hrtimer_init(&rt_b->rt_period_timer,
-- CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(&rt_b->rt_period_timer, CLOCK_MONOTONIC,
-+ HRTIMER_MODE_REL_HARD);
- rt_b->rt_period_timer.function = sched_rt_period_timer;
- }
-
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -1109,7 +1109,9 @@ void hrtimer_start_range_ns(struct hrtim
- * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft
- * match.
- */
-+#ifndef CONFIG_PREEMPT_RT_BASE
- WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft);
-+#endif
-
- base = lock_hrtimer_base(timer, &flags);
-
-@@ -1269,10 +1271,17 @@ static inline int hrtimer_clockid_to_bas
- static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
- enum hrtimer_mode mode)
- {
-- bool softtimer = !!(mode & HRTIMER_MODE_SOFT);
-- int base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
-+ bool softtimer;
-+ int base;
- struct hrtimer_cpu_base *cpu_base;
-
-+ softtimer = !!(mode & HRTIMER_MODE_SOFT);
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ if (!softtimer && !(mode & HRTIMER_MODE_HARD))
-+ softtimer = true;
-+#endif
-+ base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
-+
- memset(timer, 0, sizeof(struct hrtimer));
-
- cpu_base = raw_cpu_ptr(&hrtimer_bases);
-@@ -1656,6 +1665,14 @@ static void __hrtimer_init_sleeper(struc
- enum hrtimer_mode mode,
- struct task_struct *task)
- {
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ if (!(mode & (HRTIMER_MODE_SOFT | HRTIMER_MODE_HARD))) {
-+ if (task_is_realtime(current) || system_state != SYSTEM_RUNNING)
-+ mode |= HRTIMER_MODE_HARD;
-+ else
-+ mode |= HRTIMER_MODE_SOFT;
-+ }
-+#endif
- __hrtimer_init(&sl->timer, clock_id, mode);
- sl->timer.function = hrtimer_wakeup;
- sl->task = task;
---- a/kernel/time/tick-broadcast-hrtimer.c
-+++ b/kernel/time/tick-broadcast-hrtimer.c
-@@ -104,7 +104,7 @@ static enum hrtimer_restart bc_handler(s
-
- void tick_setup_hrtimer_broadcast(void)
- {
-- hrtimer_init(&bctimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-+ hrtimer_init(&bctimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- bctimer.function = bc_handler;
- clockevents_register_device(&ce_broadcast_hrtimer);
- }
---- a/kernel/time/tick-sched.c
-+++ b/kernel/time/tick-sched.c
-@@ -1327,7 +1327,7 @@ void tick_setup_sched_timer(void)
- /*
- * Emulate tick processing via per-CPU hrtimers:
- */
-- hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-+ hrtimer_init(&ts->sched_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
- ts->sched_timer.function = tick_sched_timer;
-
- /* Get the next period (per-CPU) */
---- a/kernel/watchdog.c
-+++ b/kernel/watchdog.c
-@@ -490,7 +490,7 @@ static void watchdog_enable(unsigned int
- * Start the timer first to prevent the NMI watchdog triggering
- * before the timer has a chance to fire.
- */
-- hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- hrtimer->function = watchdog_timer_fn;
- hrtimer_start(hrtimer, ns_to_ktime(sample_period),
- HRTIMER_MODE_REL_PINNED);
diff --git a/debian/patches-rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch b/debian/patches-rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch
deleted file mode 100644
index 7d620ef729b1..000000000000
--- a/debian/patches-rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch
+++ /dev/null
@@ -1,271 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 3 Jul 2018 11:25:41 +0200
-Subject: [PATCH v2] hrtimer: consolidate hrtimer_init() + hrtimer_init_sleeper() calls
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-hrtimer_init_sleeper() calls require a prior initialisation of the
-hrtimer object with hrtimer_init(). Lets make the initialisation of
-the hrtimer object part of hrtimer_init_sleeper(). To remain
-consistent consider init_on_stack as well.
-
-Beside adapting the hrtimer_init_sleeper[_on_stack]() functions, call
-sites need to be updated as well.
-
-Link: http://lkml.kernel.org/r/20180703092541.2870-1-anna-maria@linutronix.de
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-[anna-maria: Updating the commit message, add staging/android/vsoc.c]
-Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
----
- block/blk-mq.c | 3 --
- drivers/staging/android/vsoc.c | 6 +----
- include/linux/hrtimer.h | 19 ++++++++++++++--
- include/linux/wait.h | 4 +--
- kernel/futex.c | 19 +++++++---------
- kernel/time/hrtimer.c | 46 ++++++++++++++++++++++++++++++++---------
- net/core/pktgen.c | 4 +--
- 7 files changed, 67 insertions(+), 34 deletions(-)
-
---- a/block/blk-mq.c
-+++ b/block/blk-mq.c
-@@ -3423,10 +3423,9 @@ static bool blk_mq_poll_hybrid_sleep(str
- kt = nsecs;
-
- mode = HRTIMER_MODE_REL;
-- hrtimer_init_on_stack(&hs.timer, CLOCK_MONOTONIC, mode);
-+ hrtimer_init_sleeper_on_stack(&hs, CLOCK_MONOTONIC, mode, current);
- hrtimer_set_expires(&hs.timer, kt);
-
-- hrtimer_init_sleeper(&hs, current);
- do {
- if (blk_mq_rq_state(rq) == MQ_RQ_COMPLETE)
- break;
---- a/drivers/staging/android/vsoc.c
-+++ b/drivers/staging/android/vsoc.c
-@@ -437,12 +437,10 @@ static int handle_vsoc_cond_wait(struct
- return -EINVAL;
- wake_time = ktime_set(arg->wake_time_sec, arg->wake_time_nsec);
-
-- hrtimer_init_on_stack(&to->timer, CLOCK_MONOTONIC,
-- HRTIMER_MODE_ABS);
-+ hrtimer_init_sleeper_on_stack(to, CLOCK_MONOTONIC,
-+ HRTIMER_MODE_ABS, current);
- hrtimer_set_expires_range_ns(&to->timer, wake_time,
- current->timer_slack_ns);
--
-- hrtimer_init_sleeper(to, current);
- }
-
- while (1) {
---- a/include/linux/hrtimer.h
-+++ b/include/linux/hrtimer.h
-@@ -364,10 +364,17 @@ DECLARE_PER_CPU(struct tick_device, tick
- /* Initialize timers: */
- extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
- enum hrtimer_mode mode);
-+extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
-+ enum hrtimer_mode mode,
-+ struct task_struct *task);
-
- #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
- extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
- enum hrtimer_mode mode);
-+extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
-+ clockid_t clock_id,
-+ enum hrtimer_mode mode,
-+ struct task_struct *task);
-
- extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
- #else
-@@ -377,6 +384,15 @@ static inline void hrtimer_init_on_stack
- {
- hrtimer_init(timer, which_clock, mode);
- }
-+
-+static inline void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
-+ clockid_t clock_id,
-+ enum hrtimer_mode mode,
-+ struct task_struct *task)
-+{
-+ hrtimer_init_sleeper(sl, clock_id, mode, task);
-+}
-+
- static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
- #endif
-
-@@ -481,9 +497,6 @@ extern long hrtimer_nanosleep(const stru
- const enum hrtimer_mode mode,
- const clockid_t clockid);
-
--extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
-- struct task_struct *tsk);
--
- extern int schedule_hrtimeout_range(ktime_t *expires, u64 delta,
- const enum hrtimer_mode mode);
- extern int schedule_hrtimeout_range_clock(ktime_t *expires,
---- a/include/linux/wait.h
-+++ b/include/linux/wait.h
-@@ -489,8 +489,8 @@ do { \
- int __ret = 0; \
- struct hrtimer_sleeper __t; \
- \
-- hrtimer_init_on_stack(&__t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); \
-- hrtimer_init_sleeper(&__t, current); \
-+ hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC, HRTIMER_MODE_REL, \
-+ current); \
- if ((timeout) != KTIME_MAX) \
- hrtimer_start_range_ns(&__t.timer, timeout, \
- current->timer_slack_ns, \
---- a/kernel/futex.c
-+++ b/kernel/futex.c
-@@ -2722,10 +2722,9 @@ static int futex_wait(u32 __user *uaddr,
- if (abs_time) {
- to = &timeout;
-
-- hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
-- CLOCK_REALTIME : CLOCK_MONOTONIC,
-- HRTIMER_MODE_ABS);
-- hrtimer_init_sleeper(to, current);
-+ hrtimer_init_sleeper_on_stack(to, (flags & FLAGS_CLOCKRT) ?
-+ CLOCK_REALTIME : CLOCK_MONOTONIC,
-+ HRTIMER_MODE_ABS, current);
- hrtimer_set_expires_range_ns(&to->timer, *abs_time,
- current->timer_slack_ns);
- }
-@@ -2824,9 +2823,8 @@ static int futex_lock_pi(u32 __user *uad
-
- if (time) {
- to = &timeout;
-- hrtimer_init_on_stack(&to->timer, CLOCK_REALTIME,
-- HRTIMER_MODE_ABS);
-- hrtimer_init_sleeper(to, current);
-+ hrtimer_init_sleeper_on_stack(to, CLOCK_REALTIME,
-+ HRTIMER_MODE_ABS, current);
- hrtimer_set_expires(&to->timer, *time);
- }
-
-@@ -3244,10 +3242,9 @@ static int futex_wait_requeue_pi(u32 __u
-
- if (abs_time) {
- to = &timeout;
-- hrtimer_init_on_stack(&to->timer, (flags & FLAGS_CLOCKRT) ?
-- CLOCK_REALTIME : CLOCK_MONOTONIC,
-- HRTIMER_MODE_ABS);
-- hrtimer_init_sleeper(to, current);
-+ hrtimer_init_sleeper_on_stack(to, (flags & FLAGS_CLOCKRT) ?
-+ CLOCK_REALTIME : CLOCK_MONOTONIC,
-+ HRTIMER_MODE_ABS, current);
- hrtimer_set_expires_range_ns(&to->timer, *abs_time,
- current->timer_slack_ns);
- }
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -1651,13 +1651,44 @@ static enum hrtimer_restart hrtimer_wake
- return HRTIMER_NORESTART;
- }
-
--void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, struct task_struct *task)
-+static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
-+ clockid_t clock_id,
-+ enum hrtimer_mode mode,
-+ struct task_struct *task)
- {
-+ __hrtimer_init(&sl->timer, clock_id, mode);
- sl->timer.function = hrtimer_wakeup;
- sl->task = task;
- }
-+
-+/**
-+ * hrtimer_init_sleeper - initialize sleeper to the given clock
-+ * @sl: sleeper to be initialized
-+ * @clock_id: the clock to be used
-+ * @mode: timer mode abs/rel
-+ * @task: the task to wake up
-+ */
-+void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id,
-+ enum hrtimer_mode mode, struct task_struct *task)
-+{
-+ debug_init(&sl->timer, clock_id, mode);
-+ __hrtimer_init_sleeper(sl, clock_id, mode, task);
-+
-+}
- EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
-
-+#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
-+void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl,
-+ clockid_t clock_id,
-+ enum hrtimer_mode mode,
-+ struct task_struct *task)
-+{
-+ debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr);
-+ __hrtimer_init_sleeper(sl, clock_id, mode, task);
-+}
-+EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack);
-+#endif
-+
- int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts)
- {
- switch(restart->nanosleep.type) {
-@@ -1681,8 +1712,6 @@ static int __sched do_nanosleep(struct h
- {
- struct restart_block *restart;
-
-- hrtimer_init_sleeper(t, current);
--
- do {
- set_current_state(TASK_INTERRUPTIBLE);
- hrtimer_start_expires(&t->timer, mode);
-@@ -1719,10 +1748,9 @@ static long __sched hrtimer_nanosleep_re
- struct hrtimer_sleeper t;
- int ret;
-
-- hrtimer_init_on_stack(&t.timer, restart->nanosleep.clockid,
-- HRTIMER_MODE_ABS);
-+ hrtimer_init_sleeper_on_stack(&t, restart->nanosleep.clockid,
-+ HRTIMER_MODE_ABS, current);
- hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);
--
- ret = do_nanosleep(&t, HRTIMER_MODE_ABS);
- destroy_hrtimer_on_stack(&t.timer);
- return ret;
-@@ -1740,7 +1768,7 @@ long hrtimer_nanosleep(const struct time
- if (dl_task(current) || rt_task(current))
- slack = 0;
-
-- hrtimer_init_on_stack(&t.timer, clockid, mode);
-+ hrtimer_init_sleeper_on_stack(&t, clockid, mode, current);
- hrtimer_set_expires_range_ns(&t.timer, timespec64_to_ktime(*rqtp), slack);
- ret = do_nanosleep(&t, mode);
- if (ret != -ERESTART_RESTARTBLOCK)
-@@ -1940,11 +1968,9 @@ schedule_hrtimeout_range_clock(ktime_t *
- return -EINTR;
- }
-
-- hrtimer_init_on_stack(&t.timer, clock_id, mode);
-+ hrtimer_init_sleeper_on_stack(&t, clock_id, mode, current);
- hrtimer_set_expires_range_ns(&t.timer, *expires, delta);
-
-- hrtimer_init_sleeper(&t, current);
--
- hrtimer_start_expires(&t.timer, mode);
-
- if (likely(t.task))
---- a/net/core/pktgen.c
-+++ b/net/core/pktgen.c
-@@ -2154,7 +2154,8 @@ static void spin(struct pktgen_dev *pkt_
- s64 remaining;
- struct hrtimer_sleeper t;
-
-- hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
-+ hrtimer_init_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_ABS,
-+ current);
- hrtimer_set_expires(&t.timer, spin_until);
-
- remaining = ktime_to_ns(hrtimer_expires_remaining(&t.timer));
-@@ -2169,7 +2170,6 @@ static void spin(struct pktgen_dev *pkt_
- } while (ktime_compare(end_time, spin_until) < 0);
- } else {
- /* see do_nanosleep */
-- hrtimer_init_sleeper(&t, current);
- do {
- set_current_state(TASK_INTERRUPTIBLE);
- hrtimer_start_expires(&t.timer, HRTIMER_MODE_ABS);
diff --git a/debian/patches-rt/hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch b/debian/patches-rt/hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch
index 96bc0635ca00..23c46ca10d27 100644
--- a/debian/patches-rt/hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch
+++ b/debian/patches-rt/hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 6 Dec 2018 10:15:13 +0100
Subject: [PATCH] hrtimer: move state change before hrtimer_cancel in
do_nanosleep()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
There is a small window between setting t->task to NULL and waking the
task up (which would set TASK_RUNNING). So the timer would fire, run and
@@ -29,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
-@@ -1736,12 +1736,12 @@ static int __sched do_nanosleep(struct h
+@@ -1870,12 +1870,12 @@ static int __sched do_nanosleep(struct h
if (likely(t->task))
freezable_schedule();
diff --git a/debian/patches-rt/i2c-exynos5-Remove-IRQF_ONESHOT.patch b/debian/patches-rt/i2c-exynos5-Remove-IRQF_ONESHOT.patch
deleted file mode 100644
index a5274806514d..000000000000
--- a/debian/patches-rt/i2c-exynos5-Remove-IRQF_ONESHOT.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 13 Aug 2019 12:30:12 +0200
-Subject: [PATCH] i2c: exynos5: Remove IRQF_ONESHOT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The drivers sets IRQF_ONESHOT and passes only a primary handler. The IRQ
-is masked while the primary is handler is invoked independently of
-IRQF_ONESHOT.
-With IRQF_ONESHOT the core code will not force-thread the interrupt and
-this is probably not intended. I *assume* that the original author copied
-the IRQ registration from another driver which passed a primary and
-secondary handler and removed the secondary handler but keeping the
-ONESHOT flag.
-
-Remove IRQF_ONESHOT.
-
-Reported-by: Benjamin Rouxel <benjamin.rouxel@uva.nl>
-Tested-by: Benjamin Rouxel <benjamin.rouxel@uva.nl>
-Cc: Kukjin Kim <kgene@kernel.org>
-Cc: Krzysztof Kozlowski <krzk@kernel.org>
-Cc: linux-samsung-soc@vger.kernel.org
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- drivers/i2c/busses/i2c-exynos5.c | 4 +---
- 1 file changed, 1 insertion(+), 3 deletions(-)
-
---- a/drivers/i2c/busses/i2c-exynos5.c
-+++ b/drivers/i2c/busses/i2c-exynos5.c
-@@ -791,9 +791,7 @@ static int exynos5_i2c_probe(struct plat
- }
-
- ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
-- IRQF_NO_SUSPEND | IRQF_ONESHOT,
-- dev_name(&pdev->dev), i2c);
--
-+ IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c);
- if (ret != 0) {
- dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq);
- goto err_clk;
diff --git a/debian/patches-rt/i2c-hix5hd2-Remove-IRQF_ONESHOT.patch b/debian/patches-rt/i2c-hix5hd2-Remove-IRQF_ONESHOT.patch
deleted file mode 100644
index 1a38b622dba1..000000000000
--- a/debian/patches-rt/i2c-hix5hd2-Remove-IRQF_ONESHOT.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 13 Aug 2019 12:30:37 +0200
-Subject: [PATCH] i2c: hix5hd2: Remove IRQF_ONESHOT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The drivers sets IRQF_ONESHOT and passes only a primary handler. The IRQ
-is masked while the primary is handler is invoked independently of
-IRQF_ONESHOT.
-With IRQF_ONESHOT the core code will not force-thread the interrupt and
-this is probably not intended. I *assume* that the original author copied
-the IRQ registration from another driver which passed a primary and
-secondary handler and removed the secondary handler but keeping the
-ONESHOT flag.
-
-Remove IRQF_ONESHOT.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- drivers/i2c/busses/i2c-hix5hd2.c | 3 +--
- 1 file changed, 1 insertion(+), 2 deletions(-)
-
---- a/drivers/i2c/busses/i2c-hix5hd2.c
-+++ b/drivers/i2c/busses/i2c-hix5hd2.c
-@@ -445,8 +445,7 @@ static int hix5hd2_i2c_probe(struct plat
- hix5hd2_i2c_init(priv);
-
- ret = devm_request_irq(&pdev->dev, irq, hix5hd2_i2c_irq,
-- IRQF_NO_SUSPEND | IRQF_ONESHOT,
-- dev_name(&pdev->dev), priv);
-+ IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv);
- if (ret != 0) {
- dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq);
- goto err_clk;
diff --git a/debian/patches-rt/irqwork-push_most_work_into_softirq_context.patch b/debian/patches-rt/irqwork-push_most_work_into_softirq_context.patch
index d8094dafb17c..f7c27960172f 100644
--- a/debian/patches-rt/irqwork-push_most_work_into_softirq_context.patch
+++ b/debian/patches-rt/irqwork-push_most_work_into_softirq_context.patch
@@ -1,7 +1,7 @@
Subject: irqwork: push most work into softirq context
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 23 Jun 2015 15:32:51 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Initially we defered all irqwork into softirq because we didn't want the
latency spikes if perf or another user was busy and delayed the RT task.
@@ -45,7 +45,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline void irq_work_run(void) { }
#endif
-+#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
++#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT)
+void irq_work_tick_soft(void);
+#else
+static inline void irq_work_tick_soft(void) { }
@@ -67,7 +67,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void __irq_work_queue_local(struct irq_work *work)
{
+ struct llist_head *list;
-+ bool lazy_work, realtime = IS_ENABLED(CONFIG_PREEMPT_RT_FULL);
++ bool lazy_work, realtime = IS_ENABLED(CONFIG_PREEMPT_RT);
+
+ lazy_work = work->flags & IRQ_WORK_LAZY;
+
@@ -97,7 +97,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Arch remote IPI send/receive backend aren't NMI safe */
WARN_ON_ONCE(in_nmi());
- if (llist_add(&work->llnode, &per_cpu(raised_list, cpu)))
-+ if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL) && !(work->flags & IRQ_WORK_HARD_IRQ))
++ if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(work->flags & IRQ_WORK_HARD_IRQ))
+ list = &per_cpu(lazy_list, cpu);
+ else
+ list = &per_cpu(raised_list, cpu);
@@ -122,7 +122,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct llist_node *llnode;
unsigned long flags;
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+ /*
+ * nort: On RT IRQ-work may run in SOFTIRQ context.
+ */
@@ -137,7 +137,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
irq_work_run_list(this_cpu_ptr(&raised_list));
- irq_work_run_list(this_cpu_ptr(&lazy_list));
-+ if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL)) {
++ if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
+ /*
+ * NOTE: we raise softirq via IPI for safety,
+ * and execute in irq_work_tick() to move the
@@ -155,11 +155,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!llist_empty(raised) && !arch_irq_work_has_interrupt())
irq_work_run_list(raised);
+
-+ if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL))
++ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+ irq_work_run_list(this_cpu_ptr(&lazy_list));
+}
+
-+#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT_FULL)
++#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_PREEMPT_RT)
+void irq_work_tick_soft(void)
+{
irq_work_run_list(this_cpu_ptr(&lazy_list));
@@ -170,7 +170,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Synchronize against the irq_work @entry, ensures the entry is not
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
-@@ -1076,6 +1076,7 @@ static int rcu_implicit_dynticks_qs(stru
+@@ -1096,6 +1096,7 @@ static int rcu_implicit_dynticks_qs(stru
!rdp->rcu_iw_pending && rdp->rcu_iw_gp_seq != rnp->gp_seq &&
(rnp->ffmask & rdp->grpmask)) {
init_irq_work(&rdp->rcu_iw, rcu_iw_handler);
@@ -200,7 +200,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
-@@ -1727,6 +1727,8 @@ static __latent_entropy void run_timer_s
+@@ -1783,6 +1783,8 @@ static __latent_entropy void run_timer_s
{
struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
diff --git a/debian/patches-rt/jump-label-rt.patch b/debian/patches-rt/jump-label-rt.patch
index 086368c23556..986d2a45dd5d 100644
--- a/debian/patches-rt/jump-label-rt.patch
+++ b/debian/patches-rt/jump-label-rt.patch
@@ -1,7 +1,7 @@
Subject: jump-label: disable if stop_machine() is used
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 08 Jul 2015 17:14:48 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Some architectures are using stop_machine() while switching the opcode which
leads to latency spikes.
@@ -25,12 +25,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
-@@ -57,7 +57,7 @@ config ARM
+@@ -64,7 +64,7 @@ config ARM
select HARDIRQS_SW_RESEND
select HAVE_ARCH_AUDITSYSCALL if AEABI && !OABI_COMPAT
select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
- select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
-+ select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU && !PREEMPT_RT_BASE
++ select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU && !PREEMPT_RT
select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
select HAVE_ARCH_MMAP_RND_BITS if MMU
select HAVE_ARCH_SECCOMP_FILTER if AEABI && !OABI_COMPAT
diff --git a/debian/patches-rt/kconfig-disable-a-few-options-rt.patch b/debian/patches-rt/kconfig-disable-a-few-options-rt.patch
index f836056f61b6..636e0bc332b9 100644
--- a/debian/patches-rt/kconfig-disable-a-few-options-rt.patch
+++ b/debian/patches-rt/kconfig-disable-a-few-options-rt.patch
@@ -1,7 +1,7 @@
Subject: kconfig: Disable config options which are not RT compatible
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 24 Jul 2011 12:11:43 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Disable stuff which is known to have issues on RT
@@ -13,22 +13,22 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/Kconfig
+++ b/arch/Kconfig
-@@ -28,6 +28,7 @@ config OPROFILE
+@@ -31,6 +31,7 @@ config OPROFILE
tristate "OProfile system profiling"
depends on PROFILING
depends on HAVE_OPROFILE
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
select RING_BUFFER
select RING_BUFFER_ALLOW_SWAP
help
--- a/mm/Kconfig
+++ b/mm/Kconfig
-@@ -373,7 +373,7 @@ config NOMMU_INITIAL_TRIM_EXCESS
+@@ -369,7 +369,7 @@ config NOMMU_INITIAL_TRIM_EXCESS
config TRANSPARENT_HUGEPAGE
bool "Transparent Hugepage Support"
- depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE
-+ depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE && !PREEMPT_RT_FULL
++ depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE && !PREEMPT_RT
select COMPACTION
select XARRAY_MULTI
help
diff --git a/debian/patches-rt/kconfig-preempt-rt-full.patch b/debian/patches-rt/kconfig-preempt-rt-full.patch
deleted file mode 100644
index 979b8d0ae466..000000000000
--- a/debian/patches-rt/kconfig-preempt-rt-full.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-Subject: kconfig: Add PREEMPT_RT_FULL
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Wed, 29 Jun 2011 14:58:57 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Introduce the final symbol for PREEMPT_RT_FULL.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- init/Makefile | 2 +-
- kernel/Kconfig.preempt | 8 ++++++++
- scripts/mkcompile_h | 4 +++-
- 3 files changed, 12 insertions(+), 2 deletions(-)
-
---- a/init/Makefile
-+++ b/init/Makefile
-@@ -34,4 +34,4 @@ mounts-$(CONFIG_BLK_DEV_MD) += do_mounts
- include/generated/compile.h: FORCE
- @$($(quiet)chk_compile.h)
- $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
-- "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
-+ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CONFIG_PREEMPT_RT_FULL)" "$(CC) $(KBUILD_CFLAGS)"
---- a/kernel/Kconfig.preempt
-+++ b/kernel/Kconfig.preempt
-@@ -70,6 +70,14 @@ config PREEMPT_RTB
- enables changes which are preliminary for the full preemptible
- RT kernel.
-
-+config PREEMPT_RT_FULL
-+ bool "Fully Preemptible Kernel (RT)"
-+ depends on IRQ_FORCED_THREADING
-+ select PREEMPT_RT_BASE
-+ select PREEMPT_RCU
-+ help
-+ All and everything
-+
- endchoice
-
- config PREEMPT_COUNT
---- a/scripts/mkcompile_h
-+++ b/scripts/mkcompile_h
-@@ -5,7 +5,8 @@ TARGET=$1
- ARCH=$2
- SMP=$3
- PREEMPT=$4
--CC=$5
-+RT=$5
-+CC=$6
-
- vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
-
-@@ -53,6 +54,7 @@ UTS_VERSION="#$VERSION"
- CONFIG_FLAGS=""
- if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
- if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
-+if [ -n "$RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS RT"; fi
- UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
-
- # Truncate to maximum length
diff --git a/debian/patches-rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch b/debian/patches-rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch
deleted file mode 100644
index b155453e0e01..000000000000
--- a/debian/patches-rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch
+++ /dev/null
@@ -1,743 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 4 Apr 2017 12:50:16 +0200
-Subject: [PATCH] kernel: sched: Provide a pointer to the valid CPU mask
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-In commit 4b53a3412d66 ("sched/core: Remove the tsk_nr_cpus_allowed()
-wrapper") the tsk_nr_cpus_allowed() wrapper was removed. There was not
-much difference in !RT but in RT we used this to implement
-migrate_disable(). Within a migrate_disable() section the CPU mask is
-restricted to single CPU while the "normal" CPU mask remains untouched.
-
-As an alternative implementation Ingo suggested to use
- struct task_struct {
- const cpumask_t *cpus_ptr;
- cpumask_t cpus_mask;
- };
-with
- t->cpus_allowed_ptr = &t->cpus_allowed;
-
-In -RT we then can switch the cpus_ptr to
- t->cpus_allowed_ptr = &cpumask_of(task_cpu(p));
-
-in a migration disabled region. The rules are simple:
-- Code that 'uses' ->cpus_allowed would use the pointer.
-- Code that 'modifies' ->cpus_allowed would use the direct mask.
-
-While converting the existing users I tried to stick with the rules
-above however… well mostly CPUFREQ tries to temporary switch the CPU
-mask to do something on a certain CPU and then switches the mask back it
-its original value. So in theory `cpus_ptr' could or should be used.
-However if this is invoked in a migration disabled region (which is not
-the case because it would require something like preempt_disable() and
-set_cpus_allowed_ptr() might sleep so it can't be) then the "restore"
-part would restore the wrong mask. So it only looks strange and I go for
-the pointer…
-
-Some drivers copy the cpumask without cpumask_copy() and others use
-cpumask_copy but without alloc_cpumask_var(). I did not fix those as
-part of this, could do this as a follow up…
-
-So is this the way we want it?
-Is the usage of `cpus_ptr' vs `cpus_mask' for the set + restore part
-(see cpufreq users) what we want? At some point it looks like they
-should use a different interface for their doing. I am not sure why
-switching to certain CPU is important but maybe it could be done via a
-workqueue from the CPUFREQ core (so we have a comment desribing why are
-doing this and a get_online_cpus() to ensure that the CPU does not go
-offline too early).
-
-Cc: Peter Zijlstra <peterz@infradead.org>
-Cc: Thomas Gleixner <tglx@linutronix.de>
-Cc: Mike Galbraith <efault@gmx.de>
-Cc: Ingo Molnar <mingo@elte.hu>
-Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/ia64/kernel/mca.c | 2 -
- arch/mips/include/asm/switch_to.h | 4 +-
- arch/mips/kernel/mips-mt-fpaff.c | 2 -
- arch/mips/kernel/traps.c | 6 ++--
- arch/powerpc/platforms/cell/spufs/sched.c | 2 -
- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 -
- drivers/infiniband/hw/hfi1/affinity.c | 6 ++--
- drivers/infiniband/hw/hfi1/sdma.c | 3 --
- drivers/infiniband/hw/qib/qib_file_ops.c | 7 ++---
- fs/proc/array.c | 4 +-
- include/linux/sched.h | 5 ++-
- init/init_task.c | 3 +-
- kernel/cgroup/cpuset.c | 2 -
- kernel/fork.c | 2 +
- kernel/sched/core.c | 40 ++++++++++++++---------------
- kernel/sched/cpudeadline.c | 4 +-
- kernel/sched/cpupri.c | 4 +-
- kernel/sched/deadline.c | 6 ++--
- kernel/sched/fair.c | 34 ++++++++++++------------
- kernel/sched/rt.c | 4 +-
- kernel/trace/trace_hwlat.c | 2 -
- lib/smp_processor_id.c | 2 -
- samples/trace_events/trace-events-sample.c | 2 -
- 23 files changed, 75 insertions(+), 73 deletions(-)
-
---- a/arch/ia64/kernel/mca.c
-+++ b/arch/ia64/kernel/mca.c
-@@ -1831,7 +1831,7 @@ format_mca_init_stack(void *mca_data, un
- ti->cpu = cpu;
- p->stack = ti;
- p->state = TASK_UNINTERRUPTIBLE;
-- cpumask_set_cpu(cpu, &p->cpus_allowed);
-+ cpumask_set_cpu(cpu, &p->cpus_mask);
- INIT_LIST_HEAD(&p->tasks);
- p->parent = p->real_parent = p->group_leader = p;
- INIT_LIST_HEAD(&p->children);
---- a/arch/mips/include/asm/switch_to.h
-+++ b/arch/mips/include/asm/switch_to.h
-@@ -42,7 +42,7 @@ extern struct task_struct *ll_task;
- * inline to try to keep the overhead down. If we have been forced to run on
- * a "CPU" with an FPU because of a previous high level of FP computation,
- * but did not actually use the FPU during the most recent time-slice (CU1
-- * isn't set), we undo the restriction on cpus_allowed.
-+ * isn't set), we undo the restriction on cpus_mask.
- *
- * We're not calling set_cpus_allowed() here, because we have no need to
- * force prompt migration - we're already switching the current CPU to a
-@@ -57,7 +57,7 @@ do { \
- test_ti_thread_flag(__prev_ti, TIF_FPUBOUND) && \
- (!(KSTK_STATUS(prev) & ST0_CU1))) { \
- clear_ti_thread_flag(__prev_ti, TIF_FPUBOUND); \
-- prev->cpus_allowed = prev->thread.user_cpus_allowed; \
-+ prev->cpus_mask = prev->thread.user_cpus_allowed; \
- } \
- next->thread.emulated_fp = 0; \
- } while(0)
---- a/arch/mips/kernel/mips-mt-fpaff.c
-+++ b/arch/mips/kernel/mips-mt-fpaff.c
-@@ -177,7 +177,7 @@ asmlinkage long mipsmt_sys_sched_getaffi
- if (retval)
- goto out_unlock;
-
-- cpumask_or(&allowed, &p->thread.user_cpus_allowed, &p->cpus_allowed);
-+ cpumask_or(&allowed, &p->thread.user_cpus_allowed, p->cpus_ptr);
- cpumask_and(&mask, &allowed, cpu_active_mask);
-
- out_unlock:
---- a/arch/mips/kernel/traps.c
-+++ b/arch/mips/kernel/traps.c
-@@ -891,12 +891,12 @@ static void mt_ase_fp_affinity(void)
- * restricted the allowed set to exclude any CPUs with FPUs,
- * we'll skip the procedure.
- */
-- if (cpumask_intersects(&current->cpus_allowed, &mt_fpu_cpumask)) {
-+ if (cpumask_intersects(&current->cpus_mask, &mt_fpu_cpumask)) {
- cpumask_t tmask;
-
- current->thread.user_cpus_allowed
-- = current->cpus_allowed;
-- cpumask_and(&tmask, &current->cpus_allowed,
-+ = current->cpus_mask;
-+ cpumask_and(&tmask, &current->cpus_mask,
- &mt_fpu_cpumask);
- set_cpus_allowed_ptr(current, &tmask);
- set_thread_flag(TIF_FPUBOUND);
---- a/arch/powerpc/platforms/cell/spufs/sched.c
-+++ b/arch/powerpc/platforms/cell/spufs/sched.c
-@@ -128,7 +128,7 @@ void __spu_update_sched_info(struct spu_
- * runqueue. The context will be rescheduled on the proper node
- * if it is timesliced or preempted.
- */
-- cpumask_copy(&ctx->cpus_allowed, &current->cpus_allowed);
-+ cpumask_copy(&ctx->cpus_allowed, current->cpus_ptr);
-
- /* Save the current cpu id for spu interrupt routing. */
- ctx->last_ran = raw_smp_processor_id();
---- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
-+++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c
-@@ -1503,7 +1503,7 @@ static int pseudo_lock_dev_mmap(struct f
- * may be scheduled elsewhere and invalidate entries in the
- * pseudo-locked region.
- */
-- if (!cpumask_subset(&current->cpus_allowed, &plr->d->cpu_mask)) {
-+ if (!cpumask_subset(current->cpus_ptr, &plr->d->cpu_mask)) {
- mutex_unlock(&rdtgroup_mutex);
- return -EINVAL;
- }
---- a/drivers/infiniband/hw/hfi1/affinity.c
-+++ b/drivers/infiniband/hw/hfi1/affinity.c
-@@ -1038,7 +1038,7 @@ int hfi1_get_proc_affinity(int node)
- struct hfi1_affinity_node *entry;
- cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;
- const struct cpumask *node_mask,
-- *proc_mask = &current->cpus_allowed;
-+ *proc_mask = current->cpus_ptr;
- struct hfi1_affinity_node_list *affinity = &node_affinity;
- struct cpu_mask_set *set = &affinity->proc;
-
-@@ -1046,7 +1046,7 @@ int hfi1_get_proc_affinity(int node)
- * check whether process/context affinity has already
- * been set
- */
-- if (cpumask_weight(proc_mask) == 1) {
-+ if (current->nr_cpus_allowed == 1) {
- hfi1_cdbg(PROC, "PID %u %s affinity set to CPU %*pbl",
- current->pid, current->comm,
- cpumask_pr_args(proc_mask));
-@@ -1057,7 +1057,7 @@ int hfi1_get_proc_affinity(int node)
- cpu = cpumask_first(proc_mask);
- cpumask_set_cpu(cpu, &set->used);
- goto done;
-- } else if (cpumask_weight(proc_mask) < cpumask_weight(&set->mask)) {
-+ } else if (current->nr_cpus_allowed < cpumask_weight(&set->mask)) {
- hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl",
- current->pid, current->comm,
- cpumask_pr_args(proc_mask));
---- a/drivers/infiniband/hw/hfi1/sdma.c
-+++ b/drivers/infiniband/hw/hfi1/sdma.c
-@@ -869,14 +869,13 @@ struct sdma_engine *sdma_select_user_eng
- {
- struct sdma_rht_node *rht_node;
- struct sdma_engine *sde = NULL;
-- const struct cpumask *current_mask = &current->cpus_allowed;
- unsigned long cpu_id;
-
- /*
- * To ensure that always the same sdma engine(s) will be
- * selected make sure the process is pinned to this CPU only.
- */
-- if (cpumask_weight(current_mask) != 1)
-+ if (current->nr_cpus_allowed != 1)
- goto out;
-
- cpu_id = smp_processor_id();
---- a/drivers/infiniband/hw/qib/qib_file_ops.c
-+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
-@@ -1142,7 +1142,7 @@ static __poll_t qib_poll(struct file *fp
- static void assign_ctxt_affinity(struct file *fp, struct qib_devdata *dd)
- {
- struct qib_filedata *fd = fp->private_data;
-- const unsigned int weight = cpumask_weight(&current->cpus_allowed);
-+ const unsigned int weight = current->nr_cpus_allowed;
- const struct cpumask *local_mask = cpumask_of_pcibus(dd->pcidev->bus);
- int local_cpu;
-
-@@ -1623,9 +1623,8 @@ static int qib_assign_ctxt(struct file *
- ret = find_free_ctxt(i_minor - 1, fp, uinfo);
- else {
- int unit;
-- const unsigned int cpu = cpumask_first(&current->cpus_allowed);
-- const unsigned int weight =
-- cpumask_weight(&current->cpus_allowed);
-+ const unsigned int cpu = cpumask_first(current->cpus_ptr);
-+ const unsigned int weight = current->nr_cpus_allowed;
-
- if (weight == 1 && !test_bit(cpu, qib_cpulist))
- if (!find_hca(cpu, &unit) && unit >= 0)
---- a/fs/proc/array.c
-+++ b/fs/proc/array.c
-@@ -381,9 +381,9 @@ static inline void task_context_switch_c
- static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
- {
- seq_printf(m, "Cpus_allowed:\t%*pb\n",
-- cpumask_pr_args(&task->cpus_allowed));
-+ cpumask_pr_args(task->cpus_ptr));
- seq_printf(m, "Cpus_allowed_list:\t%*pbl\n",
-- cpumask_pr_args(&task->cpus_allowed));
-+ cpumask_pr_args(task->cpus_ptr));
- }
-
- static inline void task_core_dumping(struct seq_file *m, struct mm_struct *mm)
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -651,7 +651,8 @@ struct task_struct {
-
- unsigned int policy;
- int nr_cpus_allowed;
-- cpumask_t cpus_allowed;
-+ const cpumask_t *cpus_ptr;
-+ cpumask_t cpus_mask;
-
- #ifdef CONFIG_PREEMPT_RCU
- int rcu_read_lock_nesting;
-@@ -1410,7 +1411,7 @@ extern struct pid *cad_pid;
- #define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
- #define PF_MEMSTALL 0x01000000 /* Stalled due to lack of memory */
- #define PF_UMH 0x02000000 /* I'm an Usermodehelper process */
--#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
-+#define PF_NO_SETAFFINITY 0x04000000 /* serland is not allowed to meddle with cpus_mask */
- #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
- #define PF_MEMALLOC_NOCMA 0x10000000 /* All allocation request will have _GFP_MOVABLE cleared */
- #define PF_FREEZER_SKIP 0x40000000 /* Freezer should not count it as freezable */
---- a/init/init_task.c
-+++ b/init/init_task.c
-@@ -72,7 +72,8 @@ struct task_struct init_task
- .static_prio = MAX_PRIO - 20,
- .normal_prio = MAX_PRIO - 20,
- .policy = SCHED_NORMAL,
-- .cpus_allowed = CPU_MASK_ALL,
-+ .cpus_ptr = &init_task.cpus_mask,
-+ .cpus_mask = CPU_MASK_ALL,
- .nr_cpus_allowed= NR_CPUS,
- .mm = NULL,
- .active_mm = &init_mm,
---- a/kernel/cgroup/cpuset.c
-+++ b/kernel/cgroup/cpuset.c
-@@ -2829,7 +2829,7 @@ static void cpuset_fork(struct task_stru
- if (task_css_is_root(task, cpuset_cgrp_id))
- return;
-
-- set_cpus_allowed_ptr(task, &current->cpus_allowed);
-+ set_cpus_allowed_ptr(task, current->cpus_ptr);
- task->mems_allowed = current->mems_allowed;
- }
-
---- a/kernel/fork.c
-+++ b/kernel/fork.c
-@@ -898,6 +898,8 @@ static struct task_struct *dup_task_stru
- #ifdef CONFIG_STACKPROTECTOR
- tsk->stack_canary = get_random_canary();
- #endif
-+ if (orig->cpus_ptr == &orig->cpus_mask)
-+ tsk->cpus_ptr = &tsk->cpus_mask;
-
- /*
- * One for us, one for whoever does the "release_task()" (usually
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -930,7 +930,7 @@ static inline bool is_per_cpu_kthread(st
- */
- static inline bool is_cpu_allowed(struct task_struct *p, int cpu)
- {
-- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
- return false;
-
- if (is_per_cpu_kthread(p))
-@@ -1025,7 +1025,7 @@ static int migration_cpu_stop(void *data
- local_irq_disable();
- /*
- * We need to explicitly wake pending tasks before running
-- * __migrate_task() such that we will not miss enforcing cpus_allowed
-+ * __migrate_task() such that we will not miss enforcing cpus_ptr
- * during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test.
- */
- sched_ttwu_pending();
-@@ -1056,7 +1056,7 @@ static int migration_cpu_stop(void *data
- */
- void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask)
- {
-- cpumask_copy(&p->cpus_allowed, new_mask);
-+ cpumask_copy(&p->cpus_mask, new_mask);
- p->nr_cpus_allowed = cpumask_weight(new_mask);
- }
-
-@@ -1126,7 +1126,7 @@ static int __set_cpus_allowed_ptr(struct
- goto out;
- }
-
-- if (cpumask_equal(&p->cpus_allowed, new_mask))
-+ if (cpumask_equal(p->cpus_ptr, new_mask))
- goto out;
-
- if (!cpumask_intersects(new_mask, cpu_valid_mask)) {
-@@ -1286,10 +1286,10 @@ static int migrate_swap_stop(void *data)
- if (task_cpu(arg->src_task) != arg->src_cpu)
- goto unlock;
-
-- if (!cpumask_test_cpu(arg->dst_cpu, &arg->src_task->cpus_allowed))
-+ if (!cpumask_test_cpu(arg->dst_cpu, arg->src_task->cpus_ptr))
- goto unlock;
-
-- if (!cpumask_test_cpu(arg->src_cpu, &arg->dst_task->cpus_allowed))
-+ if (!cpumask_test_cpu(arg->src_cpu, arg->dst_task->cpus_ptr))
- goto unlock;
-
- __migrate_swap_task(arg->src_task, arg->dst_cpu);
-@@ -1331,10 +1331,10 @@ int migrate_swap(struct task_struct *cur
- if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu))
- goto out;
-
-- if (!cpumask_test_cpu(arg.dst_cpu, &arg.src_task->cpus_allowed))
-+ if (!cpumask_test_cpu(arg.dst_cpu, arg.src_task->cpus_ptr))
- goto out;
-
-- if (!cpumask_test_cpu(arg.src_cpu, &arg.dst_task->cpus_allowed))
-+ if (!cpumask_test_cpu(arg.src_cpu, arg.dst_task->cpus_ptr))
- goto out;
-
- trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu);
-@@ -1479,7 +1479,7 @@ void kick_process(struct task_struct *p)
- EXPORT_SYMBOL_GPL(kick_process);
-
- /*
-- * ->cpus_allowed is protected by both rq->lock and p->pi_lock
-+ * ->cpus_ptr is protected by both rq->lock and p->pi_lock
- *
- * A few notes on cpu_active vs cpu_online:
- *
-@@ -1519,14 +1519,14 @@ static int select_fallback_rq(int cpu, s
- for_each_cpu(dest_cpu, nodemask) {
- if (!cpu_active(dest_cpu))
- continue;
-- if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed))
-+ if (cpumask_test_cpu(dest_cpu, p->cpus_ptr))
- return dest_cpu;
- }
- }
-
- for (;;) {
- /* Any allowed, online CPU? */
-- for_each_cpu(dest_cpu, &p->cpus_allowed) {
-+ for_each_cpu(dest_cpu, p->cpus_ptr) {
- if (!is_cpu_allowed(p, dest_cpu))
- continue;
-
-@@ -1570,7 +1570,7 @@ static int select_fallback_rq(int cpu, s
- }
-
- /*
-- * The caller (fork, wakeup) owns p->pi_lock, ->cpus_allowed is stable.
-+ * The caller (fork, wakeup) owns p->pi_lock, ->cpus_ptr is stable.
- */
- static inline
- int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags)
-@@ -1580,11 +1580,11 @@ int select_task_rq(struct task_struct *p
- if (p->nr_cpus_allowed > 1)
- cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags);
- else
-- cpu = cpumask_any(&p->cpus_allowed);
-+ cpu = cpumask_any(p->cpus_ptr);
-
- /*
- * In order not to call set_task_cpu() on a blocking task we need
-- * to rely on ttwu() to place the task on a valid ->cpus_allowed
-+ * to rely on ttwu() to place the task on a valid ->cpus_ptr
- * CPU.
- *
- * Since this is common to all placement strategies, this lives here.
-@@ -2395,7 +2395,7 @@ void wake_up_new_task(struct task_struct
- #ifdef CONFIG_SMP
- /*
- * Fork balancing, do it here and not earlier because:
-- * - cpus_allowed can change in the fork path
-+ * - cpus_ptr can change in the fork path
- * - any previously selected CPU might disappear through hotplug
- *
- * Use __set_task_cpu() to avoid calling sched_class::migrate_task_rq,
-@@ -4270,7 +4270,7 @@ static int __sched_setscheduler(struct t
- * the entire root_domain to become SCHED_DEADLINE. We
- * will also fail if there's no bandwidth available.
- */
-- if (!cpumask_subset(span, &p->cpus_allowed) ||
-+ if (!cpumask_subset(span, p->cpus_ptr) ||
- rq->rd->dl_bw.bw == 0) {
- task_rq_unlock(rq, p, &rf);
- return -EPERM;
-@@ -4869,7 +4869,7 @@ long sched_getaffinity(pid_t pid, struct
- goto out_unlock;
-
- raw_spin_lock_irqsave(&p->pi_lock, flags);
-- cpumask_and(mask, &p->cpus_allowed, cpu_active_mask);
-+ cpumask_and(mask, &p->cpus_mask, cpu_active_mask);
- raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-
- out_unlock:
-@@ -5446,7 +5446,7 @@ int task_can_attach(struct task_struct *
- * allowed nodes is unnecessary. Thus, cpusets are not
- * applicable for such threads. This prevents checking for
- * success of set_cpus_allowed_ptr() on all attached tasks
-- * before cpus_allowed may be changed.
-+ * before cpus_mask may be changed.
- */
- if (p->flags & PF_NO_SETAFFINITY) {
- ret = -EINVAL;
-@@ -5473,7 +5473,7 @@ int migrate_task_to(struct task_struct *
- if (curr_cpu == target_cpu)
- return 0;
-
-- if (!cpumask_test_cpu(target_cpu, &p->cpus_allowed))
-+ if (!cpumask_test_cpu(target_cpu, p->cpus_ptr))
- return -EINVAL;
-
- /* TODO: This is not properly updating schedstats */
-@@ -5611,7 +5611,7 @@ static void migrate_tasks(struct rq *dea
- put_prev_task(rq, next);
-
- /*
-- * Rules for changing task_struct::cpus_allowed are holding
-+ * Rules for changing task_struct::cpus_mask are holding
- * both pi_lock and rq->lock, such that holding either
- * stabilizes the mask.
- *
---- a/kernel/sched/cpudeadline.c
-+++ b/kernel/sched/cpudeadline.c
-@@ -120,14 +120,14 @@ int cpudl_find(struct cpudl *cp, struct
- const struct sched_dl_entity *dl_se = &p->dl;
-
- if (later_mask &&
-- cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) {
-+ cpumask_and(later_mask, cp->free_cpus, p->cpus_ptr)) {
- return 1;
- } else {
- int best_cpu = cpudl_maximum(cp);
-
- WARN_ON(best_cpu != -1 && !cpu_present(best_cpu));
-
-- if (cpumask_test_cpu(best_cpu, &p->cpus_allowed) &&
-+ if (cpumask_test_cpu(best_cpu, p->cpus_ptr) &&
- dl_time_before(dl_se->deadline, cp->elements[0].dl)) {
- if (later_mask)
- cpumask_set_cpu(best_cpu, later_mask);
---- a/kernel/sched/cpupri.c
-+++ b/kernel/sched/cpupri.c
-@@ -94,11 +94,11 @@ int cpupri_find(struct cpupri *cp, struc
- if (skip)
- continue;
-
-- if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids)
-+ if (cpumask_any_and(p->cpus_ptr, vec->mask) >= nr_cpu_ids)
- continue;
-
- if (lowest_mask) {
-- cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask);
-+ cpumask_and(lowest_mask, p->cpus_ptr, vec->mask);
-
- /*
- * We have to ensure that we have at least one bit
---- a/kernel/sched/deadline.c
-+++ b/kernel/sched/deadline.c
-@@ -538,7 +538,7 @@ static struct rq *dl_task_offline_migrat
- * If we cannot preempt any rq, fall back to pick any
- * online CPU:
- */
-- cpu = cpumask_any_and(cpu_active_mask, &p->cpus_allowed);
-+ cpu = cpumask_any_and(cpu_active_mask, p->cpus_ptr);
- if (cpu >= nr_cpu_ids) {
- /*
- * Failed to find any suitable CPU.
-@@ -1824,7 +1824,7 @@ static void set_curr_task_dl(struct rq *
- static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
- {
- if (!task_running(rq, p) &&
-- cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ cpumask_test_cpu(cpu, p->cpus_ptr))
- return 1;
- return 0;
- }
-@@ -1974,7 +1974,7 @@ static struct rq *find_lock_later_rq(str
- /* Retry if something changed. */
- if (double_lock_balance(rq, later_rq)) {
- if (unlikely(task_rq(task) != rq ||
-- !cpumask_test_cpu(later_rq->cpu, &task->cpus_allowed) ||
-+ !cpumask_test_cpu(later_rq->cpu, task->cpus_ptr) ||
- task_running(rq, task) ||
- !dl_task(task) ||
- !task_on_rq_queued(task))) {
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -1653,7 +1653,7 @@ static void task_numa_compare(struct tas
- * be incurred if the tasks were swapped.
- */
- /* Skip this swap candidate if cannot move to the source cpu */
-- if (!cpumask_test_cpu(env->src_cpu, &cur->cpus_allowed))
-+ if (!cpumask_test_cpu(env->src_cpu, cur->cpus_ptr))
- goto unlock;
-
- /*
-@@ -1751,7 +1751,7 @@ static void task_numa_find_cpu(struct ta
-
- for_each_cpu(cpu, cpumask_of_node(env->dst_nid)) {
- /* Skip this CPU if the source task cannot migrate */
-- if (!cpumask_test_cpu(cpu, &env->p->cpus_allowed))
-+ if (!cpumask_test_cpu(cpu, env->p->cpus_ptr))
- continue;
-
- env->dst_cpu = cpu;
-@@ -5890,7 +5890,7 @@ find_idlest_group(struct sched_domain *s
-
- /* Skip over this group if it has no CPUs allowed */
- if (!cpumask_intersects(sched_group_span(group),
-- &p->cpus_allowed))
-+ p->cpus_ptr))
- continue;
-
- local_group = cpumask_test_cpu(this_cpu,
-@@ -6022,7 +6022,7 @@ find_idlest_group_cpu(struct sched_group
- return cpumask_first(sched_group_span(group));
-
- /* Traverse only the allowed CPUs */
-- for_each_cpu_and(i, sched_group_span(group), &p->cpus_allowed) {
-+ for_each_cpu_and(i, sched_group_span(group), p->cpus_ptr) {
- if (available_idle_cpu(i)) {
- struct rq *rq = cpu_rq(i);
- struct cpuidle_state *idle = idle_get_state(rq);
-@@ -6062,7 +6062,7 @@ static inline int find_idlest_cpu(struct
- {
- int new_cpu = cpu;
-
-- if (!cpumask_intersects(sched_domain_span(sd), &p->cpus_allowed))
-+ if (!cpumask_intersects(sched_domain_span(sd), p->cpus_ptr))
- return prev_cpu;
-
- /*
-@@ -6179,7 +6179,7 @@ static int select_idle_core(struct task_
- if (!test_idle_cores(target, false))
- return -1;
-
-- cpumask_and(cpus, sched_domain_span(sd), &p->cpus_allowed);
-+ cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
-
- for_each_cpu_wrap(core, cpus, target) {
- bool idle = true;
-@@ -6213,7 +6213,7 @@ static int select_idle_smt(struct task_s
- return -1;
-
- for_each_cpu(cpu, cpu_smt_mask(target)) {
-- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
- continue;
- if (available_idle_cpu(cpu))
- return cpu;
-@@ -6276,7 +6276,7 @@ static int select_idle_cpu(struct task_s
- for_each_cpu_wrap(cpu, sched_domain_span(sd), target) {
- if (!--nr)
- return -1;
-- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
- continue;
- if (available_idle_cpu(cpu))
- break;
-@@ -6313,7 +6313,7 @@ static int select_idle_sibling(struct ta
- recent_used_cpu != target &&
- cpus_share_cache(recent_used_cpu, target) &&
- available_idle_cpu(recent_used_cpu) &&
-- cpumask_test_cpu(p->recent_used_cpu, &p->cpus_allowed)) {
-+ cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr)) {
- /*
- * Replace recent_used_cpu with prev as it is a potential
- * candidate for the next wake:
-@@ -6659,7 +6659,7 @@ static int find_energy_efficient_cpu(str
- int max_spare_cap_cpu = -1;
-
- for_each_cpu_and(cpu, perf_domain_span(pd), sched_domain_span(sd)) {
-- if (!cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
- continue;
-
- /* Skip CPUs that will be overutilized. */
-@@ -6748,7 +6748,7 @@ select_task_rq_fair(struct task_struct *
- }
-
- want_affine = !wake_wide(p) && !wake_cap(p, cpu, prev_cpu) &&
-- cpumask_test_cpu(cpu, &p->cpus_allowed);
-+ cpumask_test_cpu(cpu, p->cpus_ptr);
- }
-
- rcu_read_lock();
-@@ -7504,14 +7504,14 @@ int can_migrate_task(struct task_struct
- /*
- * We do not migrate tasks that are:
- * 1) throttled_lb_pair, or
-- * 2) cannot be migrated to this CPU due to cpus_allowed, or
-+ * 2) cannot be migrated to this CPU due to cpus_ptr, or
- * 3) running (obviously), or
- * 4) are cache-hot on their current CPU.
- */
- if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
- return 0;
-
-- if (!cpumask_test_cpu(env->dst_cpu, &p->cpus_allowed)) {
-+ if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) {
- int cpu;
-
- schedstat_inc(p->se.statistics.nr_failed_migrations_affine);
-@@ -7531,7 +7531,7 @@ int can_migrate_task(struct task_struct
-
- /* Prevent to re-select dst_cpu via env's CPUs: */
- for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) {
-- if (cpumask_test_cpu(cpu, &p->cpus_allowed)) {
-+ if (cpumask_test_cpu(cpu, p->cpus_ptr)) {
- env->flags |= LBF_DST_PINNED;
- env->new_dst_cpu = cpu;
- break;
-@@ -8158,7 +8158,7 @@ static inline int check_misfit_status(st
-
- /*
- * Group imbalance indicates (and tries to solve) the problem where balancing
-- * groups is inadequate due to ->cpus_allowed constraints.
-+ * groups is inadequate due to ->cpus_ptr constraints.
- *
- * Imagine a situation of two groups of 4 CPUs each and 4 tasks each with a
- * cpumask covering 1 CPU of the first group and 3 CPUs of the second group.
-@@ -8827,7 +8827,7 @@ static struct sched_group *find_busiest_
- /*
- * If the busiest group is imbalanced the below checks don't
- * work because they assume all things are equal, which typically
-- * isn't true due to cpus_allowed constraints and the like.
-+ * isn't true due to cpus_ptr constraints and the like.
- */
- if (busiest->group_type == group_imbalanced)
- goto force_balance;
-@@ -9269,7 +9269,7 @@ static int load_balance(int this_cpu, st
- * if the curr task on busiest CPU can't be
- * moved to this_cpu:
- */
-- if (!cpumask_test_cpu(this_cpu, &busiest->curr->cpus_allowed)) {
-+ if (!cpumask_test_cpu(this_cpu, busiest->curr->cpus_ptr)) {
- raw_spin_unlock_irqrestore(&busiest->lock,
- flags);
- env.flags |= LBF_ALL_PINNED;
---- a/kernel/sched/rt.c
-+++ b/kernel/sched/rt.c
-@@ -1614,7 +1614,7 @@ static void put_prev_task_rt(struct rq *
- static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
- {
- if (!task_running(rq, p) &&
-- cpumask_test_cpu(cpu, &p->cpus_allowed))
-+ cpumask_test_cpu(cpu, p->cpus_ptr))
- return 1;
-
- return 0;
-@@ -1751,7 +1751,7 @@ static struct rq *find_lock_lowest_rq(st
- * Also make sure that it wasn't scheduled on its rq.
- */
- if (unlikely(task_rq(task) != rq ||
-- !cpumask_test_cpu(lowest_rq->cpu, &task->cpus_allowed) ||
-+ !cpumask_test_cpu(lowest_rq->cpu, task->cpus_ptr) ||
- task_running(rq, task) ||
- !rt_task(task) ||
- !task_on_rq_queued(task))) {
---- a/kernel/trace/trace_hwlat.c
-+++ b/kernel/trace/trace_hwlat.c
-@@ -277,7 +277,7 @@ static void move_to_next_cpu(void)
- * of this thread, than stop migrating for the duration
- * of the current test.
- */
-- if (!cpumask_equal(current_mask, &current->cpus_allowed))
-+ if (!cpumask_equal(current_mask, current->cpus_ptr))
- goto disable;
-
- get_online_cpus();
---- a/lib/smp_processor_id.c
-+++ b/lib/smp_processor_id.c
-@@ -23,7 +23,7 @@ unsigned int check_preemption_disabled(c
- * Kernel threads bound to a single CPU can safely use
- * smp_processor_id():
- */
-- if (cpumask_equal(&current->cpus_allowed, cpumask_of(this_cpu)))
-+ if (cpumask_equal(current->cpus_ptr, cpumask_of(this_cpu)))
- goto out;
-
- /*
---- a/samples/trace_events/trace-events-sample.c
-+++ b/samples/trace_events/trace-events-sample.c
-@@ -34,7 +34,7 @@ static void simple_thread_func(int cnt)
-
- /* Silly tracepoints */
- trace_foo_bar("hello", cnt, array, random_strings[len],
-- &current->cpus_allowed);
-+ current->cpus_ptr);
-
- trace_foo_with_template_simple("HELLO", cnt);
-
diff --git a/debian/patches-rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch b/debian/patches-rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
index ebf2e4db067a..580b25b95a35 100644
--- a/debian/patches-rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
+++ b/debian/patches-rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
@@ -2,19 +2,21 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 21 Nov 2016 19:31:08 +0100
Subject: [PATCH] kernel/sched: move stack + kprobe clean up to
__put_task_struct()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
There is no need to free the stack before the task struct (except for reasons
mentioned in commit 68f24b08ee89 ("sched/core: Free the stack early if
CONFIG_THREAD_INFO_IN_TASK")). This also comes handy on -RT because we can't
free memory in preempt disabled region.
+vfree_atomic() delays the memory cleanup to a worker. Since we move everything
+to the RCU callback, we can also free it immediately.
Cc: stable-rt@vger.kernel.org #for kprobe_flush_task()
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/fork.c | 10 ++++++++++
+ kernel/fork.c | 12 +++++++++++-
kernel/sched/core.c | 9 ---------
- 2 files changed, 10 insertions(+), 9 deletions(-)
+ 2 files changed, 11 insertions(+), 10 deletions(-)
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -26,7 +28,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/vmacache.h>
#include <linux/nsproxy.h>
#include <linux/capability.h>
-@@ -742,6 +743,15 @@ void __put_task_struct(struct task_struc
+@@ -289,7 +290,7 @@ static inline void free_thread_stack(str
+ return;
+ }
+
+- vfree_atomic(tsk->stack);
++ vfree(tsk->stack);
+ return;
+ }
+ #endif
+@@ -750,6 +751,15 @@ void __put_task_struct(struct task_struc
WARN_ON(refcount_read(&tsk->usage));
WARN_ON(tsk == current);
@@ -44,7 +55,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
security_task_free(tsk);
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -2721,15 +2721,6 @@ static struct rq *finish_task_switch(str
+@@ -3253,15 +3253,6 @@ static struct rq *finish_task_switch(str
if (prev->sched_class->task_dead)
prev->sched_class->task_dead(prev);
@@ -57,6 +68,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- /* Task is done with its stack. */
- put_task_stack(prev);
-
- put_task_struct(prev);
+ put_task_struct_rcu_user(prev);
}
diff --git a/debian/patches-rt/kmemleak-Change-the-lock-of-kmemleak_object-to-raw_s.patch b/debian/patches-rt/kmemleak-Change-the-lock-of-kmemleak_object-to-raw_s.patch
new file mode 100644
index 000000000000..e50bb401c19d
--- /dev/null
+++ b/debian/patches-rt/kmemleak-Change-the-lock-of-kmemleak_object-to-raw_s.patch
@@ -0,0 +1,272 @@
+From: Liu Haitao <haitao.liu@windriver.com>
+Date: Fri, 27 Sep 2019 16:22:30 +0800
+Subject: [PATCH] kmemleak: Change the lock of kmemleak_object to
+ raw_spinlock_t
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The commit ("kmemleak: Turn kmemleak_lock to raw spinlock on RT")
+changed the kmemleak_lock to raw spinlock. However the
+kmemleak_object->lock is held after the kmemleak_lock is held in
+scan_block().
+
+Make the object->lock a raw_spinlock_t.
+
+Cc: stable-rt@vger.kernel.org
+Link: https://lkml.kernel.org/r/20190927082230.34152-1-yongxin.liu@windriver.com
+Signed-off-by: Liu Haitao <haitao.liu@windriver.com>
+Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ mm/kmemleak.c | 68 +++++++++++++++++++++++++++++-----------------------------
+ 1 file changed, 34 insertions(+), 34 deletions(-)
+
+--- a/mm/kmemleak.c
++++ b/mm/kmemleak.c
+@@ -135,7 +135,7 @@ struct kmemleak_scan_area {
+ * (use_count) and freed using the RCU mechanism.
+ */
+ struct kmemleak_object {
+- spinlock_t lock;
++ raw_spinlock_t lock;
+ unsigned int flags; /* object status flags */
+ struct list_head object_list;
+ struct list_head gray_list;
+@@ -585,7 +585,7 @@ static struct kmemleak_object *create_ob
+ INIT_LIST_HEAD(&object->object_list);
+ INIT_LIST_HEAD(&object->gray_list);
+ INIT_HLIST_HEAD(&object->area_list);
+- spin_lock_init(&object->lock);
++ raw_spin_lock_init(&object->lock);
+ atomic_set(&object->use_count, 1);
+ object->flags = OBJECT_ALLOCATED;
+ object->pointer = ptr;
+@@ -667,9 +667,9 @@ static void __delete_object(struct kmeml
+ * Locking here also ensures that the corresponding memory block
+ * cannot be freed when it is being scanned.
+ */
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ object->flags &= ~OBJECT_ALLOCATED;
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ put_object(object);
+ }
+
+@@ -739,9 +739,9 @@ static void paint_it(struct kmemleak_obj
+ {
+ unsigned long flags;
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ __paint_it(object, color);
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+
+ static void paint_ptr(unsigned long ptr, int color)
+@@ -798,7 +798,7 @@ static void add_scan_area(unsigned long
+ if (scan_area_cache)
+ area = kmem_cache_alloc(scan_area_cache, gfp_kmemleak_mask(gfp));
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if (!area) {
+ pr_warn_once("Cannot allocate a scan area, scanning the full object\n");
+ /* mark the object for full scan to avoid false positives */
+@@ -820,7 +820,7 @@ static void add_scan_area(unsigned long
+
+ hlist_add_head(&area->node, &object->area_list);
+ out_unlock:
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ put_object(object);
+ }
+
+@@ -842,9 +842,9 @@ static void object_set_excess_ref(unsign
+ return;
+ }
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ object->excess_ref = excess_ref;
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ put_object(object);
+ }
+
+@@ -864,9 +864,9 @@ static void object_no_scan(unsigned long
+ return;
+ }
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ object->flags |= OBJECT_NO_SCAN;
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ put_object(object);
+ }
+
+@@ -1026,9 +1026,9 @@ void __ref kmemleak_update_trace(const v
+ return;
+ }
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ object->trace_len = __save_stack_trace(object->trace);
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+
+ put_object(object);
+ }
+@@ -1268,7 +1268,7 @@ static void scan_block(void *_start, voi
+ * previously acquired in scan_object(). These locks are
+ * enclosed by scan_mutex.
+ */
+- spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING);
++ raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING);
+ /* only pass surplus references (object already gray) */
+ if (color_gray(object)) {
+ excess_ref = object->excess_ref;
+@@ -1277,7 +1277,7 @@ static void scan_block(void *_start, voi
+ excess_ref = 0;
+ update_refs(object);
+ }
+- spin_unlock(&object->lock);
++ raw_spin_unlock(&object->lock);
+
+ if (excess_ref) {
+ object = lookup_object(excess_ref, 0);
+@@ -1286,9 +1286,9 @@ static void scan_block(void *_start, voi
+ if (object == scanned)
+ /* circular reference, ignore */
+ continue;
+- spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING);
++ raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING);
+ update_refs(object);
+- spin_unlock(&object->lock);
++ raw_spin_unlock(&object->lock);
+ }
+ }
+ raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
+@@ -1324,7 +1324,7 @@ static void scan_object(struct kmemleak_
+ * Once the object->lock is acquired, the corresponding memory block
+ * cannot be freed (the same lock is acquired in delete_object).
+ */
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if (object->flags & OBJECT_NO_SCAN)
+ goto out;
+ if (!(object->flags & OBJECT_ALLOCATED))
+@@ -1344,9 +1344,9 @@ static void scan_object(struct kmemleak_
+ if (start >= end)
+ break;
+
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ cond_resched();
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ } while (object->flags & OBJECT_ALLOCATED);
+ } else
+ hlist_for_each_entry(area, &object->area_list, node)
+@@ -1354,7 +1354,7 @@ static void scan_object(struct kmemleak_
+ (void *)(area->start + area->size),
+ object);
+ out:
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+
+ /*
+@@ -1407,7 +1407,7 @@ static void kmemleak_scan(void)
+ /* prepare the kmemleak_object's */
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list) {
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ #ifdef DEBUG
+ /*
+ * With a few exceptions there should be a maximum of
+@@ -1424,7 +1424,7 @@ static void kmemleak_scan(void)
+ if (color_gray(object) && get_object(object))
+ list_add_tail(&object->gray_list, &gray_list);
+
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+ rcu_read_unlock();
+
+@@ -1492,14 +1492,14 @@ static void kmemleak_scan(void)
+ */
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list) {
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if (color_white(object) && (object->flags & OBJECT_ALLOCATED)
+ && update_checksum(object) && get_object(object)) {
+ /* color it gray temporarily */
+ object->count = object->min_count;
+ list_add_tail(&object->gray_list, &gray_list);
+ }
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+ rcu_read_unlock();
+
+@@ -1519,7 +1519,7 @@ static void kmemleak_scan(void)
+ */
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list) {
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if (unreferenced_object(object) &&
+ !(object->flags & OBJECT_REPORTED)) {
+ object->flags |= OBJECT_REPORTED;
+@@ -1529,7 +1529,7 @@ static void kmemleak_scan(void)
+
+ new_leaks++;
+ }
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+ rcu_read_unlock();
+
+@@ -1681,10 +1681,10 @@ static int kmemleak_seq_show(struct seq_
+ struct kmemleak_object *object = v;
+ unsigned long flags;
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if ((object->flags & OBJECT_REPORTED) && unreferenced_object(object))
+ print_unreferenced(seq, object);
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ return 0;
+ }
+
+@@ -1714,9 +1714,9 @@ static int dump_str_object_info(const ch
+ return -EINVAL;
+ }
+
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ dump_object_info(object);
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+
+ put_object(object);
+ return 0;
+@@ -1735,11 +1735,11 @@ static void kmemleak_clear(void)
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(object, &object_list, object_list) {
+- spin_lock_irqsave(&object->lock, flags);
++ raw_spin_lock_irqsave(&object->lock, flags);
+ if ((object->flags & OBJECT_REPORTED) &&
+ unreferenced_object(object))
+ __paint_it(object, KMEMLEAK_GREY);
+- spin_unlock_irqrestore(&object->lock, flags);
++ raw_spin_unlock_irqrestore(&object->lock, flags);
+ }
+ rcu_read_unlock();
+
diff --git a/debian/patches-rt/kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch b/debian/patches-rt/kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch
index 8a0ef0032359..ab0d36fb1a3f 100644
--- a/debian/patches-rt/kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch
+++ b/debian/patches-rt/kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch
@@ -1,7 +1,7 @@
From: He Zhe <zhe.he@windriver.com>
Date: Wed, 19 Dec 2018 16:30:57 +0100
Subject: [PATCH] kmemleak: Turn kmemleak_lock to raw spinlock on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
kmemleak_lock, as a rwlock on RT, can possibly be held in atomic context and
causes the follow BUG.
@@ -71,8 +71,8 @@ Link: https://lkml.kernel.org/r/1542877459-144382-1-git-send-email-zhe.he@windri
Link: https://lkml.kernel.org/r/20181218150744.GB20197@arrakis.emea.arm.com
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- mm/kmemleak.c | 20 ++++++++++----------
- 1 file changed, 10 insertions(+), 10 deletions(-)
+ mm/kmemleak.c | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -85,7 +85,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* accesses to the object_tree_root. The object_list is the main list
* holding the metadata (struct kmemleak_object) for the allocated memory
* blocks. The object_tree_root is a red black tree used to look-up
-@@ -186,7 +186,7 @@ static LIST_HEAD(gray_list);
+@@ -192,7 +192,7 @@ static LIST_HEAD(mem_pool_free_list);
/* search tree for object boundaries */
static struct rb_root object_tree_root = RB_ROOT;
/* rw_lock protecting the access to object_list and object_tree_root */
@@ -94,7 +94,37 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* allocation caches for kmemleak internal data */
static struct kmem_cache *object_cache;
-@@ -497,9 +497,9 @@ static struct kmemleak_object *find_and_
+@@ -426,7 +426,7 @@ static struct kmemleak_object *mem_pool_
+ }
+
+ /* slab allocation failed, try the memory pool */
+- write_lock_irqsave(&kmemleak_lock, flags);
++ raw_spin_lock_irqsave(&kmemleak_lock, flags);
+ object = list_first_entry_or_null(&mem_pool_free_list,
+ typeof(*object), object_list);
+ if (object)
+@@ -435,7 +435,7 @@ static struct kmemleak_object *mem_pool_
+ object = &mem_pool[--mem_pool_free_count];
+ else
+ pr_warn_once("Memory pool empty, consider increasing CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE\n");
+- write_unlock_irqrestore(&kmemleak_lock, flags);
++ raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
+
+ return object;
+ }
+@@ -453,9 +453,9 @@ static void mem_pool_free(struct kmemlea
+ }
+
+ /* add the object to the memory pool free list */
+- write_lock_irqsave(&kmemleak_lock, flags);
++ raw_spin_lock_irqsave(&kmemleak_lock, flags);
+ list_add(&object->object_list, &mem_pool_free_list);
+- write_unlock_irqrestore(&kmemleak_lock, flags);
++ raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
+ }
+
+ /*
+@@ -514,9 +514,9 @@ static struct kmemleak_object *find_and_
struct kmemleak_object *object;
rcu_read_lock();
@@ -106,23 +136,21 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* check whether the object is still available */
if (object && !get_object(object))
-@@ -519,13 +519,13 @@ static struct kmemleak_object *find_and_
+@@ -546,11 +546,11 @@ static struct kmemleak_object *find_and_
unsigned long flags;
struct kmemleak_object *object;
- write_lock_irqsave(&kmemleak_lock, flags);
+ raw_spin_lock_irqsave(&kmemleak_lock, flags);
object = lookup_object(ptr, alias);
- if (object) {
- rb_erase(&object->rb_node, &object_tree_root);
- list_del_rcu(&object->object_list);
- }
+ if (object)
+ __remove_object(object);
- write_unlock_irqrestore(&kmemleak_lock, flags);
+ raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
return object;
}
-@@ -592,7 +592,7 @@ static struct kmemleak_object *create_ob
+@@ -617,7 +617,7 @@ static struct kmemleak_object *create_ob
/* kernel backtrace */
object->trace_len = __save_stack_trace(object->trace);
@@ -131,7 +159,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
untagged_ptr = (unsigned long)kasan_reset_tag((void *)ptr);
min_addr = min(min_addr, untagged_ptr);
-@@ -624,7 +624,7 @@ static struct kmemleak_object *create_ob
+@@ -649,7 +649,7 @@ static struct kmemleak_object *create_ob
list_add_tail_rcu(&object->object_list, &object_list);
out:
@@ -140,7 +168,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return object;
}
-@@ -1311,7 +1311,7 @@ static void scan_block(void *_start, voi
+@@ -1233,7 +1233,7 @@ static void scan_block(void *_start, voi
unsigned long flags;
unsigned long untagged_ptr;
@@ -149,7 +177,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
for (ptr = start; ptr < end; ptr++) {
struct kmemleak_object *object;
unsigned long pointer;
-@@ -1369,7 +1369,7 @@ static void scan_block(void *_start, voi
+@@ -1291,7 +1291,7 @@ static void scan_block(void *_start, voi
spin_unlock(&object->lock);
}
}
diff --git a/debian/patches-rt/leds-trigger-disable-CPU-trigger-on-RT.patch b/debian/patches-rt/leds-trigger-disable-CPU-trigger-on-RT.patch
index 1266d4147b2c..307bc06d57a2 100644
--- a/debian/patches-rt/leds-trigger-disable-CPU-trigger-on-RT.patch
+++ b/debian/patches-rt/leds-trigger-disable-CPU-trigger-on-RT.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 23 Jan 2014 14:45:59 +0100
Subject: leds: trigger: disable CPU trigger on -RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
as it triggers:
|CPU: 0 PID: 0 Comm: swapper Not tainted 3.12.8-rt10 #141
@@ -29,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
config LEDS_TRIGGER_CPU
bool "LED CPU Trigger"
-+ depends on !PREEMPT_RT_BASE
++ depends on !PREEMPT_RT
help
This allows LEDs to be controlled by active CPUs. This shows
the active CPUs across an array of LEDs so you can see which
diff --git a/debian/patches-rt/lib-smp_processor_id-Don-t-use-cpumask_equal.patch b/debian/patches-rt/lib-smp_processor_id-Don-t-use-cpumask_equal.patch
new file mode 100644
index 000000000000..4519ecd9200c
--- /dev/null
+++ b/debian/patches-rt/lib-smp_processor_id-Don-t-use-cpumask_equal.patch
@@ -0,0 +1,36 @@
+From: Waiman Long <longman@redhat.com>
+Date: Thu, 3 Oct 2019 16:36:08 -0400
+Subject: [PATCH] lib/smp_processor_id: Don't use cpumask_equal()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The check_preemption_disabled() function uses cpumask_equal() to see
+if the task is bounded to the current CPU only. cpumask_equal() calls
+memcmp() to do the comparison. As x86 doesn't have __HAVE_ARCH_MEMCMP,
+the slow memcmp() function in lib/string.c is used.
+
+On a RT kernel that call check_preemption_disabled() very frequently,
+below is the perf-record output of a certain microbenchmark:
+
+ 42.75% 2.45% testpmd [kernel.kallsyms] [k] check_preemption_disabled
+ 40.01% 39.97% testpmd [kernel.kallsyms] [k] memcmp
+
+We should avoid calling memcmp() in performance critical path. So the
+cpumask_equal() call is now replaced with an equivalent simpler check.
+
+Signed-off-by: Waiman Long <longman@redhat.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ lib/smp_processor_id.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/smp_processor_id.c
++++ b/lib/smp_processor_id.c
+@@ -23,7 +23,7 @@ unsigned int check_preemption_disabled(c
+ * Kernel threads bound to a single CPU can safely use
+ * smp_processor_id():
+ */
+- if (cpumask_equal(current->cpus_ptr, cpumask_of(this_cpu)))
++ if (current->nr_cpus_allowed == 1)
+ goto out;
+
+ /*
diff --git a/debian/patches-rt/lib-ubsan-Don-t-seralize-UBSAN-report.patch b/debian/patches-rt/lib-ubsan-Don-t-seralize-UBSAN-report.patch
new file mode 100644
index 000000000000..32f6321dee37
--- /dev/null
+++ b/debian/patches-rt/lib-ubsan-Don-t-seralize-UBSAN-report.patch
@@ -0,0 +1,299 @@
+From: Julien Grall <julien.grall@arm.com>
+Date: Fri, 20 Sep 2019 11:08:35 +0100
+Subject: [PATCH] lib/ubsan: Don't seralize UBSAN report
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+At the moment, UBSAN report will be serialized using a spin_lock(). On
+RT-systems, spinlocks are turned to rt_spin_lock and may sleep. This will
+result to the following splat if the undefined behavior is in a context
+that can sleep:
+
+| BUG: sleeping function called from invalid context at /src/linux/kernel/locking/rtmutex.c:968
+| in_atomic(): 1, irqs_disabled(): 128, pid: 3447, name: make
+| 1 lock held by make/3447:
+| #0: 000000009a966332 (&mm->mmap_sem){++++}, at: do_page_fault+0x140/0x4f8
+| Preemption disabled at:
+| [<ffff000011324a4c>] rt_mutex_futex_unlock+0x4c/0xb0
+| CPU: 3 PID: 3447 Comm: make Tainted: G W 5.2.14-rt7-01890-ge6e057589653 #911
+| Call trace:
+| dump_backtrace+0x0/0x148
+| show_stack+0x14/0x20
+| dump_stack+0xbc/0x104
+| ___might_sleep+0x154/0x210
+| rt_spin_lock+0x68/0xa0
+| ubsan_prologue+0x30/0x68
+| handle_overflow+0x64/0xe0
+| __ubsan_handle_add_overflow+0x10/0x18
+| __lock_acquire+0x1c28/0x2a28
+| lock_acquire+0xf0/0x370
+| _raw_spin_lock_irqsave+0x58/0x78
+| rt_mutex_futex_unlock+0x4c/0xb0
+| rt_spin_unlock+0x28/0x70
+| get_page_from_freelist+0x428/0x2b60
+| __alloc_pages_nodemask+0x174/0x1708
+| alloc_pages_vma+0x1ac/0x238
+| __handle_mm_fault+0x4ac/0x10b0
+| handle_mm_fault+0x1d8/0x3b0
+| do_page_fault+0x1c8/0x4f8
+| do_translation_fault+0xb8/0xe0
+| do_mem_abort+0x3c/0x98
+| el0_da+0x20/0x24
+
+The spin_lock() will protect against multiple CPUs to output a report
+together, I guess to prevent them to be interleaved. However, they can
+still interleave with other messages (and even splat from __migth_sleep).
+
+So the lock usefulness seems pretty limited. Rather than trying to
+accomodate RT-system by switching to a raw_spin_lock(), the lock is now
+completely dropped.
+
+Link: https://lkml.kernel.org/r/20190920100835.14999-1-julien.grall@arm.com
+Reported-by: Andre Przywara <andre.przywara@arm.com>
+Signed-off-by: Julien Grall <julien.grall@arm.com>
+Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ lib/ubsan.c | 64 +++++++++++++++++++++---------------------------------------
+ 1 file changed, 23 insertions(+), 41 deletions(-)
+
+--- a/lib/ubsan.c
++++ b/lib/ubsan.c
+@@ -140,25 +140,21 @@ static void val_to_string(char *str, siz
+ }
+ }
+
+-static DEFINE_SPINLOCK(report_lock);
+-
+-static void ubsan_prologue(struct source_location *location,
+- unsigned long *flags)
++static void ubsan_prologue(struct source_location *location)
+ {
+ current->in_ubsan++;
+- spin_lock_irqsave(&report_lock, *flags);
+
+ pr_err("========================================"
+ "========================================\n");
+ print_source_location("UBSAN: Undefined behaviour in", location);
+ }
+
+-static void ubsan_epilogue(unsigned long *flags)
++static void ubsan_epilogue(void)
+ {
+ dump_stack();
+ pr_err("========================================"
+ "========================================\n");
+- spin_unlock_irqrestore(&report_lock, *flags);
++
+ current->in_ubsan--;
+ }
+
+@@ -167,14 +163,13 @@ static void handle_overflow(struct overf
+ {
+
+ struct type_descriptor *type = data->type;
+- unsigned long flags;
+ char lhs_val_str[VALUE_LENGTH];
+ char rhs_val_str[VALUE_LENGTH];
+
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(lhs_val_str, sizeof(lhs_val_str), type, lhs);
+ val_to_string(rhs_val_str, sizeof(rhs_val_str), type, rhs);
+@@ -186,7 +181,7 @@ static void handle_overflow(struct overf
+ rhs_val_str,
+ type->type_name);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+
+ void __ubsan_handle_add_overflow(struct overflow_data *data,
+@@ -214,20 +209,19 @@ EXPORT_SYMBOL(__ubsan_handle_mul_overflo
+ void __ubsan_handle_negate_overflow(struct overflow_data *data,
+ void *old_val)
+ {
+- unsigned long flags;
+ char old_val_str[VALUE_LENGTH];
+
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(old_val_str, sizeof(old_val_str), data->type, old_val);
+
+ pr_err("negation of %s cannot be represented in type %s:\n",
+ old_val_str, data->type->type_name);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+ EXPORT_SYMBOL(__ubsan_handle_negate_overflow);
+
+@@ -235,13 +229,12 @@ EXPORT_SYMBOL(__ubsan_handle_negate_over
+ void __ubsan_handle_divrem_overflow(struct overflow_data *data,
+ void *lhs, void *rhs)
+ {
+- unsigned long flags;
+ char rhs_val_str[VALUE_LENGTH];
+
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(rhs_val_str, sizeof(rhs_val_str), data->type, rhs);
+
+@@ -251,58 +244,52 @@ void __ubsan_handle_divrem_overflow(stru
+ else
+ pr_err("division by zero\n");
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+ EXPORT_SYMBOL(__ubsan_handle_divrem_overflow);
+
+ static void handle_null_ptr_deref(struct type_mismatch_data_common *data)
+ {
+- unsigned long flags;
+-
+ if (suppress_report(data->location))
+ return;
+
+- ubsan_prologue(data->location, &flags);
++ ubsan_prologue(data->location);
+
+ pr_err("%s null pointer of type %s\n",
+ type_check_kinds[data->type_check_kind],
+ data->type->type_name);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+
+ static void handle_misaligned_access(struct type_mismatch_data_common *data,
+ unsigned long ptr)
+ {
+- unsigned long flags;
+-
+ if (suppress_report(data->location))
+ return;
+
+- ubsan_prologue(data->location, &flags);
++ ubsan_prologue(data->location);
+
+ pr_err("%s misaligned address %p for type %s\n",
+ type_check_kinds[data->type_check_kind],
+ (void *)ptr, data->type->type_name);
+ pr_err("which requires %ld byte alignment\n", data->alignment);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+
+ static void handle_object_size_mismatch(struct type_mismatch_data_common *data,
+ unsigned long ptr)
+ {
+- unsigned long flags;
+-
+ if (suppress_report(data->location))
+ return;
+
+- ubsan_prologue(data->location, &flags);
++ ubsan_prologue(data->location);
+ pr_err("%s address %p with insufficient space\n",
+ type_check_kinds[data->type_check_kind],
+ (void *) ptr);
+ pr_err("for an object of type %s\n", data->type->type_name);
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+
+ static void ubsan_type_mismatch_common(struct type_mismatch_data_common *data,
+@@ -351,25 +338,23 @@ EXPORT_SYMBOL(__ubsan_handle_type_mismat
+
+ void __ubsan_handle_out_of_bounds(struct out_of_bounds_data *data, void *index)
+ {
+- unsigned long flags;
+ char index_str[VALUE_LENGTH];
+
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(index_str, sizeof(index_str), data->index_type, index);
+ pr_err("index %s is out of range for type %s\n", index_str,
+ data->array_type->type_name);
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+ EXPORT_SYMBOL(__ubsan_handle_out_of_bounds);
+
+ void __ubsan_handle_shift_out_of_bounds(struct shift_out_of_bounds_data *data,
+ void *lhs, void *rhs)
+ {
+- unsigned long flags;
+ struct type_descriptor *rhs_type = data->rhs_type;
+ struct type_descriptor *lhs_type = data->lhs_type;
+ char rhs_str[VALUE_LENGTH];
+@@ -378,7 +363,7 @@ void __ubsan_handle_shift_out_of_bounds(
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(rhs_str, sizeof(rhs_str), rhs_type, rhs);
+ val_to_string(lhs_str, sizeof(lhs_str), lhs_type, lhs);
+@@ -401,18 +386,16 @@ void __ubsan_handle_shift_out_of_bounds(
+ lhs_str, rhs_str,
+ lhs_type->type_name);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+ EXPORT_SYMBOL(__ubsan_handle_shift_out_of_bounds);
+
+
+ void __ubsan_handle_builtin_unreachable(struct unreachable_data *data)
+ {
+- unsigned long flags;
+-
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+ pr_err("calling __builtin_unreachable()\n");
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ panic("can't return from __builtin_unreachable()");
+ }
+ EXPORT_SYMBOL(__ubsan_handle_builtin_unreachable);
+@@ -420,19 +403,18 @@ EXPORT_SYMBOL(__ubsan_handle_builtin_unr
+ void __ubsan_handle_load_invalid_value(struct invalid_value_data *data,
+ void *val)
+ {
+- unsigned long flags;
+ char val_str[VALUE_LENGTH];
+
+ if (suppress_report(&data->location))
+ return;
+
+- ubsan_prologue(&data->location, &flags);
++ ubsan_prologue(&data->location);
+
+ val_to_string(val_str, sizeof(val_str), data->type, val);
+
+ pr_err("load of value %s is not a valid value for type %s\n",
+ val_str, data->type->type_name);
+
+- ubsan_epilogue(&flags);
++ ubsan_epilogue();
+ }
+ EXPORT_SYMBOL(__ubsan_handle_load_invalid_value);
diff --git a/debian/patches-rt/list_bl-fixup-bogus-lockdep-warning.patch b/debian/patches-rt/list_bl-fixup-bogus-lockdep-warning.patch
deleted file mode 100644
index 1938c0b32ca7..000000000000
--- a/debian/patches-rt/list_bl-fixup-bogus-lockdep-warning.patch
+++ /dev/null
@@ -1,98 +0,0 @@
-From: Josh Cartwright <joshc@ni.com>
-Date: Thu, 31 Mar 2016 00:04:25 -0500
-Subject: [PATCH] list_bl: fixup bogus lockdep warning
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-At first glance, the use of 'static inline' seems appropriate for
-INIT_HLIST_BL_HEAD().
-
-However, when a 'static inline' function invocation is inlined by gcc,
-all callers share any static local data declared within that inline
-function.
-
-This presents a problem for how lockdep classes are setup. raw_spinlocks, for
-example, when CONFIG_DEBUG_SPINLOCK,
-
- # define raw_spin_lock_init(lock) \
- do { \
- static struct lock_class_key __key; \
- \
- __raw_spin_lock_init((lock), #lock, &__key); \
- } while (0)
-
-When this macro is expanded into a 'static inline' caller, like
-INIT_HLIST_BL_HEAD():
-
- static inline INIT_HLIST_BL_HEAD(struct hlist_bl_head *h)
- {
- h->first = NULL;
- raw_spin_lock_init(&h->lock);
- }
-
-...the static local lock_class_key object is made a function static.
-
-For compilation units which initialize invoke INIT_HLIST_BL_HEAD() more
-than once, then, all of the invocations share this same static local
-object.
-
-This can lead to some very confusing lockdep splats (example below).
-Solve this problem by forcing the INIT_HLIST_BL_HEAD() to be a macro,
-which prevents the lockdep class object sharing.
-
- =============================================
- [ INFO: possible recursive locking detected ]
- 4.4.4-rt11 #4 Not tainted
- ---------------------------------------------
- kswapd0/59 is trying to acquire lock:
- (&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
-
- but task is already holding lock:
- (&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
-
- other info that might help us debug this:
- Possible unsafe locking scenario:
-
- CPU0
- ----
- lock(&h->lock#2);
- lock(&h->lock#2);
-
- *** DEADLOCK ***
-
- May be due to missing lock nesting notation
-
- 2 locks held by kswapd0/59:
- #0: (shrinker_rwsem){+.+...}, at: rt_down_read_trylock
- #1: (&h->lock#2){+.+.-.}, at: mb_cache_shrink_scan
-
-Reported-by: Luis Claudio R. Goncalves <lclaudio@uudg.org>
-Tested-by: Luis Claudio R. Goncalves <lclaudio@uudg.org>
-Signed-off-by: Josh Cartwright <joshc@ni.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/list_bl.h | 12 +++++++-----
- 1 file changed, 7 insertions(+), 5 deletions(-)
-
---- a/include/linux/list_bl.h
-+++ b/include/linux/list_bl.h
-@@ -43,13 +43,15 @@ struct hlist_bl_node {
- struct hlist_bl_node *next, **pprev;
- };
-
--static inline void INIT_HLIST_BL_HEAD(struct hlist_bl_head *h)
--{
-- h->first = NULL;
- #ifdef CONFIG_PREEMPT_RT_BASE
-- raw_spin_lock_init(&h->lock);
-+#define INIT_HLIST_BL_HEAD(h) \
-+do { \
-+ (h)->first = NULL; \
-+ raw_spin_lock_init(&(h)->lock); \
-+} while (0)
-+#else
-+#define INIT_HLIST_BL_HEAD(h) (h)->first = NULL
- #endif
--}
-
- static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
- {
diff --git a/debian/patches-rt/list_bl.h-make-list-head-locking-RT-safe.patch b/debian/patches-rt/list_bl.h-make-list-head-locking-RT-safe.patch
index 086240430918..b6760673ca9f 100644
--- a/debian/patches-rt/list_bl.h-make-list-head-locking-RT-safe.patch
+++ b/debian/patches-rt/list_bl.h-make-list-head-locking-RT-safe.patch
@@ -1,7 +1,7 @@
From: Paul Gortmaker <paul.gortmaker@windriver.com>
Date: Fri, 21 Jun 2013 15:07:25 -0400
Subject: list_bl: Make list head locking RT safe
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
As per changes in include/linux/jbd_common.h for avoiding the
bit_spin_locks on RT ("fs: jbd/jbd2: Make state lock and journal
@@ -46,10 +46,12 @@ concern.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
+[julia@ni.com: Use #define instead static inline to avoid false positive from
+ lockdep]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- include/linux/list_bl.h | 28 ++++++++++++++++++++++++++--
- 1 file changed, 26 insertions(+), 2 deletions(-)
+ include/linux/list_bl.h | 30 ++++++++++++++++++++++++++++--
+ 1 file changed, 28 insertions(+), 2 deletions(-)
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -61,11 +63,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/bit_spinlock.h>
/*
-@@ -33,13 +34,22 @@
+@@ -33,13 +34,24 @@
struct hlist_bl_head {
struct hlist_bl_node *first;
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ raw_spinlock_t lock;
+#endif
};
@@ -76,21 +78,23 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-#define INIT_HLIST_BL_HEAD(ptr) \
- ((ptr)->first = NULL)
+
-+static inline void INIT_HLIST_BL_HEAD(struct hlist_bl_head *h)
-+{
-+ h->first = NULL;
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ raw_spin_lock_init(&h->lock);
++#ifdef CONFIG_PREEMPT_RT
++#define INIT_HLIST_BL_HEAD(h) \
++do { \
++ (h)->first = NULL; \
++ raw_spin_lock_init(&(h)->lock); \
++} while (0)
++#else
++#define INIT_HLIST_BL_HEAD(h) (h)->first = NULL
+#endif
-+}
static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
{
-@@ -145,12 +155,26 @@ static inline void hlist_bl_del_init(str
+@@ -145,12 +157,26 @@ static inline void hlist_bl_del_init(str
static inline void hlist_bl_lock(struct hlist_bl_head *b)
{
-+#ifndef CONFIG_PREEMPT_RT_BASE
++#ifndef CONFIG_PREEMPT_RT
bit_spin_lock(0, (unsigned long *)b);
+#else
+ raw_spin_lock(&b->lock);
@@ -102,7 +106,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline void hlist_bl_unlock(struct hlist_bl_head *b)
{
-+#ifndef CONFIG_PREEMPT_RT_BASE
++#ifndef CONFIG_PREEMPT_RT
__bit_spin_unlock(0, (unsigned long *)b);
+#else
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
diff --git a/debian/patches-rt/locallock-provide-get-put-_locked_ptr-variants.patch b/debian/patches-rt/locallock-provide-get-put-_locked_ptr-variants.patch
deleted file mode 100644
index 7a42c1d66d5e..000000000000
--- a/debian/patches-rt/locallock-provide-get-put-_locked_ptr-variants.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From: Julia Cartwright <julia@ni.com>
-Date: Mon, 7 May 2018 08:58:56 -0500
-Subject: [PATCH] locallock: provide {get,put}_locked_ptr() variants
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Provide a set of locallocked accessors for pointers to per-CPU data;
-this is useful for dynamically-allocated per-CPU regions, for example.
-
-These are symmetric with the {get,put}_cpu_ptr() per-CPU accessor
-variants.
-
-Signed-off-by: Julia Cartwright <julia@ni.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/locallock.h | 10 ++++++++++
- 1 file changed, 10 insertions(+)
-
---- a/include/linux/locallock.h
-+++ b/include/linux/locallock.h
-@@ -222,6 +222,14 @@ static inline int __local_unlock_irqrest
-
- #define put_locked_var(lvar, var) local_unlock(lvar);
-
-+#define get_locked_ptr(lvar, var) \
-+ ({ \
-+ local_lock(lvar); \
-+ this_cpu_ptr(var); \
-+ })
-+
-+#define put_locked_ptr(lvar, var) local_unlock(lvar);
-+
- #define local_lock_cpu(lvar) \
- ({ \
- local_lock(lvar); \
-@@ -262,6 +270,8 @@ static inline void local_irq_lock_init(i
-
- #define get_locked_var(lvar, var) get_cpu_var(var)
- #define put_locked_var(lvar, var) put_cpu_var(var)
-+#define get_locked_ptr(lvar, var) get_cpu_ptr(var)
-+#define put_locked_ptr(lvar, var) put_cpu_ptr(var)
-
- #define local_lock_cpu(lvar) get_cpu()
- #define local_unlock_cpu(lvar) put_cpu()
diff --git a/debian/patches-rt/localversion.patch b/debian/patches-rt/localversion.patch
index 0701644d330e..fef69d70abd4 100644
--- a/debian/patches-rt/localversion.patch
+++ b/debian/patches-rt/localversion.patch
@@ -1,7 +1,7 @@
Subject: Add localversion for -RT release
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 08 Jul 2011 20:25:16 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
@@ -11,4 +11,4 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- /dev/null
+++ b/localversion-rt
@@ -0,0 +1 @@
-+-rt9
++-rt1
diff --git a/debian/patches-rt/lockdep-disable-self-test.patch b/debian/patches-rt/lockdep-disable-self-test.patch
index 9adf49e69bfd..f65256821bfc 100644
--- a/debian/patches-rt/lockdep-disable-self-test.patch
+++ b/debian/patches-rt/lockdep-disable-self-test.patch
@@ -4,7 +4,7 @@ Subject: [PATCH] lockdep: disable self-test
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The self-test wasn't always 100% accurate for RT. We disabled a few
tests which failed because they had a different semantic for RT. Some
@@ -18,12 +18,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
-@@ -1268,7 +1268,7 @@ config DEBUG_ATOMIC_SLEEP
+@@ -1248,7 +1248,7 @@ config DEBUG_ATOMIC_SLEEP
config DEBUG_LOCKING_API_SELFTESTS
bool "Locking API boot-time self-tests"
- depends on DEBUG_KERNEL
-+ depends on DEBUG_KERNEL && !PREEMPT_RT_FULL
++ depends on DEBUG_KERNEL && !PREEMPT_RT
help
Say Y here if you want the kernel to run a short self-test during
bootup. The self-test checks whether common types of locking bugs
diff --git a/debian/patches-rt/lockdep-no-softirq-accounting-on-rt.patch b/debian/patches-rt/lockdep-no-softirq-accounting-on-rt.patch
index 310213ab77da..fe6fb5efa9fd 100644
--- a/debian/patches-rt/lockdep-no-softirq-accounting-on-rt.patch
+++ b/debian/patches-rt/lockdep-no-softirq-accounting-on-rt.patch
@@ -1,7 +1,7 @@
Subject: lockdep: Make it RT aware
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 17 Jul 2011 18:51:23 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
teach lockdep that we don't really do softirqs on -RT.
@@ -33,7 +33,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
# define lockdep_softirq_exit() do { } while (0)
#endif
+
-+#if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PREEMPT_RT_FULL)
++#if defined(CONFIG_TRACE_IRQFLAGS) && !defined(CONFIG_PREEMPT_RT)
+# define lockdep_softirq_enter() \
+do { \
+ current->softirq_context++; \
@@ -52,15 +52,15 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
defined(CONFIG_PREEMPT_TRACER)
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
-@@ -4244,6 +4244,7 @@ static void check_flags(unsigned long fl
+@@ -4410,6 +4410,7 @@ static void check_flags(unsigned long fl
}
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
/*
* We dont accurately track softirq state in e.g.
* hardirq contexts (such as on 4KSTACKS), so only
-@@ -4258,6 +4259,7 @@ static void check_flags(unsigned long fl
+@@ -4424,6 +4425,7 @@ static void check_flags(unsigned long fl
DEBUG_LOCKS_WARN_ON(!current->softirqs_enabled);
}
}
diff --git a/debian/patches-rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch b/debian/patches-rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch
index 5963aa4e3706..77ff5d23acc8 100644
--- a/debian/patches-rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch
+++ b/debian/patches-rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch
@@ -1,10 +1,10 @@
From: Josh Cartwright <josh.cartwright@ni.com>
Date: Wed, 28 Jan 2015 13:08:45 -0600
Subject: lockdep: selftest: fix warnings due to missing PREEMPT_RT conditionals
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
"lockdep: Selftest: Only do hardirq context test for raw spinlock"
-disabled the execution of certain tests with PREEMPT_RT_FULL, but did
+disabled the execution of certain tests with PREEMPT_RT, but did
not prevent the tests from still being defined. This leads to warnings
like:
@@ -15,7 +15,7 @@ like:
./linux/lib/locking-selftest.c:580:1: warning: 'irqsafe1_soft_spin_12' defined but not used [-Wunused-function]
...
-Fixed by wrapping the test definitions in #ifndef CONFIG_PREEMPT_RT_FULL
+Fixed by wrapping the test definitions in #ifndef CONFIG_PREEMPT_RT
conditionals.
@@ -33,7 +33,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "locking-selftest-spin-hardirq.h"
GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_hard_spin)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
#include "locking-selftest-rlock-hardirq.h"
GENERATE_PERMUTATIONS_2_EVENTS(irqsafe1_hard_rlock)
@@ -47,7 +47,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#undef E1
#undef E2
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
/*
* Enabling hardirqs with a softirq-safe lock held:
*/
@@ -64,7 +64,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "locking-selftest-spin-hardirq.h"
GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_hard_spin)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
#include "locking-selftest-rlock-hardirq.h"
GENERATE_PERMUTATIONS_2_EVENTS(irqsafe2B_hard_rlock)
@@ -82,7 +82,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "locking-selftest-spin-hardirq.h"
GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_hard_spin)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
#include "locking-selftest-rlock-hardirq.h"
GENERATE_PERMUTATIONS_3_EVENTS(irqsafe3_hard_rlock)
@@ -100,7 +100,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "locking-selftest-spin-hardirq.h"
GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_hard_spin)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
#include "locking-selftest-rlock-hardirq.h"
GENERATE_PERMUTATIONS_3_EVENTS(irqsafe4_hard_rlock)
@@ -115,7 +115,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#undef E2
#undef E3
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
/*
* read-lock / write-lock irq inversion.
@@ -126,7 +126,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#endif
+
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
/*
* read-lock / write-lock recursion that is actually safe.
diff --git a/debian/patches-rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch b/debian/patches-rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch
index e058a0ac2263..26ee04bbafc2 100644
--- a/debian/patches-rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch
+++ b/debian/patches-rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch
@@ -1,7 +1,7 @@
Subject: lockdep: selftest: Only do hardirq context test for raw spinlock
From: Yong Zhang <yong.zhang0@gmail.com>
Date: Mon, 16 Apr 2012 15:01:56 +0800
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
From: Yong Zhang <yong.zhang@windriver.com>
@@ -22,7 +22,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
printk(" --------------------------------------------------------------------------\n");
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
/*
* irq-context testcases:
*/
diff --git a/debian/patches-rt/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch b/debian/patches-rt/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
new file mode 100644
index 000000000000..6590fba76277
--- /dev/null
+++ b/debian/patches-rt/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
@@ -0,0 +1,117 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Tue, 19 Nov 2019 09:25:04 +0100
+Subject: [PATCH] locking: Make spinlock_t and rwlock_t a RCU section on RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+On !RT a locked spinlock_t and rwlock_t disables preemption which
+implies a RCU read section. There is code that relies on that behaviour.
+
+Add an explicit RCU read section on RT while a sleeping lock (a lock
+which would disables preemption on !RT) acquired.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/locking/rtmutex.c | 6 ++++++
+ kernel/locking/rwlock-rt.c | 6 ++++++
+ 2 files changed, 12 insertions(+)
+
+--- a/kernel/locking/rtmutex.c
++++ b/kernel/locking/rtmutex.c
+@@ -1141,6 +1141,7 @@ void __sched rt_spin_lock_slowunlock(str
+ void __lockfunc rt_spin_lock(spinlock_t *lock)
+ {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+ rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
+@@ -1156,6 +1157,7 @@ void __lockfunc __rt_spin_lock(struct rt
+ void __lockfunc rt_spin_lock_nested(spinlock_t *lock, int subclass)
+ {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
+ rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
+@@ -1169,6 +1171,7 @@ void __lockfunc rt_spin_unlock(spinlock_
+ spin_release(&lock->dep_map, 1, _RET_IP_);
+ rt_spin_lock_fastunlock(&lock->lock, rt_spin_lock_slowunlock);
+ migrate_enable();
++ rcu_read_unlock();
+ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_spin_unlock);
+@@ -1200,6 +1203,7 @@ int __lockfunc rt_spin_trylock(spinlock_
+ ret = __rt_mutex_trylock(&lock->lock);
+ if (ret) {
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
++ rcu_read_lock();
+ } else {
+ migrate_enable();
+ sleeping_lock_dec();
+@@ -1216,6 +1220,7 @@ int __lockfunc rt_spin_trylock_bh(spinlo
+ ret = __rt_mutex_trylock(&lock->lock);
+ if (ret) {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+ } else
+@@ -1232,6 +1237,7 @@ int __lockfunc rt_spin_trylock_irqsave(s
+ ret = __rt_mutex_trylock(&lock->lock);
+ if (ret) {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+ }
+--- a/kernel/locking/rwlock-rt.c
++++ b/kernel/locking/rwlock-rt.c
+@@ -310,6 +310,7 @@ int __lockfunc rt_read_trylock(rwlock_t
+ ret = do_read_rt_trylock(rwlock);
+ if (ret) {
+ rwlock_acquire_read(&rwlock->dep_map, 0, 1, _RET_IP_);
++ rcu_read_lock();
+ } else {
+ migrate_enable();
+ sleeping_lock_dec();
+@@ -327,6 +328,7 @@ int __lockfunc rt_write_trylock(rwlock_t
+ ret = do_write_rt_trylock(rwlock);
+ if (ret) {
+ rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_);
++ rcu_read_lock();
+ } else {
+ migrate_enable();
+ sleeping_lock_dec();
+@@ -338,6 +340,7 @@ EXPORT_SYMBOL(rt_write_trylock);
+ void __lockfunc rt_read_lock(rwlock_t *rwlock)
+ {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_);
+ do_read_rt_lock(rwlock);
+@@ -347,6 +350,7 @@ EXPORT_SYMBOL(rt_read_lock);
+ void __lockfunc rt_write_lock(rwlock_t *rwlock)
+ {
+ sleeping_lock_inc();
++ rcu_read_lock();
+ migrate_disable();
+ rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_);
+ do_write_rt_lock(rwlock);
+@@ -358,6 +362,7 @@ void __lockfunc rt_read_unlock(rwlock_t
+ rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
+ do_read_rt_unlock(rwlock);
+ migrate_enable();
++ rcu_read_unlock();
+ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_read_unlock);
+@@ -367,6 +372,7 @@ void __lockfunc rt_write_unlock(rwlock_t
+ rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
+ do_write_rt_unlock(rwlock);
+ migrate_enable();
++ rcu_read_unlock();
+ sleeping_lock_dec();
+ }
+ EXPORT_SYMBOL(rt_write_unlock);
diff --git a/debian/patches-rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch b/debian/patches-rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch
index 68c04c95780a..0df979561927 100644
--- a/debian/patches-rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch
+++ b/debian/patches-rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 4 Aug 2017 17:40:42 +0200
Subject: [PATCH 1/2] locking: don't check for __LINUX_SPINLOCK_TYPES_H on -RT
archs
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Upstream uses arch_spinlock_t within spinlock_t and requests that
spinlock_types.h header file is included first.
diff --git a/debian/patches-rt/locking-lockdep-Don-t-complain-about-incorrect-name-.patch b/debian/patches-rt/locking-lockdep-Don-t-complain-about-incorrect-name-.patch
deleted file mode 100644
index 28d605fb6e44..000000000000
--- a/debian/patches-rt/locking-lockdep-Don-t-complain-about-incorrect-name-.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Fri, 17 May 2019 23:22:34 +0200
-Subject: [PATCH] locking/lockdep: Don't complain about incorrect name for no
- validate class
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-[ Upstream commit 978315462d3ea3cf6cfacd34c563ec1eb02a3aa5 ]
-
-It is possible to ignore the validation for a certain lock by using:
-
- lockdep_set_novalidate_class()
-
-on it. Each invocation will assign a new name to the class it created
-for created __lockdep_no_validate__. That means that once
-lockdep_set_novalidate_class() has been used on two locks then
-class->name won't match lock->name for the first lock triggering the
-warning.
-
-So ignore changed non-matching ->name pointer for the special
-__lockdep_no_validate__ class.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Cc: Linus Torvalds <torvalds@linux-foundation.org>
-Cc: Peter Zijlstra <peterz@infradead.org>
-Cc: Thomas Gleixner <tglx@linutronix.de>
-Cc: Will Deacon <will.deacon@arm.com>
-Link: http://lkml.kernel.org/r/20190517212234.32611-1-bigeasy@linutronix.de
-Signed-off-by: Ingo Molnar <mingo@kernel.org>
----
- kernel/locking/lockdep.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/kernel/locking/lockdep.c
-+++ b/kernel/locking/lockdep.c
-@@ -732,7 +732,8 @@ look_up_lock_class(const struct lockdep_
- * Huh! same key, different name? Did someone trample
- * on some memory? We're most confused.
- */
-- WARN_ON_ONCE(class->name != lock->name);
-+ WARN_ON_ONCE(class->name != lock->name &&
-+ lock->key != &__lockdep_no_validate__);
- return class;
- }
- }
diff --git a/debian/patches-rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch b/debian/patches-rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch
index be0bfbeb0b13..363dc5b129cd 100644
--- a/debian/patches-rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch
+++ b/debian/patches-rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch
@@ -1,10 +1,10 @@
From: "Wolfgang M. Reimer" <linuxball@gmail.com>
Date: Tue, 21 Jul 2015 16:20:07 +0200
Subject: locking: locktorture: Do NOT include rwlock.h directly
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Including rwlock.h directly will cause kernel builds to fail
-if CONFIG_PREEMPT_RT_FULL is defined. The correct header file
+if CONFIG_PREEMPT_RT is defined. The correct header file
(rwlock_rt.h OR rwlock.h) will be included by spinlock.h which
is included by locktorture.c anyway.
diff --git a/debian/patches-rt/locking-rt-mutex-Flush-block-plug-on-__down_read.patch b/debian/patches-rt/locking-rt-mutex-Flush-block-plug-on-__down_read.patch
index 091c7dc58777..43659f6290b8 100644
--- a/debian/patches-rt/locking-rt-mutex-Flush-block-plug-on-__down_read.patch
+++ b/debian/patches-rt/locking-rt-mutex-Flush-block-plug-on-__down_read.patch
@@ -1,7 +1,7 @@
From: Scott Wood <swood@redhat.com>
Date: Fri, 4 Jan 2019 15:33:21 -0500
Subject: [PATCH] locking/rt-mutex: Flush block plug on __down_read()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
__down_read() bypasses the rtmutex frontend to call
rt_mutex_slowlock_locked() directly, and thus it needs to call
diff --git a/debian/patches-rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch b/debian/patches-rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch
index 6dd43e679a72..fb9196d0f3a0 100644
--- a/debian/patches-rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch
+++ b/debian/patches-rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch
@@ -1,7 +1,7 @@
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Mon, 13 Nov 2017 12:56:53 -0500
Subject: [PATCH] locking/rt-mutex: fix deadlock in device mapper / block-IO
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
When some block device driver creates a bio and submits it to another
block device driver, the bio is added to current->bio_list (in order to
@@ -13,7 +13,7 @@ is called when device mapper driver blocks. It redirects bios queued on
current->bio_list to helper workqueues, so that these bios can proceed
even if the driver is blocked.
-The problem with CONFIG_PREEMPT_RT_FULL is that when the device mapper
+The problem with CONFIG_PREEMPT_RT is that when the device mapper
driver blocks, it won't call flush_current_bio_list (because
tsk_is_pi_blocked returns true in sched_submit_work), so deadlocks in
block device stack can happen.
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "rtmutex_common.h"
-@@ -1895,6 +1896,15 @@ rt_mutex_fastlock(struct rt_mutex *lock,
+@@ -1918,6 +1919,15 @@ rt_mutex_fastlock(struct rt_mutex *lock,
if (likely(rt_mutex_cmpxchg_acquire(lock, NULL, current)))
return 0;
@@ -62,7 +62,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return slowfn(lock, state, NULL, RT_MUTEX_MIN_CHAINWALK, ww_ctx);
}
-@@ -1912,6 +1922,9 @@ rt_mutex_timed_fastlock(struct rt_mutex
+@@ -1935,6 +1945,9 @@ rt_mutex_timed_fastlock(struct rt_mutex
likely(rt_mutex_cmpxchg_acquire(lock, NULL, current)))
return 0;
diff --git a/debian/patches-rt/locking-rtmutex-Clean-pi_blocked_on-in-the-error-cas.patch b/debian/patches-rt/locking-rtmutex-Clean-pi_blocked_on-in-the-error-cas.patch
new file mode 100644
index 000000000000..52d9d4dd170c
--- /dev/null
+++ b/debian/patches-rt/locking-rtmutex-Clean-pi_blocked_on-in-the-error-cas.patch
@@ -0,0 +1,92 @@
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Mon, 30 Sep 2019 18:15:44 +0200
+Subject: [PATCH] locking/rtmutex: Clean ->pi_blocked_on in the error case
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The function rt_mutex_wait_proxy_lock() cleans ->pi_blocked_on in case
+of failure (timeout, signal). The same cleanup is required in
+__rt_mutex_start_proxy_lock().
+In both the cases the tasks was interrupted by a signal or timeout while
+acquiring the lock and after the interruption it longer blocks on the
+lock.
+
+Fixes: 1a1fb985f2e2b ("futex: Handle early deadlock return correctly")
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/locking/rtmutex.c | 43 +++++++++++++++++++++++++------------------
+ 1 file changed, 25 insertions(+), 18 deletions(-)
+
+--- a/kernel/locking/rtmutex.c
++++ b/kernel/locking/rtmutex.c
+@@ -2137,6 +2137,26 @@ void rt_mutex_proxy_unlock(struct rt_mut
+ rt_mutex_set_owner(lock, NULL);
+ }
+
++static void fixup_rt_mutex_blocked(struct rt_mutex *lock)
++{
++ struct task_struct *tsk = current;
++ /*
++ * RT has a problem here when the wait got interrupted by a timeout
++ * or a signal. task->pi_blocked_on is still set. The task must
++ * acquire the hash bucket lock when returning from this function.
++ *
++ * If the hash bucket lock is contended then the
++ * BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in
++ * task_blocks_on_rt_mutex() will trigger. This can be avoided by
++ * clearing task->pi_blocked_on which removes the task from the
++ * boosting chain of the rtmutex. That's correct because the task
++ * is not longer blocked on it.
++ */
++ raw_spin_lock(&tsk->pi_lock);
++ tsk->pi_blocked_on = NULL;
++ raw_spin_unlock(&tsk->pi_lock);
++}
++
+ /**
+ * __rt_mutex_start_proxy_lock() - Start lock acquisition for another task
+ * @lock: the rt_mutex to take
+@@ -2209,6 +2229,9 @@ int __rt_mutex_start_proxy_lock(struct r
+ ret = 0;
+ }
+
++ if (ret)
++ fixup_rt_mutex_blocked(lock);
++
+ debug_rt_mutex_print_deadlock(waiter);
+
+ return ret;
+@@ -2289,7 +2312,6 @@ int rt_mutex_wait_proxy_lock(struct rt_m
+ struct hrtimer_sleeper *to,
+ struct rt_mutex_waiter *waiter)
+ {
+- struct task_struct *tsk = current;
+ int ret;
+
+ raw_spin_lock_irq(&lock->wait_lock);
+@@ -2301,23 +2323,8 @@ int rt_mutex_wait_proxy_lock(struct rt_m
+ * have to fix that up.
+ */
+ fixup_rt_mutex_waiters(lock);
+- /*
+- * RT has a problem here when the wait got interrupted by a timeout
+- * or a signal. task->pi_blocked_on is still set. The task must
+- * acquire the hash bucket lock when returning from this function.
+- *
+- * If the hash bucket lock is contended then the
+- * BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on)) in
+- * task_blocks_on_rt_mutex() will trigger. This can be avoided by
+- * clearing task->pi_blocked_on which removes the task from the
+- * boosting chain of the rtmutex. That's correct because the task
+- * is not longer blocked on it.
+- */
+- if (ret) {
+- raw_spin_lock(&tsk->pi_lock);
+- tsk->pi_blocked_on = NULL;
+- raw_spin_unlock(&tsk->pi_lock);
+- }
++ if (ret)
++ fixup_rt_mutex_blocked(lock);
+
+ raw_spin_unlock_irq(&lock->wait_lock);
+
diff --git a/debian/patches-rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch b/debian/patches-rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch
index 366c51406d18..754899b19ec1 100644
--- a/debian/patches-rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch
+++ b/debian/patches-rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 16 Nov 2017 16:48:48 +0100
Subject: [PATCH] locking/rtmutex: re-init the wait_lock in
rt_mutex_init_proxy_locked()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
We could provide a key-class for the lockdep (and fixup all callers) or
move the init to all callers (like it was) in order to avoid lockdep
@@ -16,7 +16,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -2257,6 +2257,14 @@ void rt_mutex_init_proxy_locked(struct r
+@@ -2280,6 +2280,14 @@ void rt_mutex_init_proxy_locked(struct r
struct task_struct *proxy_owner)
{
__rt_mutex_init(lock, NULL, NULL);
diff --git a/debian/patches-rt/md-disable-bcache.patch b/debian/patches-rt/md-disable-bcache.patch
index 648bbb653bb2..9f683a05f347 100644
--- a/debian/patches-rt/md-disable-bcache.patch
+++ b/debian/patches-rt/md-disable-bcache.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 29 Aug 2013 11:48:57 +0200
Subject: md: disable bcache
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
It uses anon semaphores
|drivers/md/bcache/request.c: In function ‘cached_dev_write_complete’:
@@ -15,6 +15,7 @@ It uses anon semaphores
either we get rid of those or we have to introduce them…
+Link: http://lkml.kernel.org/r/20130820111602.3cea203c@gandalf.local.home
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
drivers/md/bcache/Kconfig | 1 +
@@ -26,7 +27,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
config BCACHE
tristate "Block device as cache"
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
select CRC64
help
Allows a block device to be used as cache for other devices; uses
diff --git a/debian/patches-rt/md-raid5-percpu-handling-rt-aware.patch b/debian/patches-rt/md-raid5-percpu-handling-rt-aware.patch
index 3cff171ae2d7..ba8290e5659f 100644
--- a/debian/patches-rt/md-raid5-percpu-handling-rt-aware.patch
+++ b/debian/patches-rt/md-raid5-percpu-handling-rt-aware.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 6 Apr 2010 16:51:31 +0200
Subject: md: raid5: Make raid5_percpu handling RT aware
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
__raid_run_ops() disables preemption with get_cpu() around the access
to the raid5_percpu variables. That causes scheduling while atomic
@@ -42,7 +42,7 @@ Tested-by: Udo van den Heuvel <udovdh@xs4all.nl>
}
static void free_stripe(struct kmem_cache *sc, struct stripe_head *sh)
-@@ -6813,6 +6815,7 @@ static int raid456_cpu_up_prepare(unsign
+@@ -6821,6 +6823,7 @@ static int raid456_cpu_up_prepare(unsign
__func__, cpu);
return -ENOMEM;
}
@@ -52,7 +52,7 @@ Tested-by: Udo van den Heuvel <udovdh@xs4all.nl>
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
-@@ -637,6 +637,7 @@ struct r5conf {
+@@ -634,6 +634,7 @@ struct r5conf {
int recovery_disabled;
/* per cpu variables */
struct raid5_percpu {
diff --git a/debian/patches-rt/mips-disable-highmem-on-rt.patch b/debian/patches-rt/mips-disable-highmem-on-rt.patch
index eef5064a6f26..1e8b06206ac2 100644
--- a/debian/patches-rt/mips-disable-highmem-on-rt.patch
+++ b/debian/patches-rt/mips-disable-highmem-on-rt.patch
@@ -1,7 +1,7 @@
Subject: mips: Disable highmem on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 18 Jul 2011 17:10:12 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The current highmem handling on -RT is not compatible and needs fixups.
@@ -12,12 +12,12 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
-@@ -2602,7 +2602,7 @@ config MIPS_CRC_SUPPORT
+@@ -2586,7 +2586,7 @@ config MIPS_CRC_SUPPORT
#
config HIGHMEM
bool "High Memory Support"
- depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA
-+ depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA && !PREEMPT_RT_FULL
++ depends on 32BIT && CPU_SUPPORTS_HIGHMEM && SYS_SUPPORTS_HIGHMEM && !CPU_MIPS32_3_5_EVA && !PREEMPT_RT
config CPU_SUPPORTS_HIGHMEM
bool
diff --git a/debian/patches-rt/mm-compaction-Disable-compact_unevictable_allowed-on.patch b/debian/patches-rt/mm-compaction-Disable-compact_unevictable_allowed-on.patch
new file mode 100644
index 000000000000..d30468f92609
--- /dev/null
+++ b/debian/patches-rt/mm-compaction-Disable-compact_unevictable_allowed-on.patch
@@ -0,0 +1,55 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 8 Nov 2019 12:55:47 +0100
+Subject: [PATCH] mm/compaction: Disable compact_unevictable_allowed on RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Since commit
+ 5bbe3547aa3ba ("mm: allow compaction of unevictable pages")
+
+it is allowed to examine mlocked pages for pages to compact by default.
+On -RT even minor pagefaults are problematic because it may take a few
+100us to resolve them and until then the task is blocked.
+
+Make compact_unevictable_allowed = 0 default and remove it from /proc on
+RT.
+
+Link: https://lore.kernel.org/linux-mm/20190710144138.qyn4tuttdq6h7kqx@linutronix.de/
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/sysctl.c | 3 ++-
+ mm/compaction.c | 4 ++++
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+--- a/kernel/sysctl.c
++++ b/kernel/sysctl.c
+@@ -1488,6 +1488,7 @@ static struct ctl_table vm_table[] = {
+ .extra1 = &min_extfrag_threshold,
+ .extra2 = &max_extfrag_threshold,
+ },
++#ifndef CONFIG_PREEMPT_RT
+ {
+ .procname = "compact_unevictable_allowed",
+ .data = &sysctl_compact_unevictable_allowed,
+@@ -1497,7 +1498,7 @@ static struct ctl_table vm_table[] = {
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+-
++#endif
+ #endif /* CONFIG_COMPACTION */
+ {
+ .procname = "min_free_kbytes",
+--- a/mm/compaction.c
++++ b/mm/compaction.c
+@@ -1590,7 +1590,11 @@ typedef enum {
+ * Allow userspace to control policy on scanning the unevictable LRU for
+ * compactable pages.
+ */
++#ifdef CONFIG_PREEMPT_RT
++#define sysctl_compact_unevictable_allowed 0
++#else
+ int sysctl_compact_unevictable_allowed __read_mostly = 1;
++#endif
+
+ static inline void
+ update_fast_start_pfn(struct compact_control *cc, unsigned long pfn)
diff --git a/debian/patches-rt/mm-convert-swap-to-percpu-locked.patch b/debian/patches-rt/mm-convert-swap-to-percpu-locked.patch
deleted file mode 100644
index 6bf831e999d6..000000000000
--- a/debian/patches-rt/mm-convert-swap-to-percpu-locked.patch
+++ /dev/null
@@ -1,200 +0,0 @@
-From: Ingo Molnar <mingo@elte.hu>
-Date: Fri, 3 Jul 2009 08:29:51 -0500
-Subject: mm/swap: Convert to percpu locked
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Replace global locks (get_cpu + local_irq_save) with "local_locks()".
-Currently there is one of for "rotate" and one for "swap".
-
-Signed-off-by: Ingo Molnar <mingo@elte.hu>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-
----
- include/linux/swap.h | 2 ++
- mm/compaction.c | 6 ++++--
- mm/page_alloc.c | 3 ++-
- mm/swap.c | 38 ++++++++++++++++++++++----------------
- 4 files changed, 30 insertions(+), 19 deletions(-)
-
---- a/include/linux/swap.h
-+++ b/include/linux/swap.h
-@@ -12,6 +12,7 @@
- #include <linux/fs.h>
- #include <linux/atomic.h>
- #include <linux/page-flags.h>
-+#include <linux/locallock.h>
- #include <asm/page.h>
-
- struct notifier_block;
-@@ -329,6 +330,7 @@ extern unsigned long nr_free_pagecache_p
-
-
- /* linux/mm/swap.c */
-+DECLARE_LOCAL_IRQ_LOCK(swapvec_lock);
- extern void lru_cache_add(struct page *);
- extern void lru_cache_add_anon(struct page *page);
- extern void lru_cache_add_file(struct page *page);
---- a/mm/compaction.c
-+++ b/mm/compaction.c
-@@ -2229,10 +2229,12 @@ compact_zone(struct compact_control *cc,
- block_start_pfn(cc->migrate_pfn, cc->order);
-
- if (last_migrated_pfn < current_block_start) {
-- cpu = get_cpu();
-+ cpu = get_cpu_light();
-+ local_lock_irq(swapvec_lock);
- lru_add_drain_cpu(cpu);
-+ local_unlock_irq(swapvec_lock);
- drain_local_pages(cc->zone);
-- put_cpu();
-+ put_cpu_light();
- /* No more flushing until we migrate again */
- last_migrated_pfn = 0;
- }
---- a/mm/page_alloc.c
-+++ b/mm/page_alloc.c
-@@ -7572,8 +7572,9 @@ void __init free_area_init(unsigned long
-
- static int page_alloc_cpu_dead(unsigned int cpu)
- {
--
-+ local_lock_irq_on(swapvec_lock, cpu);
- lru_add_drain_cpu(cpu);
-+ local_unlock_irq_on(swapvec_lock, cpu);
- drain_pages(cpu);
-
- /*
---- a/mm/swap.c
-+++ b/mm/swap.c
-@@ -33,6 +33,7 @@
- #include <linux/memcontrol.h>
- #include <linux/gfp.h>
- #include <linux/uio.h>
-+#include <linux/locallock.h>
- #include <linux/hugetlb.h>
- #include <linux/page_idle.h>
-
-@@ -51,6 +52,8 @@ static DEFINE_PER_CPU(struct pagevec, lr
- #ifdef CONFIG_SMP
- static DEFINE_PER_CPU(struct pagevec, activate_page_pvecs);
- #endif
-+static DEFINE_LOCAL_IRQ_LOCK(rotate_lock);
-+DEFINE_LOCAL_IRQ_LOCK(swapvec_lock);
-
- /*
- * This path almost never happens for VM activity - pages are normally
-@@ -253,11 +256,11 @@ void rotate_reclaimable_page(struct page
- unsigned long flags;
-
- get_page(page);
-- local_irq_save(flags);
-+ local_lock_irqsave(rotate_lock, flags);
- pvec = this_cpu_ptr(&lru_rotate_pvecs);
- if (!pagevec_add(pvec, page) || PageCompound(page))
- pagevec_move_tail(pvec);
-- local_irq_restore(flags);
-+ local_unlock_irqrestore(rotate_lock, flags);
- }
- }
-
-@@ -307,12 +310,13 @@ void activate_page(struct page *page)
- {
- page = compound_head(page);
- if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) {
-- struct pagevec *pvec = &get_cpu_var(activate_page_pvecs);
-+ struct pagevec *pvec = &get_locked_var(swapvec_lock,
-+ activate_page_pvecs);
-
- get_page(page);
- if (!pagevec_add(pvec, page) || PageCompound(page))
- pagevec_lru_move_fn(pvec, __activate_page, NULL);
-- put_cpu_var(activate_page_pvecs);
-+ put_locked_var(swapvec_lock, activate_page_pvecs);
- }
- }
-
-@@ -334,7 +338,7 @@ void activate_page(struct page *page)
-
- static void __lru_cache_activate_page(struct page *page)
- {
-- struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
-+ struct pagevec *pvec = &get_locked_var(swapvec_lock, lru_add_pvec);
- int i;
-
- /*
-@@ -356,7 +360,7 @@ static void __lru_cache_activate_page(st
- }
- }
-
-- put_cpu_var(lru_add_pvec);
-+ put_locked_var(swapvec_lock, lru_add_pvec);
- }
-
- /*
-@@ -398,12 +402,12 @@ EXPORT_SYMBOL(mark_page_accessed);
-
- static void __lru_cache_add(struct page *page)
- {
-- struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
-+ struct pagevec *pvec = &get_locked_var(swapvec_lock, lru_add_pvec);
-
- get_page(page);
- if (!pagevec_add(pvec, page) || PageCompound(page))
- __pagevec_lru_add(pvec);
-- put_cpu_var(lru_add_pvec);
-+ put_locked_var(swapvec_lock, lru_add_pvec);
- }
-
- /**
-@@ -581,9 +585,9 @@ void lru_add_drain_cpu(int cpu)
- unsigned long flags;
-
- /* No harm done if a racing interrupt already did this */
-- local_irq_save(flags);
-+ local_lock_irqsave(rotate_lock, flags);
- pagevec_move_tail(pvec);
-- local_irq_restore(flags);
-+ local_unlock_irqrestore(rotate_lock, flags);
- }
-
- pvec = &per_cpu(lru_deactivate_file_pvecs, cpu);
-@@ -615,11 +619,12 @@ void deactivate_file_page(struct page *p
- return;
-
- if (likely(get_page_unless_zero(page))) {
-- struct pagevec *pvec = &get_cpu_var(lru_deactivate_file_pvecs);
-+ struct pagevec *pvec = &get_locked_var(swapvec_lock,
-+ lru_deactivate_file_pvecs);
-
- if (!pagevec_add(pvec, page) || PageCompound(page))
- pagevec_lru_move_fn(pvec, lru_deactivate_file_fn, NULL);
-- put_cpu_var(lru_deactivate_file_pvecs);
-+ put_locked_var(swapvec_lock, lru_deactivate_file_pvecs);
- }
- }
-
-@@ -634,19 +639,20 @@ void mark_page_lazyfree(struct page *pag
- {
- if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) &&
- !PageSwapCache(page) && !PageUnevictable(page)) {
-- struct pagevec *pvec = &get_cpu_var(lru_lazyfree_pvecs);
-+ struct pagevec *pvec = &get_locked_var(swapvec_lock,
-+ lru_lazyfree_pvecs);
-
- get_page(page);
- if (!pagevec_add(pvec, page) || PageCompound(page))
- pagevec_lru_move_fn(pvec, lru_lazyfree_fn, NULL);
-- put_cpu_var(lru_lazyfree_pvecs);
-+ put_locked_var(swapvec_lock, lru_lazyfree_pvecs);
- }
- }
-
- void lru_add_drain(void)
- {
-- lru_add_drain_cpu(get_cpu());
-- put_cpu();
-+ lru_add_drain_cpu(local_lock_cpu(swapvec_lock));
-+ local_unlock_cpu(swapvec_lock);
- }
-
- #ifdef CONFIG_SMP
diff --git a/debian/patches-rt/mm-disable-sloub-rt.patch b/debian/patches-rt/mm-disable-sloub-rt.patch
index 2fdf588116a3..d6e130730ae1 100644
--- a/debian/patches-rt/mm-disable-sloub-rt.patch
+++ b/debian/patches-rt/mm-disable-sloub-rt.patch
@@ -1,32 +1,41 @@
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:44:03 -0500
-Subject: mm: Allow only slub on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: mm: Allow only SLUB on RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Memory allocation disables interrupts as part of the allocation and freeing
+process. For -RT it is important that this section remain short and don't
+depend on the size of the request or an internal state of the memory allocator.
+At the beginning the SLAB memory allocator was adopted for RT's needs and it
+required substantial changes. Later, with the addition of the SLUB memory
+allocator we adopted this one as well and the changes were smaller. More
+important, due to the design of the SLUB allocator it performs better and its
+worst case latency was smaller. In the end only SLUB remained supported.
Disable SLAB and SLOB on -RT. Only SLUB is adopted to -RT needs.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
init/Kconfig | 2 ++
1 file changed, 2 insertions(+)
--- a/init/Kconfig
+++ b/init/Kconfig
-@@ -1693,6 +1693,7 @@ choice
+@@ -1805,6 +1805,7 @@ choice
config SLAB
bool "SLAB"
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
select HAVE_HARDENED_USERCOPY_ALLOCATOR
help
The regular slab allocator that is established and known to work
-@@ -1713,6 +1714,7 @@ config SLUB
+@@ -1825,6 +1826,7 @@ config SLUB
config SLOB
depends on EXPERT
bool "SLOB (Simple Allocator)"
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
help
SLOB replaces the stock allocator with a drastically simpler
allocator. SLOB is generally more space efficient but
diff --git a/debian/patches-rt/mm-enable-slub.patch b/debian/patches-rt/mm-enable-slub.patch
index 907653714718..439bc07eba64 100644
--- a/debian/patches-rt/mm-enable-slub.patch
+++ b/debian/patches-rt/mm-enable-slub.patch
@@ -1,7 +1,7 @@
Subject: mm: Enable SLUB for RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 25 Oct 2012 10:32:35 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Avoid the memory allocation in IRQ section
@@ -14,11 +14,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/slub.c
+++ b/mm/slub.c
-@@ -3721,6 +3721,11 @@ static void list_slab_objects(struct kme
+@@ -3730,6 +3730,11 @@ static void list_slab_objects(struct kme
const char *text)
{
#ifdef CONFIG_SLUB_DEBUG
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ /* XXX move out of irq-off section */
+ slab_err(s, page, text, s->name);
+#else
@@ -26,7 +26,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
void *addr = page_address(page);
void *p;
unsigned long *map = bitmap_zalloc(page->objects, GFP_ATOMIC);
-@@ -3740,8 +3745,10 @@ static void list_slab_objects(struct kme
+@@ -3749,8 +3754,10 @@ static void list_slab_objects(struct kme
slab_unlock(page);
bitmap_free(map);
#endif
diff --git a/debian/patches-rt/mm-make-vmstat-rt-aware.patch b/debian/patches-rt/mm-make-vmstat-rt-aware.patch
index b0f2c11d70fc..f09961d37e9d 100644
--- a/debian/patches-rt/mm-make-vmstat-rt-aware.patch
+++ b/debian/patches-rt/mm-make-vmstat-rt-aware.patch
@@ -1,7 +1,7 @@
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:30:13 -0500
Subject: mm/vmstat: Protect per cpu variables with preempt disable on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Disable preemption on -RT for the vmstat code. On vanila the code runs in
IRQ-off regions while on -RT it is not. "preempt_disable" ensures that the
diff --git a/debian/patches-rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch b/debian/patches-rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch
index ac750759943a..52a5abb3a1b2 100644
--- a/debian/patches-rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch
+++ b/debian/patches-rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch
@@ -1,7 +1,7 @@
From: Yang Shi <yang.shi@windriver.com>
Subject: mm/memcontrol: Don't call schedule_work_on in preemption disabled context
Date: Wed, 30 Oct 2013 11:48:33 -0700
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The following trace is triggered when running ltp oom test cases:
@@ -49,7 +49,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
-@@ -2184,7 +2184,7 @@ static void drain_all_stock(struct mem_c
+@@ -2265,7 +2265,7 @@ static void drain_all_stock(struct mem_c
* as well as workers from this path always operate on the local
* per-cpu data. CPU up doesn't touch memcg_stock at all.
*/
@@ -58,9 +58,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
for_each_online_cpu(cpu) {
struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
struct mem_cgroup *memcg;
-@@ -2204,7 +2204,7 @@ static void drain_all_stock(struct mem_c
+@@ -2286,7 +2286,7 @@ static void drain_all_stock(struct mem_c
+ schedule_work_on(cpu, &stock->work);
}
- css_put(&memcg->css);
}
- put_cpu();
+ put_cpu_light();
diff --git a/debian/patches-rt/mm-memcontrol-do_not_disable_irq.patch b/debian/patches-rt/mm-memcontrol-do_not_disable_irq.patch
index 7329c0c4e5eb..2b12211840ee 100644
--- a/debian/patches-rt/mm-memcontrol-do_not_disable_irq.patch
+++ b/debian/patches-rt/mm-memcontrol-do_not_disable_irq.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: mm/memcontrol: Replace local_irq_disable with local locks
Date: Wed, 28 Jan 2015 17:14:16 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
There are a few local_irq_disable() which then take sleeping locks. This
patch converts them local locks.
@@ -13,7 +13,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
-@@ -61,6 +61,7 @@
+@@ -63,6 +63,7 @@
#include <net/sock.h>
#include <net/ip.h>
#include "slab.h"
@@ -21,8 +21,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/uaccess.h>
-@@ -86,6 +87,8 @@ int do_swap_account __read_mostly;
- #define do_swap_account 0
+@@ -92,6 +93,8 @@ int do_swap_account __read_mostly;
+ static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq);
#endif
+static DEFINE_LOCAL_IRQ_LOCK(event_lock);
@@ -30,7 +30,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Whether legacy memory+swap accounting is active */
static bool do_memsw_account(void)
{
-@@ -5053,12 +5056,12 @@ static int mem_cgroup_move_account(struc
+@@ -5515,12 +5518,12 @@ static int mem_cgroup_move_account(struc
ret = 0;
@@ -45,7 +45,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
out_unlock:
unlock_page(page);
out:
-@@ -6172,10 +6175,10 @@ void mem_cgroup_commit_charge(struct pag
+@@ -6568,10 +6571,10 @@ void mem_cgroup_commit_charge(struct pag
commit_charge(page, memcg, lrucare);
@@ -58,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (do_memsw_account() && PageSwapCache(page)) {
swp_entry_t entry = { .val = page_private(page) };
-@@ -6244,7 +6247,7 @@ static void uncharge_batch(const struct
+@@ -6640,7 +6643,7 @@ static void uncharge_batch(const struct
memcg_oom_recover(ug->memcg);
}
@@ -67,7 +67,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
__mod_memcg_state(ug->memcg, MEMCG_RSS, -ug->nr_anon);
__mod_memcg_state(ug->memcg, MEMCG_CACHE, -ug->nr_file);
__mod_memcg_state(ug->memcg, MEMCG_RSS_HUGE, -ug->nr_huge);
-@@ -6252,7 +6255,7 @@ static void uncharge_batch(const struct
+@@ -6648,7 +6651,7 @@ static void uncharge_batch(const struct
__count_memcg_events(ug->memcg, PGPGOUT, ug->pgpgout);
__this_cpu_add(ug->memcg->vmstats_percpu->nr_page_events, nr_pages);
memcg_check_events(ug->memcg, ug->dummy_page);
@@ -76,7 +76,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!mem_cgroup_is_root(ug->memcg))
css_put_many(&ug->memcg->css, nr_pages);
-@@ -6415,10 +6418,10 @@ void mem_cgroup_migrate(struct page *old
+@@ -6811,10 +6814,10 @@ void mem_cgroup_migrate(struct page *old
commit_charge(newpage, memcg, false);
@@ -89,7 +89,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key);
-@@ -6610,6 +6613,7 @@ void mem_cgroup_swapout(struct page *pag
+@@ -7006,6 +7009,7 @@ void mem_cgroup_swapout(struct page *pag
struct mem_cgroup *memcg, *swap_memcg;
unsigned int nr_entries;
unsigned short oldid;
@@ -97,12 +97,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
VM_BUG_ON_PAGE(PageLRU(page), page);
VM_BUG_ON_PAGE(page_count(page), page);
-@@ -6655,13 +6659,17 @@ void mem_cgroup_swapout(struct page *pag
+@@ -7051,13 +7055,17 @@ void mem_cgroup_swapout(struct page *pag
* important here to have the interrupts disabled because it is the
* only synchronisation we have for updating the per-CPU variables.
*/
+ local_lock_irqsave(event_lock, flags);
-+#ifndef CONFIG_PREEMPT_RT_BASE
++#ifndef CONFIG_PREEMPT_RT
VM_BUG_ON(!irqs_disabled());
+#endif
mem_cgroup_charge_statistics(memcg, page, PageTransHuge(page),
diff --git a/debian/patches-rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch b/debian/patches-rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch
index cedce16d267d..b25c97da67b8 100644
--- a/debian/patches-rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch
+++ b/debian/patches-rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch
@@ -1,7 +1,7 @@
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:29:37 -0500
Subject: mm: page_alloc: rt-friendly per-cpu pages
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
rt-friendly per-cpu pages: convert the irqs-off per-cpu locking
method into a preemptible, explicit-per-cpu-locks method.
@@ -13,12 +13,12 @@ Contains fixes from:
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- mm/page_alloc.c | 62 ++++++++++++++++++++++++++++++++++++++------------------
- 1 file changed, 43 insertions(+), 19 deletions(-)
+ mm/page_alloc.c | 51 ++++++++++++++++++++++++++++++++-------------------
+ 1 file changed, 32 insertions(+), 19 deletions(-)
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
-@@ -62,6 +62,7 @@
+@@ -61,6 +61,7 @@
#include <linux/hugetlb.h>
#include <linux/sched/rt.h>
#include <linux/sched/mm.h>
@@ -26,13 +26,13 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include <linux/page_owner.h>
#include <linux/kthread.h>
#include <linux/memcontrol.h>
-@@ -311,6 +312,18 @@ EXPORT_SYMBOL(nr_node_ids);
+@@ -357,6 +358,18 @@ EXPORT_SYMBOL(nr_node_ids);
EXPORT_SYMBOL(nr_online_nodes);
#endif
+static DEFINE_LOCAL_IRQ_LOCK(pa_lock);
+
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+# define cpu_lock_irqsave(cpu, flags) \
+ local_lock_irqsave_on(pa_lock, flags, cpu)
+# define cpu_unlock_irqrestore(cpu, flags) \
@@ -45,7 +45,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
int page_group_by_mobility_disabled __read_mostly;
#ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
-@@ -1389,10 +1402,10 @@ static void __free_pages_ok(struct page
+@@ -1450,10 +1463,10 @@ static void __free_pages_ok(struct page
return;
migratetype = get_pfnblock_migratetype(page, pfn);
@@ -58,7 +58,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
void __free_pages_core(struct page *page, unsigned int order)
-@@ -2737,13 +2750,13 @@ void drain_zone_pages(struct zone *zone,
+@@ -2823,13 +2836,13 @@ void drain_zone_pages(struct zone *zone,
int to_drain, batch;
LIST_HEAD(dst);
@@ -74,7 +74,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (to_drain > 0)
free_pcppages_bulk(zone, &dst, false);
-@@ -2765,7 +2778,7 @@ static void drain_pages_zone(unsigned in
+@@ -2851,7 +2864,7 @@ static void drain_pages_zone(unsigned in
LIST_HEAD(dst);
int count;
@@ -83,7 +83,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
pset = per_cpu_ptr(zone->pageset, cpu);
pcp = &pset->pcp;
-@@ -2773,7 +2786,7 @@ static void drain_pages_zone(unsigned in
+@@ -2859,7 +2872,7 @@ static void drain_pages_zone(unsigned in
if (count)
isolate_pcp_pages(count, pcp, &dst);
@@ -92,46 +92,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (count)
free_pcppages_bulk(zone, &dst, false);
-@@ -2811,6 +2824,7 @@ void drain_local_pages(struct zone *zone
- drain_pages(cpu);
- }
-
-+#ifndef CONFIG_PREEMPT_RT_BASE
- static void drain_local_pages_wq(struct work_struct *work)
- {
- struct pcpu_drain *drain;
-@@ -2828,6 +2842,7 @@ static void drain_local_pages_wq(struct
- drain_local_pages(drain->zone);
- preempt_enable();
- }
-+#endif
-
- /*
- * Spill all the per-cpu pages from all CPUs back into the buddy allocator.
-@@ -2895,6 +2910,14 @@ void drain_all_pages(struct zone *zone)
- cpumask_clear_cpu(cpu, &cpus_with_pcps);
- }
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ for_each_cpu(cpu, &cpus_with_pcps) {
-+ if (zone)
-+ drain_pages_zone(cpu, zone);
-+ else
-+ drain_pages(cpu);
-+ }
-+#else
- for_each_cpu(cpu, &cpus_with_pcps) {
- struct pcpu_drain *drain = per_cpu_ptr(&pcpu_drain, cpu);
-
-@@ -2904,6 +2927,7 @@ void drain_all_pages(struct zone *zone)
- }
- for_each_cpu(cpu, &cpus_with_pcps)
- flush_work(&per_cpu_ptr(&pcpu_drain, cpu)->work);
-+#endif
-
- mutex_unlock(&pcpu_drain_mutex);
- }
-@@ -3023,9 +3047,9 @@ void free_unref_page(struct page *page)
+@@ -3109,9 +3122,9 @@ void free_unref_page(struct page *page)
if (!free_unref_page_prepare(page, pfn))
return;
@@ -143,7 +104,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (!list_empty(&dst))
free_pcppages_bulk(zone, &dst, false);
}
-@@ -3052,7 +3076,7 @@ void free_unref_page_list(struct list_he
+@@ -3138,7 +3151,7 @@ void free_unref_page_list(struct list_he
set_page_private(page, pfn);
}
@@ -152,7 +113,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
list_for_each_entry_safe(page, next, list, lru) {
unsigned long pfn = page_private(page);
enum zone_type type;
-@@ -3067,12 +3091,12 @@ void free_unref_page_list(struct list_he
+@@ -3153,12 +3166,12 @@ void free_unref_page_list(struct list_he
* a large list of pages to free.
*/
if (++batch_count == SWAP_CLUSTER_MAX) {
@@ -168,7 +129,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
for (i = 0; i < __MAX_NR_ZONES; ) {
struct page *page;
-@@ -3222,7 +3246,7 @@ static struct page *rmqueue_pcplist(stru
+@@ -3308,7 +3321,7 @@ static struct page *rmqueue_pcplist(stru
struct page *page;
unsigned long flags;
@@ -177,7 +138,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
pcp = &this_cpu_ptr(zone->pageset)->pcp;
list = &pcp->lists[migratetype];
page = __rmqueue_pcplist(zone, migratetype, alloc_flags, pcp, list);
-@@ -3230,7 +3254,7 @@ static struct page *rmqueue_pcplist(stru
+@@ -3316,7 +3329,7 @@ static struct page *rmqueue_pcplist(stru
__count_zid_vm_events(PGALLOC, page_zonenum(page), 1);
zone_statistics(preferred_zone, zone);
}
@@ -186,7 +147,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return page;
}
-@@ -3257,7 +3281,7 @@ struct page *rmqueue(struct zone *prefer
+@@ -3343,7 +3356,7 @@ struct page *rmqueue(struct zone *prefer
* allocate greater than order-1 page units with __GFP_NOFAIL.
*/
WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1));
@@ -195,7 +156,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
do {
page = NULL;
-@@ -3277,7 +3301,7 @@ struct page *rmqueue(struct zone *prefer
+@@ -3363,7 +3376,7 @@ struct page *rmqueue(struct zone *prefer
__count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order);
zone_statistics(preferred_zone, zone);
@@ -204,7 +165,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
out:
/* Separate test+clear to avoid unnecessary atomics */
-@@ -3290,7 +3314,7 @@ struct page *rmqueue(struct zone *prefer
+@@ -3376,7 +3389,7 @@ struct page *rmqueue(struct zone *prefer
return page;
failed:
@@ -213,7 +174,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return NULL;
}
-@@ -8479,7 +8503,7 @@ void zone_pcp_reset(struct zone *zone)
+@@ -8600,7 +8613,7 @@ void zone_pcp_reset(struct zone *zone)
struct per_cpu_pageset *pset;
/* avoid races with drain_pages() */
@@ -222,7 +183,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (zone->pageset != &boot_pageset) {
for_each_online_cpu(cpu) {
pset = per_cpu_ptr(zone->pageset, cpu);
-@@ -8488,7 +8512,7 @@ void zone_pcp_reset(struct zone *zone)
+@@ -8609,7 +8622,7 @@ void zone_pcp_reset(struct zone *zone)
free_percpu(zone->pageset);
zone->pageset = &boot_pageset;
}
diff --git a/debian/patches-rt/mm-perform-lru_add_drain_all-remotely.patch b/debian/patches-rt/mm-perform-lru_add_drain_all-remotely.patch
deleted file mode 100644
index 4006bc3ac7c5..000000000000
--- a/debian/patches-rt/mm-perform-lru_add_drain_all-remotely.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-From: Luiz Capitulino <lcapitulino@redhat.com>
-Date: Fri, 27 May 2016 15:03:28 +0200
-Subject: [PATCH] mm: perform lru_add_drain_all() remotely
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-lru_add_drain_all() works by scheduling lru_add_drain_cpu() to run
-on all CPUs that have non-empty LRU pagevecs and then waiting for
-the scheduled work to complete. However, workqueue threads may never
-have the chance to run on a CPU that's running a SCHED_FIFO task.
-This causes lru_add_drain_all() to block forever.
-
-This commit solves this problem by changing lru_add_drain_all()
-to drain the LRU pagevecs of remote CPUs. This is done by grabbing
-swapvec_lock and calling lru_add_drain_cpu().
-
-PS: This is based on an idea and initial implementation by
- Rik van Riel.
-
-Signed-off-by: Rik van Riel <riel@redhat.com>
-Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- mm/swap.c | 36 ++++++++++++++++++++++++++++++------
- 1 file changed, 30 insertions(+), 6 deletions(-)
-
---- a/mm/swap.c
-+++ b/mm/swap.c
-@@ -585,9 +585,15 @@ void lru_add_drain_cpu(int cpu)
- unsigned long flags;
-
- /* No harm done if a racing interrupt already did this */
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ local_lock_irqsave_on(rotate_lock, flags, cpu);
-+ pagevec_move_tail(pvec);
-+ local_unlock_irqrestore_on(rotate_lock, flags, cpu);
-+#else
- local_lock_irqsave(rotate_lock, flags);
- pagevec_move_tail(pvec);
- local_unlock_irqrestore(rotate_lock, flags);
-+#endif
- }
-
- pvec = &per_cpu(lru_deactivate_file_pvecs, cpu);
-@@ -657,6 +663,16 @@ void lru_add_drain(void)
-
- #ifdef CONFIG_SMP
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+static inline void remote_lru_add_drain(int cpu, struct cpumask *has_work)
-+{
-+ local_lock_on(swapvec_lock, cpu);
-+ lru_add_drain_cpu(cpu);
-+ local_unlock_on(swapvec_lock, cpu);
-+}
-+
-+#else
-+
- static DEFINE_PER_CPU(struct work_struct, lru_add_drain_work);
-
- static void lru_add_drain_per_cpu(struct work_struct *dummy)
-@@ -664,6 +680,16 @@ static void lru_add_drain_per_cpu(struct
- lru_add_drain();
- }
-
-+static inline void remote_lru_add_drain(int cpu, struct cpumask *has_work)
-+{
-+ struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
-+
-+ INIT_WORK(work, lru_add_drain_per_cpu);
-+ queue_work_on(cpu, mm_percpu_wq, work);
-+ cpumask_set_cpu(cpu, has_work);
-+}
-+#endif
-+
- /*
- * Doesn't need any cpu hotplug locking because we do rely on per-cpu
- * kworkers being shut down before our page_alloc_cpu_dead callback is
-@@ -688,21 +714,19 @@ void lru_add_drain_all(void)
- cpumask_clear(&has_work);
-
- for_each_online_cpu(cpu) {
-- struct work_struct *work = &per_cpu(lru_add_drain_work, cpu);
-
- if (pagevec_count(&per_cpu(lru_add_pvec, cpu)) ||
- pagevec_count(&per_cpu(lru_rotate_pvecs, cpu)) ||
- pagevec_count(&per_cpu(lru_deactivate_file_pvecs, cpu)) ||
- pagevec_count(&per_cpu(lru_lazyfree_pvecs, cpu)) ||
-- need_activate_page_drain(cpu)) {
-- INIT_WORK(work, lru_add_drain_per_cpu);
-- queue_work_on(cpu, mm_percpu_wq, work);
-- cpumask_set_cpu(cpu, &has_work);
-- }
-+ need_activate_page_drain(cpu))
-+ remote_lru_add_drain(cpu, &has_work);
- }
-
-+#ifndef CONFIG_PREEMPT_RT_BASE
- for_each_cpu(cpu, &has_work)
- flush_work(&per_cpu(lru_add_drain_work, cpu));
-+#endif
-
- mutex_unlock(&lock);
- }
diff --git a/debian/patches-rt/mm-protect-activate-switch-mm.patch b/debian/patches-rt/mm-protect-activate-switch-mm.patch
deleted file mode 100644
index afad8f532adb..000000000000
--- a/debian/patches-rt/mm-protect-activate-switch-mm.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-From: Yong Zhang <yong.zhang0@gmail.com>
-Date: Tue, 15 May 2012 13:53:56 +0800
-Subject: mm: Protect activate_mm() by preempt_[disable&enable]_rt()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-User preempt_*_rt instead of local_irq_*_rt or otherwise there will be
-warning on ARM like below:
-
-WARNING: at build/linux/kernel/smp.c:459 smp_call_function_many+0x98/0x264()
-Modules linked in:
-[<c0013bb4>] (unwind_backtrace+0x0/0xe4) from [<c001be94>] (warn_slowpath_common+0x4c/0x64)
-[<c001be94>] (warn_slowpath_common+0x4c/0x64) from [<c001bec4>] (warn_slowpath_null+0x18/0x1c)
-[<c001bec4>] (warn_slowpath_null+0x18/0x1c) from [<c0053ff8>](smp_call_function_many+0x98/0x264)
-[<c0053ff8>] (smp_call_function_many+0x98/0x264) from [<c0054364>] (smp_call_function+0x44/0x6c)
-[<c0054364>] (smp_call_function+0x44/0x6c) from [<c0017d50>] (__new_context+0xbc/0x124)
-[<c0017d50>] (__new_context+0xbc/0x124) from [<c009e49c>] (flush_old_exec+0x460/0x5e4)
-[<c009e49c>] (flush_old_exec+0x460/0x5e4) from [<c00d61ac>] (load_elf_binary+0x2e0/0x11ac)
-[<c00d61ac>] (load_elf_binary+0x2e0/0x11ac) from [<c009d060>] (search_binary_handler+0x94/0x2a4)
-[<c009d060>] (search_binary_handler+0x94/0x2a4) from [<c009e8fc>] (do_execve+0x254/0x364)
-[<c009e8fc>] (do_execve+0x254/0x364) from [<c0010e84>] (sys_execve+0x34/0x54)
-[<c0010e84>] (sys_execve+0x34/0x54) from [<c000da00>] (ret_fast_syscall+0x0/0x30)
----[ end trace 0000000000000002 ]---
-
-The reason is that ARM need irq enabled when doing activate_mm().
-According to mm-protect-activate-switch-mm.patch, actually
-preempt_[disable|enable]_rt() is sufficient.
-
-Inspired-by: Steven Rostedt <rostedt@goodmis.org>
-Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Link: http://lkml.kernel.org/r/1337061236-1766-1-git-send-email-yong.zhang0@gmail.com
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- fs/exec.c | 2 ++
- mm/mmu_context.c | 2 ++
- 2 files changed, 4 insertions(+)
-
---- a/fs/exec.c
-+++ b/fs/exec.c
-@@ -1032,12 +1032,14 @@ static int exec_mmap(struct mm_struct *m
- }
- }
- task_lock(tsk);
-+ preempt_disable_rt();
- active_mm = tsk->active_mm;
- tsk->mm = mm;
- tsk->active_mm = mm;
- activate_mm(active_mm, mm);
- tsk->mm->vmacache_seqnum = 0;
- vmacache_flush(tsk);
-+ preempt_enable_rt();
- task_unlock(tsk);
- if (old_mm) {
- up_read(&old_mm->mmap_sem);
---- a/mm/mmu_context.c
-+++ b/mm/mmu_context.c
-@@ -25,6 +25,7 @@ void use_mm(struct mm_struct *mm)
- struct task_struct *tsk = current;
-
- task_lock(tsk);
-+ preempt_disable_rt();
- active_mm = tsk->active_mm;
- if (active_mm != mm) {
- mmgrab(mm);
-@@ -32,6 +33,7 @@ void use_mm(struct mm_struct *mm)
- }
- tsk->mm = mm;
- switch_mm(active_mm, mm, tsk);
-+ preempt_enable_rt();
- task_unlock(tsk);
- #ifdef finish_arch_post_lock_switch
- finish_arch_post_lock_switch();
diff --git a/debian/patches-rt/mm-rt-kmap-atomic-scheduling.patch b/debian/patches-rt/mm-rt-kmap-atomic-scheduling.patch
index 8c1f1597bbae..00dde59cf5bf 100644
--- a/debian/patches-rt/mm-rt-kmap-atomic-scheduling.patch
+++ b/debian/patches-rt/mm-rt-kmap-atomic-scheduling.patch
@@ -1,7 +1,7 @@
Subject: mm, rt: kmap_atomic scheduling
From: Peter Zijlstra <peterz@infradead.org>
Date: Thu, 28 Jul 2011 10:43:51 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
In fact, with migrate_disable() existing one could play games with
kmap_atomic. You could save/restore the kmap_atomic slots on context
@@ -39,11 +39,11 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
#include <asm/pgtable.h>
#include <asm/ldt.h>
-@@ -202,6 +203,35 @@ start_thread(struct pt_regs *regs, unsig
+@@ -196,6 +197,35 @@ start_thread(struct pt_regs *regs, unsig
}
EXPORT_SYMBOL_GPL(start_thread);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+static void switch_kmaps(struct task_struct *prev_p, struct task_struct *next_p)
+{
+ int i;
@@ -75,7 +75,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
/*
* switch_to(x,y) should switch tasks from x to y.
-@@ -272,6 +302,8 @@ EXPORT_SYMBOL_GPL(start_thread);
+@@ -266,6 +296,8 @@ EXPORT_SYMBOL_GPL(start_thread);
switch_to_extra(prev_p, next_p);
@@ -104,7 +104,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
BUG_ON(!pte_none(*(kmap_pte-idx)));
- set_pte(kmap_pte-idx, mk_pte(page, prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = pte;
+#endif
+ set_pte(kmap_pte-idx, pte);
@@ -115,7 +115,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
* is a bad idea also, in case the page changes cacheability
* attributes or becomes a protected page in a hypervisor.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = __pte(0);
+#endif
kpte_clear_flush(kmap_pte-idx, vaddr);
@@ -145,7 +145,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
idx = type + KM_TYPE_NR * smp_processor_id();
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
- set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = pte;
+#endif
+ set_pte(kmap_pte - idx, pte);
@@ -156,7 +156,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
* is a bad idea also, in case the page changes cacheability
* attributes or becomes a protected page in a hypervisor.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->kmap_pte[type] = __pte(0);
+#endif
kpte_clear_flush(kmap_pte-idx, vaddr);
@@ -186,13 +186,13 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
#if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
DECLARE_PER_CPU(int, __kmap_atomic_idx);
+#endif
static inline int kmap_atomic_idx_push(void)
{
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
int idx = __this_cpu_inc_return(__kmap_atomic_idx) - 1;
-#ifdef CONFIG_DEBUG_HIGHMEM
@@ -211,7 +211,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
static inline int kmap_atomic_idx(void)
{
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
return __this_cpu_read(__kmap_atomic_idx) - 1;
+#else
+ return current->kmap_idx - 1;
@@ -221,7 +221,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
static inline void kmap_atomic_idx_pop(void)
{
-#ifdef CONFIG_DEBUG_HIGHMEM
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+# ifdef CONFIG_DEBUG_HIGHMEM
int idx = __this_cpu_dec_return(__kmap_atomic_idx);
@@ -240,19 +240,19 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -29,6 +29,7 @@
- #include <linux/mm_types_task.h>
+@@ -31,6 +31,7 @@
#include <linux/task_io_accounting.h>
+ #include <linux/posix-timers.h>
#include <linux/rseq.h>
+#include <asm/kmap_types.h>
/* task_struct member predeclarations (sorted alphabetically): */
struct audit_context;
-@@ -1217,6 +1218,12 @@ struct task_struct {
- #ifdef CONFIG_PREEMPT_RT_BASE
- struct rcu_head put_rcu;
+@@ -1270,6 +1271,12 @@ struct task_struct {
+ unsigned int sequential_io;
+ unsigned int sequential_io_avg;
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# if defined CONFIG_HIGHMEM || defined CONFIG_X86_32
+ int kmap_idx;
+ pte_t kmap_pte[KM_TYPE_NR];
@@ -286,7 +286,7 @@ Link: http://lkml.kernel.org/r/1311842631.5890.208.camel@twins
#include <asm/tlbflush.h>
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
#if defined(CONFIG_HIGHMEM) || defined(CONFIG_X86_32)
DEFINE_PER_CPU(int, __kmap_atomic_idx);
+EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx);
diff --git a/debian/patches-rt/mm-scatterlist-dont-disable-irqs-on-RT.patch b/debian/patches-rt/mm-scatterlist-dont-disable-irqs-on-RT.patch
index 124ccf215249..487275d6fb7c 100644
--- a/debian/patches-rt/mm-scatterlist-dont-disable-irqs-on-RT.patch
+++ b/debian/patches-rt/mm-scatterlist-dont-disable-irqs-on-RT.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 3 Jul 2009 08:44:34 -0500
Subject: mm/scatterlist: Do not disable irqs on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
For -RT it is enough to keep pagefault disabled (which is currently handled by
kmap_atomic()).
@@ -13,7 +13,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
-@@ -801,7 +801,7 @@ void sg_miter_stop(struct sg_mapping_ite
+@@ -811,7 +811,7 @@ void sg_miter_stop(struct sg_mapping_ite
flush_kernel_dcache_page(miter->page);
if (miter->__flags & SG_MITER_ATOMIC) {
diff --git a/debian/patches-rt/mm-swap-Enable-use-pvec-lock-on-RT.patch b/debian/patches-rt/mm-swap-Enable-use-pvec-lock-on-RT.patch
new file mode 100644
index 000000000000..51f7bfdf1026
--- /dev/null
+++ b/debian/patches-rt/mm-swap-Enable-use-pvec-lock-on-RT.patch
@@ -0,0 +1,42 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Mon, 12 Aug 2019 11:20:44 +0200
+Subject: [PATCH] mm/swap: Enable use pvec lock on RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+On RT we also need to avoid preempt disable/IRQ-off regions so have to enable
+the locking while accessing pvecs.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ mm/internal.h | 4 ++++
+ mm/swap.c | 4 ++++
+ 2 files changed, 8 insertions(+)
+
+--- a/mm/internal.h
++++ b/mm/internal.h
+@@ -32,7 +32,11 @@
+ /* Do not use these with a slab allocator */
+ #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
+
++#ifdef CONFIG_PREEMPT_RT
++extern struct static_key_true use_pvec_lock;
++#else
+ extern struct static_key_false use_pvec_lock;
++#endif
+
+ void page_writeback_init(void);
+
+--- a/mm/swap.c
++++ b/mm/swap.c
+@@ -44,7 +44,11 @@
+ /* How many pages do we try to swap or page in/out together? */
+ int page_cluster;
+
++#ifdef CONFIG_PREEMPT_RT
++DEFINE_STATIC_KEY_TRUE(use_pvec_lock);
++#else
+ DEFINE_STATIC_KEY_FALSE(use_pvec_lock);
++#endif
+
+ struct swap_pagevec {
+ spinlock_t lock;
diff --git a/debian/patches-rt/mm-vmalloc-remove-preempt_disable-enable-when-doing-.patch b/debian/patches-rt/mm-vmalloc-remove-preempt_disable-enable-when-doing-.patch
new file mode 100644
index 000000000000..4788adccd337
--- /dev/null
+++ b/debian/patches-rt/mm-vmalloc-remove-preempt_disable-enable-when-doing-.patch
@@ -0,0 +1,106 @@
+From: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
+Date: Sat, 30 Nov 2019 17:54:33 -0800
+Subject: [PATCH] mm/vmalloc: remove preempt_disable/enable when doing
+ preloading
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Some background. The preemption was disabled before to guarantee that a
+preloaded object is available for a CPU, it was stored for. That was
+achieved by combining the disabling the preemption and taking the spin
+lock while the ne_fit_preload_node is checked.
+
+The aim was to not allocate in atomic context when spinlock is taken
+later, for regular vmap allocations. But that approach conflicts with
+CONFIG_PREEMPT_RT philosophy. It means that calling spin_lock() with
+disabled preemption is forbidden in the CONFIG_PREEMPT_RT kernel.
+
+Therefore, get rid of preempt_disable() and preempt_enable() when the
+preload is done for splitting purpose. As a result we do not guarantee
+now that a CPU is preloaded, instead we minimize the case when it is
+not, with this change, by populating the per cpu preload pointer under
+the vmap_area_lock.
+
+This implies that at least each caller that has done the preallocation
+will not fallback to an atomic allocation later. It is possible that
+the preallocation would be pointless or that no preallocation is done
+because of the race but the data shows that this is really rare.
+
+For example i run the special test case that follows the preload pattern
+and path. 20 "unbind" threads run it and each does 1000000 allocations.
+Only 3.5 times among 1000000 a CPU was not preloaded. So it can happen
+but the number is negligible.
+
+[mhocko@suse.com: changelog additions]
+Link: http://lkml.kernel.org/r/20191016095438.12391-1-urezki@gmail.com
+Fixes: 82dd23e84be3 ("mm/vmalloc.c: preload a CPU with one object for split purpose")
+Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
+Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
+Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Acked-by: Daniel Wagner <dwagner@suse.de>
+Acked-by: Michal Hocko <mhocko@suse.com>
+Cc: Hillf Danton <hdanton@sina.com>
+Cc: Matthew Wilcox <willy@infradead.org>
+Cc: Oleksiy Avramchenko <oleksiy.avramchenko@sonymobile.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ mm/vmalloc.c | 37 ++++++++++++++++++++-----------------
+ 1 file changed, 20 insertions(+), 17 deletions(-)
+
+--- a/mm/vmalloc.c
++++ b/mm/vmalloc.c
+@@ -1077,31 +1077,34 @@ static struct vmap_area *alloc_vmap_area
+
+ retry:
+ /*
+- * Preload this CPU with one extra vmap_area object to ensure
+- * that we have it available when fit type of free area is
+- * NE_FIT_TYPE.
++ * Preload this CPU with one extra vmap_area object. It is used
++ * when fit type of free area is NE_FIT_TYPE. Please note, it
++ * does not guarantee that an allocation occurs on a CPU that
++ * is preloaded, instead we minimize the case when it is not.
++ * It can happen because of cpu migration, because there is a
++ * race until the below spinlock is taken.
+ *
+ * The preload is done in non-atomic context, thus it allows us
+ * to use more permissive allocation masks to be more stable under
+- * low memory condition and high memory pressure.
++ * low memory condition and high memory pressure. In rare case,
++ * if not preloaded, GFP_NOWAIT is used.
+ *
+- * Even if it fails we do not really care about that. Just proceed
+- * as it is. "overflow" path will refill the cache we allocate from.
++ * Set "pva" to NULL here, because of "retry" path.
+ */
+- preempt_disable();
+- if (!__this_cpu_read(ne_fit_preload_node)) {
+- preempt_enable();
+- pva = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, node);
+- preempt_disable();
++ pva = NULL;
+
+- if (__this_cpu_cmpxchg(ne_fit_preload_node, NULL, pva)) {
+- if (pva)
+- kmem_cache_free(vmap_area_cachep, pva);
+- }
+- }
++ if (!this_cpu_read(ne_fit_preload_node))
++ /*
++ * Even if it fails we do not really care about that.
++ * Just proceed as it is. If needed "overflow" path
++ * will refill the cache we allocate from.
++ */
++ pva = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, node);
+
+ spin_lock(&vmap_area_lock);
+- preempt_enable();
++
++ if (pva && __this_cpu_cmpxchg(ne_fit_preload_node, NULL, pva))
++ kmem_cache_free(vmap_area_cachep, pva);
+
+ /*
+ * If an allocation fails, the "vend" address is
diff --git a/debian/patches-rt/mm-vmalloc-use-get-cpu-light.patch b/debian/patches-rt/mm-vmalloc-use-get-cpu-light.patch
index 10ea368fb8ea..75289d6aa8cf 100644
--- a/debian/patches-rt/mm-vmalloc-use-get-cpu-light.patch
+++ b/debian/patches-rt/mm-vmalloc-use-get-cpu-light.patch
@@ -1,7 +1,7 @@
Subject: mm/vmalloc: Another preempt disable region which sucks
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 12 Jul 2011 11:39:36 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Avoid the preempt disable version of get_cpu_var(). The inner-lock should
provide enough serialisation.
@@ -13,7 +13,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
-@@ -1406,7 +1406,7 @@ static void *new_vmap_block(unsigned int
+@@ -1462,7 +1462,7 @@ static void *new_vmap_block(unsigned int
struct vmap_block *vb;
struct vmap_area *va;
unsigned long vb_idx;
@@ -22,7 +22,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void *vaddr;
node = numa_node_id();
-@@ -1449,11 +1449,12 @@ static void *new_vmap_block(unsigned int
+@@ -1505,11 +1505,12 @@ static void *new_vmap_block(unsigned int
BUG_ON(err);
radix_tree_preload_end();
@@ -37,7 +37,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return vaddr;
}
-@@ -1522,6 +1523,7 @@ static void *vb_alloc(unsigned long size
+@@ -1578,6 +1579,7 @@ static void *vb_alloc(unsigned long size
struct vmap_block *vb;
void *vaddr = NULL;
unsigned int order;
@@ -45,7 +45,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
BUG_ON(offset_in_page(size));
BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
-@@ -1536,7 +1538,8 @@ static void *vb_alloc(unsigned long size
+@@ -1592,7 +1594,8 @@ static void *vb_alloc(unsigned long size
order = get_order(size);
rcu_read_lock();
@@ -55,7 +55,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
list_for_each_entry_rcu(vb, &vbq->free, free_list) {
unsigned long pages_off;
-@@ -1559,7 +1562,7 @@ static void *vb_alloc(unsigned long size
+@@ -1615,7 +1618,7 @@ static void *vb_alloc(unsigned long size
break;
}
diff --git a/debian/patches-rt/mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch b/debian/patches-rt/mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch
index 306e35bffd5d..f793a58c63a7 100644
--- a/debian/patches-rt/mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch
+++ b/debian/patches-rt/mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 11 Feb 2019 10:40:46 +0100
Subject: [PATCH] mm: workingset: replace IRQ-off check with a lockdep assert.
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Commit
diff --git a/debian/patches-rt/mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch b/debian/patches-rt/mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch
index 6381d3f029ad..06c78c71db1a 100644
--- a/debian/patches-rt/mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch
+++ b/debian/patches-rt/mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch
@@ -2,7 +2,7 @@ From: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
Date: Tue, 25 Jun 2019 11:28:04 -0300
Subject: [PATCH] mm/zswap: Do not disable preemption in
zswap_frontswap_store()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Zswap causes "BUG: scheduling while atomic" by blocking on a rt_spin_lock() with
preemption disabled. The preemption is disabled by get_cpu_var() in
@@ -74,7 +74,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/types.h>
#include <linux/atomic.h>
#include <linux/frontswap.h>
-@@ -981,6 +982,8 @@ static void zswap_fill_page(void *ptr, u
+@@ -980,6 +981,8 @@ static void zswap_fill_page(void *ptr, u
memset_l(page, value, PAGE_SIZE / sizeof(unsigned long));
}
@@ -98,7 +98,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (ret) {
ret = -EINVAL;
goto put_dstmem;
-@@ -1085,7 +1087,7 @@ static int zswap_frontswap_store(unsigne
+@@ -1086,7 +1088,7 @@ static int zswap_frontswap_store(unsigne
memcpy(buf, &zhdr, hlen);
memcpy(buf + hlen, dst, dlen);
zpool_unmap_handle(entry->pool->zpool, handle);
@@ -107,7 +107,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* populate entry */
entry->offset = offset;
-@@ -1113,7 +1115,7 @@ static int zswap_frontswap_store(unsigne
+@@ -1114,7 +1116,7 @@ static int zswap_frontswap_store(unsigne
return 0;
put_dstmem:
diff --git a/debian/patches-rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch b/debian/patches-rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch
index a44519a60908..665e304756e8 100644
--- a/debian/patches-rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch
+++ b/debian/patches-rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch
@@ -1,7 +1,7 @@
From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Tue, 22 Mar 2016 11:16:09 +0100
Subject: [PATCH] mm/zsmalloc: copy with get_cpu_var() and locking
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
get_cpu_var() disables preemption and triggers a might_sleep() splat later.
This is replaced with get_locked_var().
@@ -18,7 +18,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
-@@ -56,6 +56,7 @@
+@@ -57,6 +57,7 @@
#include <linux/wait.h>
#include <linux/pagemap.h>
#include <linux/fs.h>
@@ -26,14 +26,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define ZSPAGE_MAGIC 0x58
-@@ -73,9 +74,22 @@
+@@ -74,9 +75,22 @@
*/
#define ZS_MAX_ZSPAGE_ORDER 2
#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)
-
#define ZS_HANDLE_SIZE (sizeof(unsigned long))
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+
+struct zsmalloc_handle {
+ unsigned long addr;
@@ -50,7 +50,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Object location (<PFN>, <obj_idx>) is encoded as
* as single (unsigned long) handle value.
-@@ -325,7 +339,7 @@ static void SetZsPageMovable(struct zs_p
+@@ -326,7 +340,7 @@ static void SetZsPageMovable(struct zs_p
static int create_cache(struct zs_pool *pool)
{
@@ -59,7 +59,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
0, 0, NULL);
if (!pool->handle_cachep)
return 1;
-@@ -349,10 +363,27 @@ static void destroy_cache(struct zs_pool
+@@ -350,10 +364,27 @@ static void destroy_cache(struct zs_pool
static unsigned long cache_alloc_handle(struct zs_pool *pool, gfp_t gfp)
{
@@ -69,7 +69,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+ p = kmem_cache_alloc(pool->handle_cachep,
+ gfp & ~(__GFP_HIGHMEM|__GFP_MOVABLE));
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (p) {
+ struct zsmalloc_handle *zh = p;
+
@@ -79,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ return (unsigned long)p;
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+static struct zsmalloc_handle *zs_get_pure_handle(unsigned long handle)
+{
+ return (void *)(handle &~((1 << OBJ_TAG_BITS) - 1));
@@ -89,11 +89,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void cache_free_handle(struct zs_pool *pool, unsigned long handle)
{
kmem_cache_free(pool->handle_cachep, (void *)handle);
-@@ -371,12 +402,18 @@ static void cache_free_zspage(struct zs_
+@@ -372,12 +403,18 @@ static void cache_free_zspage(struct zs_
static void record_obj(unsigned long handle, unsigned long obj)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ WRITE_ONCE(zh->addr, obj);
@@ -108,7 +108,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/* zpool driver */
-@@ -458,6 +495,7 @@ MODULE_ALIAS("zpool-zsmalloc");
+@@ -460,6 +497,7 @@ MODULE_ALIAS("zpool-zsmalloc");
/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */
static DEFINE_PER_CPU(struct mapping_area, zs_map_area);
@@ -116,11 +116,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static bool is_zspage_isolated(struct zspage *zspage)
{
-@@ -887,7 +925,13 @@ static unsigned long location_to_obj(str
+@@ -869,7 +907,13 @@ static unsigned long location_to_obj(str
static unsigned long handle_to_obj(unsigned long handle)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ return zh->addr;
@@ -130,11 +130,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static unsigned long obj_to_head(struct page *page, void *obj)
-@@ -901,22 +945,46 @@ static unsigned long obj_to_head(struct
+@@ -883,22 +927,46 @@ static unsigned long obj_to_head(struct
static inline int testpin_tag(unsigned long handle)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ return mutex_is_locked(&zh->lock);
@@ -145,7 +145,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline int trypin_tag(unsigned long handle)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ return mutex_trylock(&zh->lock);
@@ -156,7 +156,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void pin_tag(unsigned long handle)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ return mutex_lock(&zh->lock);
@@ -167,7 +167,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void unpin_tag(unsigned long handle)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ struct zsmalloc_handle *zh = zs_get_pure_handle(handle);
+
+ return mutex_unlock(&zh->lock);
@@ -177,7 +177,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static void reset_page(struct page *page)
-@@ -1342,7 +1410,7 @@ void *zs_map_object(struct zs_pool *pool
+@@ -1324,7 +1392,7 @@ void *zs_map_object(struct zs_pool *pool
class = pool->size_class[class_idx];
off = (class->size * obj_idx) & ~PAGE_MASK;
@@ -186,7 +186,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
area->vm_mm = mm;
if (off + class->size <= PAGE_SIZE) {
/* this object is contained entirely within a page */
-@@ -1396,7 +1464,7 @@ void zs_unmap_object(struct zs_pool *poo
+@@ -1378,7 +1446,7 @@ void zs_unmap_object(struct zs_pool *poo
__zs_unmap_object(area, pages, off, class->size);
}
diff --git a/debian/patches-rt/mutex-no-spin-on-rt.patch b/debian/patches-rt/mutex-no-spin-on-rt.patch
deleted file mode 100644
index a1e14e56f263..000000000000
--- a/debian/patches-rt/mutex-no-spin-on-rt.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Sun, 17 Jul 2011 21:51:45 +0200
-Subject: locking: Disable spin on owner for RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Drop spin on owner for mutex / rwsem. We are most likely not using it
-but…
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- kernel/Kconfig.locks | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/kernel/Kconfig.locks
-+++ b/kernel/Kconfig.locks
-@@ -226,11 +226,11 @@ config ARCH_SUPPORTS_ATOMIC_RMW
-
- config MUTEX_SPIN_ON_OWNER
- def_bool y
-- depends on SMP && ARCH_SUPPORTS_ATOMIC_RMW
-+ depends on SMP && ARCH_SUPPORTS_ATOMIC_RMW && !PREEMPT_RT_FULL
-
- config RWSEM_SPIN_ON_OWNER
- def_bool y
-- depends on SMP && ARCH_SUPPORTS_ATOMIC_RMW
-+ depends on SMP && ARCH_SUPPORTS_ATOMIC_RMW && !PREEMPT_RT_FULL
-
- config LOCK_SPIN_ON_OWNER
- def_bool y
diff --git a/debian/patches-rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch b/debian/patches-rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch
deleted file mode 100644
index b0822e46dd7e..000000000000
--- a/debian/patches-rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From: Steven Rostedt <rostedt@goodmis.org>
-Date: Tue, 6 Dec 2016 17:50:30 -0500
-Subject: [PATCH] net: Have __napi_schedule_irqoff() disable interrupts on
- RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-A customer hit a crash where the napi sd->poll_list became corrupted.
-The customer had the bnx2x driver, which does a
-__napi_schedule_irqoff() in its interrupt handler. Unfortunately, when
-running with CONFIG_PREEMPT_RT_FULL, this interrupt handler is run as a
-thread and is preemptable. The call to ____napi_schedule() must be done
-with interrupts disabled to protect the per cpu softnet_data's
-"poll_list, which is protected by disabling interrupts (disabling
-preemption is enough when all interrupts are threaded and
-local_bh_disable() can't preempt)."
-
-As bnx2x isn't the only driver that does this, the safest thing to do
-is to make __napi_schedule_irqoff() call __napi_schedule() instead when
-CONFIG_PREEMPT_RT_FULL is enabled, which will call local_irq_save()
-before calling ____napi_schedule().
-
-Cc: stable-rt@vger.kernel.org
-Signed-off-by: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/netdevice.h | 12 ++++++++++++
- net/core/dev.c | 2 ++
- 2 files changed, 14 insertions(+)
-
---- a/include/linux/netdevice.h
-+++ b/include/linux/netdevice.h
-@@ -419,7 +419,19 @@ typedef enum rx_handler_result rx_handle
- typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
-
- void __napi_schedule(struct napi_struct *n);
-+
-+/*
-+ * When PREEMPT_RT_FULL is defined, all device interrupt handlers
-+ * run as threads, and they can also be preempted (without PREEMPT_RT
-+ * interrupt threads can not be preempted). Which means that calling
-+ * __napi_schedule_irqoff() from an interrupt handler can be preempted
-+ * and can corrupt the napi->poll_list.
-+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+#define __napi_schedule_irqoff(n) __napi_schedule(n)
-+#else
- void __napi_schedule_irqoff(struct napi_struct *n);
-+#endif
-
- static inline bool napi_disable_pending(struct napi_struct *n)
- {
---- a/net/core/dev.c
-+++ b/net/core/dev.c
-@@ -6035,6 +6035,7 @@ bool napi_schedule_prep(struct napi_stru
- }
- EXPORT_SYMBOL(napi_schedule_prep);
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
- /**
- * __napi_schedule_irqoff - schedule for receive
- * @n: entry to schedule
-@@ -6046,6 +6047,7 @@ void __napi_schedule_irqoff(struct napi_
- ____napi_schedule(this_cpu_ptr(&softnet_data), n);
- }
- EXPORT_SYMBOL(__napi_schedule_irqoff);
-+#endif
-
- bool napi_complete_done(struct napi_struct *n, int work_done)
- {
diff --git a/debian/patches-rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch b/debian/patches-rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch
index 16d930b52c1e..668bf4bc24c0 100644
--- a/debian/patches-rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch
+++ b/debian/patches-rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 14 Sep 2016 17:36:35 +0200
Subject: [PATCH] net/Qdisc: use a seqlock instead seqcount
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The seqcount disables preemption on -RT while it is held which can't
remove. Also we don't want the reader to spin for ages if the writer is
@@ -17,8 +17,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
net/core/gen_estimator.c | 6 +++---
net/core/gen_stats.c | 12 ++++++------
net/sched/sch_api.c | 2 +-
- net/sched/sch_generic.c | 12 ++++++++++++
- 8 files changed, 69 insertions(+), 17 deletions(-)
+ net/sched/sch_generic.c | 13 +++++++++++++
+ 8 files changed, 70 insertions(+), 17 deletions(-)
create mode 100644 include/net/net_seq_lock.h
--- a/include/linux/seqlock.h
@@ -90,7 +90,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#ifndef __NET_NET_SEQ_LOCK_H__
+#define __NET_NET_SEQ_LOCK_H__
+
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+# define net_seqlock_t seqlock_t
+# define net_seq_begin(__r) read_seqbegin(__r)
+# define net_seq_retry(__r, __s) read_seqretry(__r, __s)
@@ -112,7 +112,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/refcount.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
-@@ -102,7 +103,7 @@ struct Qdisc {
+@@ -100,7 +101,7 @@ struct Qdisc {
struct sk_buff_head gso_skb ____cacheline_aligned_in_smp;
struct qdisc_skb_head q;
struct gnet_stats_basic_packed bstats;
@@ -121,11 +121,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct gnet_stats_queue qstats;
unsigned long state;
struct Qdisc *next_sched;
-@@ -140,7 +141,11 @@ static inline bool qdisc_is_running(stru
+@@ -138,7 +139,11 @@ static inline bool qdisc_is_running(stru
{
if (qdisc->flags & TCQ_F_NOLOCK)
return spin_is_locked(&qdisc->seqlock);
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ return spin_is_locked(&qdisc->running.lock) ? true : false;
+#else
return (raw_read_seqcount(&qdisc->running) & 1) ? true : false;
@@ -133,11 +133,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static inline bool qdisc_is_percpu_stats(const struct Qdisc *q)
-@@ -164,17 +169,27 @@ static inline bool qdisc_run_begin(struc
+@@ -162,17 +167,27 @@ static inline bool qdisc_run_begin(struc
} else if (qdisc_is_running(qdisc)) {
return false;
}
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ if (try_write_seqlock(&qdisc->running))
+ return true;
+ return false;
@@ -153,7 +153,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline void qdisc_run_end(struct Qdisc *qdisc)
{
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ write_sequnlock(&qdisc->running);
+#else
write_seqcount_end(&qdisc->running);
@@ -161,7 +161,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (qdisc->flags & TCQ_F_NOLOCK)
spin_unlock(&qdisc->seqlock);
}
-@@ -554,7 +569,7 @@ static inline spinlock_t *qdisc_root_sle
+@@ -535,7 +550,7 @@ static inline spinlock_t *qdisc_root_sle
return qdisc_lock(root);
}
@@ -264,7 +264,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
.ops = &noop_qdisc_ops,
.q.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock),
.dev_queue = &noop_netdev_queue,
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ .running = __SEQLOCK_UNLOCKED(noop_qdisc.running),
+#else
.running = SEQCNT_ZERO(noop_qdisc.running),
@@ -272,21 +272,28 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
.busylock = __SPIN_LOCK_UNLOCKED(noop_qdisc.busylock),
.gso_skb = {
.next = (struct sk_buff *)&noop_qdisc.gso_skb,
-@@ -862,9 +866,17 @@ struct Qdisc *qdisc_alloc(struct netdev_
- lockdep_set_class(&sch->busylock,
- dev->qdisc_tx_busylock ?: &qdisc_tx_busylock);
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
+@@ -853,7 +857,11 @@ struct Qdisc *qdisc_alloc(struct netdev_
+ spin_lock_init(&sch->busylock);
+ /* seqlock has the same scope of busylock, for NOLOCK qdisc */
+ spin_lock_init(&sch->seqlock);
++#ifdef CONFIG_PREEMPT_RT
+ seqlock_init(&sch->running);
-+ lockdep_set_class(&sch->running.seqcount,
-+ dev->qdisc_running_key ?: &qdisc_running_key);
-+ lockdep_set_class(&sch->running.lock,
-+ dev->qdisc_running_key ?: &qdisc_running_key);
+#else
seqcount_init(&sch->running);
- lockdep_set_class(&sch->running,
- dev->qdisc_running_key ?: &qdisc_running_key);
+#endif
sch->ops = ops;
sch->flags = ops->static_flags;
+@@ -867,7 +875,12 @@ struct Qdisc *qdisc_alloc(struct netdev_
+ if (sch != &noop_qdisc) {
+ lockdep_set_class(&sch->busylock, &dev->qdisc_tx_busylock_key);
+ lockdep_set_class(&sch->seqlock, &dev->qdisc_tx_busylock_key);
++#ifdef CONFIG_PREEMPT_RT
++ lockdep_set_class(&sch->running.seqcount, &dev->qdisc_running_key);
++ lockdep_set_class(&sch->running.lock, &dev->qdisc_running_key);
++#else
+ lockdep_set_class(&sch->running, &dev->qdisc_running_key);
++#endif
+ }
+
+ return sch;
diff --git a/debian/patches-rt/net-another-local-irq-disable-alloc-atomic-headache.patch b/debian/patches-rt/net-another-local-irq-disable-alloc-atomic-headache.patch
deleted file mode 100644
index d8011cf61fce..000000000000
--- a/debian/patches-rt/net-another-local-irq-disable-alloc-atomic-headache.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Wed, 26 Sep 2012 16:21:08 +0200
-Subject: net: Another local_irq_disable/kmalloc headache
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Replace it by a local lock. Though that's pretty inefficient :(
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- net/core/skbuff.c | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
---- a/net/core/skbuff.c
-+++ b/net/core/skbuff.c
-@@ -59,6 +59,7 @@
- #include <linux/errqueue.h>
- #include <linux/prefetch.h>
- #include <linux/if_vlan.h>
-+#include <linux/locallock.h>
-
- #include <net/protocol.h>
- #include <net/dst.h>
-@@ -364,6 +365,7 @@ struct napi_alloc_cache {
-
- static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache);
- static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache);
-+static DEFINE_LOCAL_IRQ_LOCK(netdev_alloc_lock);
-
- static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
- {
-@@ -371,10 +373,10 @@ static void *__netdev_alloc_frag(unsigne
- unsigned long flags;
- void *data;
-
-- local_irq_save(flags);
-+ local_lock_irqsave(netdev_alloc_lock, flags);
- nc = this_cpu_ptr(&netdev_alloc_cache);
- data = page_frag_alloc(nc, fragsz, gfp_mask);
-- local_irq_restore(flags);
-+ local_unlock_irqrestore(netdev_alloc_lock, flags);
- return data;
- }
-
-@@ -446,13 +448,13 @@ struct sk_buff *__netdev_alloc_skb(struc
- if (sk_memalloc_socks())
- gfp_mask |= __GFP_MEMALLOC;
-
-- local_irq_save(flags);
-+ local_lock_irqsave(netdev_alloc_lock, flags);
-
- nc = this_cpu_ptr(&netdev_alloc_cache);
- data = page_frag_alloc(nc, len, gfp_mask);
- pfmemalloc = nc->pfmemalloc;
-
-- local_irq_restore(flags);
-+ local_unlock_irqrestore(netdev_alloc_lock, flags);
-
- if (unlikely(!data))
- return NULL;
diff --git a/debian/patches-rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch b/debian/patches-rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch
deleted file mode 100644
index 6bd4ad6407ca..000000000000
--- a/debian/patches-rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Fri, 15 Jan 2016 16:33:34 +0100
-Subject: net/core: protect users of napi_alloc_cache against
- reentrance
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-On -RT the code running in BH can not be moved to another CPU so CPU
-local variable remain local. However the code can be preempted
-and another task may enter BH accessing the same CPU using the same
-napi_alloc_cache variable.
-This patch ensures that each user of napi_alloc_cache uses a local lock.
-
-Cc: stable-rt@vger.kernel.org
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- net/core/skbuff.c | 25 +++++++++++++++++++------
- 1 file changed, 19 insertions(+), 6 deletions(-)
-
---- a/net/core/skbuff.c
-+++ b/net/core/skbuff.c
-@@ -366,6 +366,7 @@ struct napi_alloc_cache {
- static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache);
- static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache);
- static DEFINE_LOCAL_IRQ_LOCK(netdev_alloc_lock);
-+static DEFINE_LOCAL_IRQ_LOCK(napi_alloc_cache_lock);
-
- static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
- {
-@@ -397,9 +398,13 @@ EXPORT_SYMBOL(netdev_alloc_frag);
-
- static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
- {
-- struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
-+ struct napi_alloc_cache *nc;
-+ void *data;
-
-- return page_frag_alloc(&nc->page, fragsz, gfp_mask);
-+ nc = &get_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
-+ data = page_frag_alloc(&nc->page, fragsz, gfp_mask);
-+ put_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
-+ return data;
- }
-
- void *napi_alloc_frag(unsigned int fragsz)
-@@ -495,9 +500,10 @@ EXPORT_SYMBOL(__netdev_alloc_skb);
- struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len,
- gfp_t gfp_mask)
- {
-- struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
-+ struct napi_alloc_cache *nc;
- struct sk_buff *skb;
- void *data;
-+ bool pfmemalloc;
-
- len += NET_SKB_PAD + NET_IP_ALIGN;
-
-@@ -515,7 +521,10 @@ struct sk_buff *__napi_alloc_skb(struct
- if (sk_memalloc_socks())
- gfp_mask |= __GFP_MEMALLOC;
-
-+ nc = &get_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- data = page_frag_alloc(&nc->page, len, gfp_mask);
-+ pfmemalloc = nc->page.pfmemalloc;
-+ put_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- if (unlikely(!data))
- return NULL;
-
-@@ -526,7 +535,7 @@ struct sk_buff *__napi_alloc_skb(struct
- }
-
- /* use OR instead of assignment to avoid clearing of bits in mask */
-- if (nc->page.pfmemalloc)
-+ if (pfmemalloc)
- skb->pfmemalloc = 1;
- skb->head_frag = 1;
-
-@@ -755,23 +764,26 @@ void __consume_stateless_skb(struct sk_b
-
- void __kfree_skb_flush(void)
- {
-- struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
-+ struct napi_alloc_cache *nc;
-
-+ nc = &get_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- /* flush skb_cache if containing objects */
- if (nc->skb_count) {
- kmem_cache_free_bulk(skbuff_head_cache, nc->skb_count,
- nc->skb_cache);
- nc->skb_count = 0;
- }
-+ put_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- }
-
- static inline void _kfree_skb_defer(struct sk_buff *skb)
- {
-- struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache);
-+ struct napi_alloc_cache *nc;
-
- /* drop skb->head and call any destructors for packet */
- skb_release_all(skb);
-
-+ nc = &get_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- /* record skb to CPU local list */
- nc->skb_cache[nc->skb_count++] = skb;
-
-@@ -786,6 +798,7 @@ static inline void _kfree_skb_defer(stru
- nc->skb_cache);
- nc->skb_count = 0;
- }
-+ put_locked_var(napi_alloc_cache_lock, napi_alloc_cache);
- }
- void __kfree_skb_defer(struct sk_buff *skb)
- {
diff --git a/debian/patches-rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch b/debian/patches-rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch
index 6758ae0c8635..46459ec4e977 100644
--- a/debian/patches-rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch
+++ b/debian/patches-rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 16 Jun 2017 19:03:16 +0200
Subject: [PATCH] net/core: use local_bh_disable() in netif_rx_ni()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
In 2004 netif_rx_ni() gained a preempt_disable() section around
netif_rx() and its do_softirq() + testing for it. The do_softirq() part
@@ -19,7 +19,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -4571,11 +4571,9 @@ int netif_rx_ni(struct sk_buff *skb)
+@@ -4490,11 +4490,9 @@ int netif_rx_ni(struct sk_buff *skb)
trace_netif_rx_ni_entry(skb);
diff --git a/debian/patches-rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch b/debian/patches-rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch
index a21605ca0d5c..da0756a6f1b1 100644
--- a/debian/patches-rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch
+++ b/debian/patches-rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 30 Mar 2016 13:36:29 +0200
Subject: [PATCH] net: dev: always take qdisc's busylock in __dev_xmit_skb()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The root-lock is dropped before dev_hard_start_xmit() is invoked and after
setting the __QDISC___STATE_RUNNING bit. If this task is now pushed away
@@ -21,11 +21,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -3509,7 +3509,11 @@ static inline int __dev_xmit_skb(struct
+@@ -3426,7 +3426,11 @@ static inline int __dev_xmit_skb(struct
* This permits qdisc->running owner to get the lock more
* often and dequeue packets faster.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ contended = true;
+#else
contended = qdisc_is_running(q);
diff --git a/debian/patches-rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch b/debian/patches-rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch
deleted file mode 100644
index 2bc6eb0c1bef..000000000000
--- a/debian/patches-rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-Subject: net: netfilter: Serialize xt_write_recseq sections on RT
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Sun, 28 Oct 2012 11:18:08 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The netfilter code relies only on the implicit semantics of
-local_bh_disable() for serializing wt_write_recseq sections. RT breaks
-that and needs explicit serialization here.
-
-Reported-by: Peter LaDow <petela@gocougs.wsu.edu>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-
----
- include/linux/netfilter/x_tables.h | 7 +++++++
- net/netfilter/core.c | 6 ++++++
- 2 files changed, 13 insertions(+)
-
---- a/include/linux/netfilter/x_tables.h
-+++ b/include/linux/netfilter/x_tables.h
-@@ -6,6 +6,7 @@
- #include <linux/netdevice.h>
- #include <linux/static_key.h>
- #include <linux/netfilter.h>
-+#include <linux/locallock.h>
- #include <uapi/linux/netfilter/x_tables.h>
-
- /* Test a struct->invflags and a boolean for inequality */
-@@ -344,6 +345,8 @@ void xt_free_table_info(struct xt_table_
- */
- DECLARE_PER_CPU(seqcount_t, xt_recseq);
-
-+DECLARE_LOCAL_IRQ_LOCK(xt_write_lock);
-+
- /* xt_tee_enabled - true if x_tables needs to handle reentrancy
- *
- * Enabled if current ip(6)tables ruleset has at least one -j TEE rule.
-@@ -364,6 +367,9 @@ static inline unsigned int xt_write_recs
- {
- unsigned int addend;
-
-+ /* RT protection */
-+ local_lock(xt_write_lock);
-+
- /*
- * Low order bit of sequence is set if we already
- * called xt_write_recseq_begin().
-@@ -394,6 +400,7 @@ static inline void xt_write_recseq_end(u
- /* this is kind of a write_seqcount_end(), but addend is 0 or 1 */
- smp_wmb();
- __this_cpu_add(xt_recseq.sequence, addend);
-+ local_unlock(xt_write_lock);
- }
-
- /*
---- a/net/netfilter/core.c
-+++ b/net/netfilter/core.c
-@@ -20,6 +20,7 @@
- #include <linux/inetdevice.h>
- #include <linux/proc_fs.h>
- #include <linux/mutex.h>
-+#include <linux/locallock.h>
- #include <linux/mm.h>
- #include <linux/rcupdate.h>
- #include <net/net_namespace.h>
-@@ -28,6 +29,11 @@
-
- #include "nf_internals.h"
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+DEFINE_LOCAL_IRQ_LOCK(xt_write_lock);
-+EXPORT_PER_CPU_SYMBOL(xt_write_lock);
-+#endif
-+
- const struct nf_ipv6_ops __rcu *nf_ipv6_ops __read_mostly;
- EXPORT_SYMBOL_GPL(nf_ipv6_ops);
-
diff --git a/debian/patches-rt/net-make-devnet_rename_seq-a-mutex.patch b/debian/patches-rt/net-make-devnet_rename_seq-a-mutex.patch
index e644585729da..f6a11c8b98be 100644
--- a/debian/patches-rt/net-make-devnet_rename_seq-a-mutex.patch
+++ b/debian/patches-rt/net-make-devnet_rename_seq-a-mutex.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 20 Mar 2013 18:06:20 +0100
Subject: net: Add a mutex around devnet_rename_seq
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
On RT write_seqcount_begin() disables preemption and device_rename()
allocates memory with GFP_KERNEL and grabs later the sysfs_mutex
@@ -22,7 +22,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -195,6 +195,7 @@ static unsigned int napi_gen_id = NR_CPU
+@@ -196,6 +196,7 @@ static unsigned int napi_gen_id = NR_CPU
static DEFINE_READ_MOSTLY_HASHTABLE(napi_hash, 8);
static seqcount_t devnet_rename_seq;
@@ -30,7 +30,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static inline void dev_base_seq_inc(struct net *net)
{
-@@ -920,7 +921,8 @@ int netdev_get_name(struct net *net, cha
+@@ -839,7 +840,8 @@ int netdev_get_name(struct net *net, cha
strcpy(name, dev->name);
rcu_read_unlock();
if (read_seqcount_retry(&devnet_rename_seq, seq)) {
@@ -40,7 +40,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
goto retry;
}
-@@ -1197,20 +1199,17 @@ int dev_change_name(struct net_device *d
+@@ -1116,20 +1118,17 @@ int dev_change_name(struct net_device *d
likely(!(dev->priv_flags & IFF_LIVE_RENAME_OK)))
return -EBUSY;
@@ -67,7 +67,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (oldname[0] && !strchr(oldname, '%'))
netdev_info(dev, "renamed from %s\n", oldname);
-@@ -1223,11 +1222,12 @@ int dev_change_name(struct net_device *d
+@@ -1142,11 +1141,12 @@ int dev_change_name(struct net_device *d
if (ret) {
memcpy(dev->name, oldname, IFNAMSIZ);
dev->name_assign_type = old_assign_type;
@@ -83,7 +83,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
netdev_adjacent_rename_links(dev, oldname);
-@@ -1248,7 +1248,8 @@ int dev_change_name(struct net_device *d
+@@ -1167,7 +1167,8 @@ int dev_change_name(struct net_device *d
/* err >= 0 after dev_alloc_name() or stores the first errno */
if (err >= 0) {
err = ret;
@@ -93,7 +93,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
memcpy(dev->name, oldname, IFNAMSIZ);
memcpy(oldname, newname, IFNAMSIZ);
dev->name_assign_type = old_assign_type;
-@@ -1261,6 +1262,11 @@ int dev_change_name(struct net_device *d
+@@ -1180,6 +1181,11 @@ int dev_change_name(struct net_device *d
}
return err;
diff --git a/debian/patches-rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch b/debian/patches-rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch
index 62f8391866d4..a278a9037e05 100644
--- a/debian/patches-rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch
+++ b/debian/patches-rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch
@@ -1,7 +1,7 @@
From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Wed, 5 Mar 2014 00:49:47 +0100
Subject: net: sched: Use msleep() instead of yield()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
On PREEMPT_RT enabled systems the interrupt handler run as threads at prio 50
(by default). If a high priority userspace process tries to shut down a busy
@@ -47,7 +47,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
-@@ -1218,7 +1218,7 @@ void dev_deactivate_many(struct list_hea
+@@ -1215,7 +1215,7 @@ void dev_deactivate_many(struct list_hea
/* Wait for outstanding qdisc_run calls. */
list_for_each_entry(dev, head, close_list) {
while (some_qdisc_is_busy(dev))
diff --git a/debian/patches-rt/net-use-cpu-chill.patch b/debian/patches-rt/net-use-cpu-chill.patch
index a5981d616afd..fb79dff4dbda 100644
--- a/debian/patches-rt/net-use-cpu-chill.patch
+++ b/debian/patches-rt/net-use-cpu-chill.patch
@@ -1,7 +1,7 @@
Subject: net: Use cpu_chill() instead of cpu_relax()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 07 Mar 2012 21:10:04 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Retry loops on RT might loop forever when the modifying side was
preempted. Use cpu_chill() instead of cpu_relax() to let the system
@@ -11,8 +11,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
net/packet/af_packet.c | 5 +++--
- net/rds/ib_rdma.c | 3 ++-
- 2 files changed, 5 insertions(+), 3 deletions(-)
+ 1 file changed, 3 insertions(+), 2 deletions(-)
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -42,22 +41,3 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
}
prb_close_block(pkc, pbd, po, status);
---- a/net/rds/ib_rdma.c
-+++ b/net/rds/ib_rdma.c
-@@ -34,6 +34,7 @@
- #include <linux/slab.h>
- #include <linux/rculist.h>
- #include <linux/llist.h>
-+#include <linux/delay.h>
-
- #include "rds_single_path.h"
- #include "ib_mr.h"
-@@ -222,7 +223,7 @@ static inline void wait_clean_list_grace
- for_each_online_cpu(cpu) {
- flag = &per_cpu(clean_list_grace, cpu);
- while (test_bit(CLEAN_LIST_BUSY_BIT, flag))
-- cpu_relax();
-+ cpu_chill();
- }
- }
-
diff --git a/debian/patches-rt/net_disable_NET_RX_BUSY_POLL.patch b/debian/patches-rt/net_disable_NET_RX_BUSY_POLL.patch
index f59cd5be4bbe..650b6c7e864c 100644
--- a/debian/patches-rt/net_disable_NET_RX_BUSY_POLL.patch
+++ b/debian/patches-rt/net_disable_NET_RX_BUSY_POLL.patch
@@ -1,15 +1,24 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat, 27 May 2017 19:02:06 +0200
-Subject: net/core: disable NET_RX_BUSY_POLL
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: net/core: disable NET_RX_BUSY_POLL on RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-sk_busy_loop() does preempt_disable() followed by a few operations which can
-take sleeping locks and may get long.
-I _think_ that we could use preempt_disable_nort() (in sk_busy_loop()) instead
-but after a successfull cmpxchg(&napi->state, …) we would gain the ressource
-and could be scheduled out. At this point nobody knows who (which context) owns
-it and so it could take a while until the state is realeased and napi_poll()
-could be invoked again.
+napi_busy_loop() disables preemption and performs a NAPI poll. We can't acquire
+sleeping locks with disabled preemption so we would have to work around this
+and add explicit locking for synchronisation against ksoftirqd.
+Without explicit synchronisation a low priority process would "own" the NAPI
+state (by setting NAPIF_STATE_SCHED) and could be scheduled out (no
+preempt_disable() and BH is preemptible on RT).
+In case a network packages arrives then the interrupt handler would set
+NAPIF_STATE_MISSED and the system would wait until the task owning the NAPI
+would be scheduled in again.
+Should a task with RT priority busy poll then it would consume the CPU instead
+allowing tasks with lower priority to run.
+
+The NET_RX_BUSY_POLL is disabled by default (the system wide sysctls for
+poll/read are set to zero) so disable NET_RX_BUSY_POLL on RT to avoid wrong
+locking context on RT. Should this feature be considered useful on RT systems
+then it could be enabled again with proper locking and synchronisation.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
@@ -18,12 +27,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/net/Kconfig
+++ b/net/Kconfig
-@@ -280,7 +280,7 @@ config CGROUP_NET_CLASSID
+@@ -278,7 +278,7 @@ config CGROUP_NET_CLASSID
config NET_RX_BUSY_POLL
bool
- default y
-+ default y if !PREEMPT_RT_FULL
++ default y if !PREEMPT_RT
config BQL
bool
diff --git a/debian/patches-rt/of-Rework-and-simplify-phandle-cache-to-use-a-fixed-.patch b/debian/patches-rt/of-Rework-and-simplify-phandle-cache-to-use-a-fixed-.patch
new file mode 100644
index 000000000000..6c301a68da0a
--- /dev/null
+++ b/debian/patches-rt/of-Rework-and-simplify-phandle-cache-to-use-a-fixed-.patch
@@ -0,0 +1,315 @@
+From: Rob Herring <robh@kernel.org>
+Date: Wed, 11 Dec 2019 17:23:45 -0600
+Subject: [PATCH] of: Rework and simplify phandle cache to use a fixed size
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The phandle cache was added to speed up of_find_node_by_phandle() by
+avoiding walking the whole DT to find a matching phandle. The
+implementation has several shortcomings:
+
+ - The cache is designed to work on a linear set of phandle values.
+ This is true for dtc generated DTs, but not for other cases such as
+ Power.
+ - The cache isn't enabled until of_core_init() and a typical system
+ may see hundreds of calls to of_find_node_by_phandle() before that
+ point.
+ - The cache is freed and re-allocated when the number of phandles
+ changes.
+ - It takes a raw spinlock around a memory allocation which breaks on
+ RT.
+
+Change the implementation to a fixed size and use hash_32() as the
+cache index. This greatly simplifies the implementation. It avoids
+the need for any re-alloc of the cache and taking a reference on nodes
+in the cache. We only have a single source of removing cache entries
+which is of_detach_node().
+
+Using hash_32() removes any assumption on phandle values improving
+the hit rate for non-linear phandle values. The effect on linear values
+using hash_32() is about a 10% collision. The chances of thrashing on
+colliding values seems to be low.
+
+To compare performance, I used a RK3399 board which is a pretty typical
+system. I found that just measuring boot time as done previously is
+noisy and may be impacted by other things. Also bringing up secondary
+cores causes some issues with measuring, so I booted with 'nr_cpus=1'.
+With no caching, calls to of_find_node_by_phandle() take about 20124 us
+for 1248 calls. There's an additional 288 calls before time keeping is
+up. Using the average time per hit/miss with the cache, we can calculate
+these calls to take 690 us (277 hit / 11 miss) with a 128 entry cache
+and 13319 us with no cache or an uninitialized cache.
+
+Comparing the 3 implementations the time spent in
+of_find_node_by_phandle() is:
+
+no cache: 20124 us (+ 13319 us)
+128 entry cache: 5134 us (+ 690 us)
+current cache: 819 us (+ 13319 us)
+
+We could move the allocation of the cache earlier to improve the
+current cache, but that just further complicates the situation as it
+needs to be after slab is up, so we can't do it when unflattening (which
+uses memblock).
+
+Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Cc: Michael Ellerman <mpe@ellerman.id.au>
+Cc: Segher Boessenkool <segher@kernel.crashing.org>
+Cc: Frank Rowand <frowand.list@gmail.com>
+Signed-off-by: Rob Herring <robh@kernel.org>
+Link: https://lkml.kernel.org/r/20191211232345.24810-1-robh@kernel.org
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ drivers/of/base.c | 133 +++++++++---------------------------------------
+ drivers/of/dynamic.c | 2
+ drivers/of/of_private.h | 4 -
+ drivers/of/overlay.c | 10 ---
+ 4 files changed, 28 insertions(+), 121 deletions(-)
+
+--- a/drivers/of/base.c
++++ b/drivers/of/base.c
+@@ -123,115 +123,38 @@ int __weak of_node_to_nid(struct device_
+ }
+ #endif
+
+-/*
+- * Assumptions behind phandle_cache implementation:
+- * - phandle property values are in a contiguous range of 1..n
+- *
+- * If the assumptions do not hold, then
+- * - the phandle lookup overhead reduction provided by the cache
+- * will likely be less
+- */
++#define OF_PHANDLE_CACHE_BITS 7
++#define OF_PHANDLE_CACHE_SZ BIT(OF_PHANDLE_CACHE_BITS)
+
+-static struct device_node **phandle_cache;
+-static u32 phandle_cache_mask;
++static struct device_node *phandle_cache[OF_PHANDLE_CACHE_SZ];
+
+-/*
+- * Caller must hold devtree_lock.
+- */
+-static void __of_free_phandle_cache(void)
++static u32 of_phandle_cache_hash(phandle handle)
+ {
+- u32 cache_entries = phandle_cache_mask + 1;
+- u32 k;
+-
+- if (!phandle_cache)
+- return;
+-
+- for (k = 0; k < cache_entries; k++)
+- of_node_put(phandle_cache[k]);
+-
+- kfree(phandle_cache);
+- phandle_cache = NULL;
++ return hash_32(handle, OF_PHANDLE_CACHE_BITS);
+ }
+
+-int of_free_phandle_cache(void)
+-{
+- unsigned long flags;
+-
+- raw_spin_lock_irqsave(&devtree_lock, flags);
+-
+- __of_free_phandle_cache();
+-
+- raw_spin_unlock_irqrestore(&devtree_lock, flags);
+-
+- return 0;
+-}
+-#if !defined(CONFIG_MODULES)
+-late_initcall_sync(of_free_phandle_cache);
+-#endif
+-
+ /*
+ * Caller must hold devtree_lock.
+ */
+-void __of_free_phandle_cache_entry(phandle handle)
++void __of_phandle_cache_inv_entry(phandle handle)
+ {
+- phandle masked_handle;
++ u32 handle_hash;
+ struct device_node *np;
+
+ if (!handle)
+ return;
+
+- masked_handle = handle & phandle_cache_mask;
+-
+- if (phandle_cache) {
+- np = phandle_cache[masked_handle];
+- if (np && handle == np->phandle) {
+- of_node_put(np);
+- phandle_cache[masked_handle] = NULL;
+- }
+- }
+-}
+-
+-void of_populate_phandle_cache(void)
+-{
+- unsigned long flags;
+- u32 cache_entries;
+- struct device_node *np;
+- u32 phandles = 0;
+-
+- raw_spin_lock_irqsave(&devtree_lock, flags);
+-
+- __of_free_phandle_cache();
++ handle_hash = of_phandle_cache_hash(handle);
+
+- for_each_of_allnodes(np)
+- if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL)
+- phandles++;
+-
+- if (!phandles)
+- goto out;
+-
+- cache_entries = roundup_pow_of_two(phandles);
+- phandle_cache_mask = cache_entries - 1;
+-
+- phandle_cache = kcalloc(cache_entries, sizeof(*phandle_cache),
+- GFP_ATOMIC);
+- if (!phandle_cache)
+- goto out;
+-
+- for_each_of_allnodes(np)
+- if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) {
+- of_node_get(np);
+- phandle_cache[np->phandle & phandle_cache_mask] = np;
+- }
+-
+-out:
+- raw_spin_unlock_irqrestore(&devtree_lock, flags);
++ np = phandle_cache[handle_hash];
++ if (np && handle == np->phandle)
++ phandle_cache[handle_hash] = NULL;
+ }
+
+ void __init of_core_init(void)
+ {
+ struct device_node *np;
+
+- of_populate_phandle_cache();
+
+ /* Create the kset, and register existing nodes */
+ mutex_lock(&of_mutex);
+@@ -241,8 +164,11 @@ void __init of_core_init(void)
+ pr_err("failed to register existing nodes\n");
+ return;
+ }
+- for_each_of_allnodes(np)
++ for_each_of_allnodes(np) {
+ __of_attach_node_sysfs(np);
++ if (np->phandle && !phandle_cache[of_phandle_cache_hash(np->phandle)])
++ phandle_cache[of_phandle_cache_hash(np->phandle)] = np;
++ }
+ mutex_unlock(&of_mutex);
+
+ /* Symlink in /proc as required by userspace ABI */
+@@ -1223,36 +1149,29 @@ struct device_node *of_find_node_by_phan
+ {
+ struct device_node *np = NULL;
+ unsigned long flags;
+- phandle masked_handle;
++ u32 handle_hash;
+
+ if (!handle)
+ return NULL;
+
+- raw_spin_lock_irqsave(&devtree_lock, flags);
++ handle_hash = of_phandle_cache_hash(handle);
+
+- masked_handle = handle & phandle_cache_mask;
++ raw_spin_lock_irqsave(&devtree_lock, flags);
+
+- if (phandle_cache) {
+- if (phandle_cache[masked_handle] &&
+- handle == phandle_cache[masked_handle]->phandle)
+- np = phandle_cache[masked_handle];
+- if (np && of_node_check_flag(np, OF_DETACHED)) {
+- WARN_ON(1); /* did not uncache np on node removal */
+- of_node_put(np);
+- phandle_cache[masked_handle] = NULL;
+- np = NULL;
+- }
++ if (phandle_cache[handle_hash] &&
++ handle == phandle_cache[handle_hash]->phandle)
++ np = phandle_cache[handle_hash];
++ if (np && of_node_check_flag(np, OF_DETACHED)) {
++ WARN_ON(1); /* did not uncache np on node removal */
++ phandle_cache[handle_hash] = NULL;
++ np = NULL;
+ }
+
+ if (!np) {
+ for_each_of_allnodes(np)
+ if (np->phandle == handle &&
+ !of_node_check_flag(np, OF_DETACHED)) {
+- if (phandle_cache) {
+- /* will put when removed from cache */
+- of_node_get(np);
+- phandle_cache[masked_handle] = np;
+- }
++ phandle_cache[handle_hash] = np;
+ break;
+ }
+ }
+--- a/drivers/of/dynamic.c
++++ b/drivers/of/dynamic.c
+@@ -276,7 +276,7 @@ void __of_detach_node(struct device_node
+ of_node_set_flag(np, OF_DETACHED);
+
+ /* race with of_find_node_by_phandle() prevented by devtree_lock */
+- __of_free_phandle_cache_entry(np->phandle);
++ __of_phandle_cache_inv_entry(np->phandle);
+ }
+
+ /**
+--- a/drivers/of/of_private.h
++++ b/drivers/of/of_private.h
+@@ -85,14 +85,12 @@ int of_resolve_phandles(struct device_no
+ #endif
+
+ #if defined(CONFIG_OF_DYNAMIC)
+-void __of_free_phandle_cache_entry(phandle handle);
++void __of_phandle_cache_inv_entry(phandle handle);
+ #endif
+
+ #if defined(CONFIG_OF_OVERLAY)
+ void of_overlay_mutex_lock(void);
+ void of_overlay_mutex_unlock(void);
+-int of_free_phandle_cache(void);
+-void of_populate_phandle_cache(void);
+ #else
+ static inline void of_overlay_mutex_lock(void) {};
+ static inline void of_overlay_mutex_unlock(void) {};
+--- a/drivers/of/overlay.c
++++ b/drivers/of/overlay.c
+@@ -971,8 +971,6 @@ static int of_overlay_apply(const void *
+ goto err_free_overlay_changeset;
+ }
+
+- of_populate_phandle_cache();
+-
+ ret = __of_changeset_apply_notify(&ovcs->cset);
+ if (ret)
+ pr_err("overlay apply changeset entry notify error %d\n", ret);
+@@ -1215,17 +1213,9 @@ int of_overlay_remove(int *ovcs_id)
+
+ list_del(&ovcs->ovcs_list);
+
+- /*
+- * Disable phandle cache. Avoids race condition that would arise
+- * from removing cache entry when the associated node is deleted.
+- */
+- of_free_phandle_cache();
+-
+ ret_apply = 0;
+ ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply);
+
+- of_populate_phandle_cache();
+-
+ if (ret) {
+ if (ret_apply)
+ devicetree_state_flags |= DTSF_REVERT_FAIL;
diff --git a/debian/patches-rt/of-allocate-free-phandle-cache-outside-of-the-devtre.patch b/debian/patches-rt/of-allocate-free-phandle-cache-outside-of-the-devtre.patch
deleted file mode 100644
index 7469e4fea602..000000000000
--- a/debian/patches-rt/of-allocate-free-phandle-cache-outside-of-the-devtre.patch
+++ /dev/null
@@ -1,96 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Fri, 31 Aug 2018 14:16:30 +0200
-Subject: [PATCH] of: allocate / free phandle cache outside of the devtree_lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The phandle cache code allocates memory while holding devtree_lock which
-is a raw_spinlock_t. Memory allocation (and free()) is not possible on
-RT while a raw_spinlock_t is held.
-Invoke the kfree() and kcalloc() while the lock is dropped.
-
-Cc: Rob Herring <robh+dt@kernel.org>
-Cc: Frank Rowand <frowand.list@gmail.com>
-Cc: devicetree@vger.kernel.org
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- drivers/of/base.c | 19 +++++++++++++------
- 1 file changed, 13 insertions(+), 6 deletions(-)
-
---- a/drivers/of/base.c
-+++ b/drivers/of/base.c
-@@ -138,31 +138,34 @@ static u32 phandle_cache_mask;
- /*
- * Caller must hold devtree_lock.
- */
--static void __of_free_phandle_cache(void)
-+static struct device_node** __of_free_phandle_cache(void)
- {
- u32 cache_entries = phandle_cache_mask + 1;
- u32 k;
-+ struct device_node **shadow;
-
- if (!phandle_cache)
-- return;
-+ return NULL;
-
- for (k = 0; k < cache_entries; k++)
- of_node_put(phandle_cache[k]);
-
-- kfree(phandle_cache);
-+ shadow = phandle_cache;
- phandle_cache = NULL;
-+ return shadow;
- }
-
- int of_free_phandle_cache(void)
- {
- unsigned long flags;
-+ struct device_node **shadow;
-
- raw_spin_lock_irqsave(&devtree_lock, flags);
-
-- __of_free_phandle_cache();
-+ shadow = __of_free_phandle_cache();
-
- raw_spin_unlock_irqrestore(&devtree_lock, flags);
--
-+ kfree(shadow);
- return 0;
- }
- #if !defined(CONFIG_MODULES)
-@@ -197,10 +200,11 @@ void of_populate_phandle_cache(void)
- u32 cache_entries;
- struct device_node *np;
- u32 phandles = 0;
-+ struct device_node **shadow;
-
- raw_spin_lock_irqsave(&devtree_lock, flags);
-
-- __of_free_phandle_cache();
-+ shadow = __of_free_phandle_cache();
-
- for_each_of_allnodes(np)
- if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL)
-@@ -208,12 +212,14 @@ void of_populate_phandle_cache(void)
-
- if (!phandles)
- goto out;
-+ raw_spin_unlock_irqrestore(&devtree_lock, flags);
-
- cache_entries = roundup_pow_of_two(phandles);
- phandle_cache_mask = cache_entries - 1;
-
- phandle_cache = kcalloc(cache_entries, sizeof(*phandle_cache),
- GFP_ATOMIC);
-+ raw_spin_lock_irqsave(&devtree_lock, flags);
- if (!phandle_cache)
- goto out;
-
-@@ -225,6 +231,7 @@ void of_populate_phandle_cache(void)
-
- out:
- raw_spin_unlock_irqrestore(&devtree_lock, flags);
-+ kfree(shadow);
- }
-
- void __init of_core_init(void)
diff --git a/debian/patches-rt/oleg-signal-rt-fix.patch b/debian/patches-rt/oleg-signal-rt-fix.patch
index 0c62e304dcde..48fb89176e23 100644
--- a/debian/patches-rt/oleg-signal-rt-fix.patch
+++ b/debian/patches-rt/oleg-signal-rt-fix.patch
@@ -1,7 +1,7 @@
From: Oleg Nesterov <oleg@redhat.com>
Date: Tue, 14 Jul 2015 14:26:34 +0200
Subject: signal/x86: Delay calling signals in atomic
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
On x86_64 we must disable preemption before we enable interrupts
for stack faults, int3 and debugging, because the current task is using
@@ -9,7 +9,7 @@ a per CPU debug stack defined by the IST. If we schedule out, another task
can come in and use the same stack and cause the stack to be corrupted
and crash the kernel on return.
-When CONFIG_PREEMPT_RT_FULL is enabled, spin_locks become mutexes, and
+When CONFIG_PREEMPT_RT is enabled, spin_locks become mutexes, and
one of these is the spin lock used in signal handling.
Some of the debug code (int3) causes do_trap() to send a signal.
@@ -22,31 +22,33 @@ the signal information is stored on the stacks task_struct and
TIF_NOTIFY_RESUME is set. Then on exit of the trap, the signal resume
code will send the signal when preemption is enabled.
-[ rostedt: Switched from #ifdef CONFIG_PREEMPT_RT_FULL to
+[ rostedt: Switched from #ifdef CONFIG_PREEMPT_RT to
ARCH_RT_DELAYS_SIGNAL_SEND and added comments to the code. ]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+[bigeasy: also needed on 32bit as per Yang Shi <yang.shi@linaro.org>]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
arch/x86/entry/common.c | 7 +++++++
arch/x86/include/asm/signal.h | 13 +++++++++++++
include/linux/sched.h | 4 ++++
- kernel/signal.c | 37 +++++++++++++++++++++++++++++++++++--
- 4 files changed, 59 insertions(+), 2 deletions(-)
+ kernel/signal.c | 28 ++++++++++++++++++++++++++++
+ 4 files changed, 52 insertions(+)
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
-@@ -153,6 +153,13 @@ static void exit_to_usermode_loop(struct
+@@ -148,6 +148,13 @@ static void exit_to_usermode_loop(struct
if (cached_flags & _TIF_NEED_RESCHED)
schedule();
+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
+ if (unlikely(current->forced_info.si_signo)) {
+ struct task_struct *t = current;
-+ force_sig_info(t->forced_info.si_signo, &t->forced_info, t);
++ force_sig_info(&t->forced_info);
+ t->forced_info.si_signo = 0;
+ }
+#endif
@@ -63,12 +65,12 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ * Because some traps use the IST stack, we must keep preemption
+ * disabled while calling do_trap(), but do_trap() may call
+ * force_sig_info() which will grab the signal spin_locks for the
-+ * task, which in PREEMPT_RT_FULL are mutexes. By defining
++ * task, which in PREEMPT_RT are mutexes. By defining
+ * ARCH_RT_DELAYS_SIGNAL_SEND the force_sig_info() will set
+ * TIF_NOTIFY_RESUME and set up the signal to be sent on exit of the
+ * trap.
+ */
-+#if defined(CONFIG_PREEMPT_RT_FULL) && defined(CONFIG_X86_64)
++#if defined(CONFIG_PREEMPT_RT)
+#define ARCH_RT_DELAYS_SIGNAL_SEND
+#endif
+
@@ -77,11 +79,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#endif
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -875,6 +875,10 @@ struct task_struct {
+@@ -918,6 +918,10 @@ struct task_struct {
/* Restored if set_restore_sigmask() was used: */
sigset_t saved_sigmask;
struct sigpending pending;
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ /* TODO: move me into ->restart_block ? */
+ struct kernel_siginfo forced_info;
+#endif
@@ -90,39 +92,26 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
unsigned int sas_ss_flags;
--- a/kernel/signal.c
+++ b/kernel/signal.c
-@@ -1287,8 +1287,8 @@ int do_send_sig_info(int sig, struct ker
- * We don't want to have recursive SIGSEGV's etc, for example,
- * that is why we also clear SIGNAL_UNKILLABLE.
- */
--int
--force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)
-+static int
-+do_force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)
- {
- unsigned long int flags;
- int ret, blocked, ignored;
-@@ -1317,6 +1317,39 @@ force_sig_info(int sig, struct kernel_si
- return ret;
- }
+@@ -1308,6 +1308,34 @@ force_sig_info_to_task(struct kernel_sig
+ struct k_sigaction *action;
+ int sig = info->si_signo;
-+int force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)
-+{
-+/*
-+ * On some archs, PREEMPT_RT has to delay sending a signal from a trap
-+ * since it can not enable preemption, and the signal code's spin_locks
-+ * turn into mutexes. Instead, it must set TIF_NOTIFY_RESUME which will
-+ * send the signal on exit of the trap.
-+ */
++ /*
++ * On some archs, PREEMPT_RT has to delay sending a signal from a trap
++ * since it can not enable preemption, and the signal code's spin_locks
++ * turn into mutexes. Instead, it must set TIF_NOTIFY_RESUME which will
++ * send the signal on exit of the trap.
++ */
+#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
+ if (in_atomic()) {
-+ if (WARN_ON_ONCE(t != current))
-+ return 0;
++ struct task_struct *t = current;
++
+ if (WARN_ON_ONCE(t->forced_info.si_signo))
+ return 0;
+
+ if (is_si_special(info)) {
+ WARN_ON_ONCE(info != SEND_SIG_PRIV);
-+ t->forced_info.si_signo = sig;
++ t->forced_info.si_signo = info->si_signo;
+ t->forced_info.si_errno = 0;
+ t->forced_info.si_code = SI_KERNEL;
+ t->forced_info.si_pid = 0;
@@ -135,9 +124,6 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ return 0;
+ }
+#endif
-+ return do_force_sig_info(sig, info, t);
-+}
-+
- /*
- * Nuke all other threads in the group.
- */
+ spin_lock_irqsave(&t->sighand->siglock, flags);
+ action = &t->sighand->action[sig-1];
+ ignored = action->sa.sa_handler == SIG_IGN;
diff --git a/debian/patches-rt/panic-disable-random-on-rt.patch b/debian/patches-rt/panic-disable-random-on-rt.patch
index 28e300c45e9c..92d98d189710 100644
--- a/debian/patches-rt/panic-disable-random-on-rt.patch
+++ b/debian/patches-rt/panic-disable-random-on-rt.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 14 Jul 2015 14:26:34 +0200
Subject: panic: skip get_random_bytes for RT_FULL in init_oops_id
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Disable on -RT. If this is invoked from irq-context we will have problems
to acquire the sleeping lock.
@@ -13,11 +13,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/panic.c
+++ b/kernel/panic.c
-@@ -512,9 +512,11 @@ static u64 oops_id;
+@@ -521,9 +521,11 @@ static u64 oops_id;
static int init_oops_id(void)
{
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
if (!oops_id)
get_random_bytes(&oops_id, sizeof(oops_id));
else
diff --git a/debian/patches-rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch b/debian/patches-rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch
index 08254768775c..9c6870a90bad 100644
--- a/debian/patches-rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch
+++ b/debian/patches-rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 4 Oct 2017 10:24:23 +0200
Subject: [PATCH] pci/switchtec: Don't use completion's wait queue
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The poll callback is using completion's wait_queue_head_t member and
puts it in poll_wait() so the poll() caller gets a wakeup after command
@@ -24,7 +24,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
-@@ -48,10 +48,11 @@ struct switchtec_user {
+@@ -52,10 +52,11 @@ struct switchtec_user {
enum mrpc_state state;
@@ -37,7 +37,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
u32 cmd;
u32 status;
u32 return_code;
-@@ -73,7 +74,7 @@ static struct switchtec_user *stuser_cre
+@@ -77,7 +78,7 @@ static struct switchtec_user *stuser_cre
stuser->stdev = stdev;
kref_init(&stuser->kref);
INIT_LIST_HEAD(&stuser->list);
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
stuser->event_cnt = atomic_read(&stdev->event_cnt);
dev_dbg(&stdev->dev, "%s: %p\n", __func__, stuser);
-@@ -171,7 +172,7 @@ static int mrpc_queue_cmd(struct switcht
+@@ -175,7 +176,7 @@ static int mrpc_queue_cmd(struct switcht
kref_get(&stuser->kref);
stuser->read_len = sizeof(stuser->data);
stuser_set_state(stuser, MRPC_QUEUED);
@@ -55,7 +55,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_add_tail(&stuser->list, &stdev->mrpc_queue);
mrpc_cmd_submit(stdev);
-@@ -218,7 +219,8 @@ static void mrpc_complete_cmd(struct swi
+@@ -222,7 +223,8 @@ static void mrpc_complete_cmd(struct swi
memcpy_fromio(stuser->data, &stdev->mmio_mrpc->output_data,
stuser->read_len);
out:
@@ -65,7 +65,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
list_del_init(&stuser->list);
stuser_put(stuser);
stdev->mrpc_busy = 0;
-@@ -490,10 +492,11 @@ static ssize_t switchtec_dev_read(struct
+@@ -494,10 +496,11 @@ static ssize_t switchtec_dev_read(struct
mutex_unlock(&stdev->mrpc_mutex);
if (filp->f_flags & O_NONBLOCK) {
@@ -79,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (rc < 0)
return rc;
}
-@@ -541,7 +544,7 @@ static __poll_t switchtec_dev_poll(struc
+@@ -545,7 +548,7 @@ static __poll_t switchtec_dev_poll(struc
struct switchtec_dev *stdev = stuser->stdev;
__poll_t ret = 0;
@@ -88,7 +88,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
poll_wait(filp, &stdev->event_wq, wait);
if (lock_mutex_and_test_alive(stdev))
-@@ -549,7 +552,7 @@ static __poll_t switchtec_dev_poll(struc
+@@ -553,7 +556,7 @@ static __poll_t switchtec_dev_poll(struc
mutex_unlock(&stdev->mrpc_mutex);
@@ -97,7 +97,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
ret |= EPOLLIN | EPOLLRDNORM;
if (stuser->event_cnt != atomic_read(&stdev->event_cnt))
-@@ -1102,7 +1105,8 @@ static void stdev_kill(struct switchtec_
+@@ -1106,7 +1109,8 @@ static void stdev_kill(struct switchtec_
/* Wake up and kill any users waiting on an MRPC request */
list_for_each_entry_safe(stuser, tmpuser, &stdev->mrpc_queue, list) {
diff --git a/debian/patches-rt/percpu-include-irqflags.h-for-raw_local_irq_save.patch b/debian/patches-rt/percpu-include-irqflags.h-for-raw_local_irq_save.patch
deleted file mode 100644
index 608bd02589e5..000000000000
--- a/debian/patches-rt/percpu-include-irqflags.h-for-raw_local_irq_save.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Thu, 11 Oct 2018 16:39:59 +0200
-Subject: [PATCH] percpu: include irqflags.h for raw_local_irq_save()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The header percpu.h header file is using raw_local_irq_save() but does
-not include irqflags.h for its definition. It compiles because the
-header file is included via an other header file.
-On -RT the build fails because raw_local_irq_save() is not defined.
-
-Include irqflags.h in percpu.h.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/asm-generic/percpu.h | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/include/asm-generic/percpu.h
-+++ b/include/asm-generic/percpu.h
-@@ -5,6 +5,7 @@
- #include <linux/compiler.h>
- #include <linux/threads.h>
- #include <linux/percpu-defs.h>
-+#include <linux/irqflags.h>
-
- #ifdef CONFIG_SMP
-
diff --git a/debian/patches-rt/percpu-refcount-use-normal-instead-of-RCU-sched.patch b/debian/patches-rt/percpu-refcount-use-normal-instead-of-RCU-sched.patch
new file mode 100644
index 000000000000..0ee0b78d854c
--- /dev/null
+++ b/debian/patches-rt/percpu-refcount-use-normal-instead-of-RCU-sched.patch
@@ -0,0 +1,101 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Wed, 4 Sep 2019 17:59:36 +0200
+Subject: [PATCH] percpu-refcount: use normal instead of RCU-sched"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+This is a revert of commit
+ a4244454df129 ("percpu-refcount: use RCU-sched insted of normal RCU")
+
+which claims the only reason for using RCU-sched is
+ "rcu_read_[un]lock() … are slightly more expensive than preempt_disable/enable()"
+
+and
+ "As the RCU critical sections are extremely short, using sched-RCU
+ shouldn't have any latency implications."
+
+The problem with RCU-sched is that it disables preemption and the
+callback must not acquire any sleeping locks like spinlock_t on
+PREEMPT_RT which is the case.
+
+Convert back to normal RCU.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/percpu-refcount.h | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/include/linux/percpu-refcount.h
++++ b/include/linux/percpu-refcount.h
+@@ -186,14 +186,14 @@ static inline void percpu_ref_get_many(s
+ {
+ unsigned long __percpu *percpu_count;
+
+- rcu_read_lock_sched();
++ rcu_read_lock();
+
+ if (__ref_is_percpu(ref, &percpu_count))
+ this_cpu_add(*percpu_count, nr);
+ else
+ atomic_long_add(nr, &ref->count);
+
+- rcu_read_unlock_sched();
++ rcu_read_unlock();
+ }
+
+ /**
+@@ -223,7 +223,7 @@ static inline bool percpu_ref_tryget(str
+ unsigned long __percpu *percpu_count;
+ bool ret;
+
+- rcu_read_lock_sched();
++ rcu_read_lock();
+
+ if (__ref_is_percpu(ref, &percpu_count)) {
+ this_cpu_inc(*percpu_count);
+@@ -232,7 +232,7 @@ static inline bool percpu_ref_tryget(str
+ ret = atomic_long_inc_not_zero(&ref->count);
+ }
+
+- rcu_read_unlock_sched();
++ rcu_read_unlock();
+
+ return ret;
+ }
+@@ -257,7 +257,7 @@ static inline bool percpu_ref_tryget_liv
+ unsigned long __percpu *percpu_count;
+ bool ret = false;
+
+- rcu_read_lock_sched();
++ rcu_read_lock();
+
+ if (__ref_is_percpu(ref, &percpu_count)) {
+ this_cpu_inc(*percpu_count);
+@@ -266,7 +266,7 @@ static inline bool percpu_ref_tryget_liv
+ ret = atomic_long_inc_not_zero(&ref->count);
+ }
+
+- rcu_read_unlock_sched();
++ rcu_read_unlock();
+
+ return ret;
+ }
+@@ -285,14 +285,14 @@ static inline void percpu_ref_put_many(s
+ {
+ unsigned long __percpu *percpu_count;
+
+- rcu_read_lock_sched();
++ rcu_read_lock();
+
+ if (__ref_is_percpu(ref, &percpu_count))
+ this_cpu_sub(*percpu_count, nr);
+ else if (unlikely(atomic_long_sub_and_test(nr, &ref->count)))
+ ref->release(ref);
+
+- rcu_read_unlock_sched();
++ rcu_read_unlock();
+ }
+
+ /**
diff --git a/debian/patches-rt/perf-core-Add-SRCU-annotation-for-pmus-list-walk.patch b/debian/patches-rt/perf-core-Add-SRCU-annotation-for-pmus-list-walk.patch
new file mode 100644
index 000000000000..3e038d436f66
--- /dev/null
+++ b/debian/patches-rt/perf-core-Add-SRCU-annotation-for-pmus-list-walk.patch
@@ -0,0 +1,31 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 15 Nov 2019 18:04:07 +0100
+Subject: [PATCH] perf/core: Add SRCU annotation for pmus list walk
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Since commit
+ 28875945ba98d ("rcu: Add support for consolidated-RCU reader checking")
+
+there is an additional check to ensure that a RCU related lock is held
+while the RCU list is iterated.
+This section holds the SRCU reader lock instead.
+
+Add annotation to list_for_each_entry_rcu() that pmus_srcu must be
+acquired during the list traversal.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/events/core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -10258,7 +10258,7 @@ static struct pmu *perf_init_event(struc
+ goto unlock;
+ }
+
+- list_for_each_entry_rcu(pmu, &pmus, entry) {
++ list_for_each_entry_rcu(pmu, &pmus, entry, lockdep_is_held(&pmus_srcu)) {
+ ret = perf_try_init_event(pmu, event);
+ if (!ret)
+ goto unlock;
diff --git a/debian/patches-rt/pid.h-include-atomic.h.patch b/debian/patches-rt/pid.h-include-atomic.h.patch
index a0ee8f5a8b3e..39063b36c18e 100644
--- a/debian/patches-rt/pid.h-include-atomic.h.patch
+++ b/debian/patches-rt/pid.h-include-atomic.h.patch
@@ -1,7 +1,7 @@
From: Grygorii Strashko <Grygorii.Strashko@linaro.org>
Date: Tue, 21 Jul 2015 19:43:56 +0300
Subject: pid.h: include atomic.h
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This patch fixes build error:
CC kernel/pid_namespace.o
@@ -32,6 +32,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/rculist.h>
+#include <linux/atomic.h>
+ #include <linux/wait.h>
+ #include <linux/refcount.h>
- enum pid_type
- {
diff --git a/debian/patches-rt/posix-timers-Unlock-expiry-lock-in-the-early-return.patch b/debian/patches-rt/posix-timers-Unlock-expiry-lock-in-the-early-return.patch
deleted file mode 100644
index fd640cb734ca..000000000000
--- a/debian/patches-rt/posix-timers-Unlock-expiry-lock-in-the-early-return.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Mon, 16 Sep 2019 12:33:59 +0200
-Subject: [PATCH] posix-timers: Unlock expiry lock in the early return
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Patch ("posix-timers: Add expiry lock") acquired a lock in
-run_posix_cpu_timers() but didn't drop the lock in the early return.
-
-Unlock the lock in the early return path.
-
-Reported-by: kbuild test robot <lkp@intel.com>
-Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
-Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/posix-cpu-timers.c | 4 +++-
- 1 file changed, 3 insertions(+), 1 deletion(-)
-
---- a/kernel/time/posix-cpu-timers.c
-+++ b/kernel/time/posix-cpu-timers.c
-@@ -1166,8 +1166,10 @@ void run_posix_cpu_timers(struct task_st
- expiry_lock = this_cpu_ptr(&cpu_timer_expiry_lock);
- spin_lock(expiry_lock);
-
-- if (!lock_task_sighand(tsk, &flags))
-+ if (!lock_task_sighand(tsk, &flags)) {
-+ spin_unlock(expiry_lock);
- return;
-+ }
- /*
- * Here we take off tsk->signal->cpu_timers[N] and
- * tsk->cpu_timers[N] all the timers that are firing, and
diff --git a/debian/patches-rt/posix-timers-expiry-lock.patch b/debian/patches-rt/posix-timers-expiry-lock.patch
index 126b10fcdf84..1f4f92fdea22 100644
--- a/debian/patches-rt/posix-timers-expiry-lock.patch
+++ b/debian/patches-rt/posix-timers-expiry-lock.patch
@@ -4,7 +4,7 @@ Subject: [PATCH] posix-timers: Add expiry lock
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
If a about to be removed posix timer is active then the code will retry the
delete operation until it succeeds / the timer callback completes.
@@ -17,103 +17,32 @@ acquire the proper per-CPU spin_lock which is acquired by the CPU which is
expirering the timer.
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
+[bigeasy: keep the posix-cpu timer bits, everything else got applied]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- fs/timerfd.c | 6 +++++-
- include/linux/hrtimer.h | 1 +
include/linux/posix-timers.h | 1 +
- kernel/time/alarmtimer.c | 2 +-
- kernel/time/hrtimer.c | 2 +-
- kernel/time/itimer.c | 1 +
- kernel/time/posix-cpu-timers.c | 23 +++++++++++++++++++++++
- kernel/time/posix-timers.c | 38 +++++++++++++++++++++++++++++---------
- kernel/time/posix-timers.h | 2 ++
- 9 files changed, 64 insertions(+), 12 deletions(-)
+ kernel/time/posix-cpu-timers.c | 28 +++++++++++++++++++++++++++-
+ 2 files changed, 28 insertions(+), 1 deletion(-)
---- a/fs/timerfd.c
-+++ b/fs/timerfd.c
-@@ -471,7 +471,11 @@ static int do_timerfd_settime(int ufd, i
- break;
- }
- spin_unlock_irq(&ctx->wqh.lock);
-- cpu_relax();
-+
-+ if (isalarm(ctx))
-+ hrtimer_grab_expiry_lock(&ctx->t.alarm.timer);
-+ else
-+ hrtimer_grab_expiry_lock(&ctx->t.tmr);
- }
-
- /*
---- a/include/linux/hrtimer.h
-+++ b/include/linux/hrtimer.h
-@@ -400,6 +400,7 @@ static inline void hrtimer_start(struct
-
- extern int hrtimer_cancel(struct hrtimer *timer);
- extern int hrtimer_try_to_cancel(struct hrtimer *timer);
-+extern void hrtimer_grab_expiry_lock(const struct hrtimer *timer);
-
- static inline void hrtimer_start_expires(struct hrtimer *timer,
- enum hrtimer_mode mode)
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
-@@ -15,6 +15,7 @@ struct cpu_timer_list {
- u64 expires;
- struct task_struct *task;
- int firing;
-+ int firing_cpu;
+@@ -72,6 +72,7 @@ struct cpu_timer {
+ struct task_struct *task;
+ struct list_head elist;
+ int firing;
++ int firing_cpu;
};
- /*
---- a/kernel/time/alarmtimer.c
-+++ b/kernel/time/alarmtimer.c
-@@ -433,7 +433,7 @@ int alarm_cancel(struct alarm *alarm)
- int ret = alarm_try_to_cancel(alarm);
- if (ret >= 0)
- return ret;
-- cpu_relax();
-+ hrtimer_grab_expiry_lock(&alarm->timer);
- }
- }
- EXPORT_SYMBOL_GPL(alarm_cancel);
---- a/kernel/time/hrtimer.c
-+++ b/kernel/time/hrtimer.c
-@@ -930,7 +930,7 @@ u64 hrtimer_forward(struct hrtimer *time
- }
- EXPORT_SYMBOL_GPL(hrtimer_forward);
-
--static void hrtimer_grab_expiry_lock(const struct hrtimer *timer)
-+void hrtimer_grab_expiry_lock(const struct hrtimer *timer)
- {
- struct hrtimer_clock_base *base = timer->base;
-
---- a/kernel/time/itimer.c
-+++ b/kernel/time/itimer.c
-@@ -213,6 +213,7 @@ int do_setitimer(int which, struct itime
- /* We are sharing ->siglock with it_real_fn() */
- if (hrtimer_try_to_cancel(timer) < 0) {
- spin_unlock_irq(&tsk->sighand->siglock);
-+ hrtimer_grab_expiry_lock(timer);
- goto again;
- }
- expires = timeval_to_ktime(value->it_value);
+ static inline bool cpu_timer_enqueue(struct timerqueue_head *head,
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
-@@ -785,6 +785,7 @@ check_timers_list(struct list_head *time
- return t->expires;
-
- t->firing = 1;
-+ t->firing_cpu = smp_processor_id();
- list_move_tail(&t->entry, firing);
- }
-
-@@ -1127,6 +1128,20 @@ static inline int fastpath_timer_check(s
- return 0;
+@@ -446,6 +446,20 @@ static int posix_cpu_timer_del(struct k_
+ return ret;
}
+static DEFINE_PER_CPU(spinlock_t, cpu_timer_expiry_lock) = __SPIN_LOCK_UNLOCKED(cpu_timer_expiry_lock);
+
-+void cpu_timers_grab_expiry_lock(struct k_itimer *timer)
++static void posix_cpu_wait_running(struct k_itimer *timer)
+{
+ int cpu = timer->it.cpu.firing_cpu;
+
@@ -125,146 +54,70 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ }
+}
+
- /*
- * This is called from the timer interrupt handler. The irq handler has
- * already updated our counts. We need to check if any timers fire now.
-@@ -1137,6 +1152,7 @@ void run_posix_cpu_timers(struct task_st
- LIST_HEAD(firing);
+ static void cleanup_timerqueue(struct timerqueue_head *head)
+ {
+ struct timerqueue_node *node;
+@@ -783,6 +797,7 @@ static u64 collect_timerqueue(struct tim
+ return expires;
+
+ ctmr->firing = 1;
++ ctmr->firing_cpu = smp_processor_id();
+ cpu_timer_dequeue(ctmr);
+ list_add_tail(&ctmr->elist, firing);
+ }
+@@ -1121,6 +1136,7 @@ static void __run_posix_cpu_timers(struc
+ {
struct k_itimer *timer, *next;
unsigned long flags;
+ spinlock_t *expiry_lock;
+ LIST_HEAD(firing);
- lockdep_assert_irqs_disabled();
-
-@@ -1147,6 +1163,9 @@ void run_posix_cpu_timers(struct task_st
+ /*
+@@ -1130,8 +1146,13 @@ static void __run_posix_cpu_timers(struc
if (!fastpath_timer_check(tsk))
return;
+- if (!lock_task_sighand(tsk, &flags))
+ expiry_lock = this_cpu_ptr(&cpu_timer_expiry_lock);
+ spin_lock(expiry_lock);
+
- if (!lock_task_sighand(tsk, &flags))
++ if (!lock_task_sighand(tsk, &flags)) {
++ spin_unlock(expiry_lock);
return;
++ }
/*
-@@ -1181,6 +1200,7 @@ void run_posix_cpu_timers(struct task_st
- list_del_init(&timer->it.cpu.entry);
+ * Here we take off tsk->signal->cpu_timers[N] and
+ * tsk->cpu_timers[N] all the timers that are firing, and
+@@ -1164,6 +1185,7 @@ static void __run_posix_cpu_timers(struc
+ list_del_init(&timer->it.cpu.elist);
cpu_firing = timer->it.cpu.firing;
timer->it.cpu.firing = 0;
+ timer->it.cpu.firing_cpu = -1;
/*
* The firing flag is -1 if we collided with a reset
* of the timer, which already reported this
-@@ -1190,6 +1210,7 @@ void run_posix_cpu_timers(struct task_st
+@@ -1173,6 +1195,7 @@ static void __run_posix_cpu_timers(struc
cpu_timer_fire(timer);
spin_unlock(&timer->it_lock);
}
+ spin_unlock(expiry_lock);
}
- /*
-@@ -1308,6 +1329,8 @@ static int do_cpu_nanosleep(const clocki
+ #ifdef CONFIG_PREEMPT_RT
+@@ -1435,6 +1458,8 @@ static int do_cpu_nanosleep(const clocki
spin_unlock_irq(&timer.it_lock);
while (error == TIMER_RETRY) {
+
-+ cpu_timers_grab_expiry_lock(&timer);
++ posix_cpu_wait_running(&timer);
/*
* We need to handle case when timer was or is in the
* middle of firing. In other cases we already freed
---- a/kernel/time/posix-timers.c
-+++ b/kernel/time/posix-timers.c
-@@ -805,6 +805,17 @@ static int common_hrtimer_try_to_cancel(
- return hrtimer_try_to_cancel(&timr->it.real.timer);
- }
-
-+static void timer_wait_for_callback(const struct k_clock *kc, struct k_itimer *timer)
-+{
-+ if (kc->timer_arm == common_hrtimer_arm)
-+ hrtimer_grab_expiry_lock(&timer->it.real.timer);
-+ else if (kc == &alarm_clock)
-+ hrtimer_grab_expiry_lock(&timer->it.alarm.alarmtimer.timer);
-+ else
-+ /* posix-cpu-timers */
-+ cpu_timers_grab_expiry_lock(timer);
-+}
-+
- /* Set a POSIX.1b interval timer. */
- int common_timer_set(struct k_itimer *timr, int flags,
- struct itimerspec64 *new_setting,
-@@ -870,11 +881,15 @@ static int do_timer_settime(timer_t time
- else
- error = kc->timer_set(timr, flags, new_spec64, old_spec64);
-
-- unlock_timer(timr, flag);
- if (error == TIMER_RETRY) {
-+ rcu_read_lock();
-+ unlock_timer(timr, flag);
-+ timer_wait_for_callback(kc, timr);
-+ rcu_read_unlock();
- old_spec64 = NULL; // We already got the old time...
- goto retry;
- }
-+ unlock_timer(timr, flag);
-
- return error;
- }
-@@ -936,13 +951,21 @@ int common_timer_del(struct k_itimer *ti
- return 0;
- }
-
--static inline int timer_delete_hook(struct k_itimer *timer)
-+static int timer_delete_hook(struct k_itimer *timer)
- {
- const struct k_clock *kc = timer->kclock;
-+ int ret;
-
- if (WARN_ON_ONCE(!kc || !kc->timer_del))
- return -EINVAL;
-- return kc->timer_del(timer);
-+ ret = kc->timer_del(timer);
-+ if (ret == TIMER_RETRY) {
-+ rcu_read_lock();
-+ spin_unlock_irq(&timer->it_lock);
-+ timer_wait_for_callback(kc, timer);
-+ rcu_read_unlock();
-+ }
-+ return ret;
- }
-
- /* Delete a POSIX.1b interval timer. */
-@@ -956,10 +979,8 @@ SYSCALL_DEFINE1(timer_delete, timer_t, t
- if (!timer)
- return -EINVAL;
-
-- if (timer_delete_hook(timer) == TIMER_RETRY) {
-- unlock_timer(timer, flags);
-+ if (timer_delete_hook(timer) == TIMER_RETRY)
- goto retry_delete;
-- }
-
- spin_lock(&current->sighand->siglock);
- list_del(&timer->list);
-@@ -985,10 +1006,9 @@ static void itimer_delete(struct k_itime
- retry_delete:
- spin_lock_irqsave(&timer->it_lock, flags);
-
-- if (timer_delete_hook(timer) == TIMER_RETRY) {
-- unlock_timer(timer, flags);
-+ if (timer_delete_hook(timer) == TIMER_RETRY)
- goto retry_delete;
-- }
-+
- list_del(&timer->list);
- /*
- * This keeps any tasks waiting on the spin lock from thinking
---- a/kernel/time/posix-timers.h
-+++ b/kernel/time/posix-timers.h
-@@ -32,6 +32,8 @@ extern const struct k_clock clock_proces
- extern const struct k_clock clock_thread;
- extern const struct k_clock alarm_clock;
-
-+extern void cpu_timers_grab_expiry_lock(struct k_itimer *timer);
-+
- int posix_timer_event(struct k_itimer *timr, int si_private);
+@@ -1553,6 +1578,7 @@ const struct k_clock clock_posix_cpu = {
+ .timer_del = posix_cpu_timer_del,
+ .timer_get = posix_cpu_timer_get,
+ .timer_rearm = posix_cpu_timer_rearm,
++ .timer_wait_running = posix_cpu_wait_running,
+ };
- void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting);
+ const struct k_clock clock_process = {
diff --git a/debian/patches-rt/posix-timers-move-rcu-out-of-union.patch b/debian/patches-rt/posix-timers-move-rcu-out-of-union.patch
deleted file mode 100644
index a9c533dfe298..000000000000
--- a/debian/patches-rt/posix-timers-move-rcu-out-of-union.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Mon, 27 May 2019 16:54:05 +0200
-Subject: [PATCH] posix-timers: move rcu out of union
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-On RT the timer can be preempted while running and therefore we wait
-with timer_wait_for_callback() for the timer to complete (instead of
-busy looping). The RCU-readlock is held to ensure that this posix timer
-is not removed while we wait on it.
-If the timer is removed then it invokes call_rcu() with a pointer that
-is shared with the hrtimer because it is part of the same union.
-In order to avoid any possible side effects I am moving the rcu pointer
-out of the union.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/posix-timers.h | 2 +-
- kernel/time/posix-timers.c | 4 ++--
- 2 files changed, 3 insertions(+), 3 deletions(-)
-
---- a/include/linux/posix-timers.h
-+++ b/include/linux/posix-timers.h
-@@ -114,8 +114,8 @@ struct k_itimer {
- struct {
- struct alarm alarmtimer;
- } alarm;
-- struct rcu_head rcu;
- } it;
-+ struct rcu_head rcu;
- };
-
- void run_posix_cpu_timers(struct task_struct *task);
---- a/kernel/time/posix-timers.c
-+++ b/kernel/time/posix-timers.c
-@@ -442,7 +442,7 @@ static struct k_itimer * alloc_posix_tim
-
- static void k_itimer_rcu_free(struct rcu_head *head)
- {
-- struct k_itimer *tmr = container_of(head, struct k_itimer, it.rcu);
-+ struct k_itimer *tmr = container_of(head, struct k_itimer, rcu);
-
- kmem_cache_free(posix_timers_cache, tmr);
- }
-@@ -459,7 +459,7 @@ static void release_posix_timer(struct k
- }
- put_pid(tmr->it_pid);
- sigqueue_free(tmr->sigq);
-- call_rcu(&tmr->it.rcu, k_itimer_rcu_free);
-+ call_rcu(&tmr->rcu, k_itimer_rcu_free);
- }
-
- static int common_timer_create(struct k_itimer *new_timer)
diff --git a/debian/patches-rt/posix-timers-thread-posix-cpu-timers-on-rt.patch b/debian/patches-rt/posix-timers-thread-posix-cpu-timers-on-rt.patch
index 84581ac96276..e7abb5e6aed8 100644
--- a/debian/patches-rt/posix-timers-thread-posix-cpu-timers-on-rt.patch
+++ b/debian/patches-rt/posix-timers-thread-posix-cpu-timers-on-rt.patch
@@ -1,7 +1,7 @@
From: John Stultz <johnstul@us.ibm.com>
Date: Fri, 3 Jul 2009 08:29:58 -0500
Subject: posix-timers: Thread posix-cpu-timers on -rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
posix-cpu-timer code takes non -rt safe locks in hard irq
context. Move it to a thread.
@@ -12,59 +12,39 @@ Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- include/linux/sched.h | 3
- init/init_task.c | 7 +
- kernel/fork.c | 3
- kernel/time/posix-cpu-timers.c | 154 ++++++++++++++++++++++++++++++++++++++++-
- 4 files changed, 164 insertions(+), 3 deletions(-)
+ include/linux/posix-timers.h | 10 ++
+ kernel/time/posix-cpu-timers.c | 175 ++++++++++++++++++++++++++++++++++++++---
+ 2 files changed, 174 insertions(+), 11 deletions(-)
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -826,6 +826,9 @@ struct task_struct {
- #ifdef CONFIG_POSIX_TIMERS
- struct task_cputime cputime_expires;
- struct list_head cpu_timers[3];
-+#ifdef CONFIG_PREEMPT_RT_BASE
+--- a/include/linux/posix-timers.h
++++ b/include/linux/posix-timers.h
+@@ -123,6 +123,9 @@ struct posix_cputimers {
+ struct posix_cputimer_base bases[CPUCLOCK_MAX];
+ unsigned int timers_active;
+ unsigned int expiry_active;
++#ifdef CONFIG_PREEMPT_RT
+ struct task_struct *posix_timer_list;
+#endif
- #endif
-
- /* Process credentials: */
---- a/init/init_task.c
-+++ b/init/init_task.c
-@@ -51,6 +51,12 @@ static struct sighand_struct init_sighan
- .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(init_sighand.signalfd_wqh),
};
-+#if defined(CONFIG_POSIX_TIMERS) && defined(CONFIG_PREEMPT_RT_BASE)
-+# define INIT_TIMER_LIST .posix_timer_list = NULL,
+ static inline void posix_cputimers_init(struct posix_cputimers *pct)
+@@ -152,9 +155,16 @@ static inline void posix_cputimers_rt_wa
+ INIT_CPU_TIMERBASE(b[2]), \
+ }
+
++#ifdef CONFIG_PREEMPT_RT
++# define INIT_TIMER_LIST .posix_timer_list = NULL,
+#else
+# define INIT_TIMER_LIST
+#endif
+
- /*
- * Set up the first task table, touch at your own risk!. Base=0,
- * limit=0x1fffff (=2MB)
-@@ -120,6 +126,7 @@ struct task_struct init_task
- INIT_CPU_TIMERS(init_task)
- .pi_lock = __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
- .timer_slack_ns = 50000, /* 50 usec default slack */
-+ INIT_TIMER_LIST
- .thread_pid = &init_struct_pid,
- .thread_group = LIST_HEAD_INIT(init_task.thread_group),
- .thread_node = LIST_HEAD_INIT(init_signals.thread_head),
---- a/kernel/fork.c
-+++ b/kernel/fork.c
-@@ -1647,6 +1647,9 @@ static void rt_mutex_init_task(struct ta
- */
- static void posix_cpu_timers_init(struct task_struct *tsk)
- {
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ tsk->posix_timer_list = NULL;
-+#endif
- tsk->cputime_expires.prof_exp = 0;
- tsk->cputime_expires.virt_exp = 0;
- tsk->cputime_expires.sched_exp = 0;
+ #define INIT_CPU_TIMERS(s) \
+ .posix_cputimers = { \
+ .bases = INIT_CPU_TIMERBASES(s.posix_cputimers.bases), \
++ INIT_TIMER_LIST \
+ },
+ #else
+ struct posix_cputimers { };
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -3,8 +3,10 @@
@@ -86,28 +66,88 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include "posix-timers.h"
-@@ -1147,15 +1150,13 @@ void cpu_timers_grab_expiry_lock(struct
+@@ -27,6 +30,9 @@ void posix_cputimers_group_init(struct p
+ pct->bases[CPUCLOCK_PROF].nextevt = cpu_limit * NSEC_PER_SEC;
+ pct->timers_active = true;
+ }
++#ifdef CONFIG_PREEMPT_RT
++ pct->posix_timer_list = NULL;
++#endif
+ }
+
+ /*
+@@ -804,7 +810,8 @@ static inline void check_dl_overrun(stru
+ }
+ }
+
+-static bool check_rlimit(u64 time, u64 limit, int signo, bool rt, bool hard)
++static bool check_rlimit(struct task_struct *tsk, u64 time, u64 limit,
++ int signo, bool rt, bool hard)
+ {
+ if (time < limit)
+ return false;
+@@ -812,9 +819,9 @@ static bool check_rlimit(u64 time, u64 l
+ if (print_fatal_signals) {
+ pr_info("%s Watchdog Timeout (%s): %s[%d]\n",
+ rt ? "RT" : "CPU", hard ? "hard" : "soft",
+- current->comm, task_pid_nr(current));
++ tsk->comm, task_pid_nr(tsk));
+ }
+- __group_send_sig_info(signo, SEND_SIG_PRIV, current);
++ __group_send_sig_info(signo, SEND_SIG_PRIV, tsk);
+ return true;
+ }
+
+@@ -850,11 +857,11 @@ static void check_thread_timers(struct t
+
+ /* At the hard limit, send SIGKILL. No further action. */
+ if (hard != RLIM_INFINITY &&
+- check_rlimit(rttime, hard, SIGKILL, true, true))
++ check_rlimit(tsk, rttime, hard, SIGKILL, true, true))
+ return;
+
+ /* At the soft limit, send a SIGXCPU every second */
+- if (check_rlimit(rttime, soft, SIGXCPU, true, false)) {
++ if (check_rlimit(tsk, rttime, soft, SIGXCPU, true, false)) {
+ soft += USEC_PER_SEC;
+ tsk->signal->rlim[RLIMIT_RTTIME].rlim_cur = soft;
+ }
+@@ -949,11 +956,11 @@ static void check_process_timers(struct
+
+ /* At the hard limit, send SIGKILL. No further action. */
+ if (hard != RLIM_INFINITY &&
+- check_rlimit(ptime, hardns, SIGKILL, false, true))
++ check_rlimit(tsk, ptime, hardns, SIGKILL, false, true))
+ return;
+
+ /* At the soft limit, send a SIGXCPU every second */
+- if (check_rlimit(ptime, softns, SIGXCPU, false, false)) {
++ if (check_rlimit(tsk, ptime, softns, SIGXCPU, false, false)) {
+ sig->rlim[RLIMIT_CPU].rlim_cur = soft + 1;
+ softns += NSEC_PER_SEC;
+ }
+@@ -1110,15 +1117,12 @@ static inline bool fastpath_timer_check(
* already updated our counts. We need to check if any timers fire now.
* Interrupts are disabled.
*/
--void run_posix_cpu_timers(struct task_struct *tsk)
+-void run_posix_cpu_timers(void)
+static void __run_posix_cpu_timers(struct task_struct *tsk)
{
- LIST_HEAD(firing);
+- struct task_struct *tsk = current;
struct k_itimer *timer, *next;
unsigned long flags;
- spinlock_t *expiry_lock;
+ LIST_HEAD(firing);
- lockdep_assert_irqs_disabled();
-
/*
* The fast path checks that there are no expired thread or thread
* group timers. If that's so, just return.
-@@ -1215,6 +1216,153 @@ void run_posix_cpu_timers(struct task_st
- spin_unlock(expiry_lock);
+@@ -1171,6 +1175,155 @@ void run_posix_cpu_timers(void)
+ }
}
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+#include <linux/kthread.h>
+#include <linux/cpu.h>
+DEFINE_PER_CPU(struct task_struct *, posix_timer_task);
@@ -134,13 +174,13 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ /* Process task list */
+ while (1) {
+ /* save next */
-+ next = tsk->posix_timer_list;
++ next = tsk->posix_cputimers.posix_timer_list;
+
+ /* run the task timers, clear its ptr and
+ * unreference it
+ */
+ __run_posix_cpu_timers(tsk);
-+ tsk->posix_timer_list = NULL;
++ tsk->posix_cputimers.posix_timer_list = NULL;
+ put_task_struct(tsk);
+
+ /* check if this is the last on the list */
@@ -156,18 +196,19 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ if (unlikely(tsk->exit_state))
+ return 0;
+
-+ if (!task_cputime_zero(&tsk->cputime_expires))
-+ return 1;
++ if (!expiry_cache_is_inactive(&tsk->posix_cputimers))
++ return 1;
+
-+ if (!task_cputime_zero(&tsk->signal->cputime_expires))
-+ return 1;
++ if (!expiry_cache_is_inactive(&tsk->signal->posix_cputimers))
++ return 1;
+
+ return 0;
+}
+
-+void run_posix_cpu_timers(struct task_struct *tsk)
++void run_posix_cpu_timers(void)
+{
+ unsigned int cpu = smp_processor_id();
++ struct task_struct *tsk = current;
+ struct task_struct *tasklist;
+
+ BUG_ON(!irqs_disabled());
@@ -179,16 +220,16 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ tasklist = per_cpu(posix_timer_tasklist, cpu);
+
+ /* check to see if we're already queued */
-+ if (!tsk->posix_timer_list && __fastpath_timer_check(tsk)) {
++ if (!tsk->posix_cputimers.posix_timer_list && __fastpath_timer_check(tsk)) {
+ get_task_struct(tsk);
+ if (tasklist) {
-+ tsk->posix_timer_list = tasklist;
++ tsk->posix_cputimers.posix_timer_list = tasklist;
+ } else {
+ /*
+ * The list is terminated by a self-pointing
+ * task_struct
+ */
-+ tsk->posix_timer_list = tsk;
++ tsk->posix_cputimers.posix_timer_list = tsk;
+ }
+ per_cpu(posix_timer_tasklist, cpu) = tsk;
+
@@ -246,13 +287,14 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ return 0;
+}
+early_initcall(posix_cpu_thread_init);
-+#else /* CONFIG_PREEMPT_RT_BASE */
-+void run_posix_cpu_timers(struct task_struct *tsk)
++
++#else /* CONFIG_PREEMPT_RT */
++void run_posix_cpu_timers(void)
+{
+ lockdep_assert_irqs_disabled();
-+ __run_posix_cpu_timers(tsk);
++ __run_posix_cpu_timers(current);
+}
-+#endif /* CONFIG_PREEMPT_RT_BASE */
++#endif /* CONFIG_PREEMPT_RT */
+
/*
* Set one of the process-wide special case CPU timers or RLIMIT_CPU.
diff --git a/debian/patches-rt/power-disable-highmem-on-rt.patch b/debian/patches-rt/power-disable-highmem-on-rt.patch
index a8f39ece80a8..ab432f041578 100644
--- a/debian/patches-rt/power-disable-highmem-on-rt.patch
+++ b/debian/patches-rt/power-disable-highmem-on-rt.patch
@@ -1,7 +1,7 @@
Subject: powerpc: Disable highmem on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 18 Jul 2011 17:08:34 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The current highmem handling on -RT is not compatible and needs fixups.
@@ -12,12 +12,12 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
-@@ -387,7 +387,7 @@ menu "Kernel options"
+@@ -399,7 +399,7 @@ menu "Kernel options"
config HIGHMEM
bool "High memory support"
- depends on PPC32
-+ depends on PPC32 && !PREEMPT_RT_FULL
++ depends on PPC32 && !PREEMPT_RT
source "kernel/Kconfig.hz"
diff --git a/debian/patches-rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch b/debian/patches-rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch
index 38d55f4f764b..c98a643e8698 100644
--- a/debian/patches-rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch
+++ b/debian/patches-rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch
@@ -1,7 +1,7 @@
From: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Date: Fri, 24 Apr 2015 15:53:13 +0000
-Subject: powerpc/kvm: Disable in-kernel MPIC emulation for PREEMPT_RT_FULL
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: powerpc/kvm: Disable in-kernel MPIC emulation for PREEMPT_RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
While converting the openpic emulation code to use a raw_spinlock_t enables
guests to run on RT, there's still a performance issue. For interrupts sent in
@@ -28,11 +28,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
-@@ -177,6 +177,7 @@ config KVM_E500MC
+@@ -178,6 +178,7 @@ config KVM_E500MC
config KVM_MPIC
bool "KVM in-kernel MPIC emulation"
depends on KVM && E500
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
select HAVE_KVM_IRQCHIP
select HAVE_KVM_IRQFD
select HAVE_KVM_IRQ_ROUTING
diff --git a/debian/patches-rt/powerpc-preempt-lazy-support.patch b/debian/patches-rt/powerpc-preempt-lazy-support.patch
index 774244975ea1..11aab2576925 100644
--- a/debian/patches-rt/powerpc-preempt-lazy-support.patch
+++ b/debian/patches-rt/powerpc-preempt-lazy-support.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 1 Nov 2012 10:14:11 +0100
Subject: powerpc: Add support for lazy preemption
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Implement the powerpc pieces for lazy preempt.
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
-@@ -214,6 +214,7 @@ config PPC
+@@ -221,6 +221,7 @@ config PPC
select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
@@ -134,22 +134,22 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
addi r12,r2,TI_FLAGS
3: lwarx r8,0,r12
andc r8,r8,r11
-@@ -890,7 +892,14 @@ user_exc_return: /* r10 contains MSR_KE
+@@ -903,7 +905,14 @@ user_exc_return: /* r10 contains MSR_KE
cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
bne restore_kuap
andi. r8,r8,_TIF_NEED_RESCHED
+ bne+ 1f
-+ lwz r0,TI_PREEMPT_LAZY(r9)
++ lwz r0,TI_PREEMPT_LAZY(r2)
+ cmpwi 0,r0,0 /* if non-zero, just restore regs and return */
+ bne restore_kuap
-+ lwz r0,TI_FLAGS(r9)
++ lwz r0,TI_FLAGS(r2)
+ andi. r0,r0,_TIF_NEED_RESCHED_LAZY
beq+ restore_kuap
+1:
lwz r3,_MSR(r1)
andi. r0,r3,MSR_EE /* interrupts off? */
beq restore_kuap /* don't schedule if so */
-@@ -1211,7 +1220,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRE
+@@ -1224,7 +1233,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRE
#endif /* !(CONFIG_4xx || CONFIG_BOOKE) */
do_work: /* r10 contains MSR_KERNEL here */
@@ -158,7 +158,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
beq do_user_signal
do_resched: /* r10 contains MSR_KERNEL here */
-@@ -1232,7 +1241,7 @@ do_resched: /* r10 contains MSR_KERNEL
+@@ -1245,7 +1254,7 @@ do_resched: /* r10 contains MSR_KERNEL
SYNC
MTMSRD(r10) /* disable interrupts */
lwz r9,TI_FLAGS(r2)
@@ -169,7 +169,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
beq restore_user
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
-@@ -249,7 +249,9 @@ system_call: /* label this so stack tr
+@@ -240,7 +240,9 @@ system_call: /* label this so stack tr
ld r9,TI_FLAGS(r12)
li r11,-MAX_ERRNO
@@ -180,7 +180,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
bne- .Lsyscall_exit_work
andi. r0,r8,MSR_FP
-@@ -372,25 +374,25 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
+@@ -363,25 +365,25 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
/* If TIF_RESTOREALL is set, don't scribble on either r3 or ccr.
If TIF_NOERROR is set, just save r3 as it is. */
@@ -210,7 +210,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
addi r12,r12,TI_FLAGS
3: ldarx r10,0,r12
andc r10,r10,r11
-@@ -784,7 +786,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
+@@ -786,7 +788,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
bl restore_math
b restore
#endif
@@ -219,9 +219,9 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
beq 2f
bl restore_interrupts
SCHEDULE_USER
-@@ -846,10 +848,18 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
+@@ -848,10 +850,18 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
/* Check if we need to preempt */
+ lwz r8,TI_PREEMPT(r9)
+ cmpwi 0,r8,0 /* if non-zero, just restore regs and return */
diff --git a/debian/patches-rt/powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch b/debian/patches-rt/powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch
index 6bc9a44f007a..6c18bb8e9c92 100644
--- a/debian/patches-rt/powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch
+++ b/debian/patches-rt/powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 26 Mar 2019 18:31:54 +0100
Subject: [PATCH] powerpc/pseries/iommu: Use a locallock instead
local_irq_save()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The locallock protects the per-CPU variable tce_page. The function
attempts to allocate memory while tce_page is protected (by disabling
@@ -26,7 +26,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <asm/io.h>
#include <asm/prom.h>
#include <asm/rtas.h>
-@@ -177,6 +178,7 @@ static int tce_build_pSeriesLP(struct io
+@@ -178,6 +179,7 @@ static int tce_build_pSeriesLP(struct io
}
static DEFINE_PER_CPU(__be64 *, tce_page);
@@ -34,7 +34,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
long npages, unsigned long uaddr,
-@@ -197,7 +199,8 @@ static int tce_buildmulti_pSeriesLP(stru
+@@ -198,7 +200,8 @@ static int tce_buildmulti_pSeriesLP(stru
direction, attrs);
}
@@ -44,7 +44,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
tcep = __this_cpu_read(tce_page);
-@@ -208,7 +211,7 @@ static int tce_buildmulti_pSeriesLP(stru
+@@ -209,7 +212,7 @@ static int tce_buildmulti_pSeriesLP(stru
tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
/* If allocation fails, fall back to the loop implementation */
if (!tcep) {
@@ -53,7 +53,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
direction, attrs);
}
-@@ -242,7 +245,7 @@ static int tce_buildmulti_pSeriesLP(stru
+@@ -243,7 +246,7 @@ static int tce_buildmulti_pSeriesLP(stru
tcenum += limit;
} while (npages > 0 && !rc);
@@ -62,7 +62,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) {
ret = (int)rc;
-@@ -400,13 +403,14 @@ static int tce_setrange_multi_pSeriesLP(
+@@ -401,13 +404,14 @@ static int tce_setrange_multi_pSeriesLP(
u64 rc = 0;
long l, limit;
@@ -79,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return -ENOMEM;
}
__this_cpu_write(tce_page, tcep);
-@@ -452,7 +456,7 @@ static int tce_setrange_multi_pSeriesLP(
+@@ -453,7 +457,7 @@ static int tce_setrange_multi_pSeriesLP(
/* error cleanup: caller will clear whole range */
diff --git a/debian/patches-rt/powerpc-stackprotector-work-around-stack-guard-init-.patch b/debian/patches-rt/powerpc-stackprotector-work-around-stack-guard-init-.patch
index f40eff5ffeb4..7ef5d8128a40 100644
--- a/debian/patches-rt/powerpc-stackprotector-work-around-stack-guard-init-.patch
+++ b/debian/patches-rt/powerpc-stackprotector-work-around-stack-guard-init-.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 26 Mar 2019 18:31:29 +0100
Subject: [PATCH ] powerpc/stackprotector: work around stack-guard init from
atomic
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This is invoked from the secondary CPU in atomic context. On x86 we use
tsc instead. On Power we XOR it against mftb() so lets use stack address
@@ -20,7 +20,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned long canary;
/* Try to get a semi random initial value. */
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ canary = (unsigned long)&canary;
+#else
canary = get_random_canary();
diff --git a/debian/patches-rt/preempt-lazy-support.patch b/debian/patches-rt/preempt-lazy-support.patch
index 086b4ceeaa3e..97aeed2350c0 100644
--- a/debian/patches-rt/preempt-lazy-support.patch
+++ b/debian/patches-rt/preempt-lazy-support.patch
@@ -1,7 +1,7 @@
Subject: sched: Add support for lazy preemption
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 26 Oct 2012 18:50:54 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
It has become an obsession to mitigate the determinism vs. throughput
loss of RT. Looking at the mainline semantics of preemption points
@@ -58,15 +58,14 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/thread_info.h | 12 +++++-
include/linux/trace_events.h | 1
kernel/Kconfig.preempt | 6 +++
- kernel/cpu.c | 2 +
- kernel/sched/core.c | 83 +++++++++++++++++++++++++++++++++++++++++--
+ kernel/sched/core.c | 82 +++++++++++++++++++++++++++++++++++++++++--
kernel/sched/fair.c | 16 ++++----
kernel/sched/features.h | 3 +
kernel/sched/sched.h | 9 ++++
kernel/trace/trace.c | 35 ++++++++++--------
kernel/trace/trace.h | 2 +
kernel/trace/trace_output.c | 14 ++++++-
- 13 files changed, 227 insertions(+), 29 deletions(-)
+ 12 files changed, 224 insertions(+), 29 deletions(-)
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -115,7 +114,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ preempt_check_resched(); \
+} while (0)
+
- #else /* !CONFIG_PREEMPT */
+ #else /* !CONFIG_PREEMPTION */
#define preempt_enable() \
do { \
@@ -254,6 +281,12 @@ do { \
@@ -142,7 +141,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -1744,6 +1744,44 @@ static inline int test_tsk_need_resched(
+@@ -1791,6 +1791,44 @@ static inline int test_tsk_need_resched(
return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
}
@@ -220,40 +219,21 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#define TRACE_EVENT_TYPE_MAX \
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
-@@ -7,6 +7,12 @@ config PREEMPT_RT_BASE
- bool
- select PREEMPT
+@@ -1,5 +1,11 @@
+ # SPDX-License-Identifier: GPL-2.0-only
+config HAVE_PREEMPT_LAZY
+ bool
+
+config PREEMPT_LAZY
-+ def_bool y if HAVE_PREEMPT_LAZY && PREEMPT_RT_FULL
++ def_bool y if HAVE_PREEMPT_LAZY && PREEMPT_RT
+
choice
prompt "Preemption Model"
default PREEMPT_NONE
---- a/kernel/cpu.c
-+++ b/kernel/cpu.c
-@@ -305,6 +305,7 @@ void pin_current_cpu(void)
- return;
- }
- cpu = smp_processor_id();
-+ preempt_lazy_enable();
- preempt_enable();
-
- sleeping_lock_inc();
-@@ -312,6 +313,7 @@ void pin_current_cpu(void)
- sleeping_lock_dec();
-
- preempt_disable();
-+ preempt_lazy_disable();
- if (cpu != smp_processor_id()) {
- __read_rt_unlock(cpuhp_pin);
- goto again;
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -544,6 +544,48 @@ void resched_curr(struct rq *rq)
+@@ -555,6 +555,48 @@ void resched_curr(struct rq *rq)
trace_sched_wake_idle_without_ipi(cpu);
}
@@ -302,7 +282,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void resched_cpu(int cpu)
{
struct rq *rq = cpu_rq(cpu);
-@@ -2449,6 +2491,9 @@ int sched_fork(unsigned long clone_flags
+@@ -3002,6 +3044,9 @@ int sched_fork(unsigned long clone_flags
p->on_cpu = 0;
#endif
init_task_preempt_count(p);
@@ -312,7 +292,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#ifdef CONFIG_SMP
plist_node_init(&p->pushable_tasks, MAX_PRIO);
RB_CLEAR_NODE(&p->pushable_dl_tasks);
-@@ -3507,6 +3552,7 @@ static void __sched notrace __schedule(b
+@@ -4139,6 +4184,7 @@ static void __sched notrace __schedule(b
next = pick_next_task(rq, prev, &rf);
clear_tsk_need_resched(prev);
@@ -320,7 +300,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
clear_preempt_need_resched();
if (likely(prev != next)) {
-@@ -3690,6 +3736,30 @@ static void __sched notrace preempt_sche
+@@ -4326,6 +4372,30 @@ static void __sched notrace preempt_sche
} while (need_resched());
}
@@ -348,10 +328,10 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+
+#endif
+
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
/*
- * this is the entry point to schedule() from in-kernel preemption
-@@ -3704,7 +3774,8 @@ asmlinkage __visible void __sched notrac
+ * This is the entry point to schedule() from in-kernel preemption
+@@ -4339,7 +4409,8 @@ asmlinkage __visible void __sched notrac
*/
if (likely(!preemptible()))
return;
@@ -361,7 +341,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
preempt_schedule_common();
}
NOKPROBE_SYMBOL(preempt_schedule);
-@@ -3731,6 +3802,9 @@ asmlinkage __visible void __sched notrac
+@@ -4366,6 +4437,9 @@ asmlinkage __visible void __sched notrac
if (likely(!preemptible()))
return;
@@ -371,7 +351,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
do {
/*
* Because the function tracer can trace preempt_count_sub()
-@@ -5496,7 +5570,9 @@ void init_idle(struct task_struct *idle,
+@@ -6156,7 +6230,9 @@ void init_idle(struct task_struct *idle,
/* Set the preempt count _outside_ the spinlocks! */
init_idle_preempt_count(idle, cpu);
@@ -382,33 +362,25 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* The idle tasks have their own, simple scheduling class:
*/
-@@ -7250,6 +7326,7 @@ void migrate_disable(void)
+@@ -8093,6 +8169,7 @@ void migrate_disable(void)
+
+ if (++current->migrate_disable == 1) {
+ this_rq()->nr_pinned++;
++ preempt_lazy_disable();
+ #ifdef CONFIG_SCHED_DEBUG
+ WARN_ON_ONCE(current->pinned_on_cpu >= 0);
+ current->pinned_on_cpu = smp_processor_id();
+@@ -8169,6 +8246,7 @@ void migrate_enable(void)
}
- preempt_disable();
-+ preempt_lazy_disable();
- pin_current_cpu();
-
- migrate_disable_update_cpus_allowed(p);
-@@ -7317,6 +7394,7 @@ void migrate_enable(void)
- arg.dest_cpu = dest_cpu;
-
- unpin_current_cpu();
-+ preempt_lazy_enable();
- preempt_enable();
-
- sleeping_lock_inc();
-@@ -7326,6 +7404,7 @@ void migrate_enable(void)
- }
- }
- unpin_current_cpu();
+ out:
+ preempt_lazy_enable();
preempt_enable();
}
EXPORT_SYMBOL(migrate_enable);
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
-@@ -4104,7 +4104,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq
+@@ -4122,7 +4122,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq
ideal_runtime = sched_slice(cfs_rq, curr);
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
if (delta_exec > ideal_runtime) {
@@ -417,7 +389,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* The current task ran long enough, ensure it doesn't get
* re-elected due to buddy favours.
-@@ -4128,7 +4128,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq
+@@ -4146,7 +4146,7 @@ check_preempt_tick(struct cfs_rq *cfs_rq
return;
if (delta > ideal_runtime)
@@ -426,7 +398,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
static void
-@@ -4270,7 +4270,7 @@ entity_tick(struct cfs_rq *cfs_rq, struc
+@@ -4289,7 +4289,7 @@ entity_tick(struct cfs_rq *cfs_rq, struc
* validating it and just reschedule.
*/
if (queued) {
@@ -435,7 +407,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return;
}
/*
-@@ -4456,7 +4456,7 @@ static void __account_cfs_rq_runtime(str
+@@ -4414,7 +4414,7 @@ static void __account_cfs_rq_runtime(str
* hierarchy can be throttled
*/
if (!assign_cfs_rq_runtime(cfs_rq) && likely(cfs_rq->curr))
@@ -444,7 +416,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
static __always_inline
-@@ -5169,7 +5169,7 @@ static void hrtick_start_fair(struct rq
+@@ -5127,7 +5127,7 @@ static void hrtick_start_fair(struct rq
if (delta < 0) {
if (rq->curr == p)
@@ -453,7 +425,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return;
}
hrtick_start(rq, delta);
-@@ -7009,7 +7009,7 @@ static void check_preempt_wakeup(struct
+@@ -6729,7 +6729,7 @@ static void check_preempt_wakeup(struct
return;
preempt:
@@ -462,7 +434,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* Only set the backward buddy when the current task is still
* on the rq. This can happen when a wakeup gets interleaved
-@@ -10281,7 +10281,7 @@ static void task_fork_fair(struct task_s
+@@ -9984,7 +9984,7 @@ static void task_fork_fair(struct task_s
* 'current' within the tree based on its new key value.
*/
swap(curr->vruntime, se->vruntime);
@@ -471,7 +443,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
se->vruntime -= cfs_rq->min_vruntime;
-@@ -10305,7 +10305,7 @@ prio_changed_fair(struct rq *rq, struct
+@@ -10008,7 +10008,7 @@ prio_changed_fair(struct rq *rq, struct
*/
if (rq->curr == p) {
if (p->prio > oldprio)
@@ -482,9 +454,9 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
-@@ -48,6 +48,9 @@ SCHED_FEAT(NONTASK_CAPACITY, true)
+@@ -47,6 +47,9 @@ SCHED_FEAT(NONTASK_CAPACITY, true)
- #ifdef CONFIG_PREEMPT_RT_FULL
+ #ifdef CONFIG_PREEMPT_RT
SCHED_FEAT(TTWU_QUEUE, false)
+# ifdef CONFIG_PREEMPT_LAZY
+SCHED_FEAT(PREEMPT_LAZY, true)
@@ -494,7 +466,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
-@@ -1786,6 +1786,15 @@ extern void reweight_task(struct task_st
+@@ -1876,6 +1876,15 @@ extern void reweight_task(struct task_st
extern void resched_curr(struct rq *rq);
extern void resched_cpu(int cpu);
@@ -512,15 +484,15 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
-@@ -2318,6 +2318,7 @@ tracing_generic_entry_update(struct trac
+@@ -2335,6 +2335,7 @@ tracing_generic_entry_update(struct trac
struct task_struct *tsk = current;
entry->preempt_count = pc & 0xff;
+ entry->preempt_lazy_count = preempt_lazy_count();
entry->pid = (tsk) ? tsk->pid : 0;
+ entry->type = type;
entry->flags =
- #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
-@@ -2328,7 +2329,8 @@ tracing_generic_entry_update(struct trac
+@@ -2346,7 +2347,8 @@ tracing_generic_entry_update(struct trac
((pc & NMI_MASK ) ? TRACE_FLAG_NMI : 0) |
((pc & HARDIRQ_MASK) ? TRACE_FLAG_HARDIRQ : 0) |
((pc & SOFTIRQ_OFFSET) ? TRACE_FLAG_SOFTIRQ : 0) |
@@ -530,7 +502,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
(test_preempt_need_resched() ? TRACE_FLAG_PREEMPT_RESCHED : 0);
entry->migrate_disable = (tsk) ? __migrate_disabled(tsk) & 0xFF : 0;
-@@ -3555,15 +3557,17 @@ unsigned long trace_total_entries(struct
+@@ -3575,15 +3577,17 @@ unsigned long trace_total_entries(struct
static void print_lat_help_header(struct seq_file *m)
{
@@ -543,21 +515,21 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
- "# ||||| / delay \n"
- "# cmd pid |||||| time | caller \n"
- "# \\ / ||||| \\ | / \n");
-+ seq_puts(m, "# _--------=> CPU# \n"
-+ "# / _-------=> irqs-off \n"
-+ "# | / _------=> need-resched \n"
-+ "# || / _-----=> need-resched_lazy \n"
-+ "# ||| / _----=> hardirq/softirq \n"
-+ "# |||| / _---=> preempt-depth \n"
-+ "# ||||| / _--=> preempt-lazy-depth\n"
-+ "# |||||| / _-=> migrate-disable \n"
-+ "# ||||||| / delay \n"
-+ "# cmd pid |||||||| time | caller \n"
-+ "# \\ / |||||||| \\ | / \n");
++ seq_puts(m, "# _--------=> CPU# \n"
++ "# / _-------=> irqs-off \n"
++ "# | / _------=> need-resched \n"
++ "# || / _-----=> need-resched_lazy \n"
++ "# ||| / _----=> hardirq/softirq \n"
++ "# |||| / _---=> preempt-depth \n"
++ "# ||||| / _--=> preempt-lazy-depth\n"
++ "# |||||| / _-=> migrate-disable \n"
++ "# ||||||| / delay \n"
++ "# cmd pid |||||||| time | caller \n"
++ "# \\ / |||||||| \\ | / \n");
}
static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
-@@ -3599,11 +3603,12 @@ static void print_func_help_header_irq(s
+@@ -3619,11 +3623,12 @@ static void print_func_help_header_irq(s
seq_printf(m, "# %.*s _-----=> irqs-off\n", prec, space);
seq_printf(m, "# %.*s / _----=> need-resched\n", prec, space);
diff --git a/debian/patches-rt/preempt-nort-rt-variants.patch b/debian/patches-rt/preempt-nort-rt-variants.patch
index d0eaf7bbc395..66cee71ace1a 100644
--- a/debian/patches-rt/preempt-nort-rt-variants.patch
+++ b/debian/patches-rt/preempt-nort-rt-variants.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 24 Jul 2009 12:38:56 +0200
Subject: preempt: Provide preempt_*_(no)rt variants
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
RT needs a few preempt_disable/enable points which are not necessary
otherwise. Implement variants to avoid #ifdeffery.
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
} while (0)
-#define preempt_enable_no_resched() sched_preempt_enable_no_resched()
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+# define preempt_enable_no_resched() sched_preempt_enable_no_resched()
+#else
+# define preempt_enable_no_resched() preempt_enable()
@@ -27,11 +27,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#define preemptible() (preempt_count() == 0 && !irqs_disabled())
-@@ -304,6 +308,18 @@ do { \
+@@ -281,6 +285,18 @@ do { \
set_preempt_need_resched(); \
} while (0)
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# define preempt_disable_rt() preempt_disable()
+# define preempt_enable_rt() preempt_enable()
+# define preempt_disable_nort() barrier()
diff --git a/debian/patches-rt/printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch b/debian/patches-rt/printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch
index 1af907707f0c..e1ef1805ba69 100644
--- a/debian/patches-rt/printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch
+++ b/debian/patches-rt/printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Fri, 22 Feb 2019 23:02:44 +0100
Subject: [PATCH] printk: devkmsg: llseek: reset clear if it is lost
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
SEEK_DATA will seek to the last clear record. If this clear record
is no longer in the ring buffer, devkmsg_llseek() will go into an
@@ -16,7 +16,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -751,6 +751,7 @@ static loff_t devkmsg_llseek(struct file
+@@ -761,6 +761,7 @@ static loff_t devkmsg_llseek(struct file
{
struct devkmsg_user *user = file->private_data;
loff_t ret;
@@ -24,7 +24,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (!user)
return -EBADF;
-@@ -773,7 +774,7 @@ static loff_t devkmsg_llseek(struct file
+@@ -783,7 +784,7 @@ static loff_t devkmsg_llseek(struct file
* changes no global state, and does not clear anything.
*/
for (;;) {
@@ -33,7 +33,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
ret = prb_iter_seek(&user->iter, clear_seq);
if (ret > 0) {
/* seeked to clear seq */
-@@ -790,6 +791,10 @@ static loff_t devkmsg_llseek(struct file
+@@ -800,6 +801,10 @@ static loff_t devkmsg_llseek(struct file
break;
}
/* iterator invalid, start over */
diff --git a/debian/patches-rt/printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch b/debian/patches-rt/printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch
index e87d48c1865d..2c778adff639 100644
--- a/debian/patches-rt/printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch
+++ b/debian/patches-rt/printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch
@@ -2,7 +2,7 @@ From: He Zhe <zhe.he@windriver.com>
Date: Tue, 24 Sep 2019 15:26:39 +0800
Subject: [PATCH] printk: devkmsg: read: Return EPIPE when the first
message user-space wants has gone
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
When user-space wants to read the first message, that is when user->seq
is 0, and that message has gone, it currently automatically resets
@@ -23,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -703,14 +703,10 @@ static ssize_t devkmsg_read(struct file
+@@ -713,14 +713,10 @@ static ssize_t devkmsg_read(struct file
goto out;
}
diff --git a/debian/patches-rt/printk-hack-out-emergency-loglevel-usage.patch b/debian/patches-rt/printk-hack-out-emergency-loglevel-usage.patch
new file mode 100644
index 000000000000..f4e9eda8a55d
--- /dev/null
+++ b/debian/patches-rt/printk-hack-out-emergency-loglevel-usage.patch
@@ -0,0 +1,53 @@
+From: John Ogness <john.ogness@linutronix.de>
+Date: Tue, 3 Dec 2019 09:14:57 +0100
+Subject: [PATCH] printk: hack out emergency loglevel usage
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Instead of using an emergency loglevel to determine if atomic
+messages should be printed, use oops_in_progress. This conforms
+to the decision that latency-causing atomic messages never be
+generated during normal operation.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/printk/printk.c | 13 +++----------
+ 1 file changed, 3 insertions(+), 10 deletions(-)
+
+--- a/kernel/printk/printk.c
++++ b/kernel/printk/printk.c
+@@ -1777,15 +1777,8 @@ static void call_console_drivers(u64 seq
+ con->wrote_history = 1;
+ con->printk_seq = seq - 1;
+ }
+- if (con->write_atomic && level < emergency_console_loglevel &&
+- facility == 0) {
+- /* skip emergency messages, already printed */
+- if (con->printk_seq < seq)
+- con->printk_seq = seq;
+- continue;
+- }
+ if (con->flags & CON_BOOT && facility == 0) {
+- /* skip emergency messages, already printed */
++ /* skip boot messages, already printed */
+ if (con->printk_seq < seq)
+ con->printk_seq = seq;
+ continue;
+@@ -3171,7 +3164,7 @@ static bool console_can_emergency(int le
+ for_each_console(con) {
+ if (!(con->flags & CON_ENABLED))
+ continue;
+- if (con->write_atomic && level < emergency_console_loglevel)
++ if (con->write_atomic && oops_in_progress)
+ return true;
+ if (con->write && (con->flags & CON_BOOT))
+ return true;
+@@ -3187,7 +3180,7 @@ static void call_emergency_console_drive
+ for_each_console(con) {
+ if (!(con->flags & CON_ENABLED))
+ continue;
+- if (con->write_atomic && level < emergency_console_loglevel) {
++ if (con->write_atomic && oops_in_progress) {
+ con->write_atomic(con, text, text_len);
+ continue;
+ }
diff --git a/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch b/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch
new file mode 100644
index 000000000000..6b64b9ca9b53
--- /dev/null
+++ b/debian/patches-rt/printk-handle-iterating-while-buffer-changing.patch
@@ -0,0 +1,44 @@
+From: John Ogness <john.ogness@linutronix.de>
+Date: Mon, 7 Oct 2019 16:20:39 +0200
+Subject: [PATCH] printk: handle iterating while buffer changing
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The syslog and kmsg_dump readers are provided buffers to fill.
+Both try to maximize the provided buffer usage by calculating the
+maximum number of messages that can fit. However, if after the
+calculation, messages are dropped and new messages added, the
+calculation will no longer match.
+
+For syslog, add a check to make sure the provided buffer is not
+overfilled.
+
+For kmsg_dump, start over by recalculating the messages
+available.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/printk/printk.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/kernel/printk/printk.c
++++ b/kernel/printk/printk.c
+@@ -1446,6 +1446,9 @@ static int syslog_print_all(char __user
+ break;
+ }
+
++ if (len + textlen > size)
++ break;
++
+ if (copy_to_user(buf + len, text, textlen))
+ len = -EFAULT;
+ else
+@@ -3085,7 +3088,7 @@ bool kmsg_dump_get_buffer(struct kmsg_du
+ ret = prb_iter_next(&iter, msgbuf, PRINTK_RECORD_MAX, &seq);
+ if (ret == 0) {
+ break;
+- } else if (ret < 0) {
++ } else if (ret < 0 || seq >= end_seq) {
+ prb_iter_init(&iter, &printk_rb, &seq);
+ goto retry;
+ }
diff --git a/debian/patches-rt/printk-kmsg_dump-remove-mutex-usage.patch b/debian/patches-rt/printk-kmsg_dump-remove-mutex-usage.patch
index a70ee6b0d13b..768bf2137d14 100644
--- a/debian/patches-rt/printk-kmsg_dump-remove-mutex-usage.patch
+++ b/debian/patches-rt/printk-kmsg_dump-remove-mutex-usage.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Wed, 24 Apr 2019 16:36:04 +0200
Subject: [PATCH] printk: kmsg_dump: remove mutex usage
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The kmsg dumper can be called from any context, but the dumping
helpers were using a mutex to synchronize the iterator against
@@ -20,7 +20,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -369,8 +369,6 @@ static u64 syslog_seq;
+@@ -379,8 +379,6 @@ static u64 syslog_seq;
static size_t syslog_partial;
static bool syslog_time;
@@ -29,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* the next printk record to read after the last 'clear' command */
static u64 clear_seq;
-@@ -2867,6 +2865,7 @@ module_param_named(always_kmsg_dump, alw
+@@ -2877,6 +2875,7 @@ module_param_named(always_kmsg_dump, alw
*/
void kmsg_dump(enum kmsg_dump_reason reason)
{
@@ -37,7 +37,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct kmsg_dumper *dumper;
if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
-@@ -2877,16 +2876,18 @@ void kmsg_dump(enum kmsg_dump_reason rea
+@@ -2887,16 +2886,18 @@ void kmsg_dump(enum kmsg_dump_reason rea
if (dumper->max_reason && reason > dumper->max_reason)
continue;
@@ -63,7 +63,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
rcu_read_unlock();
}
-@@ -2998,9 +2999,7 @@ bool kmsg_dump_get_line(struct kmsg_dump
+@@ -3008,9 +3009,7 @@ bool kmsg_dump_get_line(struct kmsg_dump
{
bool ret;
@@ -73,7 +73,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return ret;
}
-@@ -3152,9 +3151,7 @@ void kmsg_dump_rewind_nolock(struct kmsg
+@@ -3162,9 +3161,7 @@ void kmsg_dump_rewind_nolock(struct kmsg
*/
void kmsg_dump_rewind(struct kmsg_dumper *dumper)
{
diff --git a/debian/patches-rt/printk-only-allow-kernel-to-emergency-message.patch b/debian/patches-rt/printk-only-allow-kernel-to-emergency-message.patch
index d66f015447f4..77fe9092b977 100644
--- a/debian/patches-rt/printk-only-allow-kernel-to-emergency-message.patch
+++ b/debian/patches-rt/printk-only-allow-kernel-to-emergency-message.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Sun, 17 Feb 2019 03:11:20 +0100
Subject: [PATCH] printk: only allow kernel to emergency message
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Emergency messages exist as a mechanism for the kernel to
communicate critical information to users. It is not meant for
@@ -16,7 +16,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1744,7 +1744,8 @@ static void printk_write_history(struct
+@@ -1754,7 +1754,8 @@ static void printk_write_history(struct
* The console_lock must be held.
*/
static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len,
@@ -26,7 +26,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
struct console *con;
-@@ -1764,13 +1765,14 @@ static void call_console_drivers(u64 seq
+@@ -1774,13 +1775,14 @@ static void call_console_drivers(u64 seq
con->wrote_history = 1;
con->printk_seq = seq - 1;
}
@@ -43,7 +43,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* skip emergency messages, already printed */
if (con->printk_seq < seq)
con->printk_seq = seq;
-@@ -1941,7 +1943,10 @@ asmlinkage int vprintk_emit(int facility
+@@ -1951,7 +1953,10 @@ asmlinkage int vprintk_emit(int facility
* - text points to beginning of text
* - there is room before text for prefix
*/
@@ -55,7 +55,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if ((lflags & LOG_CONT) || !(lflags & LOG_NEWLINE)) {
cont_add(ctx, cpu, caller_id, facility, level, lflags, text, text_len);
-@@ -2705,8 +2710,8 @@ static int printk_kthread_func(void *dat
+@@ -2715,8 +2720,8 @@ static int printk_kthread_func(void *dat
&len, printk_time);
console_lock();
diff --git a/debian/patches-rt/printk-print-rate-limitted-message-as-info.patch b/debian/patches-rt/printk-print-rate-limitted-message-as-info.patch
index 829ca0282001..3a6cb0f25840 100644
--- a/debian/patches-rt/printk-print-rate-limitted-message-as-info.patch
+++ b/debian/patches-rt/printk-print-rate-limitted-message-as-info.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 22 Feb 2019 12:47:13 +0100
Subject: [PATCH] printk: print "rate-limitted" message as info
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
If messages which are injected via kmsg are dropped then they don't need
to be printed as warnings. This is to avoid latency spikes if the
diff --git a/debian/patches-rt/printk-set-deferred-to-default-loglevel-enforce-mask.patch b/debian/patches-rt/printk-set-deferred-to-default-loglevel-enforce-mask.patch
index f5ca99539e16..9dea797e84c3 100644
--- a/debian/patches-rt/printk-set-deferred-to-default-loglevel-enforce-mask.patch
+++ b/debian/patches-rt/printk-set-deferred-to-default-loglevel-enforce-mask.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Thu, 14 Feb 2019 23:13:30 +0100
Subject: [PATCH] printk: set deferred to default loglevel, enforce mask
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
All messages printed via vpritnk_deferred() were being
automatically treated as emergency messages.
@@ -19,7 +19,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1941,7 +1941,7 @@ asmlinkage int vprintk_emit(int facility
+@@ -1951,7 +1951,7 @@ asmlinkage int vprintk_emit(int facility
* - text points to beginning of text
* - there is room before text for prefix
*/
@@ -28,7 +28,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if ((lflags & LOG_CONT) || !(lflags & LOG_NEWLINE)) {
cont_add(ctx, cpu, caller_id, facility, level, lflags, text, text_len);
-@@ -2734,7 +2734,7 @@ late_initcall(init_printk_kthread);
+@@ -2744,7 +2744,7 @@ late_initcall(init_printk_kthread);
static int vprintk_deferred(const char *fmt, va_list args)
{
diff --git a/debian/patches-rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch b/debian/patches-rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch
index de53ca53de2c..845121307826 100644
--- a/debian/patches-rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch
+++ b/debian/patches-rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 29 Aug 2013 18:21:04 +0200
Subject: ptrace: fix ptrace vs tasklist_lock race
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
As explained by Alexander Fyodorov <halcy@yandex.ru>:
@@ -31,7 +31,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -103,12 +103,8 @@ struct task_group;
+@@ -107,12 +107,8 @@ struct task_group;
__TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \
TASK_PARKED)
@@ -44,7 +44,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define task_contributes_to_load(task) ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \
(task->flags & PF_FROZEN) == 0 && \
(task->state & TASK_NOLOAD) == 0)
-@@ -1731,6 +1727,51 @@ static inline int test_tsk_need_resched(
+@@ -1772,6 +1768,51 @@ static inline int test_tsk_need_resched(
return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
}
@@ -52,7 +52,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+{
+ if (task->state & (__TASK_STOPPED | __TASK_TRACED))
+ return true;
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (task->saved_state & (__TASK_STOPPED | __TASK_TRACED))
+ return true;
+#endif
@@ -63,7 +63,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+{
+ bool traced_stopped;
+
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&task->pi_lock, flags);
@@ -81,7 +81,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+ if (task->state & __TASK_TRACED)
+ return true;
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ /* in case the task is sleeping on tasklist_lock */
+ raw_spin_lock_irq(&task->pi_lock);
+ if (task->state & __TASK_TRACED)
@@ -98,7 +98,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* explicit rescheduling in places that are safe. The return
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
-@@ -175,7 +175,14 @@ static bool ptrace_freeze_traced(struct
+@@ -180,7 +180,14 @@ static bool ptrace_freeze_traced(struct
spin_lock_irq(&task->sighand->siglock);
if (task_is_traced(task) && !__fatal_signal_pending(task)) {
@@ -116,7 +116,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
spin_unlock_irq(&task->sighand->siglock);
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -1395,6 +1395,18 @@ int migrate_swap(struct task_struct *cur
+@@ -1899,6 +1899,18 @@ int migrate_swap(struct task_struct *cur
}
#endif /* CONFIG_NUMA_BALANCING */
@@ -135,7 +135,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* wait_task_inactive - wait for a thread to unschedule.
*
-@@ -1439,7 +1451,7 @@ unsigned long wait_task_inactive(struct
+@@ -1943,7 +1955,7 @@ unsigned long wait_task_inactive(struct
* is actually now running somewhere else!
*/
while (task_running(rq, p)) {
@@ -144,7 +144,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 0;
cpu_relax();
}
-@@ -1454,7 +1466,8 @@ unsigned long wait_task_inactive(struct
+@@ -1958,7 +1970,8 @@ unsigned long wait_task_inactive(struct
running = task_running(rq, p);
queued = task_on_rq_queued(p);
ncsw = 0;
diff --git a/debian/patches-rt/radix-tree-use-local-locks.patch b/debian/patches-rt/radix-tree-use-local-locks.patch
index 0a9be54a652a..adbcee1bfa7a 100644
--- a/debian/patches-rt/radix-tree-use-local-locks.patch
+++ b/debian/patches-rt/radix-tree-use-local-locks.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 25 Jan 2017 16:34:27 +0100
Subject: [PATCH] radix-tree: use local locks
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The preload functionality uses per-CPU variables and preempt-disable to
ensure that it does not switch CPUs during its usage. This patch adds
diff --git a/debian/patches-rt/random-make-it-work-on-rt.patch b/debian/patches-rt/random-make-it-work-on-rt.patch
index 52c093ca992d..2a89659000c3 100644
--- a/debian/patches-rt/random-make-it-work-on-rt.patch
+++ b/debian/patches-rt/random-make-it-work-on-rt.patch
@@ -1,7 +1,7 @@
Subject: random: Make it work on rt
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 21 Aug 2012 20:38:50 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Delegate the random insertion to the forced threaded interrupt
handler. Store the return IP of the hard interrupt handler in the irq
@@ -11,15 +11,33 @@ entropy.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- drivers/char/random.c | 11 +++++------
- drivers/hv/hv.c | 4 +++-
- drivers/hv/vmbus_drv.c | 4 +++-
- include/linux/irqdesc.h | 1 +
- include/linux/random.h | 2 +-
- kernel/irq/handle.c | 8 +++++++-
- kernel/irq/manage.c | 6 ++++++
- 7 files changed, 26 insertions(+), 10 deletions(-)
+ arch/x86/kernel/cpu/mshyperv.c | 3 ++-
+ drivers/char/random.c | 11 +++++------
+ drivers/hv/hyperv_vmbus.h | 1 +
+ drivers/hv/vmbus_drv.c | 5 ++++-
+ include/linux/irqdesc.h | 1 +
+ include/linux/random.h | 2 +-
+ kernel/irq/handle.c | 8 +++++++-
+ kernel/irq/manage.c | 6 ++++++
+ 8 files changed, 27 insertions(+), 10 deletions(-)
+--- a/arch/x86/kernel/cpu/mshyperv.c
++++ b/arch/x86/kernel/cpu/mshyperv.c
+@@ -77,12 +77,13 @@ EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq);
+ __visible void __irq_entry hv_stimer0_vector_handler(struct pt_regs *regs)
+ {
+ struct pt_regs *old_regs = set_irq_regs(regs);
++ u64 ip = regs ? instruction_pointer(regs) : 0;
+
+ entering_irq();
+ inc_irq_stat(hyperv_stimer0_count);
+ if (hv_stimer0_handler)
+ hv_stimer0_handler();
+- add_interrupt_randomness(HYPERV_STIMER0_VECTOR, 0);
++ add_interrupt_randomness(HYPERV_STIMER0_VECTOR, 0, ip);
+ ack_APIC_irq();
+
+ exiting_irq();
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1305,28 +1305,27 @@ static __u32 get_reg(struct fast_pool *f
@@ -56,25 +74,27 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
fast_mix(fast_pool);
add_interrupt_bench(cycles);
---- a/drivers/hv/hv.c
-+++ b/drivers/hv/hv.c
-@@ -97,10 +97,12 @@ int hv_post_message(union hv_connection_
- static void hv_stimer0_isr(void)
- {
- struct hv_per_cpu_context *hv_cpu;
-+ struct pt_regs *regs = get_irq_regs();
-+ u64 ip = regs ? instruction_pointer(regs) : 0;
+--- a/drivers/hv/hyperv_vmbus.h
++++ b/drivers/hv/hyperv_vmbus.h
+@@ -18,6 +18,7 @@
+ #include <linux/atomic.h>
+ #include <linux/hyperv.h>
+ #include <linux/interrupt.h>
++#include <linux/irq.h>
- hv_cpu = this_cpu_ptr(hv_context.cpu_context);
- hv_cpu->clk_evt->event_handler(hv_cpu->clk_evt);
-- add_interrupt_randomness(stimer0_vector, 0);
-+ add_interrupt_randomness(stimer0_vector, 0, ip);
- }
+ #include "hv_trace.h"
- static int hv_ce_set_next_event(unsigned long delta,
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
-@@ -1122,6 +1122,8 @@ static void vmbus_isr(void)
+@@ -22,6 +22,7 @@
+ #include <linux/clockchips.h>
+ #include <linux/cpu.h>
+ #include <linux/sched/task_stack.h>
++#include <linux/irq.h>
+
+ #include <asm/mshyperv.h>
+ #include <linux/delay.h>
+@@ -1199,6 +1200,8 @@ static void vmbus_isr(void)
void *page_addr = hv_cpu->synic_event_page;
struct hv_message *msg;
union hv_synic_event_flags *event;
@@ -83,7 +103,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
bool handled = false;
if (unlikely(page_addr == NULL))
-@@ -1165,7 +1167,7 @@ static void vmbus_isr(void)
+@@ -1243,7 +1246,7 @@ static void vmbus_isr(void)
tasklet_schedule(&hv_cpu->msg_dpc);
}
@@ -104,7 +124,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
const struct cpumask *percpu_affinity;
--- a/include/linux/random.h
+++ b/include/linux/random.h
-@@ -32,7 +32,7 @@ static inline void add_latent_entropy(vo
+@@ -33,7 +33,7 @@ static inline void add_latent_entropy(vo
extern void add_input_randomness(unsigned int type, unsigned int code,
unsigned int value) __latent_entropy;
@@ -125,7 +145,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
retval = __handle_irq_event_percpu(desc, &flags);
- add_interrupt_randomness(desc->irq_data.irq, flags);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ desc->random_ip = ip;
+#else
+ add_interrupt_randomness(desc->irq_data.irq, flags, ip);
@@ -135,11 +155,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
note_interrupt(desc, retval);
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
-@@ -1101,6 +1101,12 @@ static int irq_thread(void *data)
+@@ -1099,6 +1099,12 @@ static int irq_thread(void *data)
if (action_ret == IRQ_WAKE_THREAD)
irq_wake_secondary(desc, action);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ migrate_disable();
+ add_interrupt_randomness(action->irq, 0,
+ desc->random_ip ^ (unsigned long) action);
diff --git a/debian/patches-rt/rcu-Acquire-RCU-lock-when-disabling-BHs.patch b/debian/patches-rt/rcu-Acquire-RCU-lock-when-disabling-BHs.patch
deleted file mode 100644
index 2999947963c5..000000000000
--- a/debian/patches-rt/rcu-Acquire-RCU-lock-when-disabling-BHs.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-From: Scott Wood <swood@redhat.com>
-Date: Wed, 11 Sep 2019 17:57:25 +0100
-Subject: [PATCH] rcu: Acquire RCU lock when disabling BHs
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-A plain local_bh_disable() is documented as creating an RCU critical
-section, and (at least) rcutorture expects this to be the case. However,
-in_softirq() doesn't block a grace period on PREEMPT_RT, since RCU checks
-preempt_count() directly. Even if RCU were changed to check
-in_softirq(), that wouldn't allow blocked BH disablers to be boosted.
-
-Fix this by calling rcu_read_lock() from local_bh_disable().
-
-Signed-off-by: Scott Wood <swood@redhat.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/softirq.c | 12 +++++++++---
- 1 file changed, 9 insertions(+), 3 deletions(-)
-
---- a/kernel/softirq.c
-+++ b/kernel/softirq.c
-@@ -115,8 +115,10 @@ void __local_bh_disable_ip(unsigned long
- long soft_cnt;
-
- WARN_ON_ONCE(in_irq());
-- if (!in_atomic())
-+ if (!in_atomic()) {
- local_lock(bh_lock);
-+ rcu_read_lock();
-+ }
- soft_cnt = this_cpu_inc_return(softirq_counter);
- WARN_ON_ONCE(soft_cnt == 0);
- current->softirq_count += SOFTIRQ_DISABLE_OFFSET;
-@@ -151,8 +153,10 @@ void _local_bh_enable(void)
- #endif
-
- current->softirq_count -= SOFTIRQ_DISABLE_OFFSET;
-- if (!in_atomic())
-+ if (!in_atomic()) {
-+ rcu_read_unlock();
- local_unlock(bh_lock);
-+ }
- }
-
- void _local_bh_enable_rt(void)
-@@ -185,8 +189,10 @@ void __local_bh_enable_ip(unsigned long
- WARN_ON_ONCE(count < 0);
- local_irq_enable();
-
-- if (!in_atomic())
-+ if (!in_atomic()) {
-+ rcu_read_unlock();
- local_unlock(bh_lock);
-+ }
-
- current->softirq_count -= SOFTIRQ_DISABLE_OFFSET;
- preempt_check_resched();
diff --git a/debian/patches-rt/rcu-Eliminate-softirq-processing-from-rcutree.patch b/debian/patches-rt/rcu-Eliminate-softirq-processing-from-rcutree.patch
deleted file mode 100644
index ee370efddd67..000000000000
--- a/debian/patches-rt/rcu-Eliminate-softirq-processing-from-rcutree.patch
+++ /dev/null
@@ -1,452 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 20 Mar 2019 22:13:33 +0100
-Subject: [PATCH] rcu: Enable elimination of Tree-RCU softirq processing
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Some workloads need to change kthread priority for RCU core processing
-without affecting other softirq work. This commit therefore introduces
-the rcutree.use_softirq kernel boot parameter, which moves the RCU core
-work from softirq to a per-CPU SCHED_OTHER kthread named rcuc. Use of
-SCHED_OTHER approach avoids the scalability problems that appeared
-with the earlier attempt to move RCU core processing to from softirq
-to kthreads. That said, kernels built with RCU_BOOST=y will run the
-rcuc kthreads at the RCU-boosting priority.
-
-Note that rcutree.use_softirq=0 must be specified to move RCU core
-processing to the rcuc kthreads: rcutree.use_softirq=1 is the default.
-
-Reported-by: Thomas Gleixner <tglx@linutronix.de>
-Tested-by: Mike Galbraith <efault@gmx.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-[ paulmck: Adjust for invoke_rcu_callbacks() only ever being invoked
- from RCU core processing, in contrast to softirq->rcuc transition
- in old mainline RCU priority boosting. ]
-[ paulmck: Avoid wakeups when scheduler might have invoked rcu_read_unlock()
- while holding rq or pi locks, also possibly fixing a pre-existing latent
- bug involving raise_softirq()-induced wakeups. ]
-Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
----
- Documentation/admin-guide/kernel-parameters.txt | 6 +
- kernel/rcu/tree.c | 138 +++++++++++++++++++++---
- kernel/rcu/tree.h | 2
- kernel/rcu/tree_plugin.h | 134 ++---------------------
- 4 files changed, 146 insertions(+), 134 deletions(-)
-
---- a/Documentation/admin-guide/kernel-parameters.txt
-+++ b/Documentation/admin-guide/kernel-parameters.txt
-@@ -3752,6 +3752,12 @@
- the propagation of recent CPU-hotplug changes up
- the rcu_node combining tree.
-
-+ rcutree.use_softirq= [KNL]
-+ If set to zero, move all RCU_SOFTIRQ processing to
-+ per-CPU rcuc kthreads. Defaults to a non-zero
-+ value, meaning that RCU_SOFTIRQ is used by default.
-+ Specify rcutree.use_softirq=0 to use rcuc kthreads.
-+
- rcutree.rcu_fanout_exact= [KNL]
- Disable autobalancing of the rcu_node combining
- tree. This is used by rcutorture, and might
---- a/kernel/rcu/tree.c
-+++ b/kernel/rcu/tree.c
-@@ -51,6 +51,12 @@
- #include <linux/tick.h>
- #include <linux/sysrq.h>
- #include <linux/kprobes.h>
-+#include <linux/gfp.h>
-+#include <linux/oom.h>
-+#include <linux/smpboot.h>
-+#include <linux/jiffies.h>
-+#include <linux/sched/isolation.h>
-+#include "../time/tick-internal.h"
-
- #include "tree.h"
- #include "rcu.h"
-@@ -92,6 +98,9 @@ struct rcu_state rcu_state = {
- /* Dump rcu_node combining tree at boot to verify correct setup. */
- static bool dump_tree;
- module_param(dump_tree, bool, 0444);
-+/* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
-+static bool use_softirq = 1;
-+module_param(use_softirq, bool, 0444);
- /* Control rcu_node-tree auto-balancing at boot time. */
- static bool rcu_fanout_exact;
- module_param(rcu_fanout_exact, bool, 0444);
-@@ -2253,7 +2262,7 @@ void rcu_force_quiescent_state(void)
- EXPORT_SYMBOL_GPL(rcu_force_quiescent_state);
-
- /* Perform RCU core processing work for the current CPU. */
--static __latent_entropy void rcu_core(struct softirq_action *unused)
-+static __latent_entropy void rcu_core(void)
- {
- unsigned long flags;
- struct rcu_data *rdp = raw_cpu_ptr(&rcu_data);
-@@ -2295,29 +2304,131 @@ static __latent_entropy void rcu_core(st
- trace_rcu_utilization(TPS("End RCU core"));
- }
-
-+static void rcu_core_si(struct softirq_action *h)
-+{
-+ rcu_core();
-+}
-+
-+static void rcu_wake_cond(struct task_struct *t, int status)
-+{
-+ /*
-+ * If the thread is yielding, only wake it when this
-+ * is invoked from idle
-+ */
-+ if (t && (status != RCU_KTHREAD_YIELDING || is_idle_task(current)))
-+ wake_up_process(t);
-+}
-+
-+static void invoke_rcu_core_kthread(void)
-+{
-+ struct task_struct *t;
-+ unsigned long flags;
-+
-+ local_irq_save(flags);
-+ __this_cpu_write(rcu_data.rcu_cpu_has_work, 1);
-+ t = __this_cpu_read(rcu_data.rcu_cpu_kthread_task);
-+ if (t != NULL && t != current)
-+ rcu_wake_cond(t, __this_cpu_read(rcu_data.rcu_cpu_kthread_status));
-+ local_irq_restore(flags);
-+}
-+
- /*
-- * Schedule RCU callback invocation. If the running implementation of RCU
-- * does not support RCU priority boosting, just do a direct call, otherwise
-- * wake up the per-CPU kernel kthread. Note that because we are running
-- * on the current CPU with softirqs disabled, the rcu_cpu_kthread_task
-- * cannot disappear out from under us.
-+ * Do RCU callback invocation. Not that if we are running !use_softirq,
-+ * we are already in the rcuc kthread. If callbacks are offloaded, then
-+ * ->cblist is always empty, so we don't get here. Therefore, we only
-+ * ever need to check for the scheduler being operational (some callbacks
-+ * do wakeups, so we do need the scheduler).
- */
- static void invoke_rcu_callbacks(struct rcu_data *rdp)
- {
- if (unlikely(!READ_ONCE(rcu_scheduler_fully_active)))
- return;
-- if (likely(!rcu_state.boost)) {
-- rcu_do_batch(rdp);
-- return;
-- }
-- invoke_rcu_callbacks_kthread();
-+ rcu_do_batch(rdp);
- }
-
-+/*
-+ * Wake up this CPU's rcuc kthread to do RCU core processing.
-+ */
- static void invoke_rcu_core(void)
- {
-- if (cpu_online(smp_processor_id()))
-+ if (!cpu_online(smp_processor_id()))
-+ return;
-+ if (use_softirq)
- raise_softirq(RCU_SOFTIRQ);
-+ else
-+ invoke_rcu_core_kthread();
-+}
-+
-+static void rcu_cpu_kthread_park(unsigned int cpu)
-+{
-+ per_cpu(rcu_data.rcu_cpu_kthread_status, cpu) = RCU_KTHREAD_OFFCPU;
-+}
-+
-+static int rcu_cpu_kthread_should_run(unsigned int cpu)
-+{
-+ return __this_cpu_read(rcu_data.rcu_cpu_has_work);
-+}
-+
-+/*
-+ * Per-CPU kernel thread that invokes RCU callbacks. This replaces
-+ * the RCU softirq used in configurations of RCU that do not support RCU
-+ * priority boosting.
-+ */
-+static void rcu_cpu_kthread(unsigned int cpu)
-+{
-+ unsigned int *statusp = this_cpu_ptr(&rcu_data.rcu_cpu_kthread_status);
-+ char work, *workp = this_cpu_ptr(&rcu_data.rcu_cpu_has_work);
-+ int spincnt;
-+
-+ for (spincnt = 0; spincnt < 10; spincnt++) {
-+ trace_rcu_utilization(TPS("Start CPU kthread@rcu_wait"));
-+ local_bh_disable();
-+ *statusp = RCU_KTHREAD_RUNNING;
-+ local_irq_disable();
-+ work = *workp;
-+ *workp = 0;
-+ local_irq_enable();
-+ if (work)
-+ rcu_core();
-+ local_bh_enable();
-+ if (*workp == 0) {
-+ trace_rcu_utilization(TPS("End CPU kthread@rcu_wait"));
-+ *statusp = RCU_KTHREAD_WAITING;
-+ return;
-+ }
-+ }
-+ *statusp = RCU_KTHREAD_YIELDING;
-+ trace_rcu_utilization(TPS("Start CPU kthread@rcu_yield"));
-+ schedule_timeout_interruptible(2);
-+ trace_rcu_utilization(TPS("End CPU kthread@rcu_yield"));
-+ *statusp = RCU_KTHREAD_WAITING;
-+}
-+
-+static struct smp_hotplug_thread rcu_cpu_thread_spec = {
-+ .store = &rcu_data.rcu_cpu_kthread_task,
-+ .thread_should_run = rcu_cpu_kthread_should_run,
-+ .thread_fn = rcu_cpu_kthread,
-+ .thread_comm = "rcuc/%u",
-+ .setup = rcu_cpu_kthread_setup,
-+ .park = rcu_cpu_kthread_park,
-+};
-+
-+/*
-+ * Spawn per-CPU RCU core processing kthreads.
-+ */
-+static int __init rcu_spawn_core_kthreads(void)
-+{
-+ int cpu;
-+
-+ for_each_possible_cpu(cpu)
-+ per_cpu(rcu_data.rcu_cpu_has_work, cpu) = 0;
-+ if (!IS_ENABLED(CONFIG_RCU_BOOST) && use_softirq)
-+ return 0;
-+ WARN_ONCE(smpboot_register_percpu_thread(&rcu_cpu_thread_spec),
-+ "%s: Could not start rcuc kthread, OOM is now expected behavior\n", __func__);
-+ return 0;
- }
-+early_initcall(rcu_spawn_core_kthreads);
-
- /*
- * Handle any core-RCU processing required by a call_rcu() invocation.
-@@ -3355,7 +3466,8 @@ void __init rcu_init(void)
- rcu_init_one();
- if (dump_tree)
- rcu_dump_rcu_node_tree();
-- open_softirq(RCU_SOFTIRQ, rcu_core);
-+ if (use_softirq)
-+ open_softirq(RCU_SOFTIRQ, rcu_core_si);
-
- /*
- * We don't need protection against CPU-hotplug here because
---- a/kernel/rcu/tree.h
-+++ b/kernel/rcu/tree.h
-@@ -407,8 +407,8 @@ void call_rcu(struct rcu_head *head, rcu
- static void dump_blkd_tasks(struct rcu_node *rnp, int ncheck);
- static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags);
- static void rcu_preempt_boost_start_gp(struct rcu_node *rnp);
--static void invoke_rcu_callbacks_kthread(void);
- static bool rcu_is_callbacks_kthread(void);
-+static void rcu_cpu_kthread_setup(unsigned int cpu);
- static void __init rcu_spawn_boost_kthreads(void);
- static void rcu_prepare_kthreads(int cpu);
- static void rcu_cleanup_after_idle(void);
---- a/kernel/rcu/tree_plugin.h
-+++ b/kernel/rcu/tree_plugin.h
-@@ -11,29 +11,7 @@
- * Paul E. McKenney <paulmck@linux.ibm.com>
- */
-
--#include <linux/delay.h>
--#include <linux/gfp.h>
--#include <linux/oom.h>
--#include <linux/sched/debug.h>
--#include <linux/smpboot.h>
--#include <linux/sched/isolation.h>
--#include <uapi/linux/sched/types.h>
--#include "../time/tick-internal.h"
--
--#ifdef CONFIG_RCU_BOOST
- #include "../locking/rtmutex_common.h"
--#else /* #ifdef CONFIG_RCU_BOOST */
--
--/*
-- * Some architectures do not define rt_mutexes, but if !CONFIG_RCU_BOOST,
-- * all uses are in dead code. Provide a definition to keep the compiler
-- * happy, but add WARN_ON_ONCE() to complain if used in the wrong place.
-- * This probably needs to be excluded from -rt builds.
-- */
--#define rt_mutex_owner(a) ({ WARN_ON_ONCE(1); NULL; })
--#define rt_mutex_futex_unlock(x) WARN_ON_ONCE(1)
--
--#endif /* #else #ifdef CONFIG_RCU_BOOST */
-
- #ifdef CONFIG_RCU_NOCB_CPU
- static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */
-@@ -94,6 +72,8 @@ static void __init rcu_bootup_announce_o
- pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_init_delay);
- if (gp_cleanup_delay)
- pr_info("\tRCU debug GP init slowdown %d jiffies.\n", gp_cleanup_delay);
-+ if (!use_softirq)
-+ pr_info("\tRCU_SOFTIRQ processing moved to rcuc kthreads.\n");
- if (IS_ENABLED(CONFIG_RCU_EQS_DEBUG))
- pr_info("\tRCU debug extended QS entry/exit.\n");
- rcupdate_announce_bootup_oddness();
-@@ -631,7 +611,7 @@ static void rcu_read_unlock_special(stru
- if (preempt_bh_were_disabled || irqs_were_disabled) {
- WRITE_ONCE(t->rcu_read_unlock_special.b.exp_hint, false);
- /* Need to defer quiescent state until everything is enabled. */
-- if (irqs_were_disabled) {
-+ if (irqs_were_disabled && use_softirq) {
- /* Enabling irqs does not reschedule, so... */
- raise_softirq_irqoff(RCU_SOFTIRQ);
- } else {
-@@ -948,18 +928,21 @@ dump_blkd_tasks(struct rcu_node *rnp, in
-
- #endif /* #else #ifdef CONFIG_PREEMPT_RCU */
-
-+/*
-+ * If boosting, set rcuc kthreads to realtime priority.
-+ */
-+static void rcu_cpu_kthread_setup(unsigned int cpu)
-+{
- #ifdef CONFIG_RCU_BOOST
-+ struct sched_param sp;
-
--static void rcu_wake_cond(struct task_struct *t, int status)
--{
-- /*
-- * If the thread is yielding, only wake it when this
-- * is invoked from idle
-- */
-- if (status != RCU_KTHREAD_YIELDING || is_idle_task(current))
-- wake_up_process(t);
-+ sp.sched_priority = kthread_prio;
-+ sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
-+#endif /* #ifdef CONFIG_RCU_BOOST */
- }
-
-+#ifdef CONFIG_RCU_BOOST
-+
- /*
- * Carry out RCU priority boosting on the task indicated by ->exp_tasks
- * or ->boost_tasks, advancing the pointer to the next task in the
-@@ -1095,23 +1078,6 @@ static void rcu_initiate_boost(struct rc
- }
-
- /*
-- * Wake up the per-CPU kthread to invoke RCU callbacks.
-- */
--static void invoke_rcu_callbacks_kthread(void)
--{
-- unsigned long flags;
--
-- local_irq_save(flags);
-- __this_cpu_write(rcu_data.rcu_cpu_has_work, 1);
-- if (__this_cpu_read(rcu_data.rcu_cpu_kthread_task) != NULL &&
-- current != __this_cpu_read(rcu_data.rcu_cpu_kthread_task)) {
-- rcu_wake_cond(__this_cpu_read(rcu_data.rcu_cpu_kthread_task),
-- __this_cpu_read(rcu_data.rcu_cpu_kthread_status));
-- }
-- local_irq_restore(flags);
--}
--
--/*
- * Is the current CPU running the RCU-callbacks kthread?
- * Caller must have preemption disabled.
- */
-@@ -1164,59 +1130,6 @@ static int rcu_spawn_one_boost_kthread(s
- return 0;
- }
-
--static void rcu_cpu_kthread_setup(unsigned int cpu)
--{
-- struct sched_param sp;
--
-- sp.sched_priority = kthread_prio;
-- sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
--}
--
--static void rcu_cpu_kthread_park(unsigned int cpu)
--{
-- per_cpu(rcu_data.rcu_cpu_kthread_status, cpu) = RCU_KTHREAD_OFFCPU;
--}
--
--static int rcu_cpu_kthread_should_run(unsigned int cpu)
--{
-- return __this_cpu_read(rcu_data.rcu_cpu_has_work);
--}
--
--/*
-- * Per-CPU kernel thread that invokes RCU callbacks. This replaces
-- * the RCU softirq used in configurations of RCU that do not support RCU
-- * priority boosting.
-- */
--static void rcu_cpu_kthread(unsigned int cpu)
--{
-- unsigned int *statusp = this_cpu_ptr(&rcu_data.rcu_cpu_kthread_status);
-- char work, *workp = this_cpu_ptr(&rcu_data.rcu_cpu_has_work);
-- int spincnt;
--
-- for (spincnt = 0; spincnt < 10; spincnt++) {
-- trace_rcu_utilization(TPS("Start CPU kthread@rcu_wait"));
-- local_bh_disable();
-- *statusp = RCU_KTHREAD_RUNNING;
-- local_irq_disable();
-- work = *workp;
-- *workp = 0;
-- local_irq_enable();
-- if (work)
-- rcu_do_batch(this_cpu_ptr(&rcu_data));
-- local_bh_enable();
-- if (*workp == 0) {
-- trace_rcu_utilization(TPS("End CPU kthread@rcu_wait"));
-- *statusp = RCU_KTHREAD_WAITING;
-- return;
-- }
-- }
-- *statusp = RCU_KTHREAD_YIELDING;
-- trace_rcu_utilization(TPS("Start CPU kthread@rcu_yield"));
-- schedule_timeout_interruptible(2);
-- trace_rcu_utilization(TPS("End CPU kthread@rcu_yield"));
-- *statusp = RCU_KTHREAD_WAITING;
--}
--
- /*
- * Set the per-rcu_node kthread's affinity to cover all CPUs that are
- * served by the rcu_node in question. The CPU hotplug lock is still
-@@ -1247,27 +1160,13 @@ static void rcu_boost_kthread_setaffinit
- free_cpumask_var(cm);
- }
-
--static struct smp_hotplug_thread rcu_cpu_thread_spec = {
-- .store = &rcu_data.rcu_cpu_kthread_task,
-- .thread_should_run = rcu_cpu_kthread_should_run,
-- .thread_fn = rcu_cpu_kthread,
-- .thread_comm = "rcuc/%u",
-- .setup = rcu_cpu_kthread_setup,
-- .park = rcu_cpu_kthread_park,
--};
--
- /*
- * Spawn boost kthreads -- called as soon as the scheduler is running.
- */
- static void __init rcu_spawn_boost_kthreads(void)
- {
- struct rcu_node *rnp;
-- int cpu;
-
-- for_each_possible_cpu(cpu)
-- per_cpu(rcu_data.rcu_cpu_has_work, cpu) = 0;
-- if (WARN_ONCE(smpboot_register_percpu_thread(&rcu_cpu_thread_spec), "%s: Could not start rcub kthread, OOM is now expected behavior\n", __func__))
-- return;
- rcu_for_each_leaf_node(rnp)
- (void)rcu_spawn_one_boost_kthread(rnp);
- }
-@@ -1290,11 +1189,6 @@ static void rcu_initiate_boost(struct rc
- raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
- }
-
--static void invoke_rcu_callbacks_kthread(void)
--{
-- WARN_ON_ONCE(1);
--}
--
- static bool rcu_is_callbacks_kthread(void)
- {
- return false;
diff --git a/debian/patches-rt/rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch b/debian/patches-rt/rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch
index 57c6d2d395e8..69492bf66505 100644
--- a/debian/patches-rt/rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch
+++ b/debian/patches-rt/rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch
@@ -1,7 +1,7 @@
From: Scott Wood <swood@redhat.com>
Date: Wed, 11 Sep 2019 17:57:28 +0100
Subject: [PATCH] rcu: Use rcuc threads on PREEMPT_RT as we did
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
While switching to the reworked RCU-thread code, it has been forgotten
to enable the thread processing on -RT.
@@ -16,13 +16,13 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
-@@ -99,8 +99,10 @@ struct rcu_state rcu_state = {
+@@ -100,8 +100,10 @@ struct rcu_state rcu_state = {
static bool dump_tree;
module_param(dump_tree, bool, 0444);
/* By default, use RCU_SOFTIRQ instead of rcuc kthreads. */
-static bool use_softirq = 1;
-+static bool use_softirq = !IS_ENABLED(CONFIG_PREEMPT_RT_FULL);
-+#ifndef CONFIG_PREEMPT_RT_FULL
++static bool use_softirq = !IS_ENABLED(CONFIG_PREEMPT_RT);
++#ifndef CONFIG_PREEMPT_RT
module_param(use_softirq, bool, 0444);
+#endif
/* Control rcu_node-tree auto-balancing at boot time. */
diff --git a/debian/patches-rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch b/debian/patches-rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch
index 8d113c775180..c47fd3b6afa2 100644
--- a/debian/patches-rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch
+++ b/debian/patches-rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch
@@ -1,14 +1,14 @@
From: Julia Cartwright <julia@ni.com>
Date: Wed, 12 Oct 2016 11:21:14 -0500
Subject: [PATCH] rcu: enable rcu_normal_after_boot by default for RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The forcing of an expedited grace period is an expensive and very
RT-application unfriendly operation, as it forcibly preempts all running
tasks on CPUs which are preventing the gp from expiring.
By default, as a policy decision, disable the expediting of grace
-periods (after boot) on configurations which enable PREEMPT_RT_FULL.
+periods (after boot) on configurations which enable PREEMPT_RT.
Suggested-by: Luiz Capitulino <lcapitulino@redhat.com>
Acked-by: Paul E. McKenney <paulmck@linux.ibm.com>
@@ -25,8 +25,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
extern int rcu_normal; /* from sysctl */
module_param(rcu_normal, int, 0);
-static int rcu_normal_after_boot;
-+static int rcu_normal_after_boot = IS_ENABLED(CONFIG_PREEMPT_RT_FULL);
-+#ifndef CONFIG_PREEMPT_RT_FULL
++static int rcu_normal_after_boot = IS_ENABLED(CONFIG_PREEMPT_RT);
++#ifndef CONFIG_PREEMPT_RT
module_param(rcu_normal_after_boot, int, 0);
+#endif
#endif /* #ifndef CONFIG_TINY_RCU */
diff --git a/debian/patches-rt/rcu-make-RCU_BOOST-default-on-RT.patch b/debian/patches-rt/rcu-make-RCU_BOOST-default-on-RT.patch
index 7a5cfd0f7758..516234096985 100644
--- a/debian/patches-rt/rcu-make-RCU_BOOST-default-on-RT.patch
+++ b/debian/patches-rt/rcu-make-RCU_BOOST-default-on-RT.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Fri, 21 Mar 2014 20:19:05 +0100
Subject: rcu: make RCU_BOOST default on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Since it is no longer invoked from the softirq people run into OOM more
often if the priority of the RCU thread is too low. Making boosting
@@ -21,8 +21,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
bool "Enable RCU priority boosting"
- depends on RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT
- default n
-+ depends on (RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT) || PREEMPT_RT_FULL
-+ default y if PREEMPT_RT_FULL
++ depends on (RT_MUTEXES && PREEMPT_RCU && RCU_EXPERT) || PREEMPT_RT
++ default y if PREEMPT_RT
help
This option boosts the priority of preempted RCU readers that
block the current preemptible RCU grace period for too long.
diff --git a/debian/patches-rt/rcutorture-Avoid-problematic-critical-section-nestin.patch b/debian/patches-rt/rcutorture-Avoid-problematic-critical-section-nestin.patch
index de03e4ca387c..8cf8c56d6e20 100644
--- a/debian/patches-rt/rcutorture-Avoid-problematic-critical-section-nestin.patch
+++ b/debian/patches-rt/rcutorture-Avoid-problematic-critical-section-nestin.patch
@@ -2,7 +2,7 @@ From: Scott Wood <swood@redhat.com>
Date: Wed, 11 Sep 2019 17:57:29 +0100
Subject: [PATCH] rcutorture: Avoid problematic critical section nesting
on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
rcutorture was generating some nesting scenarios that are not
reasonable. Constrain the state selection to avoid them.
@@ -59,7 +59,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define RCUTORTURE_RDR_MAX_LOOPS 0x7 /* Maximum reader extensions. */
/* Must be power of two minus one. */
#define RCUTORTURE_RDR_MAX_SEGS (RCUTORTURE_RDR_MAX_LOOPS + 3)
-@@ -1092,31 +1095,52 @@ static void rcutorture_one_extend(int *r
+@@ -1152,31 +1155,52 @@ static void rcutorture_one_extend(int *r
WARN_ON_ONCE((idxold >> RCUTORTURE_RDR_SHIFT) > 1);
rtrsp->rt_readstate = newstate;
@@ -119,7 +119,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (statesold & RCUTORTURE_RDR_RCU)
cur_ops->readunlock(idxold >> RCUTORTURE_RDR_SHIFT);
-@@ -1152,6 +1176,12 @@ rcutorture_extend_mask(int oldmask, stru
+@@ -1212,6 +1236,12 @@ rcutorture_extend_mask(int oldmask, stru
int mask = rcutorture_extend_mask_max();
unsigned long randmask1 = torture_random(trsp) >> 8;
unsigned long randmask2 = randmask1 >> 3;
@@ -132,7 +132,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
WARN_ON_ONCE(mask >> RCUTORTURE_RDR_SHIFT);
/* Mostly only one bit (need preemption!), sometimes lots of bits. */
-@@ -1159,11 +1189,49 @@ rcutorture_extend_mask(int oldmask, stru
+@@ -1219,11 +1249,49 @@ rcutorture_extend_mask(int oldmask, stru
mask = mask & randmask2;
else
mask = mask & (1 << (randmask2 % RCUTORTURE_RDR_NBITS));
@@ -154,7 +154,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ * (regardless of RT), but until then don't stop testing
+ * them on non-RT.
+ */
-+ if (IS_ENABLED(CONFIG_PREEMPT_RT_FULL)) {
++ if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
+ /*
+ * Can't release the outermost rcu lock in an irq disabled
+ * section without preemption also being disabled, if irqs
diff --git a/debian/patches-rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch b/debian/patches-rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch
deleted file mode 100644
index 9374743dbe43..000000000000
--- a/debian/patches-rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-Subject: ARM: Initialize split page table locks for vector page
-From: Frank Rowand <frank.rowand@am.sony.com>
-Date: Sat, 1 Oct 2011 18:58:13 -0700
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Without this patch, ARM can not use SPLIT_PTLOCK_CPUS if
-PREEMPT_RT_FULL=y because vectors_user_mapping() creates a
-VM_ALWAYSDUMP mapping of the vector page (address 0xffff0000), but no
-ptl->lock has been allocated for the page. An attempt to coredump
-that page will result in a kernel NULL pointer dereference when
-follow_page() attempts to lock the page.
-
-The call tree to the NULL pointer dereference is:
-
- do_notify_resume()
- get_signal_to_deliver()
- do_coredump()
- elf_core_dump()
- get_dump_page()
- __get_user_pages()
- follow_page()
- pte_offset_map_lock() <----- a #define
- ...
- rt_spin_lock()
-
-The underlying problem is exposed by mm-shrink-the-page-frame-to-rt-size.patch.
-
-Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
-Cc: Frank <Frank_Rowand@sonyusa.com>
-Cc: Peter Zijlstra <peterz@infradead.org>
-Link: http://lkml.kernel.org/r/4E87C535.2030907@am.sony.com
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- arch/arm/kernel/process.c | 24 ++++++++++++++++++++++++
- 1 file changed, 24 insertions(+)
-
---- a/arch/arm/kernel/process.c
-+++ b/arch/arm/kernel/process.c
-@@ -325,6 +325,30 @@ unsigned long arch_randomize_brk(struct
- }
-
- #ifdef CONFIG_MMU
-+/*
-+ * CONFIG_SPLIT_PTLOCK_CPUS results in a page->ptl lock. If the lock is not
-+ * initialized by pgtable_page_ctor() then a coredump of the vector page will
-+ * fail.
-+ */
-+static int __init vectors_user_mapping_init_page(void)
-+{
-+ struct page *page;
-+ unsigned long addr = 0xffff0000;
-+ pgd_t *pgd;
-+ pud_t *pud;
-+ pmd_t *pmd;
-+
-+ pgd = pgd_offset_k(addr);
-+ pud = pud_offset(pgd, addr);
-+ pmd = pmd_offset(pud, addr);
-+ page = pmd_page(*(pmd));
-+
-+ pgtable_page_ctor(page);
-+
-+ return 0;
-+}
-+late_initcall(vectors_user_mapping_init_page);
-+
- #ifdef CONFIG_KUSER_HELPERS
- /*
- * The vectors page is always readable from user space for the
diff --git a/debian/patches-rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch b/debian/patches-rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch
deleted file mode 100644
index 28c93480a5c7..000000000000
--- a/debian/patches-rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch
+++ /dev/null
@@ -1,155 +0,0 @@
-From: Daniel Bristot de Oliveira <bristot@redhat.com>
-Date: Mon, 26 Jun 2017 17:07:15 +0200
-Subject: rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-There is a problem in the migrate_disable()/enable() implementation
-regarding the number of migratory tasks in the rt/dl RQs. The problem
-is the following:
-
-When a task is attached to the rt runqueue, it is checked if it either
-can run in more than one CPU, or if it is with migration disable. If
-either check is true, the rt_rq->rt_nr_migratory counter is not
-increased. The counter increases otherwise.
-
-When the task is detached, the same check is done. If either check is
-true, the rt_rq->rt_nr_migratory counter is not decreased. The counter
-decreases otherwise. The same check is done in the dl scheduler.
-
-One important thing is that, migrate disable/enable does not touch this
-counter for tasks attached to the rt rq. So suppose the following chain
-of events.
-
-Assumptions:
-Task A is the only runnable task in A Task B runs on the CPU B
-Task A runs on CFS (non-rt) Task B has RT priority
-Thus, rt_nr_migratory is 0 B is running
-Task A can run on all CPUS.
-
-Timeline:
- CPU A/TASK A CPU B/TASK B
-A takes the rt mutex X .
-A disables migration .
- . B tries to take the rt mutex X
- . As it is held by A {
- . A inherits the rt priority of B
- . A is dequeued from CFS RQ of CPU A
- . A is enqueued in the RT RQ of CPU A
- . As migration is disabled
- . rt_nr_migratory in A is not increased
- .
-A enables migration
-A releases the rt mutex X {
- A returns to its original priority
- A ask to be dequeued from RT RQ {
- As migration is now enabled and it can run on all CPUS {
- rt_nr_migratory should be decreased
- As rt_nr_migratory is 0, rt_nr_migratory under flows
- }
-}
-
-This variable is important because it notifies if there are more than one
-runnable & migratory task in the runqueue. If there are more than one
-tasks, the rt_rq is set as overloaded, and then tries to migrate some
-tasks. This rule is important to keep the scheduler working conserving,
-that is, in a system with M CPUs, the M highest priority tasks should be
-running.
-
-As rt_nr_migratory is unsigned, it will become > 0, notifying that the
-RQ is overloaded, activating pushing mechanism without need.
-
-This patch fixes this problem by decreasing/increasing the
-rt/dl_nr_migratory in the migrate disable/enable operations.
-
-Reported-by: Pei Zhang <pezhang@redhat.com>
-Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
-Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
-Cc: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
-Cc: Clark Williams <williams@redhat.com>
-Cc: Luiz Capitulino <lcapitulino@redhat.com>
-Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Cc: Thomas Gleixner <tglx@linutronix.de>
-Cc: Steven Rostedt <rostedt@goodmis.org>
-Cc: Peter Zijlstra <peterz@infradead.org>
-Cc: Ingo Molnar <mingo@kernel.org>
-Cc: LKML <linux-kernel@vger.kernel.org>
-Cc: linux-rt-users <linux-rt-users@vger.kernel.org>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/core.c | 49 ++++++++++++++++++++++++++++++++++++++++++++-----
- 1 file changed, 44 insertions(+), 5 deletions(-)
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7152,6 +7152,47 @@ const u32 sched_prio_to_wmult[40] = {
-
- #if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-
-+static inline void
-+update_nr_migratory(struct task_struct *p, long delta)
-+{
-+ if (unlikely((p->sched_class == &rt_sched_class ||
-+ p->sched_class == &dl_sched_class) &&
-+ p->nr_cpus_allowed > 1)) {
-+ if (p->sched_class == &rt_sched_class)
-+ task_rq(p)->rt.rt_nr_migratory += delta;
-+ else
-+ task_rq(p)->dl.dl_nr_migratory += delta;
-+ }
-+}
-+
-+static inline void
-+migrate_disable_update_cpus_allowed(struct task_struct *p)
-+{
-+ struct rq *rq;
-+ struct rq_flags rf;
-+
-+ p->cpus_ptr = cpumask_of(smp_processor_id());
-+
-+ rq = task_rq_lock(p, &rf);
-+ update_nr_migratory(p, -1);
-+ p->nr_cpus_allowed = 1;
-+ task_rq_unlock(rq, p, &rf);
-+}
-+
-+static inline void
-+migrate_enable_update_cpus_allowed(struct task_struct *p)
-+{
-+ struct rq *rq;
-+ struct rq_flags rf;
-+
-+ p->cpus_ptr = &p->cpus_mask;
-+
-+ rq = task_rq_lock(p, &rf);
-+ p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
-+ update_nr_migratory(p, 1);
-+ task_rq_unlock(rq, p, &rf);
-+}
-+
- void migrate_disable(void)
- {
- struct task_struct *p = current;
-@@ -7175,10 +7216,9 @@ void migrate_disable(void)
- }
-
- preempt_disable();
-- p->migrate_disable = 1;
-
-- p->cpus_ptr = cpumask_of(smp_processor_id());
-- p->nr_cpus_allowed = 1;
-+ migrate_disable_update_cpus_allowed(p);
-+ p->migrate_disable = 1;
-
- preempt_enable();
- }
-@@ -7210,9 +7250,8 @@ void migrate_enable(void)
-
- preempt_disable();
-
-- p->cpus_ptr = &p->cpus_mask;
-- p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
- p->migrate_disable = 0;
-+ migrate_enable_update_cpus_allowed(p);
-
- if (p->migrate_disable_update) {
- struct rq *rq;
diff --git a/debian/patches-rt/rt-introduce-cpu-chill.patch b/debian/patches-rt/rt-introduce-cpu-chill.patch
index 44dead0e2fa9..541ac6840847 100644
--- a/debian/patches-rt/rt-introduce-cpu-chill.patch
+++ b/debian/patches-rt/rt-introduce-cpu-chill.patch
@@ -1,7 +1,7 @@
Subject: rt: Introduce cpu_chill()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 07 Mar 2012 20:51:03 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Retry loops on RT might loop forever when the modifying side was
preempted. Add cpu_chill() to replace cpu_relax(). cpu_chill()
@@ -66,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
msleep(seconds * 1000);
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+extern void cpu_chill(void);
+#else
+# define cpu_chill() cpu_relax()
@@ -75,11 +75,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#endif /* defined(_LINUX_DELAY_H) */
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
-@@ -1855,6 +1855,38 @@ SYSCALL_DEFINE2(nanosleep_time32, struct
+@@ -1979,6 +1979,38 @@ SYSCALL_DEFINE2(nanosleep_time32, struct
}
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+/*
+ * Sleep for 1 ms in hope whoever holds what we want will let it go.
+ */
diff --git a/debian/patches-rt/rt-local-irq-lock.patch b/debian/patches-rt/rt-local-irq-lock.patch
index f42dc869a3a6..bb39990b4829 100644
--- a/debian/patches-rt/rt-local-irq-lock.patch
+++ b/debian/patches-rt/rt-local-irq-lock.patch
@@ -1,7 +1,7 @@
Subject: rt: Add local irq locks
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 20 Jun 2011 09:03:47 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Introduce locallock. For !RT this maps to preempt_disable()/
local_irq_disable() so there is not much that changes. For RT this will
@@ -13,20 +13,20 @@ is held and the owner is preempted.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- include/linux/locallock.h | 271 ++++++++++++++++++++++++++++++++++++++++++++++
+ include/linux/locallock.h | 281 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/percpu.h | 29 ++++
- 2 files changed, 300 insertions(+)
+ 2 files changed, 310 insertions(+)
--- /dev/null
+++ b/include/linux/locallock.h
-@@ -0,0 +1,271 @@
+@@ -0,0 +1,281 @@
+#ifndef _LINUX_LOCALLOCK_H
+#define _LINUX_LOCALLOCK_H
+
+#include <linux/percpu.h>
+#include <linux/spinlock.h>
+
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+# define LL_WARN(cond) WARN_ON(cond)
@@ -244,6 +244,14 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+
+#define put_locked_var(lvar, var) local_unlock(lvar);
+
++#define get_locked_ptr(lvar, var) \
++ ({ \
++ local_lock(lvar); \
++ this_cpu_ptr(var); \
++ })
++
++#define put_locked_ptr(lvar, var) local_unlock(lvar);
++
+#define local_lock_cpu(lvar) \
+ ({ \
+ local_lock(lvar); \
@@ -252,7 +260,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+
+#define local_unlock_cpu(lvar) local_unlock(lvar)
+
-+#else /* PREEMPT_RT_BASE */
++#else /* PREEMPT_RT */
+
+#define DEFINE_LOCAL_IRQ_LOCK(lvar) __typeof__(const int) lvar
+#define DECLARE_LOCAL_IRQ_LOCK(lvar) extern __typeof__(const int) lvar
@@ -284,6 +292,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+
+#define get_locked_var(lvar, var) get_cpu_var(var)
+#define put_locked_var(lvar, var) put_cpu_var(var)
++#define get_locked_ptr(lvar, var) get_cpu_ptr(var)
++#define put_locked_ptr(lvar, var) put_cpu_ptr(var)
+
+#define local_lock_cpu(lvar) get_cpu()
+#define local_unlock_cpu(lvar) put_cpu()
@@ -297,7 +307,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#define PERCPU_MODULE_RESERVE 0
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+
+#define get_local_var(var) (*({ \
+ migrate_disable(); \
diff --git a/debian/patches-rt/rt-preempt-base-config.patch b/debian/patches-rt/rt-preempt-base-config.patch
deleted file mode 100644
index be2c59557700..000000000000
--- a/debian/patches-rt/rt-preempt-base-config.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-Subject: rt: Provide PREEMPT_RT_BASE config switch
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Fri, 17 Jun 2011 12:39:57 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Introduce PREEMPT_RT_BASE which enables parts of
-PREEMPT_RT_FULL. Forces interrupt threading and enables some of the RT
-substitutions for testing.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- kernel/Kconfig.preempt | 19 +++++++++++++++++--
- 1 file changed, 17 insertions(+), 2 deletions(-)
-
---- a/kernel/Kconfig.preempt
-+++ b/kernel/Kconfig.preempt
-@@ -1,4 +1,11 @@
- # SPDX-License-Identifier: GPL-2.0-only
-+config PREEMPT
-+ bool
-+ select PREEMPT_COUNT
-+
-+config PREEMPT_RT_BASE
-+ bool
-+ select PREEMPT
-
- choice
- prompt "Preemption Model"
-@@ -35,10 +42,10 @@ config PREEMPT_VOLUNTARY
-
- Select this if you are building a kernel for a desktop system.
-
--config PREEMPT
-+config PREEMPT__LL
- bool "Preemptible Kernel (Low-Latency Desktop)"
- depends on !ARCH_NO_PREEMPT
-- select PREEMPT_COUNT
-+ select PREEMPT
- select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
- help
- This option reduces the latency of the kernel by making
-@@ -55,6 +62,14 @@ config PREEMPT
- embedded system with latency requirements in the milliseconds
- range.
-
-+config PREEMPT_RTB
-+ bool "Preemptible Kernel (Basic RT)"
-+ select PREEMPT_RT_BASE
-+ help
-+ This option is basically the same as (Low-Latency Desktop) but
-+ enables changes which are preliminary for the full preemptible
-+ RT kernel.
-+
- endchoice
-
- config PREEMPT_COUNT
diff --git a/debian/patches-rt/rt-serial-warn-fix.patch b/debian/patches-rt/rt-serial-warn-fix.patch
index 8aac64d81915..9b1615a78fac 100644
--- a/debian/patches-rt/rt-serial-warn-fix.patch
+++ b/debian/patches-rt/rt-serial-warn-fix.patch
@@ -1,7 +1,7 @@
Subject: rt: Improve the serial console PASS_LIMIT
From: Ingo Molnar <mingo@elte.hu>
Date: Wed Dec 14 13:05:54 CET 2011
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Beyond the warning:
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
-@@ -54,7 +54,16 @@ static struct uart_driver serial8250_reg
+@@ -55,7 +55,16 @@ static struct uart_driver serial8250_reg
static unsigned int skip_txen_test; /* force skip of txen test at init time */
@@ -28,7 +28,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ * so - so don't drop work spuriously and spam the
+ * syslog:
+ */
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# define PASS_LIMIT 1000000
+#else
+# define PASS_LIMIT 512
diff --git a/debian/patches-rt/rtmutex-Make-lock_killable-work.patch b/debian/patches-rt/rtmutex-Make-lock_killable-work.patch
index a5cbaef9cb30..04c091d75ce5 100644
--- a/debian/patches-rt/rtmutex-Make-lock_killable-work.patch
+++ b/debian/patches-rt/rtmutex-Make-lock_killable-work.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sat, 1 Apr 2017 12:50:59 +0200
Subject: [PATCH] rtmutex: Make lock_killable work
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Locking an rt mutex killable does not work because signal handling is
restricted to TASK_INTERRUPTIBLE.
@@ -17,7 +17,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1177,18 +1177,13 @@ static int __sched
+@@ -1200,18 +1200,13 @@ static int __sched
if (try_to_take_rt_mutex(lock, current, waiter))
break;
diff --git a/debian/patches-rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch b/debian/patches-rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch
index 5415b991f5d9..166c88ad69aa 100644
--- a/debian/patches-rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch
+++ b/debian/patches-rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 16:14:22 +0200
Subject: rtmutex: Provide rt_mutex_slowlock_locked()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This is the inner-part of rt_mutex_slowlock(), required for rwsem-rt.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1220,35 +1220,16 @@ static void rt_mutex_handle_deadlock(int
+@@ -1243,35 +1243,16 @@ static void rt_mutex_handle_deadlock(int
}
}
@@ -56,7 +56,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
set_current_state(state);
-@@ -1256,16 +1237,16 @@ rt_mutex_slowlock(struct rt_mutex *lock,
+@@ -1279,16 +1260,16 @@ rt_mutex_slowlock(struct rt_mutex *lock,
if (unlikely(timeout))
hrtimer_start_expires(&timeout->timer, HRTIMER_MODE_ABS);
@@ -77,7 +77,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -1273,6 +1254,34 @@ rt_mutex_slowlock(struct rt_mutex *lock,
+@@ -1296,6 +1277,34 @@ rt_mutex_slowlock(struct rt_mutex *lock,
* unconditionally. We might have to fix that up.
*/
fixup_rt_mutex_waiters(lock);
@@ -122,7 +122,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* This is the control structure for tasks blocked on a rt_mutex,
-@@ -156,6 +157,12 @@ extern bool __rt_mutex_futex_unlock(stru
+@@ -159,6 +160,12 @@ extern bool __rt_mutex_futex_unlock(stru
struct wake_q_head *wqh);
extern void rt_mutex_postunlock(struct wake_q_head *wake_q);
diff --git a/debian/patches-rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch b/debian/patches-rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch
index 958b10c60829..9aed58daf50a 100644
--- a/debian/patches-rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch
+++ b/debian/patches-rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 17:17:03 +0200
Subject: rtmutex: add mutex implementation based on rtmutex
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
diff --git a/debian/patches-rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch b/debian/patches-rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch
index 00d820c4dfe5..e1014bd90cbb 100644
--- a/debian/patches-rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch
+++ b/debian/patches-rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 17:18:06 +0200
Subject: rtmutex: add rwlock implementation based on rtmutex
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The implementation is bias-based, similar to the rwsem implementation.
diff --git a/debian/patches-rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch b/debian/patches-rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch
index 2f43b2206d9c..c8b1e40708b4 100644
--- a/debian/patches-rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch
+++ b/debian/patches-rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 17:28:34 +0200
Subject: rtmutex: add rwsem implementation based on rtmutex
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The RT specific R/W semaphore implementation restricts the number of readers
to one because a writer cannot block on multiple readers and inherit its
diff --git a/debian/patches-rt/rtmutex-add-sleeping-lock-implementation.patch b/debian/patches-rt/rtmutex-add-sleeping-lock-implementation.patch
index cee55a3e2f1c..91cea51f2d01 100644
--- a/debian/patches-rt/rtmutex-add-sleeping-lock-implementation.patch
+++ b/debian/patches-rt/rtmutex-add-sleeping-lock-implementation.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 17:11:19 +0200
Subject: rtmutex: add sleeping lock implementation
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
@@ -9,7 +9,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
include/linux/kernel.h | 5
include/linux/rtmutex.h | 21 +
include/linux/sched.h | 8
- include/linux/sched/wake_q.h | 15 +
+ include/linux/sched/wake_q.h | 13 +
include/linux/spinlock_rt.h | 156 +++++++++++++
include/linux/spinlock_types_rt.h | 48 ++++
kernel/fork.c | 1
@@ -17,13 +17,13 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
kernel/locking/rtmutex.c | 436 ++++++++++++++++++++++++++++++++++----
kernel/locking/rtmutex_common.h | 14 -
kernel/sched/core.c | 39 ++-
- 11 files changed, 696 insertions(+), 58 deletions(-)
+ 11 files changed, 694 insertions(+), 58 deletions(-)
create mode 100644 include/linux/spinlock_rt.h
create mode 100644 include/linux/spinlock_types_rt.h
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
-@@ -223,6 +223,10 @@ extern void __cant_sleep(const char *fil
+@@ -227,6 +227,10 @@ extern void __cant_sleep(const char *fil
*/
# define might_sleep() \
do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0)
@@ -34,14 +34,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/**
* cant_sleep - annotation for functions that cannot sleep
*
-@@ -237,6 +241,7 @@ extern void __cant_sleep(const char *fil
+@@ -258,6 +262,7 @@ extern void __cant_sleep(const char *fil
static inline void __might_sleep(const char *file, int line,
int preempt_offset) { }
# define might_sleep() do { might_resched(); } while (0)
+# define might_sleep_no_state_check() do { might_resched(); } while (0)
# define cant_sleep() do { } while (0)
# define sched_annotate_sleep() do { } while (0)
- #endif
+ # define non_block_start() do { } while (0)
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -14,11 +14,15 @@
@@ -100,7 +100,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* @lock: the mutex to be queried
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -136,6 +136,9 @@ struct task_group;
+@@ -140,6 +140,9 @@ struct task_group;
smp_store_mb(current->state, (state_value)); \
} while (0)
@@ -110,7 +110,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define set_special_state(state_value) \
do { \
unsigned long flags; /* may shadow */ \
-@@ -145,6 +148,7 @@ struct task_group;
+@@ -149,6 +152,7 @@ struct task_group;
current->state = (state_value); \
raw_spin_unlock_irqrestore(&current->pi_lock, flags); \
} while (0)
@@ -118,7 +118,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#else
/*
* set_current_state() includes a barrier so that the write of current->state
-@@ -189,6 +193,9 @@ struct task_group;
+@@ -193,6 +197,9 @@ struct task_group;
#define set_current_state(state_value) \
smp_store_mb(current->state, (state_value))
@@ -128,7 +128,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* set_special_state() should be used for those states when the blocking task
* can not use the regular condition based wait-loop. In that case we must
-@@ -910,6 +917,7 @@ struct task_struct {
+@@ -950,6 +957,7 @@ struct task_struct {
raw_spinlock_t pi_lock;
struct wake_q_node wake_q;
@@ -138,16 +138,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* PI waiters blocked on a rt_mutex held by this task: */
--- a/include/linux/sched/wake_q.h
+++ b/include/linux/sched/wake_q.h
-@@ -51,8 +51,21 @@ static inline void wake_q_init(struct wa
- head->lastp = &head->first;
- }
+@@ -58,6 +58,17 @@ static inline bool wake_q_empty(struct w
-+
extern void wake_q_add(struct wake_q_head *head, struct task_struct *task);
extern void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task);
-extern void wake_up_q(struct wake_q_head *head);
+extern void wake_q_add_sleeper(struct wake_q_head *head, struct task_struct *task);
-+
+extern void __wake_up_q(struct wake_q_head *head, bool sleeper);
+
+static inline void wake_up_q(struct wake_q_head *head)
@@ -373,7 +369,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#endif
--- a/kernel/fork.c
+++ b/kernel/fork.c
-@@ -949,6 +949,7 @@ static struct task_struct *dup_task_stru
+@@ -950,6 +950,7 @@ static struct task_struct *dup_task_stru
tsk->splice_pipe = NULL;
tsk->task_frag.page = NULL;
tsk->wake_q.next = NULL;
@@ -383,7 +379,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/futex.c
+++ b/kernel/futex.c
-@@ -1490,6 +1490,7 @@ static int wake_futex_pi(u32 __user *uad
+@@ -1556,6 +1556,7 @@ static int wake_futex_pi(u32 __user *uad
struct task_struct *new_owner;
bool postunlock = false;
DEFINE_WAKE_Q(wake_q);
@@ -391,7 +387,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int ret = 0;
new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
-@@ -1549,13 +1550,13 @@ static int wake_futex_pi(u32 __user *uad
+@@ -1615,13 +1616,13 @@ static int wake_futex_pi(u32 __user *uad
pi_state->owner = new_owner;
raw_spin_unlock(&new_owner->pi_lock);
@@ -408,7 +404,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return ret;
}
-@@ -2879,7 +2880,7 @@ static int futex_lock_pi(u32 __user *uad
+@@ -2963,7 +2964,7 @@ static int futex_lock_pi(u32 __user *uad
goto no_block;
}
@@ -417,7 +413,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* On PREEMPT_RT_FULL, when hb->lock becomes an rt_mutex, we must not
-@@ -3253,7 +3254,7 @@ static int futex_wait_requeue_pi(u32 __u
+@@ -3331,7 +3332,7 @@ static int futex_wait_requeue_pi(u32 __u
* The waiter is allocated on our stack, manipulated by the requeue
* code while we sleep on uaddr.
*/
@@ -432,15 +428,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* Copyright (C) 2005-2006 Timesys Corp., Thomas Gleixner <tglx@timesys.com>
* Copyright (C) 2005 Kihon Technologies Inc., Steven Rostedt
* Copyright (C) 2006 Esben Nielsen
-+ * Adaptive Spinlocks:
++ * Adaptive Spinlocks:
+ * Copyright (C) 2008 Novell, Inc., Gregory Haskins, Sven Dietrich,
+ * and Peter Morreale,
+ * Adaptive Spinlocks simplification:
+ * Copyright (C) 2008 Red Hat, Inc., Steven Rostedt <srostedt@redhat.com>
*
- * See Documentation/locking/rt-mutex-design.txt for details.
+ * See Documentation/locking/rt-mutex-design.rst for details.
*/
-@@ -229,7 +234,7 @@ static inline bool unlock_rt_mutex_safe(
+@@ -235,7 +240,7 @@ static inline bool unlock_rt_mutex_safe(
* Only use with rt_mutex_waiter_{less,equal}()
*/
#define task_to_waiter(p) \
@@ -449,7 +445,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline int
rt_mutex_waiter_less(struct rt_mutex_waiter *left,
-@@ -269,6 +274,27 @@ rt_mutex_waiter_equal(struct rt_mutex_wa
+@@ -275,6 +280,27 @@ rt_mutex_waiter_equal(struct rt_mutex_wa
return 1;
}
@@ -477,7 +473,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static void
rt_mutex_enqueue(struct rt_mutex *lock, struct rt_mutex_waiter *waiter)
{
-@@ -373,6 +399,14 @@ static bool rt_mutex_cond_detect_deadloc
+@@ -379,6 +405,14 @@ static bool rt_mutex_cond_detect_deadloc
return debug_rt_mutex_detect_deadlock(waiter, chwalk);
}
@@ -492,7 +488,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Max number of times we'll walk the boosting chain:
*/
-@@ -697,13 +731,16 @@ static int rt_mutex_adjust_prio_chain(st
+@@ -703,13 +737,16 @@ static int rt_mutex_adjust_prio_chain(st
* follow here. This is the end of the chain we are walking.
*/
if (!rt_mutex_owner(lock)) {
@@ -511,7 +507,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
raw_spin_unlock_irq(&lock->wait_lock);
return 0;
}
-@@ -805,9 +842,11 @@ static int rt_mutex_adjust_prio_chain(st
+@@ -810,9 +847,11 @@ static int rt_mutex_adjust_prio_chain(st
* @task: The task which wants to acquire the lock
* @waiter: The waiter that is queued to the lock's wait tree if the
* callsite called task_blocked_on_lock(), otherwise NULL
@@ -525,7 +521,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
lockdep_assert_held(&lock->wait_lock);
-@@ -843,12 +882,11 @@ static int try_to_take_rt_mutex(struct r
+@@ -848,12 +887,11 @@ static int try_to_take_rt_mutex(struct r
*/
if (waiter) {
/*
@@ -541,7 +537,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We can acquire the lock. Remove the waiter from the
* lock waiters tree.
-@@ -866,14 +904,12 @@ static int try_to_take_rt_mutex(struct r
+@@ -871,14 +909,12 @@ static int try_to_take_rt_mutex(struct r
*/
if (rt_mutex_has_waiters(lock)) {
/*
@@ -560,11 +556,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* The current top waiter stays enqueued. We
* don't have to change anything in the lock
-@@ -920,6 +956,296 @@ static int try_to_take_rt_mutex(struct r
+@@ -925,6 +961,296 @@ static int try_to_take_rt_mutex(struct r
return 1;
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+/*
+ * preemptible spin_lock functions:
+ */
@@ -845,7 +841,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+}
+EXPORT_SYMBOL(__rt_spin_lock_init);
+
-+#endif /* PREEMPT_RT_FULL */
++#endif /* PREEMPT_RT */
+
+static inline int
+try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task,
@@ -857,7 +853,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Task blocks on lock.
*
-@@ -1017,6 +1343,7 @@ static int task_blocks_on_rt_mutex(struc
+@@ -1038,6 +1364,7 @@ static int task_blocks_on_rt_mutex(struc
* Called with lock->wait_lock held and interrupts disabled.
*/
static void mark_wakeup_next_waiter(struct wake_q_head *wake_q,
@@ -865,7 +861,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
struct rt_mutex *lock)
{
struct rt_mutex_waiter *waiter;
-@@ -1056,7 +1383,10 @@ static void mark_wakeup_next_waiter(stru
+@@ -1077,7 +1404,10 @@ static void mark_wakeup_next_waiter(stru
* Pairs with preempt_enable() in rt_mutex_postunlock();
*/
preempt_disable();
@@ -877,7 +873,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
raw_spin_unlock(&current->pi_lock);
}
-@@ -1138,21 +1468,22 @@ void rt_mutex_adjust_pi(struct task_stru
+@@ -1161,21 +1491,22 @@ void rt_mutex_adjust_pi(struct task_stru
return;
}
next_lock = waiter->lock;
@@ -902,7 +898,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -1269,7 +1600,7 @@ rt_mutex_slowlock(struct rt_mutex *lock,
+@@ -1292,7 +1623,7 @@ rt_mutex_slowlock(struct rt_mutex *lock,
unsigned long flags;
int ret = 0;
@@ -911,7 +907,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Technically we could use raw_spin_[un]lock_irq() here, but this can
-@@ -1342,7 +1673,8 @@ static inline int rt_mutex_slowtrylock(s
+@@ -1365,7 +1696,8 @@ static inline int rt_mutex_slowtrylock(s
* Return whether the current task needs to call rt_mutex_postunlock().
*/
static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
@@ -921,7 +917,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
unsigned long flags;
-@@ -1396,7 +1728,7 @@ static bool __sched rt_mutex_slowunlock(
+@@ -1419,7 +1751,7 @@ static bool __sched rt_mutex_slowunlock(
*
* Queue the next waiter for wakeup once we release the wait_lock.
*/
@@ -930,7 +926,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
return true; /* call rt_mutex_postunlock() */
-@@ -1448,9 +1780,11 @@ rt_mutex_fasttrylock(struct rt_mutex *lo
+@@ -1471,9 +1803,11 @@ rt_mutex_fasttrylock(struct rt_mutex *lo
/*
* Performs the wakeup of the the top-waiter and re-enables preemption.
*/
@@ -943,7 +939,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Pairs with preempt_disable() in rt_mutex_slowunlock() */
preempt_enable();
-@@ -1459,15 +1793,17 @@ void rt_mutex_postunlock(struct wake_q_h
+@@ -1482,15 +1816,17 @@ void rt_mutex_postunlock(struct wake_q_h
static inline void
rt_mutex_fastunlock(struct rt_mutex *lock,
bool (*slowfn)(struct rt_mutex *lock,
@@ -964,7 +960,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
int __sched __rt_mutex_lock_state(struct rt_mutex *lock, int state)
-@@ -1649,16 +1985,13 @@ void __sched __rt_mutex_unlock(struct rt
+@@ -1668,16 +2004,13 @@ void __sched __rt_mutex_unlock(struct rt
void __sched rt_mutex_unlock(struct rt_mutex *lock)
{
mutex_release(&lock->dep_map, 1, _RET_IP_);
@@ -985,7 +981,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
lockdep_assert_held(&lock->wait_lock);
-@@ -1675,23 +2008,35 @@ bool __sched __rt_mutex_futex_unlock(str
+@@ -1694,23 +2027,35 @@ bool __sched __rt_mutex_futex_unlock(str
* avoid inversion prior to the wakeup. preempt_disable()
* therein pairs with rt_mutex_postunlock().
*/
@@ -1024,7 +1020,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -1730,7 +2075,7 @@ void __rt_mutex_init(struct rt_mutex *lo
+@@ -1749,7 +2094,7 @@ void __rt_mutex_init(struct rt_mutex *lo
if (name && key)
debug_rt_mutex_init(lock, name, key);
}
@@ -1033,7 +1029,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/**
* rt_mutex_init_proxy_locked - initialize and lock a rt_mutex on behalf of a
-@@ -1897,6 +2242,7 @@ int rt_mutex_wait_proxy_lock(struct rt_m
+@@ -1944,6 +2289,7 @@ int rt_mutex_wait_proxy_lock(struct rt_m
struct hrtimer_sleeper *to,
struct rt_mutex_waiter *waiter)
{
@@ -1041,7 +1037,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
int ret;
raw_spin_lock_irq(&lock->wait_lock);
-@@ -1908,6 +2254,24 @@ int rt_mutex_wait_proxy_lock(struct rt_m
+@@ -1955,6 +2301,24 @@ int rt_mutex_wait_proxy_lock(struct rt_m
* have to fix that up.
*/
fixup_rt_mutex_waiters(lock);
@@ -1076,7 +1072,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#ifdef CONFIG_DEBUG_RT_MUTEXES
unsigned long ip;
struct pid *deadlock_task_pid;
-@@ -136,7 +137,7 @@ extern void rt_mutex_init_proxy_locked(s
+@@ -139,7 +140,7 @@ extern void rt_mutex_init_proxy_locked(s
struct task_struct *proxy_owner);
extern void rt_mutex_proxy_unlock(struct rt_mutex *lock,
struct task_struct *proxy_owner);
@@ -1085,7 +1081,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
extern int __rt_mutex_start_proxy_lock(struct rt_mutex *lock,
struct rt_mutex_waiter *waiter,
struct task_struct *task);
-@@ -154,9 +155,12 @@ extern int __rt_mutex_futex_trylock(stru
+@@ -157,9 +158,12 @@ extern int __rt_mutex_futex_trylock(stru
extern void rt_mutex_futex_unlock(struct rt_mutex *lock);
extern bool __rt_mutex_futex_unlock(struct rt_mutex *lock,
@@ -1100,7 +1096,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* RW semaphore special interface */
extern int __rt_mutex_lock_state(struct rt_mutex *lock, int state);
-@@ -166,6 +170,10 @@ int __sched rt_mutex_slowlock_locked(str
+@@ -169,6 +173,10 @@ int __sched rt_mutex_slowlock_locked(str
struct hrtimer_sleeper *timeout,
enum rtmutex_chainwalk chwalk,
struct rt_mutex_waiter *waiter);
@@ -1113,7 +1109,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
# include "rtmutex-debug.h"
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -403,9 +403,15 @@ static bool set_nr_if_polling(struct tas
+@@ -414,9 +414,15 @@ static bool set_nr_if_polling(struct tas
#endif
#endif
@@ -1131,7 +1127,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Atomically grab the task, if ->wake_q is !nil already it means
-@@ -441,7 +447,13 @@ static bool __wake_q_add(struct wake_q_h
+@@ -452,7 +458,13 @@ static bool __wake_q_add(struct wake_q_h
*/
void wake_q_add(struct wake_q_head *head, struct task_struct *task)
{
@@ -1146,7 +1142,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
get_task_struct(task);
}
-@@ -464,28 +476,39 @@ void wake_q_add(struct wake_q_head *head
+@@ -475,28 +487,39 @@ void wake_q_add(struct wake_q_head *head
*/
void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task)
{
diff --git a/debian/patches-rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch b/debian/patches-rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch
index a65963895496..fad1fdd21c90 100644
--- a/debian/patches-rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch
+++ b/debian/patches-rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 12 Oct 2017 17:34:38 +0200
Subject: rtmutex: add ww_mutex addon for mutex-rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
@@ -20,11 +20,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include "rtmutex_common.h"
-@@ -1239,6 +1240,40 @@ EXPORT_SYMBOL(__rt_spin_lock_init);
+@@ -1244,6 +1245,40 @@ EXPORT_SYMBOL(__rt_spin_lock_init);
- #endif /* PREEMPT_RT_FULL */
+ #endif /* PREEMPT_RT */
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ static inline int __sched
+__mutex_lock_check_stamp(struct rt_mutex *lock, struct ww_acquire_ctx *ctx)
+{
@@ -61,7 +61,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline int
try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task,
struct rt_mutex_waiter *waiter)
-@@ -1499,7 +1534,8 @@ void rt_mutex_init_waiter(struct rt_mute
+@@ -1522,7 +1557,8 @@ void rt_mutex_init_waiter(struct rt_mute
static int __sched
__rt_mutex_slowlock(struct rt_mutex *lock, int state,
struct hrtimer_sleeper *timeout,
@@ -71,7 +71,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
int ret = 0;
-@@ -1517,6 +1553,12 @@ static int __sched
+@@ -1540,6 +1576,12 @@ static int __sched
break;
}
@@ -84,7 +84,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
raw_spin_unlock_irq(&lock->wait_lock);
debug_rt_mutex_print_deadlock(waiter);
-@@ -1551,16 +1593,106 @@ static void rt_mutex_handle_deadlock(int
+@@ -1574,16 +1616,106 @@ static void rt_mutex_handle_deadlock(int
}
}
@@ -128,7 +128,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ ww_ctx->acquired++;
+}
+
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+static void ww_mutex_account_lock(struct rt_mutex *lock,
+ struct ww_acquire_ctx *ww_ctx)
+{
@@ -172,7 +172,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
int ret;
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (ww_ctx) {
+ struct ww_mutex *ww;
+
@@ -192,7 +192,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
set_current_state(state);
-@@ -1570,14 +1702,24 @@ int __sched rt_mutex_slowlock_locked(str
+@@ -1593,14 +1725,24 @@ int __sched rt_mutex_slowlock_locked(str
ret = task_blocks_on_rt_mutex(lock, waiter, current, chwalk);
@@ -220,7 +220,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/*
-@@ -1594,7 +1736,8 @@ int __sched rt_mutex_slowlock_locked(str
+@@ -1617,7 +1759,8 @@ int __sched rt_mutex_slowlock_locked(str
static int __sched
rt_mutex_slowlock(struct rt_mutex *lock, int state,
struct hrtimer_sleeper *timeout,
@@ -230,7 +230,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
struct rt_mutex_waiter waiter;
unsigned long flags;
-@@ -1612,7 +1755,8 @@ rt_mutex_slowlock(struct rt_mutex *lock,
+@@ -1635,7 +1778,8 @@ rt_mutex_slowlock(struct rt_mutex *lock,
*/
raw_spin_lock_irqsave(&lock->wait_lock, flags);
@@ -240,7 +240,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
-@@ -1742,29 +1886,33 @@ static bool __sched rt_mutex_slowunlock(
+@@ -1765,29 +1909,33 @@ static bool __sched rt_mutex_slowunlock(
*/
static inline int
rt_mutex_fastlock(struct rt_mutex *lock, int state,
@@ -278,7 +278,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
static inline int
-@@ -1809,7 +1957,7 @@ rt_mutex_fastunlock(struct rt_mutex *loc
+@@ -1832,7 +1980,7 @@ rt_mutex_fastunlock(struct rt_mutex *loc
int __sched __rt_mutex_lock_state(struct rt_mutex *lock, int state)
{
might_sleep();
@@ -287,7 +287,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
/**
-@@ -1929,6 +2077,7 @@ rt_mutex_timed_lock(struct rt_mutex *loc
+@@ -1952,6 +2100,7 @@ rt_mutex_timed_lock(struct rt_mutex *loc
mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_);
ret = rt_mutex_timed_fastlock(lock, TASK_INTERRUPTIBLE, timeout,
RT_MUTEX_MIN_CHAINWALK,
@@ -295,7 +295,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
rt_mutex_slowlock);
if (ret)
mutex_release(&lock->dep_map, 1, _RET_IP_);
-@@ -2248,7 +2397,7 @@ int rt_mutex_wait_proxy_lock(struct rt_m
+@@ -2321,7 +2470,7 @@ int rt_mutex_wait_proxy_lock(struct rt_m
raw_spin_lock_irq(&lock->wait_lock);
/* sleep on the mutex */
set_current_state(TASK_INTERRUPTIBLE);
@@ -304,7 +304,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* try_to_take_rt_mutex() sets the waiter bit unconditionally. We might
* have to fix that up.
-@@ -2333,3 +2482,99 @@ bool rt_mutex_cleanup_proxy_lock(struct
+@@ -2391,3 +2540,99 @@ bool rt_mutex_cleanup_proxy_lock(struct
return cleanup;
}
@@ -335,7 +335,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ return 0;
+}
+
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+int __sched
+ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
+{
@@ -406,7 +406,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#endif
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
-@@ -162,6 +162,7 @@ extern void rt_mutex_postunlock(struct w
+@@ -165,6 +165,7 @@ extern void rt_mutex_postunlock(struct w
struct wake_q_head *wake_sleeper_q);
/* RW semaphore special interface */
@@ -414,7 +414,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
extern int __rt_mutex_lock_state(struct rt_mutex *lock, int state);
extern int __rt_mutex_trylock(struct rt_mutex *lock);
-@@ -169,6 +170,7 @@ extern void __rt_mutex_unlock(struct rt_
+@@ -172,6 +173,7 @@ extern void __rt_mutex_unlock(struct rt_
int __sched rt_mutex_slowlock_locked(struct rt_mutex *lock, int state,
struct hrtimer_sleeper *timeout,
enum rtmutex_chainwalk chwalk,
diff --git a/debian/patches-rt/rtmutex-annotate-sleeping-lock-context.patch b/debian/patches-rt/rtmutex-annotate-sleeping-lock-context.patch
deleted file mode 100644
index 765d7f10b82c..000000000000
--- a/debian/patches-rt/rtmutex-annotate-sleeping-lock-context.patch
+++ /dev/null
@@ -1,294 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Thu, 21 Sep 2017 14:25:13 +0200
-Subject: [PATCH] rtmutex: annotate sleeping lock context
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The RCU code complains on schedule() within a rcu_readlock() section.
-The valid scenario on -RT is if a sleeping is held. In order to suppress
-the warning the mirgrate_disable counter was used to identify the
-invocation of schedule() due to lock contention.
-
-Grygorii Strashko report that during CPU hotplug we might see the
-warning via
- rt_spin_lock() -> migrate_disable() -> pin_current_cpu() -> __read_rt_lock()
-
-because the counter is not yet set.
-It is also possible to trigger the warning from cpu_chill()
-(seen on a kblockd_mod_delayed_work_on() caller).
-
-To address this RCU warning I annotate the sleeping lock context. The
-counter is incremented before migrate_disable() so the warning Grygorii
-should not trigger anymore. Additionally I use that counter in
-cpu_chill() to avoid the RCU warning from there.
-
-Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/preempt.h | 9 +++++++++
- include/linux/sched.h | 26 ++++++++++++++++++++++++++
- kernel/locking/rtmutex.c | 12 ++++++++++--
- kernel/locking/rwlock-rt.c | 18 ++++++++++++++----
- kernel/rcu/tree_plugin.h | 6 +++++-
- kernel/sched/core.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
- 6 files changed, 109 insertions(+), 7 deletions(-)
-
---- a/include/linux/preempt.h
-+++ b/include/linux/preempt.h
-@@ -208,6 +208,15 @@ extern void migrate_enable(void);
-
- int __migrate_disabled(struct task_struct *p);
-
-+#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-+
-+extern void migrate_disable(void);
-+extern void migrate_enable(void);
-+static inline int __migrate_disabled(struct task_struct *p)
-+{
-+ return 0;
-+}
-+
- #else
- #define migrate_disable() barrier()
- #define migrate_enable() barrier()
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -664,6 +664,15 @@ struct task_struct {
- # ifdef CONFIG_SCHED_DEBUG
- int migrate_disable_atomic;
- # endif
-+
-+#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-+ int migrate_disable;
-+# ifdef CONFIG_SCHED_DEBUG
-+ int migrate_disable_atomic;
-+# endif
-+#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ int sleeping_lock;
- #endif
-
- #ifdef CONFIG_PREEMPT_RCU
-@@ -1824,6 +1833,23 @@ static __always_inline bool need_resched
- return unlikely(tif_need_resched());
- }
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+static inline void sleeping_lock_inc(void)
-+{
-+ current->sleeping_lock++;
-+}
-+
-+static inline void sleeping_lock_dec(void)
-+{
-+ current->sleeping_lock--;
-+}
-+
-+#else
-+
-+static inline void sleeping_lock_inc(void) { }
-+static inline void sleeping_lock_dec(void) { }
-+#endif
-+
- /*
- * Wrappers for p->thread_info->cpu access. No-op on UP.
- */
---- a/kernel/locking/rtmutex.c
-+++ b/kernel/locking/rtmutex.c
-@@ -1135,6 +1135,7 @@ void __sched rt_spin_lock_slowunlock(str
-
- void __lockfunc rt_spin_lock(spinlock_t *lock)
- {
-+ sleeping_lock_inc();
- migrate_disable();
- spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
- rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
-@@ -1149,6 +1150,7 @@ void __lockfunc __rt_spin_lock(struct rt
- #ifdef CONFIG_DEBUG_LOCK_ALLOC
- void __lockfunc rt_spin_lock_nested(spinlock_t *lock, int subclass)
- {
-+ sleeping_lock_inc();
- migrate_disable();
- spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
- rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
-@@ -1162,6 +1164,7 @@ void __lockfunc rt_spin_unlock(spinlock_
- spin_release(&lock->dep_map, 1, _RET_IP_);
- rt_spin_lock_fastunlock(&lock->lock, rt_spin_lock_slowunlock);
- migrate_enable();
-+ sleeping_lock_dec();
- }
- EXPORT_SYMBOL(rt_spin_unlock);
-
-@@ -1187,12 +1190,15 @@ int __lockfunc rt_spin_trylock(spinlock_
- {
- int ret;
-
-+ sleeping_lock_inc();
- migrate_disable();
- ret = __rt_mutex_trylock(&lock->lock);
-- if (ret)
-+ if (ret) {
- spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
-- else
-+ } else {
- migrate_enable();
-+ sleeping_lock_dec();
-+ }
- return ret;
- }
- EXPORT_SYMBOL(rt_spin_trylock);
-@@ -1204,6 +1210,7 @@ int __lockfunc rt_spin_trylock_bh(spinlo
- local_bh_disable();
- ret = __rt_mutex_trylock(&lock->lock);
- if (ret) {
-+ sleeping_lock_inc();
- migrate_disable();
- spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
- } else
-@@ -1219,6 +1226,7 @@ int __lockfunc rt_spin_trylock_irqsave(s
- *flags = 0;
- ret = __rt_mutex_trylock(&lock->lock);
- if (ret) {
-+ sleeping_lock_inc();
- migrate_disable();
- spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
- }
---- a/kernel/locking/rwlock-rt.c
-+++ b/kernel/locking/rwlock-rt.c
-@@ -305,12 +305,15 @@ int __lockfunc rt_read_trylock(rwlock_t
- {
- int ret;
-
-+ sleeping_lock_inc();
- migrate_disable();
- ret = do_read_rt_trylock(rwlock);
-- if (ret)
-+ if (ret) {
- rwlock_acquire_read(&rwlock->dep_map, 0, 1, _RET_IP_);
-- else
-+ } else {
- migrate_enable();
-+ sleeping_lock_dec();
-+ }
- return ret;
- }
- EXPORT_SYMBOL(rt_read_trylock);
-@@ -319,18 +322,22 @@ int __lockfunc rt_write_trylock(rwlock_t
- {
- int ret;
-
-+ sleeping_lock_inc();
- migrate_disable();
- ret = do_write_rt_trylock(rwlock);
-- if (ret)
-+ if (ret) {
- rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_);
-- else
-+ } else {
- migrate_enable();
-+ sleeping_lock_dec();
-+ }
- return ret;
- }
- EXPORT_SYMBOL(rt_write_trylock);
-
- void __lockfunc rt_read_lock(rwlock_t *rwlock)
- {
-+ sleeping_lock_inc();
- migrate_disable();
- rwlock_acquire_read(&rwlock->dep_map, 0, 0, _RET_IP_);
- do_read_rt_lock(rwlock);
-@@ -339,6 +346,7 @@ EXPORT_SYMBOL(rt_read_lock);
-
- void __lockfunc rt_write_lock(rwlock_t *rwlock)
- {
-+ sleeping_lock_inc();
- migrate_disable();
- rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_);
- do_write_rt_lock(rwlock);
-@@ -350,6 +358,7 @@ void __lockfunc rt_read_unlock(rwlock_t
- rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
- do_read_rt_unlock(rwlock);
- migrate_enable();
-+ sleeping_lock_dec();
- }
- EXPORT_SYMBOL(rt_read_unlock);
-
-@@ -358,6 +367,7 @@ void __lockfunc rt_write_unlock(rwlock_t
- rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
- do_write_rt_unlock(rwlock);
- migrate_enable();
-+ sleeping_lock_dec();
- }
- EXPORT_SYMBOL(rt_write_unlock);
-
---- a/kernel/rcu/tree_plugin.h
-+++ b/kernel/rcu/tree_plugin.h
-@@ -307,11 +307,15 @@ void rcu_note_context_switch(bool preemp
- struct task_struct *t = current;
- struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
- struct rcu_node *rnp;
-+ int sleeping_l = 0;
-
- barrier(); /* Avoid RCU read-side critical sections leaking down. */
- trace_rcu_utilization(TPS("Start context switch"));
- lockdep_assert_irqs_disabled();
-- WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0);
-+#if defined(CONFIG_PREEMPT_RT_FULL)
-+ sleeping_l = t->sleeping_lock;
-+#endif
-+ WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0 && !sleeping_l);
- if (t->rcu_read_lock_nesting > 0 &&
- !t->rcu_read_unlock_special.b.blocked) {
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7326,4 +7326,49 @@ void migrate_enable(void)
- preempt_enable();
- }
- EXPORT_SYMBOL(migrate_enable);
-+
-+#elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-+void migrate_disable(void)
-+{
-+ struct task_struct *p = current;
-+
-+ if (in_atomic() || irqs_disabled()) {
-+#ifdef CONFIG_SCHED_DEBUG
-+ p->migrate_disable_atomic++;
-+#endif
-+ return;
-+ }
-+#ifdef CONFIG_SCHED_DEBUG
-+ if (unlikely(p->migrate_disable_atomic)) {
-+ tracing_off();
-+ WARN_ON_ONCE(1);
-+ }
-+#endif
-+
-+ p->migrate_disable++;
-+}
-+EXPORT_SYMBOL(migrate_disable);
-+
-+void migrate_enable(void)
-+{
-+ struct task_struct *p = current;
-+
-+ if (in_atomic() || irqs_disabled()) {
-+#ifdef CONFIG_SCHED_DEBUG
-+ p->migrate_disable_atomic--;
-+#endif
-+ return;
-+ }
-+
-+#ifdef CONFIG_SCHED_DEBUG
-+ if (unlikely(p->migrate_disable_atomic)) {
-+ tracing_off();
-+ WARN_ON_ONCE(1);
-+ }
-+#endif
-+
-+ WARN_ON_ONCE(p->migrate_disable <= 0);
-+ p->migrate_disable--;
-+}
-+EXPORT_SYMBOL(migrate_enable);
- #endif
diff --git a/debian/patches-rt/rtmutex-avoid-include-hell.patch b/debian/patches-rt/rtmutex-avoid-include-hell.patch
index 2c7cf6995329..aefc7c5d33be 100644
--- a/debian/patches-rt/rtmutex-avoid-include-hell.patch
+++ b/debian/patches-rt/rtmutex-avoid-include-hell.patch
@@ -1,7 +1,7 @@
Subject: rtmutex: Avoid include hell
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 29 Jun 2011 20:06:39 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Include only the required raw types. This avoids pulling in the
complete spinlock header which in turn requires rtmutex.h at some point.
diff --git a/debian/patches-rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch b/debian/patches-rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch
index 2d4031d6bad1..3a5a37c0403c 100644
--- a/debian/patches-rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch
+++ b/debian/patches-rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch
@@ -2,20 +2,20 @@ From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 16:36:39 +0200
Subject: rtmutex: export lockdep-less version of rt_mutex's lock,
trylock and unlock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Required for lock implementation ontop of rtmutex.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/locking/rtmutex.c | 67 +++++++++++++++++++++++++---------------
- kernel/locking/rtmutex_common.h | 3 +
- 2 files changed, 46 insertions(+), 24 deletions(-)
+ kernel/locking/rtmutex.c | 59 ++++++++++++++++++++++++++--------------
+ kernel/locking/rtmutex_common.h | 3 ++
+ 2 files changed, 42 insertions(+), 20 deletions(-)
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1470,12 +1470,33 @@ rt_mutex_fastunlock(struct rt_mutex *loc
+@@ -1493,12 +1493,33 @@ rt_mutex_fastunlock(struct rt_mutex *loc
rt_mutex_postunlock(&wake_q);
}
@@ -51,7 +51,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
#ifdef CONFIG_DEBUG_LOCK_ALLOC
-@@ -1516,16 +1537,7 @@ EXPORT_SYMBOL_GPL(rt_mutex_lock);
+@@ -1539,16 +1560,7 @@ EXPORT_SYMBOL_GPL(rt_mutex_lock);
*/
int __sched rt_mutex_lock_interruptible(struct rt_mutex *lock)
{
@@ -69,7 +69,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
EXPORT_SYMBOL_GPL(rt_mutex_lock_interruptible);
-@@ -1551,13 +1563,10 @@ int __sched __rt_mutex_futex_trylock(str
+@@ -1574,13 +1586,10 @@ int __sched __rt_mutex_futex_trylock(str
* Returns:
* 0 on success
* -EINTR when interrupted by a signal
@@ -84,17 +84,13 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
EXPORT_SYMBOL_GPL(rt_mutex_lock_killable);
-@@ -1592,6 +1601,18 @@ rt_mutex_timed_lock(struct rt_mutex *loc
+@@ -1615,6 +1624,14 @@ rt_mutex_timed_lock(struct rt_mutex *loc
}
EXPORT_SYMBOL_GPL(rt_mutex_timed_lock);
+int __sched __rt_mutex_trylock(struct rt_mutex *lock)
+{
-+#ifdef CONFIG_PREEMPT_RT_FULL
-+ if (WARN_ON_ONCE(in_irq() || in_nmi()))
-+#else
+ if (WARN_ON_ONCE(in_irq() || in_nmi() || in_serving_softirq()))
-+#endif
+ return 0;
+
+ return rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
@@ -103,15 +99,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/**
* rt_mutex_trylock - try to lock a rt_mutex
*
-@@ -1607,14 +1628,7 @@ int __sched rt_mutex_trylock(struct rt_m
+@@ -1630,10 +1647,7 @@ int __sched rt_mutex_trylock(struct rt_m
{
int ret;
--#ifdef CONFIG_PREEMPT_RT_FULL
-- if (WARN_ON_ONCE(in_irq() || in_nmi()))
--#else
- if (WARN_ON_ONCE(in_irq() || in_nmi() || in_serving_softirq()))
--#endif
- return 0;
-
- ret = rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
@@ -119,7 +111,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
if (ret)
mutex_acquire(&lock->dep_map, 0, 1, _RET_IP_);
-@@ -1622,6 +1636,11 @@ int __sched rt_mutex_trylock(struct rt_m
+@@ -1641,6 +1655,11 @@ int __sched rt_mutex_trylock(struct rt_m
}
EXPORT_SYMBOL_GPL(rt_mutex_trylock);
@@ -133,7 +125,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*
--- a/kernel/locking/rtmutex_common.h
+++ b/kernel/locking/rtmutex_common.h
-@@ -159,6 +159,9 @@ extern bool __rt_mutex_futex_unlock(stru
+@@ -162,6 +162,9 @@ extern bool __rt_mutex_futex_unlock(stru
extern void rt_mutex_postunlock(struct wake_q_head *wake_q);
/* RW semaphore special interface */
diff --git a/debian/patches-rt/rtmutex-futex-prepare-rt.patch b/debian/patches-rt/rtmutex-futex-prepare-rt.patch
new file mode 100644
index 000000000000..e39f7be7a561
--- /dev/null
+++ b/debian/patches-rt/rtmutex-futex-prepare-rt.patch
@@ -0,0 +1,245 @@
+Subject: rtmutex: Handle the various new futex race conditions
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 10 Jun 2011 11:04:15 +0200
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+RT opens a few new interesting race conditions in the rtmutex/futex
+combo due to futex hash bucket lock being a 'sleeping' spinlock and
+therefor not disabling preemption.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+---
+ kernel/futex.c | 77 ++++++++++++++++++++++++++++++++--------
+ kernel/locking/rtmutex.c | 36 +++++++++++++++---
+ kernel/locking/rtmutex_common.h | 2 +
+ 3 files changed, 94 insertions(+), 21 deletions(-)
+
+--- a/kernel/futex.c
++++ b/kernel/futex.c
+@@ -2243,6 +2243,16 @@ static int futex_requeue(u32 __user *uad
+ requeue_pi_wake_futex(this, &key2, hb2);
+ drop_count++;
+ continue;
++ } else if (ret == -EAGAIN) {
++ /*
++ * Waiter was woken by timeout or
++ * signal and has set pi_blocked_on to
++ * PI_WAKEUP_INPROGRESS before we
++ * tried to enqueue it on the rtmutex.
++ */
++ this->pi_state = NULL;
++ put_pi_state(pi_state);
++ continue;
+ } else if (ret) {
+ /*
+ * rt_mutex_start_proxy_lock() detected a
+@@ -3298,7 +3308,7 @@ static int futex_wait_requeue_pi(u32 __u
+ struct hrtimer_sleeper timeout, *to;
+ struct futex_pi_state *pi_state = NULL;
+ struct rt_mutex_waiter rt_waiter;
+- struct futex_hash_bucket *hb;
++ struct futex_hash_bucket *hb, *hb2;
+ union futex_key key2 = FUTEX_KEY_INIT;
+ struct futex_q q = futex_q_init;
+ int res, ret;
+@@ -3350,20 +3360,55 @@ static int futex_wait_requeue_pi(u32 __u
+ /* Queue the futex_q, drop the hb lock, wait for wakeup. */
+ futex_wait_queue_me(hb, &q, to);
+
+- spin_lock(&hb->lock);
+- ret = handle_early_requeue_pi_wakeup(hb, &q, &key2, to);
+- spin_unlock(&hb->lock);
+- if (ret)
+- goto out_put_keys;
++ /*
++ * On RT we must avoid races with requeue and trying to block
++ * on two mutexes (hb->lock and uaddr2's rtmutex) by
++ * serializing access to pi_blocked_on with pi_lock.
++ */
++ raw_spin_lock_irq(&current->pi_lock);
++ if (current->pi_blocked_on) {
++ /*
++ * We have been requeued or are in the process of
++ * being requeued.
++ */
++ raw_spin_unlock_irq(&current->pi_lock);
++ } else {
++ /*
++ * Setting pi_blocked_on to PI_WAKEUP_INPROGRESS
++ * prevents a concurrent requeue from moving us to the
++ * uaddr2 rtmutex. After that we can safely acquire
++ * (and possibly block on) hb->lock.
++ */
++ current->pi_blocked_on = PI_WAKEUP_INPROGRESS;
++ raw_spin_unlock_irq(&current->pi_lock);
++
++ spin_lock(&hb->lock);
++
++ /*
++ * Clean up pi_blocked_on. We might leak it otherwise
++ * when we succeeded with the hb->lock in the fast
++ * path.
++ */
++ raw_spin_lock_irq(&current->pi_lock);
++ current->pi_blocked_on = NULL;
++ raw_spin_unlock_irq(&current->pi_lock);
++
++ ret = handle_early_requeue_pi_wakeup(hb, &q, &key2, to);
++ spin_unlock(&hb->lock);
++ if (ret)
++ goto out_put_keys;
++ }
+
+ /*
+- * In order for us to be here, we know our q.key == key2, and since
+- * we took the hb->lock above, we also know that futex_requeue() has
+- * completed and we no longer have to concern ourselves with a wakeup
+- * race with the atomic proxy lock acquisition by the requeue code. The
+- * futex_requeue dropped our key1 reference and incremented our key2
+- * reference count.
++ * In order to be here, we have either been requeued, are in
++ * the process of being requeued, or requeue successfully
++ * acquired uaddr2 on our behalf. If pi_blocked_on was
++ * non-null above, we may be racing with a requeue. Do not
++ * rely on q->lock_ptr to be hb2->lock until after blocking on
++ * hb->lock or hb2->lock. The futex_requeue dropped our key1
++ * reference and incremented our key2 reference count.
+ */
++ hb2 = hash_futex(&key2);
+
+ /* Check if the requeue code acquired the second futex for us. */
+ if (!q.rt_waiter) {
+@@ -3372,7 +3417,8 @@ static int futex_wait_requeue_pi(u32 __u
+ * did a lock-steal - fix up the PI-state in that case.
+ */
+ if (q.pi_state && (q.pi_state->owner != current)) {
+- spin_lock(q.lock_ptr);
++ spin_lock(&hb2->lock);
++ BUG_ON(&hb2->lock != q.lock_ptr);
+ ret = fixup_pi_state_owner(uaddr2, &q, current);
+ if (ret && rt_mutex_owner(&q.pi_state->pi_mutex) == current) {
+ pi_state = q.pi_state;
+@@ -3383,7 +3429,7 @@ static int futex_wait_requeue_pi(u32 __u
+ * the requeue_pi() code acquired for us.
+ */
+ put_pi_state(q.pi_state);
+- spin_unlock(q.lock_ptr);
++ spin_unlock(&hb2->lock);
+ }
+ } else {
+ struct rt_mutex *pi_mutex;
+@@ -3397,7 +3443,8 @@ static int futex_wait_requeue_pi(u32 __u
+ pi_mutex = &q.pi_state->pi_mutex;
+ ret = rt_mutex_wait_proxy_lock(pi_mutex, to, &rt_waiter);
+
+- spin_lock(q.lock_ptr);
++ spin_lock(&hb2->lock);
++ BUG_ON(&hb2->lock != q.lock_ptr);
+ if (ret && !rt_mutex_cleanup_proxy_lock(pi_mutex, &rt_waiter))
+ ret = 0;
+
+--- a/kernel/locking/rtmutex.c
++++ b/kernel/locking/rtmutex.c
+@@ -136,6 +136,11 @@ static void fixup_rt_mutex_waiters(struc
+ WRITE_ONCE(*p, owner & ~RT_MUTEX_HAS_WAITERS);
+ }
+
++static int rt_mutex_real_waiter(struct rt_mutex_waiter *waiter)
++{
++ return waiter && waiter != PI_WAKEUP_INPROGRESS;
++}
++
+ /*
+ * We can speed up the acquire/release, if there's no debugging state to be
+ * set up.
+@@ -380,7 +385,8 @@ int max_lock_depth = 1024;
+
+ static inline struct rt_mutex *task_blocked_on_lock(struct task_struct *p)
+ {
+- return p->pi_blocked_on ? p->pi_blocked_on->lock : NULL;
++ return rt_mutex_real_waiter(p->pi_blocked_on) ?
++ p->pi_blocked_on->lock : NULL;
+ }
+
+ /*
+@@ -516,7 +522,7 @@ static int rt_mutex_adjust_prio_chain(st
+ * reached or the state of the chain has changed while we
+ * dropped the locks.
+ */
+- if (!waiter)
++ if (!rt_mutex_real_waiter(waiter))
+ goto out_unlock_pi;
+
+ /*
+@@ -950,6 +956,22 @@ static int task_blocks_on_rt_mutex(struc
+ return -EDEADLK;
+
+ raw_spin_lock(&task->pi_lock);
++ /*
++ * In the case of futex requeue PI, this will be a proxy
++ * lock. The task will wake unaware that it is enqueueed on
++ * this lock. Avoid blocking on two locks and corrupting
++ * pi_blocked_on via the PI_WAKEUP_INPROGRESS
++ * flag. futex_wait_requeue_pi() sets this when it wakes up
++ * before requeue (due to a signal or timeout). Do not enqueue
++ * the task if PI_WAKEUP_INPROGRESS is set.
++ */
++ if (task != current && task->pi_blocked_on == PI_WAKEUP_INPROGRESS) {
++ raw_spin_unlock(&task->pi_lock);
++ return -EAGAIN;
++ }
++
++ BUG_ON(rt_mutex_real_waiter(task->pi_blocked_on));
++
+ waiter->task = task;
+ waiter->lock = lock;
+ waiter->prio = task->prio;
+@@ -973,7 +995,7 @@ static int task_blocks_on_rt_mutex(struc
+ rt_mutex_enqueue_pi(owner, waiter);
+
+ rt_mutex_adjust_prio(owner);
+- if (owner->pi_blocked_on)
++ if (rt_mutex_real_waiter(owner->pi_blocked_on))
+ chain_walk = 1;
+ } else if (rt_mutex_cond_detect_deadlock(waiter, chwalk)) {
+ chain_walk = 1;
+@@ -1069,7 +1091,7 @@ static void remove_waiter(struct rt_mute
+ {
+ bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock));
+ struct task_struct *owner = rt_mutex_owner(lock);
+- struct rt_mutex *next_lock;
++ struct rt_mutex *next_lock = NULL;
+
+ lockdep_assert_held(&lock->wait_lock);
+
+@@ -1095,7 +1117,8 @@ static void remove_waiter(struct rt_mute
+ rt_mutex_adjust_prio(owner);
+
+ /* Store the lock on which owner is blocked or NULL */
+- next_lock = task_blocked_on_lock(owner);
++ if (rt_mutex_real_waiter(owner->pi_blocked_on))
++ next_lock = task_blocked_on_lock(owner);
+
+ raw_spin_unlock(&owner->pi_lock);
+
+@@ -1131,7 +1154,8 @@ void rt_mutex_adjust_pi(struct task_stru
+ raw_spin_lock_irqsave(&task->pi_lock, flags);
+
+ waiter = task->pi_blocked_on;
+- if (!waiter || rt_mutex_waiter_equal(waiter, task_to_waiter(task))) {
++ if (!rt_mutex_real_waiter(waiter) ||
++ rt_mutex_waiter_equal(waiter, task_to_waiter(task))) {
+ raw_spin_unlock_irqrestore(&task->pi_lock, flags);
+ return;
+ }
+--- a/kernel/locking/rtmutex_common.h
++++ b/kernel/locking/rtmutex_common.h
+@@ -130,6 +130,8 @@ enum rtmutex_chainwalk {
+ /*
+ * PI-futex support (proxy locking functions, etc.):
+ */
++#define PI_WAKEUP_INPROGRESS ((struct rt_mutex_waiter *) 1)
++
+ extern struct task_struct *rt_mutex_next_owner(struct rt_mutex *lock);
+ extern void rt_mutex_init_proxy_locked(struct rt_mutex *lock,
+ struct task_struct *proxy_owner);
diff --git a/debian/patches-rt/rtmutex-lock-killable.patch b/debian/patches-rt/rtmutex-lock-killable.patch
index be067b5092b7..1ad45535a293 100644
--- a/debian/patches-rt/rtmutex-lock-killable.patch
+++ b/debian/patches-rt/rtmutex-lock-killable.patch
@@ -1,7 +1,7 @@
Subject: rtmutex: Add rtmutex_lock_killable()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 09 Jun 2011 11:43:52 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add "killable" type to rtmutex. We need this since rtmutex are used as
"normal" mutexes which do use this type.
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1539,6 +1539,25 @@ int __sched __rt_mutex_futex_trylock(str
+@@ -1562,6 +1562,25 @@ int __sched __rt_mutex_futex_trylock(str
}
/**
diff --git a/debian/patches-rt/rtmutex-trylock-is-okay-on-RT.patch b/debian/patches-rt/rtmutex-trylock-is-okay-on-RT.patch
index 2cde367e7ad2..18a751b052d4 100644
--- a/debian/patches-rt/rtmutex-trylock-is-okay-on-RT.patch
+++ b/debian/patches-rt/rtmutex-trylock-is-okay-on-RT.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed 02 Dec 2015 11:34:07 +0100
Subject: rtmutex: trylock is okay on -RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
non-RT kernel could deadlock on rt_mutex_trylock() in softirq context. On
-RT we don't run softirqs in IRQ context but in thread context so it is
@@ -14,15 +14,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1584,7 +1584,11 @@ int __sched rt_mutex_trylock(struct rt_m
- {
- int ret;
+@@ -1962,7 +1962,11 @@ EXPORT_SYMBOL_GPL(rt_mutex_timed_lock);
-+#ifdef CONFIG_PREEMPT_RT_FULL
+ int __sched __rt_mutex_trylock(struct rt_mutex *lock)
+ {
++#ifdef CONFIG_PREEMPT_RT
+ if (WARN_ON_ONCE(in_irq() || in_nmi()))
+#else
if (WARN_ON_ONCE(in_irq() || in_nmi() || in_serving_softirq()))
+#endif
return 0;
- ret = rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
+ return rt_mutex_fasttrylock(lock, rt_mutex_slowtrylock);
diff --git a/debian/patches-rt/rtmutex-wire-up-RT-s-locking.patch b/debian/patches-rt/rtmutex-wire-up-RT-s-locking.patch
index 01f1d9b70ece..29efb5146f74 100644
--- a/debian/patches-rt/rtmutex-wire-up-RT-s-locking.patch
+++ b/debian/patches-rt/rtmutex-wire-up-RT-s-locking.patch
@@ -1,22 +1,43 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 12 Oct 2017 17:31:14 +0200
Subject: rtmutex: wire up RT's locking
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
+ include/Kbuild | 7 +++++++
include/linux/mutex.h | 20 +++++++++++++-------
- include/linux/rwsem.h | 11 +++++++++++
+ include/linux/percpu-rwsem.h | 4 ++--
+ include/linux/rwsem.h | 12 ++++++++++++
include/linux/spinlock.h | 12 +++++++++++-
include/linux/spinlock_api_smp.h | 4 +++-
include/linux/spinlock_types.h | 11 ++++++++---
- kernel/locking/Makefile | 10 +++++++++-
+ kernel/locking/Makefile | 10 +++++++---
+ kernel/locking/rwsem.c | 8 ++++++++
kernel/locking/rwsem.h | 2 ++
kernel/locking/spinlock.c | 7 +++++++
kernel/locking/spinlock_debug.c | 5 +++++
- 9 files changed, 69 insertions(+), 13 deletions(-)
+ 12 files changed, 85 insertions(+), 17 deletions(-)
+--- a/include/Kbuild
++++ b/include/Kbuild
+@@ -1158,8 +1158,15 @@ header-test- += xen/xenbus.h
+ # Do not include directly
+ header-test- += linux/compiler-clang.h
+ header-test- += linux/compiler-gcc.h
++header-test- += linux/mutex_rt.h
+ header-test- += linux/patchkey.h
+ header-test- += linux/rwlock_api_smp.h
++header-test- += linux/rwlock_rt.h
++header-test- += linux/rwlock_types_rt.h
++header-test- += linux/rwsem-rt.h
++header-test- += linux/spinlock_rt.h
++header-test- += linux/spinlock_types_nort.h
++header-test- += linux/spinlock_types_rt.h
+ header-test- += linux/spinlock_types_up.h
+ header-test- += linux/spinlock_up.h
+ header-test- += linux/wimax/debug.h
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -22,6 +22,17 @@
@@ -30,14 +51,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+# define __DEP_MAP_MUTEX_INITIALIZER(lockname)
+#endif
+
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# include <linux/mutex_rt.h>
+#else
+
/*
* Simple, straightforward mutexes with strict semantics:
*
-@@ -118,13 +129,6 @@ do { \
+@@ -108,13 +119,6 @@ do { \
__mutex_init((mutex), #mutex, &__key); \
} while (0)
@@ -51,31 +72,52 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define __MUTEX_INITIALIZER(lockname) \
{ .owner = ATOMIC_LONG_INIT(0) \
, .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
-@@ -229,4 +233,6 @@ mutex_trylock_recursive(struct mutex *lo
- return mutex_trylock(lock);
- }
+@@ -210,4 +214,6 @@ enum mutex_trylock_recursive_enum {
+ extern /* __deprecated */ __must_check enum mutex_trylock_recursive_enum
+ mutex_trylock_recursive(struct mutex *lock);
-+#endif /* !PREEMPT_RT_FULL */
++#endif /* !PREEMPT_RT */
+
#endif /* __LINUX_MUTEX_H */
+--- a/include/linux/percpu-rwsem.h
++++ b/include/linux/percpu-rwsem.h
+@@ -119,7 +119,7 @@ static inline void percpu_rwsem_release(
+ bool read, unsigned long ip)
+ {
+ lock_release(&sem->rw_sem.dep_map, 1, ip);
+-#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
++#if defined(CONFIG_RWSEM_SPIN_ON_OWNER) && !defined(CONFIG_PREEMPT_RT)
+ if (!read)
+ atomic_long_set(&sem->rw_sem.owner, RWSEM_OWNER_UNKNOWN);
+ #endif
+@@ -129,7 +129,7 @@ static inline void percpu_rwsem_acquire(
+ bool read, unsigned long ip)
+ {
+ lock_acquire(&sem->rw_sem.dep_map, 0, 1, read, 1, NULL, ip);
+-#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
++#if defined(CONFIG_RWSEM_SPIN_ON_OWNER) && !defined(CONFIG_PREEMPT_RT)
+ if (!read)
+ atomic_long_set(&sem->rw_sem.owner, (long)current);
+ #endif
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
-@@ -20,6 +20,10 @@
- #include <linux/osq_lock.h>
- #endif
-
-+#ifdef CONFIG_PREEMPT_RT_FULL
+@@ -16,6 +16,11 @@
+ #include <linux/spinlock.h>
+ #include <linux/atomic.h>
+ #include <linux/err.h>
++
++#ifdef CONFIG_PREEMPT_RT
+#include <linux/rwsem-rt.h>
-+#else /* PREEMPT_RT_FULL */
++#else /* PREEMPT_RT */
+
- /*
- * For an uncontended rwsem, count and owner are the only fields a task
- * needs to touch when acquiring the rwsem. So they are put next to each
-@@ -109,6 +113,13 @@ static inline int rwsem_is_contended(str
+ #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
+ #include <linux/osq_lock.h>
+ #endif
+@@ -121,6 +126,13 @@ static inline int rwsem_is_contended(str
return !list_empty(&sem->wait_list);
}
-+#endif /* !PREEMPT_RT_FULL */
++#endif /* !PREEMPT_RT */
+
+/*
+ * The functions below are the same for all rwsem implementations including
@@ -92,7 +134,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Include rwlock functions */
-#include <linux/rwlock.h>
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# include <linux/rwlock_rt.h>
+#else
+# include <linux/rwlock.h>
@@ -104,9 +146,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
# include <linux/spinlock_api_up.h>
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+# include <linux/spinlock_rt.h>
-+#else /* PREEMPT_RT_FULL */
++#else /* PREEMPT_RT */
+
/*
* Map the spin_lock functions to the raw variants for PREEMPT_RT=n
@@ -115,7 +157,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock)
-+#endif /* !PREEMPT_RT_FULL */
++#endif /* !PREEMPT_RT */
+
/*
* Pull the atomic_t declaration:
@@ -127,7 +169,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
-#include <linux/rwlock_api_smp.h>
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+# include <linux/rwlock_api_smp.h>
+#endif
@@ -141,7 +183,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-#include <linux/spinlock_types_nort.h>
-
-#include <linux/rwlock_types.h>
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+# include <linux/spinlock_types_nort.h>
+# include <linux/rwlock_types.h>
+#else
@@ -157,49 +199,106 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
# and is generally not a function of system call inputs.
KCOV_INSTRUMENT := n
--obj-y += mutex.o semaphore.o rwsem.o percpu-rwsem.o rwsem-xadd.o
-+obj-y += semaphore.o percpu-rwsem.o
+-obj-y += mutex.o semaphore.o rwsem.o percpu-rwsem.o
++obj-y += semaphore.o rwsem.o percpu-rwsem.o
ifdef CONFIG_FUNCTION_TRACER
CFLAGS_REMOVE_lockdep.o = $(CC_FLAGS_FTRACE)
-@@ -12,7 +12,11 @@ CFLAGS_REMOVE_mutex-debug.o = $(CC_FLAGS
+@@ -12,19 +12,23 @@ CFLAGS_REMOVE_mutex-debug.o = $(CC_FLAGS
CFLAGS_REMOVE_rtmutex-debug.o = $(CC_FLAGS_FTRACE)
endif
-+ifneq ($(CONFIG_PREEMPT_RT_FULL),y)
-+obj-y += mutex.o
- obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
-+endif
-+obj-y += rwsem.o
+-obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
obj-$(CONFIG_LOCKDEP) += lockdep.o
ifeq ($(CONFIG_PROC_FS),y)
obj-$(CONFIG_LOCKDEP) += lockdep_proc.o
-@@ -25,6 +29,10 @@ obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
+ endif
+ obj-$(CONFIG_SMP) += spinlock.o
+-obj-$(CONFIG_LOCK_SPIN_ON_OWNER) += osq_lock.o
+ obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
+ obj-$(CONFIG_QUEUED_SPINLOCKS) += qspinlock.o
+ obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock_debug.o
-+ifneq ($(CONFIG_PREEMPT_RT_FULL),y)
-+obj-y += mutex.o rwsem.o rwsem-xadd.o
++ifneq ($(CONFIG_PREEMPT_RT),y)
++obj-y += mutex.o
++obj-$(CONFIG_LOCK_SPIN_ON_OWNER) += osq_lock.o
++obj-$(CONFIG_DEBUG_MUTEXES) += mutex-debug.o
+endif
-+obj-$(CONFIG_PREEMPT_RT_FULL) += mutex-rt.o rwsem-rt.o rwlock-rt.o
++obj-$(CONFIG_PREEMPT_RT) += mutex-rt.o rwsem-rt.o rwlock-rt.o
obj-$(CONFIG_QUEUED_RWLOCKS) += qrwlock.o
obj-$(CONFIG_LOCK_TORTURE_TEST) += locktorture.o
obj-$(CONFIG_WW_MUTEX_SELFTEST) += test-ww_mutex.o
---- a/kernel/locking/rwsem.h
-+++ b/kernel/locking/rwsem.h
-@@ -169,6 +169,7 @@ extern struct rw_semaphore *rwsem_down_w
- extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
- extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
+--- a/kernel/locking/rwsem.c
++++ b/kernel/locking/rwsem.c
+@@ -29,6 +29,8 @@
+ #include <linux/atomic.h>
+
+ #include "rwsem.h"
++
++#ifndef CONFIG_PREEMPT_RT
+ #include "lock_events.h"
+
+ /*
+@@ -1335,6 +1337,7 @@ static struct rw_semaphore *rwsem_downgr
+ return sem;
+ }
-+#ifndef CONFIG_PREEMPT_RT_FULL
++
/*
* lock for reading
*/
-@@ -302,3 +303,4 @@ static inline void __downgrade_write(str
- if (tmp < 0)
+@@ -1485,6 +1488,7 @@ static inline void __downgrade_write(str
+ if (tmp & RWSEM_FLAG_WAITERS)
rwsem_downgrade_wake(sem);
}
+#endif
+
+ /*
+ * lock for reading
+@@ -1616,6 +1620,7 @@ void _down_write_nest_lock(struct rw_sem
+ }
+ EXPORT_SYMBOL(_down_write_nest_lock);
+
++#ifndef CONFIG_PREEMPT_RT
+ void down_read_non_owner(struct rw_semaphore *sem)
+ {
+ might_sleep();
+@@ -1623,6 +1628,7 @@ void down_read_non_owner(struct rw_semap
+ __rwsem_set_reader_owned(sem, NULL);
+ }
+ EXPORT_SYMBOL(down_read_non_owner);
++#endif
+
+ void down_write_nested(struct rw_semaphore *sem, int subclass)
+ {
+@@ -1647,11 +1653,13 @@ int __sched down_write_killable_nested(s
+ }
+ EXPORT_SYMBOL(down_write_killable_nested);
+
++#ifndef CONFIG_PREEMPT_RT
+ void up_read_non_owner(struct rw_semaphore *sem)
+ {
+ DEBUG_RWSEMS_WARN_ON(!is_rwsem_reader_owned(sem), sem);
+ __up_read(sem);
+ }
+ EXPORT_SYMBOL(up_read_non_owner);
++#endif
+
+ #endif
+--- a/kernel/locking/rwsem.h
++++ b/kernel/locking/rwsem.h
+@@ -4,7 +4,9 @@
+ #define __INTERNAL_RWSEM_H
+ #include <linux/rwsem.h>
+
++#ifndef CONFIG_PREEMPT_RT
+ extern void __down_read(struct rw_semaphore *sem);
+ extern void __up_read(struct rw_semaphore *sem);
++#endif
+
+ #endif /* __INTERNAL_RWSEM_H */
--- a/kernel/locking/spinlock.c
+++ b/kernel/locking/spinlock.c
@@ -124,8 +124,11 @@ void __lockfunc __raw_##op##_lock_bh(loc
@@ -207,7 +306,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
*/
BUILD_LOCK_OPS(spin, raw_spinlock);
+
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
BUILD_LOCK_OPS(read, rwlock);
BUILD_LOCK_OPS(write, rwlock);
+#endif
@@ -218,7 +317,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
EXPORT_SYMBOL(_raw_spin_unlock_bh);
#endif
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+
#ifndef CONFIG_INLINE_READ_TRYLOCK
int __lockfunc _raw_read_trylock(rwlock_t *lock)
@@ -227,7 +326,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
EXPORT_SYMBOL(_raw_write_unlock_bh);
#endif
-+#endif /* !PREEMPT_RT_FULL */
++#endif /* !PREEMPT_RT */
+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -238,7 +337,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
EXPORT_SYMBOL(__raw_spin_lock_init);
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
void __rwlock_init(rwlock_t *lock, const char *name,
struct lock_class_key *key)
{
@@ -254,7 +353,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
arch_spin_unlock(&lock->raw_lock);
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
static void rwlock_bug(rwlock_t *lock, const char *msg)
{
if (!debug_locks_off())
diff --git a/debian/patches-rt/rtmutex_dont_include_rcu.patch b/debian/patches-rt/rtmutex_dont_include_rcu.patch
index d26834adfe4b..5d198f7832d6 100644
--- a/debian/patches-rt/rtmutex_dont_include_rcu.patch
+++ b/debian/patches-rt/rtmutex_dont_include_rcu.patch
@@ -1,6 +1,6 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: rbtree: don't include the rcu header
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The RCU header pulls in spinlock.h and fails due not yet defined types:
@@ -20,9 +20,9 @@ a new header file which can be included by both users.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
include/linux/rbtree.h | 2 -
- include/linux/rcu_assign_pointer.h | 63 +++++++++++++++++++++++++++++++++++++
- include/linux/rcupdate.h | 57 ---------------------------------
- 3 files changed, 65 insertions(+), 57 deletions(-)
+ include/linux/rcu_assign_pointer.h | 62 +++++++++++++++++++++++++++++++++++++
+ include/linux/rcupdate.h | 56 ---------------------------------
+ 3 files changed, 64 insertions(+), 56 deletions(-)
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -37,7 +37,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
unsigned long __rb_parent_color;
--- /dev/null
+++ b/include/linux/rcu_assign_pointer.h
-@@ -0,0 +1,63 @@
+@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __LINUX_RCU_ASSIGN_POINTER_H__
+#define __LINUX_RCU_ASSIGN_POINTER_H__
@@ -88,17 +88,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ * please be careful when making changes to rcu_assign_pointer() and the
+ * other macros that it invokes.
+ */
-+#define rcu_assign_pointer(p, v) \
-+({ \
-+ uintptr_t _r_a_p__v = (uintptr_t)(v); \
-+ rcu_check_sparse(p, __rcu); \
-+ \
-+ if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
-+ WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
-+ else \
-+ smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
-+ _r_a_p__v; \
-+})
++#define rcu_assign_pointer(p, v) \
++do { \
++ uintptr_t _r_a_p__v = (uintptr_t)(v); \
++ rcu_check_sparse(p, __rcu); \
++ \
++ if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
++ WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
++ else \
++ smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
++} while (0)
+
+#endif
--- a/include/linux/rcupdate.h
@@ -111,7 +110,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
#define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
-@@ -301,13 +302,6 @@ static inline void rcu_preempt_sleep_che
+@@ -308,13 +309,6 @@ static inline void rcu_preempt_sleep_che
* (e.g., __srcu), should this make sense in the future.
*/
@@ -125,7 +124,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define __rcu_access_pointer(p, space) \
({ \
typeof(*p) *_________p1 = (typeof(*p) *__force)READ_ONCE(p); \
-@@ -336,55 +330,6 @@ static inline void rcu_preempt_sleep_che
+@@ -343,54 +337,6 @@ static inline void rcu_preempt_sleep_che
})
/**
@@ -166,16 +165,15 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- * other macros that it invokes.
- */
-#define rcu_assign_pointer(p, v) \
--({ \
+-do { \
- uintptr_t _r_a_p__v = (uintptr_t)(v); \
-- rcu_check_sparse(p, __rcu); \
+- rcu_check_sparse(p, __rcu); \
- \
- if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \
- WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \
- else \
- smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
-- _r_a_p__v; \
--})
+-} while (0)
-
-/**
* rcu_swap_protected() - swap an RCU and a regular pointer
diff --git a/debian/patches-rt/sched-Allow-pinned-user-tasks-to-be-awakened-to-the-.patch b/debian/patches-rt/sched-Allow-pinned-user-tasks-to-be-awakened-to-the-.patch
deleted file mode 100644
index 4ce50cd2131c..000000000000
--- a/debian/patches-rt/sched-Allow-pinned-user-tasks-to-be-awakened-to-the-.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From: Mike Galbraith <efault@gmx.de>
-Date: Sun, 19 Aug 2018 08:28:35 +0200
-Subject: [PATCH] sched: Allow pinned user tasks to be awakened to the CPU they
- pinned
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Since commit 7af443ee16976 ("sched/core: Require cpu_active() in
-select_task_rq(), for user tasks") select_fallback_rq() will BUG() if
-the CPU to which a task has pinned itself and pinned becomes
-!cpu_active() while it slept.
-The task will continue running on the to-be-removed CPU and will remove
-itself from the CPU during takedown_cpu() (while cpuhp_pin_lock will be
-acquired) and move to another CPU based on its mask after the
-migrate_disable() section has been left.
-
-Cc: stable-rt@vger.kernel.org
-Signed-off-by: Mike Galbraith <efault@gmx.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/core.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -960,7 +960,7 @@ static inline bool is_cpu_allowed(struct
- if (!cpumask_test_cpu(cpu, p->cpus_ptr))
- return false;
-
-- if (is_per_cpu_kthread(p))
-+ if (is_per_cpu_kthread(p) || __migrate_disabled(p))
- return cpu_online(cpu);
-
- return cpu_active(cpu);
diff --git a/debian/patches-rt/sched-Remove-dead-__migrate_disabled-check.patch b/debian/patches-rt/sched-Remove-dead-__migrate_disabled-check.patch
deleted file mode 100644
index 82f9eb6e5621..000000000000
--- a/debian/patches-rt/sched-Remove-dead-__migrate_disabled-check.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From: Scott Wood <swood@redhat.com>
-Date: Sat, 27 Jul 2019 00:56:33 -0500
-Subject: [PATCH] sched: Remove dead __migrate_disabled() check
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-This code was unreachable given the __migrate_disabled() branch
-to "out" immediately beforehand.
-
-Signed-off-by: Scott Wood <swood@redhat.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/core.c | 7 -------
- 1 file changed, 7 deletions(-)
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -1173,13 +1173,6 @@ static int __set_cpus_allowed_ptr(struct
- if (cpumask_test_cpu(task_cpu(p), new_mask) || __migrate_disabled(p))
- goto out;
-
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-- if (__migrate_disabled(p)) {
-- p->migrate_disable_update = 1;
-- goto out;
-- }
--#endif
--
- dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
- if (task_running(rq, p) || p->state == TASK_WAKING) {
- struct migration_arg arg = { p, dest_cpu };
diff --git a/debian/patches-rt/sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch b/debian/patches-rt/sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch
index d9aeebab7d33..2792531396f3 100644
--- a/debian/patches-rt/sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch
+++ b/debian/patches-rt/sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch
@@ -1,8 +1,8 @@
From: Scott Wood <swood@redhat.com>
Date: Sat, 27 Jul 2019 00:56:32 -0500
-Subject: [PATCH] sched: __set_cpus_allowed_ptr: Check cpus_mask, not
+Subject: [PATCH] sched: __set_cpus_allowed_ptr(): Check cpus_mask, not
cpus_ptr
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This function is concerned with the long-term cpu mask, not the
transitory mask the task might have while migrate disabled. Before
@@ -19,7 +19,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -1126,7 +1126,7 @@ static int __set_cpus_allowed_ptr(struct
+@@ -1680,7 +1680,7 @@ static int __set_cpus_allowed_ptr(struct
goto out;
}
@@ -27,4 +27,4 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ if (cpumask_equal(&p->cpus_mask, new_mask))
goto out;
- if (!cpumask_intersects(new_mask, cpu_valid_mask)) {
+ dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
diff --git a/debian/patches-rt/sched-completion-Fix-a-lockup-in-wait_for_completion.patch b/debian/patches-rt/sched-completion-Fix-a-lockup-in-wait_for_completion.patch
deleted file mode 100644
index 053dc7f67a50..000000000000
--- a/debian/patches-rt/sched-completion-Fix-a-lockup-in-wait_for_completion.patch
+++ /dev/null
@@ -1,61 +0,0 @@
-From: Corey Minyard <cminyard@mvista.com>
-Date: Thu, 9 May 2019 14:33:20 -0500
-Subject: [PATCH] sched/completion: Fix a lockup in wait_for_completion()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Consider following race:
-
- T0 T1 T2
- wait_for_completion()
- do_wait_for_common()
- __prepare_to_swait()
- schedule()
- complete()
- x->done++ (0 -> 1)
- raw_spin_lock_irqsave()
- swake_up_locked() wait_for_completion()
- wake_up_process(T0)
- list_del_init()
- raw_spin_unlock_irqrestore()
- raw_spin_lock_irq(&x->wait.lock)
- raw_spin_lock_irq(&x->wait.lock) x->done != UINT_MAX, 1 -> 0
- raw_spin_unlock_irq(&x->wait.lock)
- return 1
- while (!x->done && timeout),
- continue loop, not enqueued
- on &x->wait
-
-Basically, the problem is that the original wait queues used in
-completions did not remove the item from the queue in the wakeup
-function, but swake_up_locked() does.
-
-Fix it by adding the thread to the wait queue inside the do loop.
-The design of swait detects if it is already in the list and doesn't
-do the list add again.
-
-Cc: stable-rt@vger.kernel.org
-Fixes: a04ff6b4ec4ee7e ("completion: Use simple wait queues")
-Signed-off-by: Corey Minyard <cminyard@mvista.com>
-Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-[bigeasy: shorten commit message ]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/completion.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/kernel/sched/completion.c
-+++ b/kernel/sched/completion.c
-@@ -72,12 +72,12 @@ do_wait_for_common(struct completion *x,
- if (!x->done) {
- DECLARE_SWAITQUEUE(wait);
-
-- __prepare_to_swait(&x->wait, &wait);
- do {
- if (signal_pending_state(state, current)) {
- timeout = -ERESTARTSYS;
- break;
- }
-+ __prepare_to_swait(&x->wait, &wait);
- __set_current_state(state);
- raw_spin_unlock_irq(&x->wait.lock);
- timeout = action(timeout);
diff --git a/debian/patches-rt/sched-core-migrate_enable-must-access-takedown_cpu_t.patch b/debian/patches-rt/sched-core-migrate_enable-must-access-takedown_cpu_t.patch
new file mode 100644
index 000000000000..384a89080496
--- /dev/null
+++ b/debian/patches-rt/sched-core-migrate_enable-must-access-takedown_cpu_t.patch
@@ -0,0 +1,44 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Fri, 29 Nov 2019 17:24:55 +0100
+Subject: [PATCH] sched/core: migrate_enable() must access takedown_cpu_task on
+ !HOTPLUG_CPU
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+The variable takedown_cpu_task is never declared/used on !HOTPLUG_CPU
+except for migrate_enable(). This leads to a link error.
+
+Don't use takedown_cpu_task in !HOTPLUG_CPU.
+
+Reported-by: Dick Hollenbeck <dick@softplc.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/cpu.c | 2 ++
+ kernel/sched/core.c | 2 ++
+ 2 files changed, 4 insertions(+)
+
+--- a/kernel/cpu.c
++++ b/kernel/cpu.c
+@@ -887,7 +887,9 @@ static int take_cpu_down(void *_param)
+ return 0;
+ }
+
++#ifdef CONFIG_PREEMPT_RT
+ struct task_struct *takedown_cpu_task;
++#endif
+
+ static int takedown_cpu(unsigned int cpu)
+ {
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -8129,9 +8129,11 @@ void migrate_enable(void)
+
+ p->migrate_disable = 0;
+ rq->nr_pinned--;
++#ifdef CONFIG_HOTPLUG_CPU
+ if (rq->nr_pinned == 0 && unlikely(!cpu_active(cpu)) &&
+ takedown_cpu_task)
+ wake_up_process(takedown_cpu_task);
++#endif
+
+ if (!p->migrate_disable_scheduled)
+ goto out;
diff --git a/debian/patches-rt/sched-deadline-Ensure-inactive_timer-runs-in-hardirq.patch b/debian/patches-rt/sched-deadline-Ensure-inactive_timer-runs-in-hardirq.patch
deleted file mode 100644
index 12c03de10c21..000000000000
--- a/debian/patches-rt/sched-deadline-Ensure-inactive_timer-runs-in-hardirq.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From: Juri Lelli <juri.lelli@redhat.com>
-Date: Wed, 31 Jul 2019 12:37:15 +0200
-Subject: [PATCH] sched/deadline: Ensure inactive_timer runs in hardirq
- context
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-SCHED_DEADLINE inactive timer needs to run in hardirq context (as
-dl_task_timer already does) on PREEMPT_RT
-
-Change the mode to HRTIMER_MODE_REL_HARD.
-
-[ tglx: Fixed up the start site, so mode debugging works ]
-
-Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Link: https://lkml.kernel.org/r/20190731103715.4047-1-juri.lelli@redhat.com
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/deadline.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/kernel/sched/deadline.c
-+++ b/kernel/sched/deadline.c
-@@ -287,7 +287,7 @@ static void task_non_contending(struct t
-
- dl_se->dl_non_contending = 1;
- get_task_struct(p);
-- hrtimer_start(timer, ns_to_ktime(zerolag_time), HRTIMER_MODE_REL);
-+ hrtimer_start(timer, ns_to_ktime(zerolag_time), HRTIMER_MODE_REL_HARD);
- }
-
- static void task_contending(struct sched_dl_entity *dl_se, int flags)
-@@ -1292,7 +1292,7 @@ void init_dl_inactive_task_timer(struct
- {
- struct hrtimer *timer = &dl_se->inactive_timer;
-
-- hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
-+ hrtimer_init(timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
- timer->function = inactive_task_timer;
- }
-
diff --git a/debian/patches-rt/sched-delay-put-task.patch b/debian/patches-rt/sched-delay-put-task.patch
deleted file mode 100644
index d4460d64fc20..000000000000
--- a/debian/patches-rt/sched-delay-put-task.patch
+++ /dev/null
@@ -1,86 +0,0 @@
-Subject: sched: Move task_struct cleanup to RCU
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Tue, 31 May 2011 16:59:16 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-__put_task_struct() does quite some expensive work. We don't want to
-burden random tasks with that.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- include/linux/sched.h | 3 +++
- include/linux/sched/task.h | 12 +++++++++++-
- kernel/fork.c | 14 ++++++++++++++
- 3 files changed, 28 insertions(+), 1 deletion(-)
-
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -1199,6 +1199,9 @@ struct task_struct {
- unsigned int sequential_io;
- unsigned int sequential_io_avg;
- #endif
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+ struct rcu_head put_rcu;
-+#endif
- #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
- unsigned long task_state_change;
- #endif
---- a/include/linux/sched/task.h
-+++ b/include/linux/sched/task.h
-@@ -91,6 +91,16 @@ extern void sched_exec(void);
-
- #define get_task_struct(tsk) do { refcount_inc(&(tsk)->usage); } while(0)
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+extern void __put_task_struct_cb(struct rcu_head *rhp);
-+
-+static inline void put_task_struct(struct task_struct *t)
-+{
-+ if (refcount_dec_and_test(&t->usage))
-+ call_rcu(&t->put_rcu, __put_task_struct_cb);
-+}
-+#else
-+
- extern void __put_task_struct(struct task_struct *t);
-
- static inline void put_task_struct(struct task_struct *t)
-@@ -98,7 +108,7 @@ static inline void put_task_struct(struc
- if (refcount_dec_and_test(&t->usage))
- __put_task_struct(t);
- }
--
-+#endif
- struct task_struct *task_rcu_dereference(struct task_struct **ptask);
-
- #ifdef CONFIG_ARCH_WANTS_DYNAMIC_TASK_STRUCT
---- a/kernel/fork.c
-+++ b/kernel/fork.c
-@@ -720,6 +720,9 @@ static inline void put_signal_struct(str
- free_signal_struct(sig);
- }
-
-+#ifdef CONFIG_PREEMPT_RT_BASE
-+static
-+#endif
- void __put_task_struct(struct task_struct *tsk)
- {
- WARN_ON(!tsk->exit_state);
-@@ -736,7 +739,18 @@ void __put_task_struct(struct task_struc
- if (!profile_handoff_task(tsk))
- free_task(tsk);
- }
-+#ifndef CONFIG_PREEMPT_RT_BASE
- EXPORT_SYMBOL_GPL(__put_task_struct);
-+#else
-+void __put_task_struct_cb(struct rcu_head *rhp)
-+{
-+ struct task_struct *tsk = container_of(rhp, struct task_struct, put_rcu);
-+
-+ __put_task_struct(tsk);
-+
-+}
-+EXPORT_SYMBOL_GPL(__put_task_struct_cb);
-+#endif
-
- void __init __weak arch_task_cache_init(void) { }
-
diff --git a/debian/patches-rt/sched-disable-rt-group-sched-on-rt.patch b/debian/patches-rt/sched-disable-rt-group-sched-on-rt.patch
index bb29ad241f78..81f88907ecb2 100644
--- a/debian/patches-rt/sched-disable-rt-group-sched-on-rt.patch
+++ b/debian/patches-rt/sched-disable-rt-group-sched-on-rt.patch
@@ -1,7 +1,7 @@
Subject: sched: Disable CONFIG_RT_GROUP_SCHED on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 18 Jul 2011 17:03:52 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Carsten reported problems when running:
@@ -19,11 +19,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/init/Kconfig
+++ b/init/Kconfig
-@@ -840,6 +840,7 @@ config CFS_BANDWIDTH
+@@ -923,6 +923,7 @@ config CFS_BANDWIDTH
config RT_GROUP_SCHED
bool "Group scheduling for SCHED_RR/FIFO"
depends on CGROUP_SCHED
-+ depends on !PREEMPT_RT_FULL
++ depends on !PREEMPT_RT
default n
help
This feature lets you explicitly allocate real CPU bandwidth
diff --git a/debian/patches-rt/sched-disable-ttwu-queue.patch b/debian/patches-rt/sched-disable-ttwu-queue.patch
index ac2572d50120..06708fa20901 100644
--- a/debian/patches-rt/sched-disable-ttwu-queue.patch
+++ b/debian/patches-rt/sched-disable-ttwu-queue.patch
@@ -1,7 +1,7 @@
Subject: sched: Disable TTWU_QUEUE on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 13 Sep 2011 16:42:35 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The queued remote wakeup mechanism can introduce rather large
latencies if the number of migrated tasks is high. Disable it for RT.
@@ -13,11 +13,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/sched/features.h
+++ b/kernel/sched/features.h
-@@ -46,11 +46,16 @@ SCHED_FEAT(LB_BIAS, false)
+@@ -45,11 +45,16 @@ SCHED_FEAT(DOUBLE_TICK, false)
*/
SCHED_FEAT(NONTASK_CAPACITY, true)
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+SCHED_FEAT(TTWU_QUEUE, false)
+#else
+
diff --git a/debian/patches-rt/sched-fair-Make-the-hrtimers-non-hard-again.patch b/debian/patches-rt/sched-fair-Make-the-hrtimers-non-hard-again.patch
deleted file mode 100644
index 0d6ba8b080fa..000000000000
--- a/debian/patches-rt/sched-fair-Make-the-hrtimers-non-hard-again.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 8 Jan 2019 12:31:06 +0100
-Subject: [PATCH] sched/fair: Make the hrtimers non-hard again
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Since commit "sched/fair: Robustify CFS-bandwidth timer locking" both
-hrtimer can run in softirq context because now interrupts are disabled
-as part of the locking procedure.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/fair.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/kernel/sched/fair.c
-+++ b/kernel/sched/fair.c
-@@ -5004,9 +5004,9 @@ void init_cfs_bandwidth(struct cfs_bandw
- cfs_b->period = ns_to_ktime(default_cfs_period());
-
- INIT_LIST_HEAD(&cfs_b->throttled_cfs_rq);
-- hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
-+ hrtimer_init(&cfs_b->period_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED);
- cfs_b->period_timer.function = sched_cfs_period_timer;
-- hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
-+ hrtimer_init(&cfs_b->slack_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
- cfs_b->slack_timer.function = sched_cfs_slack_timer;
- cfs_b->distribute_running = 0;
- }
diff --git a/debian/patches-rt/sched-limit-nr-migrate.patch b/debian/patches-rt/sched-limit-nr-migrate.patch
index 5bb9d2dddf59..9817cf7e6c8b 100644
--- a/debian/patches-rt/sched-limit-nr-migrate.patch
+++ b/debian/patches-rt/sched-limit-nr-migrate.patch
@@ -1,7 +1,7 @@
Subject: sched: Limit the number of task migrations per batch
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 06 Jun 2011 12:12:51 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Put an upper limit on the number of tasks which are migrated per batch
to avoid large latencies.
@@ -13,11 +13,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -45,7 +45,11 @@ const_debug unsigned int sysctl_sched_fe
+@@ -56,7 +56,11 @@ const_debug unsigned int sysctl_sched_fe
* Number of tasks to iterate in a single balance run.
* Limited because this is done with IRQs disabled.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+const_debug unsigned int sysctl_sched_nr_migrate = 8;
+#else
const_debug unsigned int sysctl_sched_nr_migrate = 32;
diff --git a/debian/patches-rt/sched-might-sleep-do-not-account-rcu-depth.patch b/debian/patches-rt/sched-might-sleep-do-not-account-rcu-depth.patch
index d43b6fb86a4f..9158701cbf61 100644
--- a/debian/patches-rt/sched-might-sleep-do-not-account-rcu-depth.patch
+++ b/debian/patches-rt/sched-might-sleep-do-not-account-rcu-depth.patch
@@ -1,7 +1,7 @@
Subject: sched: Do not account rcu_preempt_depth on RT in might_sleep()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 07 Jun 2011 09:19:06 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
RT changes the rcu_preempt_depth semantics, so we cannot check for it
in might_sleep().
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* types of kernel builds, the rcu_read_lock() nesting depth is unknowable.
*/
#define rcu_preempt_depth() (current->rcu_read_lock_nesting)
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
+#define sched_rcu_preempt_depth() rcu_preempt_depth()
+#else
+static inline int sched_rcu_preempt_depth(void) { return 0; }
@@ -37,7 +37,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/* Internal to kernel */
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -6135,7 +6135,7 @@ void __init sched_init(void)
+@@ -6766,7 +6766,7 @@ void __init sched_init(void)
#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
static inline int preempt_count_equals(int preempt_offset)
{
diff --git a/debian/patches-rt/sched-migrate-disable-Protect-cpus_ptr-with-lock.patch b/debian/patches-rt/sched-migrate-disable-Protect-cpus_ptr-with-lock.patch
deleted file mode 100644
index d36822234c9b..000000000000
--- a/debian/patches-rt/sched-migrate-disable-Protect-cpus_ptr-with-lock.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From: Scott Wood <swood@redhat.com>
-Date: Sat, 27 Jul 2019 00:56:34 -0500
-Subject: [PATCH] sched: migrate disable: Protect cpus_ptr with lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Various places assume that cpus_ptr is protected by rq/pi locks,
-so don't change it before grabbing those locks.
-
-Signed-off-by: Scott Wood <swood@redhat.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/core.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7171,9 +7171,8 @@ migrate_disable_update_cpus_allowed(stru
- struct rq *rq;
- struct rq_flags rf;
-
-- p->cpus_ptr = cpumask_of(smp_processor_id());
--
- rq = task_rq_lock(p, &rf);
-+ p->cpus_ptr = cpumask_of(smp_processor_id());
- update_nr_migratory(p, -1);
- p->nr_cpus_allowed = 1;
- task_rq_unlock(rq, p, &rf);
-@@ -7185,9 +7184,8 @@ migrate_enable_update_cpus_allowed(struc
- struct rq *rq;
- struct rq_flags rf;
-
-- p->cpus_ptr = &p->cpus_mask;
--
- rq = task_rq_lock(p, &rf);
-+ p->cpus_ptr = &p->cpus_mask;
- p->nr_cpus_allowed = cpumask_weight(&p->cpus_mask);
- update_nr_migratory(p, 1);
- task_rq_unlock(rq, p, &rf);
diff --git a/debian/patches-rt/sched-migrate_dis-enable-Use-sleeping_lock-to-annota.patch b/debian/patches-rt/sched-migrate_dis-enable-Use-sleeping_lock-to-annota.patch
deleted file mode 100644
index b969262c38b9..000000000000
--- a/debian/patches-rt/sched-migrate_dis-enable-Use-sleeping_lock-to-annota.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-From: Scott Wood <swood@redhat.com>
-Date: Tue, 24 Sep 2019 14:36:41 +0200
-Subject: [PATCH] =?UTF-8?q?sched:=20migrate=5Fdis/enable:=20Use=20sl?=
- =?UTF-8?q?eeping=5Flock=E2=80=A6()=20to=20annotate=20sleeping=20points?=
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Without this, rcu_note_context_switch() will complain if an RCU read lock
-is held when migrate_enable() calls stop_one_cpu(). Likewise when
-migrate_disable() calls pin_current_cpu() which calls __read_rt_lock() --
-which bypasses the part of the mutex code that calls sleeping_lock_inc().
-
-Signed-off-by: Scott Wood <swood@redhat.com>
-[bigeasy: use sleeping_lock_…() ]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/cpu.c | 2 ++
- kernel/sched/core.c | 3 +++
- 2 files changed, 5 insertions(+)
-
---- a/kernel/cpu.c
-+++ b/kernel/cpu.c
-@@ -307,7 +307,9 @@ void pin_current_cpu(void)
- cpu = smp_processor_id();
- preempt_enable();
-
-+ sleeping_lock_inc();
- __read_rt_lock(cpuhp_pin);
-+ sleeping_lock_dec();
-
- preempt_disable();
- if (cpu != smp_processor_id()) {
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -7318,7 +7318,10 @@ void migrate_enable(void)
-
- unpin_current_cpu();
- preempt_enable();
-+
-+ sleeping_lock_inc();
- stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
-+ sleeping_lock_dec();
- return;
- }
- }
diff --git a/debian/patches-rt/sched-migrate_disable-Add-export_symbol_gpl-for-__mi.patch b/debian/patches-rt/sched-migrate_disable-Add-export_symbol_gpl-for-__mi.patch
deleted file mode 100644
index 2ab8540112f9..000000000000
--- a/debian/patches-rt/sched-migrate_disable-Add-export_symbol_gpl-for-__mi.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Tue, 9 Oct 2018 17:34:50 +0200
-Subject: [PATCH] sched/migrate_disable: Add export_symbol_gpl for
- __migrate_disabled
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Jonathan reported that lttng/modules can't use __migrate_disabled().
-This function is only used by sched/core itself and the tracing
-infrastructure to report the migrate counter (lttng does probably the
-same). Since the rework migrate_disable() it moved from sched.h to
-preempt.h and is became an exported function instead of a "static
-inline" due to the header recursion of preempt vs sched.
-
-Since the compiler inlines the function for sched/core usage, add a
-EXPORT_SYMBOL_GPL to allow the module/LTTNG usage.
-
-Reported-by: Jonathan Rajott <jonathan.rajotte-julien@efficios.com>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/sched/core.c | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -1065,6 +1065,7 @@ int __migrate_disabled(struct task_struc
- {
- return p->migrate_disable;
- }
-+EXPORT_SYMBOL_GPL(__migrate_disabled);
- #endif
-
- static void __do_set_cpus_allowed_tail(struct task_struct *p,
diff --git a/debian/patches-rt/sched-migrate_disable-fallback-to-preempt_disable-in.patch b/debian/patches-rt/sched-migrate_disable-fallback-to-preempt_disable-in.patch
deleted file mode 100644
index b18d0effb7d3..000000000000
--- a/debian/patches-rt/sched-migrate_disable-fallback-to-preempt_disable-in.patch
+++ /dev/null
@@ -1,183 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Thu, 5 Jul 2018 14:44:51 +0200
-Subject: [PATCH] sched/migrate_disable: fallback to preempt_disable() instead
- barrier()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-On SMP + !RT migrate_disable() is still around. It is not part of spin_lock()
-anymore so it has almost no users. However the futex code has a workaround for
-the !in_atomic() part of migrate disable which fails because the matching
-migrade_disable() is no longer part of spin_lock().
-
-On !SMP + !RT migrate_disable() is reduced to barrier(). This is not optimal
-because we few spots where a "preempt_disable()" statement was replaced with
-"migrate_disable()".
-
-We also used the migration_disable counter to figure out if a sleeping lock is
-acquired so RCU does not complain about schedule() during rcu_read_lock() while
-a sleeping lock is held. This changed, we no longer use it, we have now a
-sleeping_lock counter for the RCU purpose.
-
-This means we can now:
-- for SMP + RT_BASE
- full migration program, nothing changes here
-
-- for !SMP + RT_BASE
- the migration counting is no longer required. It used to ensure that the task
- is not migrated to another CPU and that this CPU remains online. !SMP ensures
- that already.
- Move it to CONFIG_SCHED_DEBUG so the counting is done for debugging purpose
- only.
-
-- for all other cases including !RT
- fallback to preempt_disable(). The only remaining users of migrate_disable()
- are those which were converted from preempt_disable() and the futex
- workaround which is already in the preempt_disable() section due to the
- spin_lock that is held.
-
-Cc: stable-rt@vger.kernel.org
-Reported-by: joe.korty@concurrent-rt.com
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/preempt.h | 6 +++---
- include/linux/sched.h | 4 ++--
- kernel/sched/core.c | 21 ++++++++++-----------
- kernel/sched/debug.c | 2 +-
- 4 files changed, 16 insertions(+), 17 deletions(-)
-
---- a/include/linux/preempt.h
-+++ b/include/linux/preempt.h
-@@ -201,7 +201,7 @@ do { \
-
- #define preemptible() (preempt_count() == 0 && !irqs_disabled())
-
--#ifdef CONFIG_SMP
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-
- extern void migrate_disable(void);
- extern void migrate_enable(void);
-@@ -218,8 +218,8 @@ static inline int __migrate_disabled(str
- }
-
- #else
--#define migrate_disable() barrier()
--#define migrate_enable() barrier()
-+#define migrate_disable() preempt_disable()
-+#define migrate_enable() preempt_enable()
- static inline int __migrate_disabled(struct task_struct *p)
- {
- return 0;
---- a/include/linux/sched.h
-+++ b/include/linux/sched.h
-@@ -658,7 +658,7 @@ struct task_struct {
- int nr_cpus_allowed;
- const cpumask_t *cpus_ptr;
- cpumask_t cpus_mask;
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- int migrate_disable;
- int migrate_disable_update;
- # ifdef CONFIG_SCHED_DEBUG
-@@ -666,8 +666,8 @@ struct task_struct {
- # endif
-
- #elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-- int migrate_disable;
- # ifdef CONFIG_SCHED_DEBUG
-+ int migrate_disable;
- int migrate_disable_atomic;
- # endif
- #endif
---- a/kernel/sched/core.c
-+++ b/kernel/sched/core.c
-@@ -1087,7 +1087,7 @@ void set_cpus_allowed_common(struct task
- p->nr_cpus_allowed = cpumask_weight(new_mask);
- }
-
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- int __migrate_disabled(struct task_struct *p)
- {
- return p->migrate_disable;
-@@ -1127,7 +1127,7 @@ static void __do_set_cpus_allowed_tail(s
-
- void do_set_cpus_allowed(struct task_struct *p, const struct cpumask *new_mask)
- {
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- if (__migrate_disabled(p)) {
- lockdep_assert_held(&p->pi_lock);
-
-@@ -7186,7 +7186,7 @@ const u32 sched_prio_to_wmult[40] = {
-
- #undef CREATE_TRACE_POINTS
-
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-
- static inline void
- update_nr_migratory(struct task_struct *p, long delta)
-@@ -7330,45 +7330,44 @@ EXPORT_SYMBOL(migrate_enable);
- #elif !defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- void migrate_disable(void)
- {
-+#ifdef CONFIG_SCHED_DEBUG
- struct task_struct *p = current;
-
- if (in_atomic() || irqs_disabled()) {
--#ifdef CONFIG_SCHED_DEBUG
- p->migrate_disable_atomic++;
--#endif
- return;
- }
--#ifdef CONFIG_SCHED_DEBUG
-+
- if (unlikely(p->migrate_disable_atomic)) {
- tracing_off();
- WARN_ON_ONCE(1);
- }
--#endif
-
- p->migrate_disable++;
-+#endif
-+ barrier();
- }
- EXPORT_SYMBOL(migrate_disable);
-
- void migrate_enable(void)
- {
-+#ifdef CONFIG_SCHED_DEBUG
- struct task_struct *p = current;
-
- if (in_atomic() || irqs_disabled()) {
--#ifdef CONFIG_SCHED_DEBUG
- p->migrate_disable_atomic--;
--#endif
- return;
- }
-
--#ifdef CONFIG_SCHED_DEBUG
- if (unlikely(p->migrate_disable_atomic)) {
- tracing_off();
- WARN_ON_ONCE(1);
- }
--#endif
-
- WARN_ON_ONCE(p->migrate_disable <= 0);
- p->migrate_disable--;
-+#endif
-+ barrier();
- }
- EXPORT_SYMBOL(migrate_enable);
- #endif
---- a/kernel/sched/debug.c
-+++ b/kernel/sched/debug.c
-@@ -979,7 +979,7 @@ void proc_sched_show_task(struct task_st
- P(dl.runtime);
- P(dl.deadline);
- }
--#if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP)
-+#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
- P(migrate_disable);
- #endif
- P(nr_cpus_allowed);
diff --git a/debian/patches-rt/sched-migrate_enable-Use-stop_one_cpu_nowait.patch b/debian/patches-rt/sched-migrate_enable-Use-stop_one_cpu_nowait.patch
new file mode 100644
index 000000000000..e75d0e3066f7
--- /dev/null
+++ b/debian/patches-rt/sched-migrate_enable-Use-stop_one_cpu_nowait.patch
@@ -0,0 +1,112 @@
+From: Scott Wood <swood@redhat.com>
+Date: Sat, 12 Oct 2019 01:52:14 -0500
+Subject: [PATCH] sched: migrate_enable: Use stop_one_cpu_nowait()
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+migrate_enable() can be called with current->state != TASK_RUNNING.
+Avoid clobbering the existing state by using stop_one_cpu_nowait().
+Since we're stopping the current cpu, we know that we won't get
+past __schedule() until migration_cpu_stop() has run (at least up to
+the point of migrating us to another cpu).
+
+Signed-off-by: Scott Wood <swood@redhat.com>
+[bigeasy: spin until the request has been processed]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ include/linux/stop_machine.h | 2 ++
+ kernel/sched/core.c | 27 +++++++++++++++++----------
+ kernel/stop_machine.c | 7 +++++--
+ 3 files changed, 24 insertions(+), 12 deletions(-)
+
+--- a/include/linux/stop_machine.h
++++ b/include/linux/stop_machine.h
+@@ -26,6 +26,8 @@ struct cpu_stop_work {
+ cpu_stop_fn_t fn;
+ void *arg;
+ struct cpu_stop_done *done;
++ /* Did not run due to disabled stopper; for nowait debug checks */
++ bool disabled;
+ };
+
+ int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg);
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -1536,6 +1536,7 @@ static struct rq *move_queued_task(struc
+ struct migration_arg {
+ struct task_struct *task;
+ int dest_cpu;
++ bool done;
+ };
+
+ /*
+@@ -1571,6 +1572,11 @@ static int migration_cpu_stop(void *data
+ struct task_struct *p = arg->task;
+ struct rq *rq = this_rq();
+ struct rq_flags rf;
++ int dest_cpu = arg->dest_cpu;
++
++ /* We don't look at arg after this point. */
++ smp_mb();
++ arg->done = true;
+
+ /*
+ * The original target CPU might have gone down and we might
+@@ -1593,9 +1599,9 @@ static int migration_cpu_stop(void *data
+ */
+ if (task_rq(p) == rq) {
+ if (task_on_rq_queued(p))
+- rq = __migrate_task(rq, &rf, p, arg->dest_cpu);
++ rq = __migrate_task(rq, &rf, p, dest_cpu);
+ else
+- p->wake_cpu = arg->dest_cpu;
++ p->wake_cpu = dest_cpu;
+ }
+ rq_unlock(rq, &rf);
+ raw_spin_unlock(&p->pi_lock);
+@@ -8144,7 +8150,8 @@ void migrate_enable(void)
+
+ WARN_ON(smp_processor_id() != cpu);
+ if (!is_cpu_allowed(p, cpu)) {
+- struct migration_arg arg = { p };
++ struct migration_arg arg = { .task = p };
++ struct cpu_stop_work work;
+ struct rq_flags rf;
+
+ rq = task_rq_lock(p, &rf);
+@@ -8152,13 +8159,13 @@ void migrate_enable(void)
+ arg.dest_cpu = select_fallback_rq(cpu, p);
+ task_rq_unlock(rq, p, &rf);
+
+- preempt_enable();
+-
+- sleeping_lock_inc();
+- stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
+- sleeping_lock_dec();
+- return;
+-
++ stop_one_cpu_nowait(task_cpu(p), migration_cpu_stop,
++ &arg, &work);
++ __schedule(true);
++ if (!work.disabled) {
++ while (!arg.done)
++ cpu_relax();
++ }
+ }
+
+ out:
+--- a/kernel/stop_machine.c
++++ b/kernel/stop_machine.c
+@@ -86,8 +86,11 @@ static bool cpu_stop_queue_work(unsigned
+ enabled = stopper->enabled;
+ if (enabled)
+ __cpu_stop_queue_work(stopper, work, &wakeq);
+- else if (work->done)
+- cpu_stop_signal_done(work->done);
++ else {
++ work->disabled = true;
++ if (work->done)
++ cpu_stop_signal_done(work->done);
++ }
+ raw_spin_unlock_irqrestore(&stopper->lock, flags);
+
+ wake_up_q(&wakeq);
diff --git a/debian/patches-rt/sched-mmdrop-delayed.patch b/debian/patches-rt/sched-mmdrop-delayed.patch
index 983ddce1d0b7..7fa9e561404e 100644
--- a/debian/patches-rt/sched-mmdrop-delayed.patch
+++ b/debian/patches-rt/sched-mmdrop-delayed.patch
@@ -1,7 +1,7 @@
Subject: sched: Move mmdrop to RCU on RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 06 Jun 2011 12:20:33 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Takes sleeping locks and calls into the memory allocator, so nothing
we want to do in task switch and oder atomic contexts.
@@ -24,11 +24,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include <linux/page-flags-layout.h>
#include <linux/workqueue.h>
-@@ -496,6 +497,9 @@ struct mm_struct {
+@@ -520,6 +521,9 @@ struct mm_struct {
bool tlb_flush_batched;
#endif
struct uprobes_state uprobes_state;
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+ struct rcu_head delayed_drop;
+#endif
#ifdef CONFIG_HUGETLB_PAGE
@@ -40,7 +40,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
__mmdrop(mm);
}
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+extern void __mmdrop_delayed(struct rcu_head *rhp);
+static inline void mmdrop_delayed(struct mm_struct *mm)
+{
@@ -56,11 +56,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* followed by taking the mmap_sem for writing before modifying the
--- a/kernel/fork.c
+++ b/kernel/fork.c
-@@ -685,6 +685,19 @@ void __mmdrop(struct mm_struct *mm)
+@@ -696,6 +696,19 @@ void __mmdrop(struct mm_struct *mm)
}
EXPORT_SYMBOL_GPL(__mmdrop);
-+#ifdef CONFIG_PREEMPT_RT_BASE
++#ifdef CONFIG_PREEMPT_RT
+/*
+ * RCU callback for delayed mm drop. Not strictly rcu, but we don't
+ * want another facility to make this work.
@@ -78,7 +78,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
struct mm_struct *mm;
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -2709,9 +2709,13 @@ static struct rq *finish_task_switch(str
+@@ -3241,9 +3241,13 @@ static struct rq *finish_task_switch(str
* provided by mmdrop(),
* - a sync_core for SYNC_CORE.
*/
@@ -93,7 +93,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
if (unlikely(prev_state == TASK_DEAD)) {
if (prev->sched_class->task_dead)
-@@ -5539,6 +5543,8 @@ void sched_setnuma(struct task_struct *p
+@@ -6173,6 +6177,8 @@ void sched_setnuma(struct task_struct *p
#endif /* CONFIG_NUMA_BALANCING */
#ifdef CONFIG_HOTPLUG_CPU
@@ -102,7 +102,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* Ensure that the idle task is using init_mm right before its CPU goes
* offline.
-@@ -5554,7 +5560,11 @@ void idle_task_exit(void)
+@@ -6188,7 +6194,11 @@ void idle_task_exit(void)
current->active_mm = &init_mm;
finish_arch_post_lock_switch();
}
@@ -115,7 +115,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
/*
-@@ -5866,6 +5876,10 @@ int sched_cpu_dying(unsigned int cpu)
+@@ -6494,6 +6504,10 @@ int sched_cpu_dying(unsigned int cpu)
update_max_interval();
nohz_balance_exit_idle(rq);
hrtick_clear(rq);
diff --git a/debian/patches-rt/sched-rt-mutex-wakeup.patch b/debian/patches-rt/sched-rt-mutex-wakeup.patch
index b5bc8c7cbaae..fac8c65fc5d4 100644
--- a/debian/patches-rt/sched-rt-mutex-wakeup.patch
+++ b/debian/patches-rt/sched-rt-mutex-wakeup.patch
@@ -1,7 +1,7 @@
Subject: sched: Add saved_state for tasks blocked on sleeping locks
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sat, 25 Jun 2011 09:21:04 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Spinlocks are state preserving in !RT. RT changes the state when a
task gets blocked on a lock. So we need to remember the state before
@@ -12,13 +12,13 @@ sleep is done, the saved state is restored.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/sched.h | 3 +++
- kernel/sched/core.c | 33 ++++++++++++++++++++++++++++++++-
+ kernel/sched/core.c | 42 +++++++++++++++++++++++++++++++++++++++---
kernel/sched/sched.h | 1 +
- 3 files changed, 36 insertions(+), 1 deletion(-)
+ 3 files changed, 43 insertions(+), 3 deletions(-)
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -591,6 +591,8 @@ struct task_struct {
+@@ -631,6 +631,8 @@ struct task_struct {
#endif
/* -1 unrunnable, 0 runnable, >0 stopped: */
volatile long state;
@@ -27,7 +27,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* This begins the randomizable portion of task_struct. Only
-@@ -1638,6 +1640,7 @@ extern struct task_struct *find_get_task
+@@ -1679,6 +1681,7 @@ extern struct task_struct *find_get_task
extern int wake_up_state(struct task_struct *tsk, unsigned int state);
extern int wake_up_process(struct task_struct *tsk);
@@ -37,11 +37,30 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#ifdef CONFIG_SMP
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -2026,8 +2026,27 @@ try_to_wake_up(struct task_struct *p, un
+@@ -2523,6 +2523,8 @@ try_to_wake_up(struct task_struct *p, un
+ int cpu, success = 0;
+
+ preempt_disable();
++
++#ifndef CONFIG_PREEMPT_RT
+ if (p == current) {
+ /*
+ * We're waking current, this means 'p->on_rq' and 'task_cpu(p)
+@@ -2545,7 +2547,7 @@ try_to_wake_up(struct task_struct *p, un
+ trace_sched_wakeup(p);
+ goto out;
+ }
+-
++#endif
+ /*
+ * If we are going to wake up a thread waiting for CONDITION we
+ * need to ensure that CONDITION=1 done by the caller can not be
+@@ -2554,8 +2556,27 @@ try_to_wake_up(struct task_struct *p, un
*/
raw_spin_lock_irqsave(&p->pi_lock, flags);
smp_mb__after_spinlock();
- if (!(p->state & state))
+- goto unlock;
+ if (!(p->state & state)) {
+ /*
+ * The task might be running due to a spinlock sleeper
@@ -54,9 +73,9 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ success = 1;
+ }
+ }
- goto out;
++ raw_spin_unlock_irqrestore(&p->pi_lock, flags);
++ goto out_nostat;
+ }
-+
+ /*
+ * If this is a regular wakeup, then we can unconditionally
+ * clear the saved state of a "lock sleeper".
@@ -66,7 +85,20 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
trace_sched_waking(p);
-@@ -2142,6 +2161,18 @@ int wake_up_process(struct task_struct *
+@@ -2647,9 +2668,12 @@ try_to_wake_up(struct task_struct *p, un
+ ttwu_queue(p, cpu, wake_flags);
+ unlock:
+ raw_spin_unlock_irqrestore(&p->pi_lock, flags);
++#ifndef CONFIG_PREEMPT_RT
+ out:
++#endif
+ if (success)
+ ttwu_stat(p, cpu, wake_flags);
++out_nostat:
+ preempt_enable();
+
+ return success;
+@@ -2672,6 +2696,18 @@ int wake_up_process(struct task_struct *
}
EXPORT_SYMBOL(wake_up_process);
@@ -87,7 +119,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return try_to_wake_up(p, state, 0);
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
-@@ -1591,6 +1591,7 @@ static inline int task_on_rq_migrating(s
+@@ -1644,6 +1644,7 @@ static inline int task_on_rq_migrating(s
#define WF_SYNC 0x01 /* Waker goes to sleep after wakeup */
#define WF_FORK 0x02 /* Child wakeup after fork */
#define WF_MIGRATED 0x4 /* Internal use, task got migrated */
diff --git a/debian/patches-rt/scsi-fcoe-rt-aware.patch b/debian/patches-rt/scsi-fcoe-rt-aware.patch
index 999957a859fa..535fadbd3fb3 100644
--- a/debian/patches-rt/scsi-fcoe-rt-aware.patch
+++ b/debian/patches-rt/scsi-fcoe-rt-aware.patch
@@ -1,7 +1,7 @@
Subject: scsi/fcoe: Make RT aware.
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sat, 12 Nov 2011 14:00:48 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Do not disable preemption while taking sleeping locks. All user look safe
for migrate_diable() only.
@@ -15,7 +15,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
-@@ -1446,11 +1446,11 @@ static int fcoe_rcv(struct sk_buff *skb,
+@@ -1452,11 +1452,11 @@ static int fcoe_rcv(struct sk_buff *skb,
static int fcoe_alloc_paged_crc_eof(struct sk_buff *skb, int tlen)
{
struct fcoe_percpu_s *fps;
@@ -30,7 +30,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return rc;
}
-@@ -1637,11 +1637,11 @@ static inline int fcoe_filter_frames(str
+@@ -1641,11 +1641,11 @@ static inline int fcoe_filter_frames(str
return 0;
}
@@ -44,7 +44,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return -EINVAL;
}
-@@ -1682,7 +1682,7 @@ static void fcoe_recv_frame(struct sk_bu
+@@ -1686,7 +1686,7 @@ static void fcoe_recv_frame(struct sk_bu
*/
hp = (struct fcoe_hdr *) skb_network_header(skb);
@@ -53,7 +53,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (unlikely(FC_FCOE_DECAPS_VER(hp) != FC_FCOE_VER)) {
if (stats->ErrorFrames < 5)
printk(KERN_WARNING "fcoe: FCoE version "
-@@ -1714,13 +1714,13 @@ static void fcoe_recv_frame(struct sk_bu
+@@ -1718,13 +1718,13 @@ static void fcoe_recv_frame(struct sk_bu
goto drop;
if (!fcoe_filter_frames(lport, fp)) {
diff --git a/debian/patches-rt/seqlock-prevent-rt-starvation.patch b/debian/patches-rt/seqlock-prevent-rt-starvation.patch
index 70bbae4be8ce..dbb2e6b123e3 100644
--- a/debian/patches-rt/seqlock-prevent-rt-starvation.patch
+++ b/debian/patches-rt/seqlock-prevent-rt-starvation.patch
@@ -1,7 +1,7 @@
Subject: seqlock: Prevent rt starvation
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 22 Feb 2012 12:03:30 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
If a low prio writer gets preempted while holding the seqlock write
locked, a high prio reader spins forever on RT.
@@ -67,7 +67,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
* Read side functions for starting and finalizing a read side section.
*/
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
static inline unsigned read_seqbegin(const seqlock_t *sl)
{
return read_seqcount_begin(&sl->seqcount);
diff --git a/debian/patches-rt/serial-8250-export-symbols-which-are-used-by-symbols.patch b/debian/patches-rt/serial-8250-export-symbols-which-are-used-by-symbols.patch
index 077c9fe339bc..dac1b0e77456 100644
--- a/debian/patches-rt/serial-8250-export-symbols-which-are-used-by-symbols.patch
+++ b/debian/patches-rt/serial-8250-export-symbols-which-are-used-by-symbols.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat, 16 Feb 2019 09:02:00 +0100
Subject: [PATCH] serial: 8250: export symbols which are used by symbols
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
@@ -11,7 +11,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
-@@ -2084,6 +2084,7 @@ void clear_ier(struct uart_8250_port *up
+@@ -2025,6 +2025,7 @@ void clear_ier(struct uart_8250_port *up
}
console_atomic_unlock(flags);
}
@@ -19,7 +19,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
void restore_ier(struct uart_8250_port *up)
{
-@@ -2095,6 +2096,7 @@ void restore_ier(struct uart_8250_port *
+@@ -2036,6 +2037,7 @@ void restore_ier(struct uart_8250_port *
serial_port_out(port, UART_IER, atomic_read(&ier_value));
console_atomic_unlock(flags);
}
@@ -29,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -2247,6 +2247,7 @@ int is_console_locked(void)
+@@ -2257,6 +2257,7 @@ int is_console_locked(void)
{
return console_locked;
}
diff --git a/debian/patches-rt/serial-8250-remove-that-trylock-in-serial8250_consol.patch b/debian/patches-rt/serial-8250-remove-that-trylock-in-serial8250_consol.patch
index 5f0842f6675a..48f8fca01923 100644
--- a/debian/patches-rt/serial-8250-remove-that-trylock-in-serial8250_consol.patch
+++ b/debian/patches-rt/serial-8250-remove-that-trylock-in-serial8250_consol.patch
@@ -2,7 +2,7 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 14 Feb 2019 17:38:24 +0100
Subject: [PATCH] serial: 8250: remove that trylock in
serial8250_console_write_atomic()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This does not work as rtmutex in NMI context. As per John, it is not
needed.
@@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
-@@ -3276,17 +3276,9 @@ void serial8250_console_write_atomic(str
+@@ -3187,17 +3187,9 @@ void serial8250_console_write_atomic(str
{
struct uart_port *port = &up->port;
unsigned int flags;
@@ -32,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
touch_nmi_watchdog();
clear_ier(up);
-@@ -3301,9 +3293,6 @@ void serial8250_console_write_atomic(str
+@@ -3212,9 +3204,6 @@ void serial8250_console_write_atomic(str
wait_for_xmitr(up, BOTH_EMPTY);
restore_ier(up);
diff --git a/debian/patches-rt/series b/debian/patches-rt/series
index 9dab6296822b..97d479a2a19c 100644
--- a/debian/patches-rt/series
+++ b/debian/patches-rt/series
@@ -5,6 +5,44 @@
############################################################
# UPSTREAM merged
############################################################
+# e950cca3f3c40902a052a78a36b3fac1f8a62d19
+lib-smp_processor_id-Don-t-use-cpumask_equal.patch
+# ce5c31db3645b649a31044a4d8b6057f6c723702
+lib-ubsan-Don-t-seralize-UBSAN-report.patch
+
+# 2019-08-09 14:42 Jan Kara [PATCH 0/7 v2] jbd2: Bit spinlock conversions
+# + fixups due to Buffer-heads rom above
+# d84560f74d852ea0cf663edeaee3a470917c2f36 and later
+0001-jbd2-Simplify-journal_unmap_buffer.patch
+0002-jbd2-Remove-jbd_trylock_bh_state.patch
+0003-jbd2-Move-dropping-of-jh-reference-out-of-un-re-fili.patch
+0004-jbd2-Drop-unnecessary-branch-from-jbd2_journal_forge.patch
+0005-jbd2-Don-t-call-__bforget-unnecessarily.patch
+0006-jbd2-Make-state-lock-a-spinlock.patch
+0007-jbd2-Free-journal-head-outside-of-locked-region.patch
+
+# 5a6446626d7e062b47a5cc1cf27d5060e60bb0d9
+workqueue-Convert-for_each_wq-to-use-built-in-list-c.patch
+# df4393424af3fbdcd5c404077176082a8ce459c4
+x86-ioapic-Prevent-inconsistent-state-when-moving-an.patch
+# 2579a4eefc04d1c23eef8f3f0db3309f955e5792
+x86-ioapic-Rename-misnamed-functions.patch
+# 9e8d42a0f7eb9056f8bdb241b91738b5a2923f4c
+percpu-refcount-use-normal-instead-of-RCU-sched.patch
+# 1dfffa0051eae890ce36924651ecff60df5d779e
+drm-i915-Don-t-disable-interrupts-independently-of-t.patch
+# a19f89335f4bda3d77d991c96583e3e51856acbb
+watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch
+# de678bc63cc659d056a5ff3a3b11866d3eb4c1a9
+block-Don-t-disable-interrupts-in-trigger_softirq.patch
+# 0492747c72a3db0425a234abafb763c5b28c845d
+arm64-KVM-compute_layout-before-altenates-are-applie.patch
+# 4eab421bc339e ("net: sched: Avoid using yield() in a busy waiting loop")
+net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch
+# 81f1ba586e393 ("mm/vmalloc: remove preempt_disable/enable when doing preloading")
+mm-vmalloc-remove-preempt_disable-enable-when-doing-.patch
+# 9090825fa99740f0c794f94b9cbd57ad79101228
+KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch
############################################################
# POSTED by others
@@ -48,137 +86,156 @@ printk-devkmsg-llseek-reset-clear-if-it-is-lost.patch
printk-print-rate-limitted-message-as-info.patch
printk-kmsg_dump-remove-mutex-usage.patch
printk-devkmsg-read-Return-EPIPE-when-the-first-mess.patch
+printk-handle-iterating-while-buffer-changing.patch
+printk-hack-out-emergency-loglevel-usage.patch
############################################################
# POSTED
############################################################
-x86-ioapic-Don-t-let-setaffinity-unmask-threaded-EOI.patch
-cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch
-fscache-initialize-cookie-hash-table-raw-spinlocks.patch
-Drivers-hv-vmbus-include-header-for-get_irq_regs.patch
-percpu-include-irqflags.h-for-raw_local_irq_save.patch
-mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch
-tpm-remove-tpm_dev_wq_lock.patch
-drm-i915-Don-t-disable-interrupts-independently-of-t.patch
-locking-lockdep-Don-t-complain-about-incorrect-name-.patch
-arm-imx6-cpuidle-Use-raw_spinlock_t.patch
-x86-ldt-Initialize-the-context-lock-for-init_mm.patch
-i2c-exynos5-Remove-IRQF_ONESHOT.patch
-i2c-hix5hd2-Remove-IRQF_ONESHOT.patch
-sched-deadline-Ensure-inactive_timer-runs-in-hardirq.patch
+# https://lkml.kernel.org/r/20190820170818.oldsdoumzashhcgh@linutronix.de
+# 20191118132824.rclhrbujqh4b4g4d@linutronix.de
+fs-buffer-Make-BH_Uptodate_Lock-bit_spin_lock-a-regu.patch
+
+# 20191008110021.2j44ayunal7fkb7i@linutronix.de
+# Ping => 20191107091108.6ctsai6bdomalmqj@linutronix.de
thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch
+# 20191119121429.zhcubzdhm672zasg@linutronix.de
+perf-core-Add-SRCU-annotation-for-pmus-list-walk.patch
+
############################################################
# Ready for posting
############################################################
-efi-Allow-efi-runtime.patch
-dma-buf-Use-seqlock_t-instread-disabling-preemption.patch
-softirq-Add-preemptible-softirq.patch
-rcu-Acquire-RCU-lock-when-disabling-BHs.patch
-sched-swait-Add-swait_event_lock_irq.patch
-# WORKQUEUE
-workqueue-Make-alloc-apply-free_workqueue_attrs-stat.patch
-workqueue-Remove-GPF-argument-from-alloc_workqueue_a.patch
-workqueue-Convert-the-locks-to-raw-type.patch
-# The two below use a workqueue as workaround
-fs-aio-simple-simple-work.patch
-block-blk-mq-move-blk_queue_usage_counter_release-in.patch
+# 20191015191821.11479-1-bigeasy@linutronix.de
+Use-CONFIG_PREEMPTION.patch
+
+# 20191017090500.ienqyium2phkxpdo@linutronix.de
+BPF-Disable-on-PREEMPT_RT.patch
+
+# WORKQUEUE, delay
+0001-workqueue-Don-t-assume-that-the-callback-has-interru.patch
+0002-sched-swait-Add-swait_event_lock_irq.patch
+0003-workqueue-Use-swait-for-wq_manager_wait.patch
+0004-workqueue-Convert-the-locks-to-raw-type.patch
+
+# XXX
+mm-compaction-Disable-compact_unevictable_allowed-on.patch
############################################################
# Needs to address review feedback
############################################################
+# This one would keep the raw-lock and IRQ on/off as the minimal duct tape.
+# cgroup-use-irqsave-in-cgroup_rstat_flush_locked.patch
+# The alternative to remove unused code.
+# 20190816111817.834-1-bigeasy@linutronix.de | https://www.spinics.net/lists/cgroups/msg23051.html
+0001-cgroup-Remove-css_rstat_flush.patch
+0002-cgroup-Consolidate-users-of-cgroup_rstat_lock.patch
+0003-cgroup-Remove-may_sleep-from-cgroup_rstat_flush_lock.patch
+0004-cgroup-Acquire-cgroup_rstat_lock-with-enabled-interr.patch
+
+# UM, microblaze, ia64 fail to build with this patch (while compiling .S
+# files). Postpone until the orignal issue pops up.
+# percpu-include-irqflags.h-for-raw_local_irq_save.patch
+
+# 20190211113829.sqf6bdi4c4cdd3rp@linutronix.de | 20190821152158.GA12901@cmpxchg.org
+mm-workingset-replace-IRQ-off-check-with-a-lockdep-a.patch
+
+# 20190211105835.16851-1-bigeasy@linutronix.de
+# drop…
+tpm-remove-tpm_dev_wq_lock.patch
+
############################################################
# Almost ready, needs final polishing
############################################################
-arm64-KVM-compute_layout-before-altenates-are-applie.patch
-of-allocate-free-phandle-cache-outside-of-the-devtre.patch
+
+# 20191211232345.24810-1-robh@kernel.org
+of-Rework-and-simplify-phandle-cache-to-use-a-fixed-.patch
+
+# Merge, check, repost.
kmemleak-Turn-kmemleak_lock-to-raw-spinlock-on-RT.patch
-futex-Make-the-futex_hash_bucket-lock-raw.patch
-futex-Delay-deallocation-of-pi_state.patch
-
-# Deleting active timer
-timers-Introduce-expiry-spin-lock.patch
-timers-Drop-expiry-lock-after-each-timer-invocation.patch
-hrtimer-Introduce-expiry-spin-lock.patch
-posix-timers-move-rcu-out-of-union.patch
-posix-timers-expiry-lock.patch
-posix-timers-Unlock-expiry-lock-in-the-early-return.patch
+kmemleak-Change-the-lock-of-kmemleak_object-to-raw_s.patch
###############################################################
# Stuff broken upstream and upstream wants something different
###############################################################
-NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
-kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch
-sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch
-add_migrate_disable.patch
-sched-migrate_disable-Add-export_symbol_gpl-for-__mi.patch
-sched-Remove-dead-__migrate_disabled-check.patch
-# Those two should vanish soon (not use PIT during bootup)
-at91_dont_enable_disable_clock.patch
-clocksource-tclib-allow-higher-clockrates.patch
-
-# Timekeeping split jiffies lock. Needs a good argument :)
+# Timekeeping split jiffies lock or introduce RAW_SEQLOCK
timekeeping-split-jiffies-lock.patch
# PTRACE/SIGNAL crap
+# https://lore.kernel.org/lkml/CADkTA4PBT374CY+UNb85WjQEaNCDodMZu=MgpG8aMYbAu2eOGA@mail.gmail.com/
signal-revert-ptrace-preempt-magic.patch
-# NETWORKING
-net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch
-
##################################################
# REAL RT STUFF starts here
##################################################
-# Kconfig on/off
-rt-preempt-base-config.patch
+############################################################
+# SEQCOUNT related
+# XXX, rework
+dma-buf-Use-seqlock_t-instread-disabling-preemption.patch
+seqlock-prevent-rt-starvation.patch
+NFSv4-replace-seqcount_t-with-a-seqlock_t.patch
+net-Qdisc-use-a-seqlock-instead-seqcount.patch
+net-make-devnet_rename_seq-a-mutex.patch
+
+# Revisit and add to the other NFS crap
+fs-nfs-turn-rmdir_sem-into-a-semaphore.patch
+
+# Revisit
+fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch
+
+# Revisit - check HCH reply. Check all use cases
+list_bl.h-make-list-head-locking-RT-safe.patch
+# Check .... (these are needed due to the previous list_bl change)
+fscache-initialize-cookie-hash-table-raw-spinlocks.patch
+fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch
+fs-dcache-use-swait_queue-instead-of-waitqueue.patch
+############################################################
+
+# proper changelog, check
cpumask-disable-offstack-on-rt.patch
-jump-label-rt.patch
+
+# split changelog
kconfig-disable-a-few-options-rt.patch
-lockdep-disable-self-test.patch
+
+# proper changelog
mm-disable-sloub-rt.patch
-mutex-no-spin-on-rt.patch
+
+# Post
rcu-make-RCU_BOOST-default-on-RT.patch
+
+# Revisit ????
sched-disable-rt-group-sched-on-rt.patch
+
+# Post
net_disable_NET_RX_BUSY_POLL.patch
-arm-disable-NEON-in-kernel-mode.patch
-powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch
-power-disable-highmem-on-rt.patch
-mips-disable-highmem-on-rt.patch
-leds-trigger-disable-CPU-trigger-on-RT.patch
-cpufreq-drop-K8-s-driver-from-beeing-selected.patch
+
+# proper changelog
md-disable-bcache.patch
+
+# proper changelog
efi-Disable-runtime-services-on-RT.patch
-x86-Disable-HAVE_ARCH_JUMP_LABEL.patch
+efi-Allow-efi-runtime.patch
-# PREEMPT NORT
-preempt-nort-rt-variants.patch
+# Fix with something like get_locked_pte_irqsafe ...
+x86-Disable-HAVE_ARCH_JUMP_LABEL.patch
# local locks & migrate disable
+# Rework, write proper changelog and argument
rt-local-irq-lock.patch
-locallock-provide-get-put-_locked_ptr-variants.patch
-# ANNOTATE local_irq_disable sites
-mm-scatterlist-dont-disable-irqs-on-RT.patch
+# Move post local lock
+softirq-Add-preemptible-softirq.patch
# Sigh
+# Check proper again. Crap....
oleg-signal-rt-fix.patch
-x86-signal-delay-calling-signals-on-32bit.patch
-
-# BIT SPINLOCKS - SIGH
-fs-replace-bh_uptodate_lock-for-rt.patch
-fs-jbd-replace-bh_state-lock.patch
-
-# GENIRQ
-list_bl.h-make-list-head-locking-RT-safe.patch
-list_bl-fixup-bogus-lockdep-warning.patch
-genirq-disable-irqpoll-on-rt.patch
-genirq-force-threading.patch
# MM page alloc
+#
0001-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
0002-Split-IRQ-off-and-zone-lock-while-freeing-pages-from.patch
0003-mm-SLxB-change-list_lock-to-raw_spinlock_t.patch
@@ -186,15 +243,18 @@ genirq-force-threading.patch
mm-page_alloc-rt-friendly-per-cpu-pages.patch
# MM SWAP
-mm-convert-swap-to-percpu-locked.patch
-mm-perform-lru_add_drain_all-remotely.patch
+# mm-convert-swap-to-percpu-locked.patch
+# mm-perform-lru_add_drain_all-remotely.patch
+0001-mm-page_alloc-Split-drain_local_pages.patch
+0002-mm-swap-Add-static-key-dependent-pagevec-locking.patch
+0003-mm-swap-Access-struct-pagevec-remotely.patch
+0004-mm-swap-Enable-use_pvec_lock-nohz_full-dependent.patch
+mm-swap-Enable-use-pvec-lock-on-RT.patch
-# MM vmstat
+# PREEMPT NORT
+preempt-nort-rt-variants.patch
mm-make-vmstat-rt-aware.patch
-# MM memory
-re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch
-
# MM SLxB
mm-enable-slub.patch
slub-enable-irqs-for-no-wait.patch
@@ -207,67 +267,65 @@ mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch
mm-zswap-Do-not-disable-preemption-in-zswap_frontswa.patch
# RADIX TREE
+# Local lock use case ....
radix-tree-use-local-locks.patch
-# TIMERS
-timers-prepare-for-full-preemption.patch
-
# KVM require constant freq TSC (smp function call -> cpufreq)
+# proper changelog
x86-kvm-require-const-tsc-for-rt.patch
-#
+
# SIMPLE WAITQUEUE
+# Revisit
pci-switchtec-Don-t-use-completion-s-wait-queue.patch
wait.h-include-atomic.h.patch
completion-use-simple-wait-queues.patch
-sched-completion-Fix-a-lockup-in-wait_for_completion.patch
# HRTIMERS
-hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch
-hrtimer-by-timers-by-default-into-the-softirq-context.patch
-sched-fair-Make-the-hrtimers-non-hard-again.patch
+# Check whether schedule_hrtimeout() could be hard always
+hrtimer-Allow-raw-wakeups-during-boot.patch
+
+# Check, Changelog ...
hrtimer-move-state-change-before-hrtimer_cancel-in-d.patch
-0001-hrtimer-Use-READ_ONCE-to-access-timer-base-in-hrimer.patch
-0002-hrtimer-Don-t-grab-the-expiry-lock-for-non-soft-hrti.patch
-0003-hrtimer-Prevent-using-hrtimer_grab_expiry_lock-on-mi.patch
-hrtimer-Add-a-missing-bracket-and-hide-migration_bas.patch
-KVM-arm-arm64-Let-the-timer-expire-in-hardirq-contex.patch
# POSIX-CPU-TIMERS
posix-timers-thread-posix-cpu-timers-on-rt.patch
+posix-timers-expiry-lock.patch
# SCHEDULER
-sched-delay-put-task.patch
+# PUSH IPI?
sched-limit-nr-migrate.patch
+
+# Combine in series with delay put task
sched-mmdrop-delayed.patch
+
+# Revisit, still needed.
kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch
+
+# RT bulk - Revisit
sched-rt-mutex-wakeup.patch
sched-might-sleep-do-not-account-rcu-depth.patch
-cond-resched-lock-rt-tweak.patch
sched-disable-ttwu-queue.patch
-rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch
-sched-migrate-disable-Protect-cpus_ptr-with-lock.patch
-
-# MIGRATE DISABLE AND PER CPU
-hotplug-light-get-online-cpus.patch
-ftrace-migrate-disable-tracing.patch
-
-# LOCKDEP
-lockdep-no-softirq-accounting-on-rt.patch
# SOFTIRQ
softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch
+
+# A few of those will also just schedule ksoftirqd and schedule at some random
+# point. They may hold a spinlock_t so it is not always random, recheck all.
softirq-preempt-fix-3-re.patch
+
+# Post towards end with x86 crap and skip the rest for now
softirq-disable-softirq-stacks-for-rt.patch
+# Rewrite changelog and repost
net-core-use-local_bh_disable-in-netif_rx_ni.patch
-rtmutex-trylock-is-okay-on-RT.patch
-# compile fix due to rtmutex locks
-fs-nfs-turn-rmdir_sem-into-a-semaphore.patch
+# FUTEX/RTMUTEX
+rtmutex-futex-prepare-rt.patch
+futex-requeue-pi-fix.patch
+futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch
# RTMUTEX
pid.h-include-atomic.h.patch
-arm-include-definition-for-cpumask_t.patch
locking-locktorture-Do-NOT-include-rwlock.h-directly.patch
rtmutex-lock-killable.patch
rtmutex-Make-lock_killable-work.patch
@@ -277,50 +335,50 @@ rtmutex_dont_include_rcu.patch
rtmutex-Provide-rt_mutex_slowlock_locked.patch
rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch
rtmutex-add-sleeping-lock-implementation.patch
+cond-resched-lock-rt-tweak.patch
+locking-rtmutex-Clean-pi_blocked_on-in-the-error-cas.patch
+rtmutex-trylock-is-okay-on-RT.patch
rtmutex-add-mutex-implementation-based-on-rtmutex.patch
rtmutex-add-rwsem-implementation-based-on-rtmutex.patch
rtmutex-add-rwlock-implementation-based-on-rtmutex.patch
rtmutex-wire-up-RT-s-locking.patch
rtmutex-add-ww_mutex-addon-for-mutex-rt.patch
# Allow to enable RT-FULL after sleeping spinlocks are wired up
-kconfig-preempt-rt-full.patch
locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch
locking-rt-mutex-Flush-block-plug-on-__down_read.patch
locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch
ptrace-fix-ptrace-vs-tasklist_lock-race.patch
-rtmutex-annotate-sleeping-lock-context.patch
-sched-migrate_disable-fallback-to-preempt_disable-in.patch
+
+# MIGRATE DISABLE AND PER CPU
+# Revisit
+sched-__set_cpus_allowed_ptr-Check-cpus_mask-not-cpu.patch
+add_migrate_disable.patch
+sched-core-migrate_enable-must-access-takedown_cpu_t.patch
+sched-migrate_enable-Use-stop_one_cpu_nowait.patch
+ftrace-migrate-disable-tracing.patch
+futex-workaround-migrate_disable-enable-in-different.patch
locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch
# RCU
-rcu-Eliminate-softirq-processing-from-rcutree.patch
+# Talk to Paul, Local locks
+locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
rcu-Use-rcuc-threads-on-PREEMPT_RT-as-we-did.patch
srcu-replace-local_irqsave-with-a-locallock.patch
rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch
rcutorture-Avoid-problematic-critical-section-nestin.patch
-# DRIVERS SERIAL
-drivers-tty-fix-omap-lock-crap.patch
-drivers-tty-pl011-irq-disable-madness.patch
-tty-serial-pl011-warning-about-uninitialized.patch
+# Can this be more pretty? Revisit with current RT
rt-serial-warn-fix.patch
-# FS
-mm-protect-activate-switch-mm.patch
-fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch
-fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch
-squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch
-
-# POWER
-powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch
-
# CPU get light
+# Review
epoll-use-get-cpu-light.patch
mm-vmalloc-use-get-cpu-light.patch
-block-mq-use-cpu_light.patch
block-mq-drop-preempt-disable.patch
block-mq-don-t-complete-requests-via-IPI.patch
md-raid5-percpu-handling-rt-aware.patch
+scsi-fcoe-rt-aware.patch
+sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch
# CPU CHILL
rt-introduce-cpu-chill.patch
@@ -329,45 +387,25 @@ rt-introduce-cpu-chill.patch
block-use-cpu-chill.patch
# FS LIVELOCK PREVENTION
-fs-dcache-use-cpu-chill-in-trylock-loops.patch
+fs-namespace-use-cpu-chill-in-trylock-loops.patch
+# Revisit
net-use-cpu-chill.patch
-fs-dcache-use-swait_queue-instead-of-waitqueue.patch
# DEBUGOBJECTS
+# Post
debugobjects-rt.patch
-# SEQLOCKS
-seqlock-prevent-rt-starvation.patch
-
# NETWORKING
-sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch
+# Revisit
skbufhead-raw-lock.patch
net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch
-net-Qdisc-use-a-seqlock-instead-seqcount.patch
-net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch
# irqwork
+# Revisit
irqwork-push_most_work_into_softirq_context.patch
-# ARM
-ARM-enable-irq-in-translation-section-permission-fau.patch
-genirq-update-irq_set_irqchip_state-documentation.patch
-KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch
-arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch
-
-# SYSFS - RT indicator
-sysfs-realtime-entry.patch
-
-# KMAP/HIGHMEM
-mm-rt-kmap-atomic-scheduling.patch
-x86-highmem-add-a-already-used-pte-check.patch
-arm-highmem-flush-tlb-on-unmap.patch
-arm-enable-highmem-for-rt.patch
-
-# SCSI/FCOE
-scsi-fcoe-rt-aware.patch
-
# crypto drivers
+# Revisit
x86-crypto-reduce-preempt-disabled-regions.patch
crypto-Reduce-preempt-disabled-regions-more-algos.patch
crypto-limit-more-FPU-enabled-sections.patch
@@ -375,46 +413,25 @@ crypto-cryptd-add-a-lock-instead-preempt_disable-loc.patch
# RANDOM
panic-disable-random-on-rt.patch
+# Check me ....
x86-stackprot-no-random-on-rt.patch
-powerpc-stackprotector-work-around-stack-guard-init-.patch
+# Random push into ringbuffer
random-make-it-work-on-rt.patch
-# HOTPLUG
-cpu-hotplug--Implement-CPU-pinning.patch
-sched-Allow-pinned-user-tasks-to-be-awakened-to-the-.patch
-hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch
-sched-migrate_dis-enable-Use-sleeping_lock-to-annota.patch
-
# NET
+# Revisit
upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch
-net-another-local-irq-disable-alloc-atomic-headache.patch
-net-core-protect-users-of-napi_alloc_cache-against-r.patch
-net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch
-net-make-devnet_rename_seq-a-mutex.patch
# LOCKDEP
+# Lockdep together with lockdep branch ....
+lockdep-no-softirq-accounting-on-rt.patch
lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch
lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch
-
-# PREEMPT LAZY
-preempt-lazy-support.patch
-ftrace-Fix-trace-header-alignment.patch
-x86-preempt-lazy.patch
-x86-preempt-Check-preemption-level-before-looking-at.patch
-arm-preempt-lazy-support.patch
-powerpc-preempt-lazy-support.patch
-arch-arm64-Add-lazy-preempt-support.patch
-arm64-preempt-Fixup-lazy-preempt.patch
-arm64-preempt-Check-preemption-level-before-looking-.patch
-
-# DRIVERS
-connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
-drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
-drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch
-tpm_tis-fix-stall-after-iowrite-s.patch
-watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch
+# Fix lockdep selftest - talk to Peter - including lockdep branch
+lockdep-disable-self-test.patch
# I915
+# Low prio
drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch
drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch
drm-i915-disable-tracing-on-RT.patch
@@ -423,13 +440,91 @@ drm-i915-Don-t-disable-interrupts-for-intel_engine_b.patch
drm-i915-Drop-the-IRQ-off-asserts.patch
# CGROUPS
+# Revisit and Post
cpuset-Convert-callback_lock-to-raw_spinlock_t.patch
# Security
+# -next, df323337e507a ("apparmor: Use a memory pool instead per-CPU caches")
apparmor-use-a-locallock-instead-preempt_disable.patch
-# Nice to have
+################################################################################
+################################################################################
+# Enable X86-64
+x86-Enable-RT.patch
+################################################################################
+################################################################################
+
+# KMAP/HIGHMEM
+mm-rt-kmap-atomic-scheduling.patch
+x86-highmem-add-a-already-used-pte-check.patch
+arm-highmem-flush-tlb-on-unmap.patch
+arm-enable-highmem-for-rt.patch
+# Rewrite as pagefault disabled is upstream splitted already. The problem comes
+# with the highmem pieces.
+mm-scatterlist-dont-disable-irqs-on-RT.patch
+
+# PREEMPT LAZY
+preempt-lazy-support.patch
+x86-preempt-lazy.patch
+arm-preempt-lazy-support.patch
+powerpc-preempt-lazy-support.patch
+arch-arm64-Add-lazy-preempt-support.patch
+
+jump-label-rt.patch
+
+# Skip until ARM or make it depend on ARM
+leds-trigger-disable-CPU-trigger-on-RT.patch
+
+# DRIVERS SERIAL
+drivers-tty-fix-omap-lock-crap.patch
+drivers-tty-pl011-irq-disable-madness.patch
+tty-serial-pl011-warning-about-uninitialized.patch
+
+# misc ARM
+arm-include-definition-for-cpumask_t.patch
+ARM-enable-irq-in-translation-section-permission-fau.patch
+genirq-update-irq_set_irqchip_state-documentation.patch
+arm-disable-NEON-in-kernel-mode.patch
+KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch
+arm64-fpsimd-use-preemp_disable-in-addition-to-local.patch
+
+# Those two should vanish soon (not use PIT during bootup)
+at91_dont_enable_disable_clock.patch
+clocksource-tclib-allow-higher-clockrates.patch
+
+# Other architectures
+x86-Enable-RT-also-on-32bit.patch
+ARM-Allow-to-enable-RT.patch
+ARM64-Allow-to-enable-RT.patch
+
+# PowerPC
+powerpc-pseries-iommu-Use-a-locallock-instead-local_ir.patch
+powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch
+power-disable-highmem-on-rt.patch
+powerpc-stackprotector-work-around-stack-guard-init-.patch
+POWERPC-Allow-to-enable-RT.patch
+
+# MIPS
+mips-disable-highmem-on-rt.patch
+
+# DRIVERS
+# Postpone, disable
+connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
+
+# Postpone, disable
+drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
+drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch
+squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch
+
+# Generic iowriteN_buffer() function ....
+tpm_tis-fix-stall-after-iowrite-s.patch
+
+# Postpone
signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
+genirq-disable-irqpoll-on-rt.patch
+
+# SYSFS - RT indicator
+sysfs-realtime-entry.patch
# Add RT to version
localversion.patch
diff --git a/debian/patches-rt/signal-revert-ptrace-preempt-magic.patch b/debian/patches-rt/signal-revert-ptrace-preempt-magic.patch
index 8bf85a5add9e..e1a5d984f019 100644
--- a/debian/patches-rt/signal-revert-ptrace-preempt-magic.patch
+++ b/debian/patches-rt/signal-revert-ptrace-preempt-magic.patch
@@ -1,7 +1,7 @@
Subject: signal: Revert ptrace preempt magic
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 21 Sep 2011 19:57:12 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Upstream commit '53da1d9456fe7f8 fix ptrace slowness' is nothing more
than a bandaid around the ptrace design trainwreck. It's not a
@@ -14,7 +14,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/signal.c
+++ b/kernel/signal.c
-@@ -2147,15 +2147,7 @@ static void ptrace_stop(int exit_code, i
+@@ -2197,16 +2197,8 @@ static void ptrace_stop(int exit_code, i
if (gstop_done && ptrace_reparented(current))
do_notify_parent_cldstop(current, false, why);
@@ -26,7 +26,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
- */
- preempt_disable();
read_unlock(&tasklist_lock);
-- preempt_enable_no_resched();
cgroup_enter_frozen();
+- preempt_enable_no_resched();
freezable_schedule();
cgroup_leave_frozen(true);
+ } else {
diff --git a/debian/patches-rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch b/debian/patches-rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
index 2aff5984668f..cc3af2688a2b 100644
--- a/debian/patches-rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
+++ b/debian/patches-rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Fri, 3 Jul 2009 08:44:56 -0500
Subject: signals: Allow rt tasks to cache one sigqueue struct
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
To avoid allocation allow rt tasks to cache one sigqueue struct in
task struct.
@@ -18,7 +18,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -889,6 +889,8 @@ struct task_struct {
+@@ -935,6 +935,8 @@ struct task_struct {
/* Signal handlers: */
struct signal_struct *signal;
struct sighand_struct *sighand;
@@ -50,7 +50,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/fork.c
+++ b/kernel/fork.c
-@@ -1932,6 +1932,7 @@ static __latent_entropy struct task_stru
+@@ -1924,6 +1924,7 @@ static __latent_entropy struct task_stru
spin_lock_init(&p->alloc_lock);
init_sigpending(&p->pending);
@@ -68,7 +68,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
-@@ -398,13 +399,30 @@ void task_join_group_stop(struct task_st
+@@ -403,13 +404,30 @@ void task_join_group_stop(struct task_st
}
}
@@ -100,7 +100,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
{
struct sigqueue *q = NULL;
struct user_struct *user;
-@@ -421,7 +439,10 @@ static struct sigqueue *
+@@ -426,7 +444,10 @@ static struct sigqueue *
if (override_rlimit ||
atomic_read(&user->sigpending) <=
task_rlimit(t, RLIMIT_SIGPENDING)) {
@@ -112,7 +112,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
} else {
print_dropped_signal(sig);
}
-@@ -438,6 +459,13 @@ static struct sigqueue *
+@@ -443,6 +464,13 @@ static struct sigqueue *
return q;
}
@@ -126,7 +126,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static void __sigqueue_free(struct sigqueue *q)
{
if (q->flags & SIGQUEUE_PREALLOC)
-@@ -447,6 +475,21 @@ static void __sigqueue_free(struct sigqu
+@@ -452,6 +480,21 @@ static void __sigqueue_free(struct sigqu
kmem_cache_free(sigqueue_cachep, q);
}
@@ -148,7 +148,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void flush_sigqueue(struct sigpending *queue)
{
struct sigqueue *q;
-@@ -460,6 +503,21 @@ void flush_sigqueue(struct sigpending *q
+@@ -465,6 +508,21 @@ void flush_sigqueue(struct sigpending *q
}
/*
@@ -170,7 +170,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* Flush all pending signals for this kthread.
*/
void flush_signals(struct task_struct *t)
-@@ -583,7 +641,7 @@ static void collect_signal(int sig, stru
+@@ -588,7 +646,7 @@ static void collect_signal(int sig, stru
(info->si_code == SI_TIMER) &&
(info->si_sys_private);
@@ -179,7 +179,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
} else {
/*
* Ok, it wasn't in the queue. This must be
-@@ -620,6 +678,8 @@ int dequeue_signal(struct task_struct *t
+@@ -625,6 +683,8 @@ int dequeue_signal(struct task_struct *t
bool resched_timer = false;
int signr;
@@ -188,7 +188,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/* We only dequeue private signals from ourselves, we don't let
* signalfd steal them
*/
-@@ -1800,7 +1860,8 @@ EXPORT_SYMBOL(kill_pid);
+@@ -1833,7 +1893,8 @@ EXPORT_SYMBOL(kill_pid);
*/
struct sigqueue *sigqueue_alloc(void)
{
diff --git a/debian/patches-rt/skbufhead-raw-lock.patch b/debian/patches-rt/skbufhead-raw-lock.patch
index bfb00ecb4ada..bd853ddb0b7c 100644
--- a/debian/patches-rt/skbufhead-raw-lock.patch
+++ b/debian/patches-rt/skbufhead-raw-lock.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 12 Jul 2011 15:38:34 +0200
Subject: net: Use skbufhead with raw lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Use the rps lock as rawlock so we can keep irq-off regions. It looks low
latency. However we can't kfree() from this context therefore we defer this
@@ -16,7 +16,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
-@@ -3005,6 +3005,7 @@ struct softnet_data {
+@@ -3011,6 +3011,7 @@ struct softnet_data {
unsigned int dropped;
struct sk_buff_head input_pkt_queue;
struct napi_struct backlog;
@@ -26,7 +26,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
-@@ -285,6 +285,7 @@ struct sk_buff_head {
+@@ -293,6 +293,7 @@ struct sk_buff_head {
__u32 qlen;
spinlock_t lock;
@@ -34,7 +34,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
};
struct sk_buff;
-@@ -1820,6 +1821,12 @@ static inline void skb_queue_head_init(s
+@@ -1844,6 +1845,12 @@ static inline void skb_queue_head_init(s
__skb_queue_head_init(list);
}
@@ -49,7 +49,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
{
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -217,14 +217,14 @@ static inline struct hlist_head *dev_ind
+@@ -219,14 +219,14 @@ static inline struct hlist_head *dev_ind
static inline void rps_lock(struct softnet_data *sd)
{
#ifdef CONFIG_RPS
@@ -66,7 +66,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#endif
}
-@@ -5327,7 +5327,7 @@ static void flush_backlog(struct work_st
+@@ -5244,7 +5244,7 @@ static void flush_backlog(struct work_st
skb_queue_walk_safe(&sd->input_pkt_queue, skb, tmp) {
if (skb->dev->reg_state == NETREG_UNREGISTERING) {
__skb_unlink(skb, &sd->input_pkt_queue);
@@ -75,7 +75,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
input_queue_head_incr(sd);
}
}
-@@ -5337,11 +5337,14 @@ static void flush_backlog(struct work_st
+@@ -5254,11 +5254,14 @@ static void flush_backlog(struct work_st
skb_queue_walk_safe(&sd->process_queue, skb, tmp) {
if (skb->dev->reg_state == NETREG_UNREGISTERING) {
__skb_unlink(skb, &sd->process_queue);
@@ -91,7 +91,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
static void flush_all_backlogs(void)
-@@ -5941,7 +5944,9 @@ static int process_backlog(struct napi_s
+@@ -5878,7 +5881,9 @@ static int process_backlog(struct napi_s
while (again) {
struct sk_buff *skb;
@@ -101,7 +101,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
rcu_read_lock();
__netif_receive_skb(skb);
rcu_read_unlock();
-@@ -5949,9 +5954,9 @@ static int process_backlog(struct napi_s
+@@ -5886,9 +5891,9 @@ static int process_backlog(struct napi_s
if (++work >= quota)
return work;
@@ -112,7 +112,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
rps_lock(sd);
if (skb_queue_empty(&sd->input_pkt_queue)) {
/*
-@@ -6416,13 +6421,21 @@ static __latent_entropy void net_rx_acti
+@@ -6369,13 +6374,21 @@ static __latent_entropy void net_rx_acti
unsigned long time_limit = jiffies +
usecs_to_jiffies(netdev_budget_usecs);
int budget = netdev_budget;
@@ -134,7 +134,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
for (;;) {
struct napi_struct *n;
-@@ -9535,10 +9548,13 @@ static int dev_cpu_dead(unsigned int old
+@@ -9891,10 +9904,13 @@ static int dev_cpu_dead(unsigned int old
netif_rx_ni(skb);
input_queue_head_incr(oldsd);
}
@@ -149,7 +149,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return 0;
}
-@@ -9849,8 +9865,9 @@ static int __init net_dev_init(void)
+@@ -10205,8 +10221,9 @@ static int __init net_dev_init(void)
INIT_WORK(flush, flush_backlog);
diff --git a/debian/patches-rt/slub-disable-SLUB_CPU_PARTIAL.patch b/debian/patches-rt/slub-disable-SLUB_CPU_PARTIAL.patch
index de5f7267c6d3..eed51ba881bd 100644
--- a/debian/patches-rt/slub-disable-SLUB_CPU_PARTIAL.patch
+++ b/debian/patches-rt/slub-disable-SLUB_CPU_PARTIAL.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Wed, 15 Apr 2015 19:00:47 +0200
Subject: slub: Disable SLUB_CPU_PARTIAL
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915
|in_atomic(): 1, irqs_disabled(): 0, pid: 87, name: rcuop/7
@@ -37,12 +37,12 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/init/Kconfig
+++ b/init/Kconfig
-@@ -1781,7 +1781,7 @@ config SHUFFLE_PAGE_ALLOCATOR
+@@ -1893,7 +1893,7 @@ config SHUFFLE_PAGE_ALLOCATOR
config SLUB_CPU_PARTIAL
default y
- depends on SLUB && SMP
-+ depends on SLUB && SMP && !PREEMPT_RT_FULL
++ depends on SLUB && SMP && !PREEMPT_RT
bool "SLUB per cpu partial cache"
help
- Per cpu partial caches accellerate objects allocation and freeing
+ Per cpu partial caches accelerate objects allocation and freeing
diff --git a/debian/patches-rt/slub-enable-irqs-for-no-wait.patch b/debian/patches-rt/slub-enable-irqs-for-no-wait.patch
index 95c8b08b10e3..90db15287d4d 100644
--- a/debian/patches-rt/slub-enable-irqs-for-no-wait.patch
+++ b/debian/patches-rt/slub-enable-irqs-for-no-wait.patch
@@ -1,7 +1,7 @@
Subject: slub: Enable irqs for __GFP_WAIT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 09 Jan 2013 12:08:15 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
SYSTEM_RUNNING might be too late for enabling interrupts. Allocations
with GFP_WAIT can happen before that. So use this as an indicator.
@@ -13,9 +13,9 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/mm/slub.c
+++ b/mm/slub.c
-@@ -1621,10 +1621,18 @@ static struct page *allocate_slab(struct
+@@ -1627,10 +1627,18 @@ static struct page *allocate_slab(struct
void *start, *p, *next;
- int idx, order;
+ int idx;
bool shuffle;
+ bool enableirqs = false;
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
if (gfpflags_allow_blocking(flags))
+ enableirqs = true;
+
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (system_state > SYSTEM_BOOTING)
+ enableirqs = true;
+#endif
@@ -32,7 +32,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
local_irq_enable();
flags |= s->allocflags;
-@@ -1684,7 +1692,7 @@ static struct page *allocate_slab(struct
+@@ -1689,7 +1697,7 @@ static struct page *allocate_slab(struct
page->frozen = 1;
out:
diff --git a/debian/patches-rt/softirq-Add-preemptible-softirq.patch b/debian/patches-rt/softirq-Add-preemptible-softirq.patch
index 435bcde261f6..4775acf47427 100644
--- a/debian/patches-rt/softirq-Add-preemptible-softirq.patch
+++ b/debian/patches-rt/softirq-Add-preemptible-softirq.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 20 May 2019 13:09:08 +0200
Subject: [PATCH] softirq: Add preemptible softirq
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add preemptible softirq for RT's needs. By removing the softirq count
from the preempt counter, the softirq becomes preemptible. A per-CPU
@@ -11,6 +11,7 @@ per-CPU variables are not access in parallel by multiple threads.
local_bh_enable() will process all softirq work that has been raised in
its BH-disabled section once the BH counter gets to 0.
+[+ rcu_read_lock() as part of local_bh_disable() by Scott Wood]
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
include/linux/bottom_half.h | 5
@@ -18,9 +19,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
include/linux/preempt.h | 17 ++-
include/linux/rcupdate.h | 3
include/linux/sched.h | 3
- kernel/softirq.c | 222 +++++++++++++++++++++++++++++++++++++++++++-
+ kernel/softirq.c | 228 +++++++++++++++++++++++++++++++++++++++++++-
kernel/time/tick-sched.c | 9 -
- 7 files changed, 246 insertions(+), 14 deletions(-)
+ 7 files changed, 252 insertions(+), 14 deletions(-)
--- a/include/linux/bottom_half.h
+++ b/include/linux/bottom_half.h
@@ -28,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/preempt.h>
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+extern void __local_bh_disable_ip(unsigned long ip, unsigned int cnt);
+#else
+
@@ -45,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
{
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
-@@ -556,6 +556,7 @@ extern void __raise_softirq_irqoff(unsig
+@@ -561,6 +561,7 @@ extern void __raise_softirq_irqoff(unsig
extern void raise_softirq_irqoff(unsigned int nr);
extern void raise_softirq(unsigned int nr);
@@ -76,11 +77,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#define in_nmi() (preempt_count() & NMI_MASK)
#define in_task() (!(preempt_count() & \
(NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)))
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+
-+#define softirq_count() ((long)get_current()->softirq_count)
++#define softirq_count() ((long)current->softirq_count)
+#define in_softirq() (softirq_count())
-+#define in_serving_softirq() (get_current()->softirq_count & SOFTIRQ_OFFSET)
++#define in_serving_softirq() (current->softirq_count & SOFTIRQ_OFFSET)
+
+#else
+
@@ -94,23 +95,23 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* The preempt_count offset after preempt_disable();
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
-@@ -272,7 +272,8 @@ static inline void rcu_preempt_sleep_che
+@@ -279,7 +279,8 @@ static inline void rcu_preempt_sleep_che
#define rcu_sleep_check() \
do { \
rcu_preempt_sleep_check(); \
- RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map), \
-+ if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL)) \
++ if (!IS_ENABLED(CONFIG_PREEMPT_RT)) \
+ RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map), \
"Illegal context switch in RCU-bh read-side critical section"); \
RCU_LOCKDEP_WARN(lock_is_held(&rcu_sched_lock_map), \
"Illegal context switch in RCU-sched read-side critical section"); \
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -923,6 +923,9 @@ struct task_struct {
+@@ -978,6 +978,9 @@ struct task_struct {
int softirqs_enabled;
int softirq_context;
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ int softirq_count;
+#endif
@@ -122,17 +123,17 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
#include <linux/smpboot.h>
#include <linux/tick.h>
#include <linux/irq.h>
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+#include <linux/locallock.h>
+#endif
#define CREATE_TRACE_POINTS
#include <trace/events/irq.h>
-@@ -102,6 +105,98 @@ static bool ksoftirqd_running(unsigned l
+@@ -102,6 +105,104 @@ static bool ksoftirqd_running(unsigned l
* softirq and whether we just have bh disabled.
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+static DEFINE_LOCAL_IRQ_LOCK(bh_lock);
+static DEFINE_PER_CPU(long, softirq_counter);
+
@@ -142,8 +143,10 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ long soft_cnt;
+
+ WARN_ON_ONCE(in_irq());
-+ if (!in_atomic())
++ if (!in_atomic()) {
+ local_lock(bh_lock);
++ rcu_read_lock();
++ }
+ soft_cnt = this_cpu_inc_return(softirq_counter);
+ WARN_ON_ONCE(soft_cnt == 0);
+ current->softirq_count += SOFTIRQ_DISABLE_OFFSET;
@@ -178,8 +181,10 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+#endif
+
+ current->softirq_count -= SOFTIRQ_DISABLE_OFFSET;
-+ if (!in_atomic())
++ if (!in_atomic()) {
++ rcu_read_unlock();
+ local_unlock(bh_lock);
++ }
+}
+
+void _local_bh_enable_rt(void)
@@ -212,8 +217,10 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ WARN_ON_ONCE(count < 0);
+ local_irq_enable();
+
-+ if (!in_atomic())
++ if (!in_atomic()) {
++ rcu_read_unlock();
+ local_unlock(bh_lock);
++ }
+
+ current->softirq_count -= SOFTIRQ_DISABLE_OFFSET;
+ preempt_check_resched();
@@ -227,7 +234,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* This one is for softirq.c-internal use,
* where hardirqs are disabled legitimately:
-@@ -196,6 +291,7 @@ void __local_bh_enable_ip(unsigned long
+@@ -196,6 +297,7 @@ void __local_bh_enable_ip(unsigned long
preempt_check_resched();
}
EXPORT_SYMBOL(__local_bh_enable_ip);
@@ -235,11 +242,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
-@@ -266,7 +362,11 @@ asmlinkage __visible void __softirq_entr
+@@ -266,7 +368,11 @@ asmlinkage __visible void __softirq_entr
pending = local_softirq_pending();
account_irq_enter_time(current);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->softirq_count |= SOFTIRQ_OFFSET;
+#else
__local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
@@ -247,23 +254,23 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
in_hardirq = lockdep_softirq_start();
restart:
-@@ -300,9 +400,10 @@ asmlinkage __visible void __softirq_entr
+@@ -300,9 +406,10 @@ asmlinkage __visible void __softirq_entr
h++;
pending >>= softirq_bit;
}
-
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
if (__this_cpu_read(ksoftirqd) == current)
rcu_softirq_qs();
+#endif
local_irq_disable();
pending = local_softirq_pending();
-@@ -316,11 +417,16 @@ asmlinkage __visible void __softirq_entr
+@@ -316,11 +423,16 @@ asmlinkage __visible void __softirq_entr
lockdep_softirq_end(in_hardirq);
account_irq_exit_time(current);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ current->softirq_count &= ~SOFTIRQ_OFFSET;
+#else
__local_bh_enable(SOFTIRQ_OFFSET);
@@ -272,11 +279,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
current_restore_flags(old_flags, PF_MEMALLOC);
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
asmlinkage __visible void do_softirq(void)
{
__u32 pending;
-@@ -338,6 +444,7 @@ asmlinkage __visible void do_softirq(voi
+@@ -338,6 +450,7 @@ asmlinkage __visible void do_softirq(voi
local_irq_restore(flags);
}
@@ -284,11 +291,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Enter an interrupt context.
-@@ -358,6 +465,16 @@ void irq_enter(void)
+@@ -358,6 +471,16 @@ void irq_enter(void)
__irq_enter();
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+
+static inline void invoke_softirq(void)
+{
@@ -301,7 +308,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline void invoke_softirq(void)
{
if (ksoftirqd_running(local_softirq_pending()))
-@@ -383,6 +500,7 @@ static inline void invoke_softirq(void)
+@@ -383,6 +506,7 @@ static inline void invoke_softirq(void)
wakeup_softirqd();
}
}
@@ -309,11 +316,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
static inline void tick_irq_exit(void)
{
-@@ -420,6 +538,27 @@ void irq_exit(void)
+@@ -420,6 +544,27 @@ void irq_exit(void)
/*
* This function must run with irqs disabled!
*/
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+void raise_softirq_irqoff(unsigned int nr)
+{
+ __raise_softirq_irqoff(nr);
@@ -337,7 +344,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
inline void raise_softirq_irqoff(unsigned int nr)
{
__raise_softirq_irqoff(nr);
-@@ -437,6 +576,8 @@ inline void raise_softirq_irqoff(unsigne
+@@ -437,6 +582,8 @@ inline void raise_softirq_irqoff(unsigne
wakeup_softirqd();
}
@@ -346,7 +353,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
void raise_softirq(unsigned int nr)
{
unsigned long flags;
-@@ -594,6 +735,7 @@ static int ksoftirqd_should_run(unsigned
+@@ -594,6 +741,7 @@ static int ksoftirqd_should_run(unsigned
static void run_ksoftirqd(unsigned int cpu)
{
@@ -354,7 +361,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
local_irq_disable();
if (local_softirq_pending()) {
/*
-@@ -602,10 +744,12 @@ static void run_ksoftirqd(unsigned int c
+@@ -602,10 +750,12 @@ static void run_ksoftirqd(unsigned int c
*/
__do_softirq();
local_irq_enable();
@@ -367,11 +374,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
}
#ifdef CONFIG_HOTPLUG_CPU
-@@ -679,6 +823,13 @@ static struct smp_hotplug_thread softirq
+@@ -679,6 +829,13 @@ static struct smp_hotplug_thread softirq
static __init int spawn_ksoftirqd(void)
{
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ int cpu;
+
+ for_each_possible_cpu(cpu)
@@ -381,11 +388,11 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
cpuhp_setup_state_nocalls(CPUHP_SOFTIRQ_DEAD, "softirq:dead", NULL,
takeover_tasklets);
BUG_ON(smpboot_register_percpu_thread(&softirq_threads));
-@@ -687,6 +838,75 @@ static __init int spawn_ksoftirqd(void)
+@@ -687,6 +844,75 @@ static __init int spawn_ksoftirqd(void)
}
early_initcall(spawn_ksoftirqd);
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+
+/*
+ * On preempt-rt a softirq running context might be blocked on a
@@ -459,7 +466,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* GCC does not inline them incorrectly. ]
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
-@@ -893,14 +893,7 @@ static bool can_stop_idle_tick(int cpu,
+@@ -899,14 +899,7 @@ static bool can_stop_idle_tick(int cpu,
return false;
if (unlikely(local_softirq_pending())) {
diff --git a/debian/patches-rt/softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch b/debian/patches-rt/softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch
index 4663d89c10a8..1eb54ea370ab 100644
--- a/debian/patches-rt/softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch
+++ b/debian/patches-rt/softirq-Avoid-a-cancel-dead-lock-in-tasklet-handling.patch
@@ -2,10 +2,10 @@ From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat, 22 Jun 2019 00:09:22 +0200
Subject: [PATCH] softirq: Avoid a cancel dead-lock in tasklet handling due to
preemptible-softirq
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
A pending / active tasklet which is preempted by a task on the same CPU
-will spin indefinitely becauase the tasklet makes no progress.
+will spin indefinitely because the tasklet makes no progress.
To avoid this deadlock we can disable BH which will acquire the
softirq-lock which will force the completion of the softirq and so the
tasklet.
@@ -23,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
-@@ -625,7 +625,10 @@ static inline void tasklet_unlock(struct
+@@ -626,7 +626,10 @@ static inline void tasklet_unlock(struct
static inline void tasklet_unlock_wait(struct tasklet_struct *t)
{
diff --git a/debian/patches-rt/softirq-disable-softirq-stacks-for-rt.patch b/debian/patches-rt/softirq-disable-softirq-stacks-for-rt.patch
index 32aea5059da4..895d709889e0 100644
--- a/debian/patches-rt/softirq-disable-softirq-stacks-for-rt.patch
+++ b/debian/patches-rt/softirq-disable-softirq-stacks-for-rt.patch
@@ -1,7 +1,7 @@
Subject: softirq: Disable softirq stacks for RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Mon, 18 Jul 2011 13:59:17 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Disable extra stacks for softirqs. We want to preempt softirqs and
having them on special IRQ-stack does not make this easier.
@@ -24,7 +24,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void *softirq_ctx[NR_CPUS] __read_mostly;
void *hardirq_ctx[NR_CPUS] __read_mostly;
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
void do_softirq_own_stack(void)
{
call_do_softirq(softirq_ctx[smp_processor_id()]);
@@ -39,7 +39,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
* We store the saved ksp_limit in the unused part
* of the STACK_FRAME_OVERHEAD
*/
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
_GLOBAL(call_do_softirq)
mflr r0
stw r0,4(r1)
@@ -57,7 +57,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
.text
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
_GLOBAL(call_do_softirq)
mflr r0
std r0,16(r1)
@@ -75,7 +75,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
hardirq_ctx[cpu] = NULL;
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
void do_softirq_own_stack(void)
{
struct thread_info *curctx;
@@ -93,7 +93,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
set_irq_regs(old_regs);
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
void do_softirq_own_stack(void)
{
void *orig_sp, *sp = softirq_stack[smp_processor_id()];
@@ -107,15 +107,15 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
void fixup_irqs(void)
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
-@@ -1056,6 +1056,7 @@ EXPORT_SYMBOL(native_load_gs_index)
+@@ -1074,6 +1074,7 @@ EXPORT_SYMBOL(native_load_gs_index)
jmp 2b
.previous
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
/* Call softirq on interrupt stack. Interrupts are off. */
ENTRY(do_softirq_own_stack)
pushq %rbp
-@@ -1066,6 +1067,7 @@ ENTRY(do_softirq_own_stack)
+@@ -1084,6 +1085,7 @@ ENTRY(do_softirq_own_stack)
leaveq
ret
ENDPROC(do_softirq_own_stack)
@@ -129,7 +129,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return 0;
}
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
void do_softirq_own_stack(void)
{
struct irq_stack *irqstk;
@@ -139,16 +139,16 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
+#endif
- bool handle_irq(struct irq_desc *desc, struct pt_regs *regs)
+ void handle_irq(struct irq_desc *desc, struct pt_regs *regs)
{
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
-@@ -545,7 +545,7 @@ struct softirq_action
+@@ -546,7 +546,7 @@ struct softirq_action
asmlinkage void do_softirq(void);
asmlinkage void __do_softirq(void);
-#ifdef __ARCH_HAS_DO_SOFTIRQ
-+#if defined(__ARCH_HAS_DO_SOFTIRQ) && !defined(CONFIG_PREEMPT_RT_FULL)
++#if defined(__ARCH_HAS_DO_SOFTIRQ) && !defined(CONFIG_PREEMPT_RT)
void do_softirq_own_stack(void);
#else
static inline void do_softirq_own_stack(void)
diff --git a/debian/patches-rt/softirq-preempt-fix-3-re.patch b/debian/patches-rt/softirq-preempt-fix-3-re.patch
index ee179c74bba3..3ef7588e82cb 100644
--- a/debian/patches-rt/softirq-preempt-fix-3-re.patch
+++ b/debian/patches-rt/softirq-preempt-fix-3-re.patch
@@ -1,7 +1,7 @@
Subject: softirq: Check preemption after reenabling interrupts
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 13 Nov 2011 17:17:09 +0100 (CET)
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
raise_softirq_irqoff() disables interrupts and wakes the softirq
daemon, but after reenabling interrupts there is no preemption check,
@@ -15,23 +15,15 @@ Reported-by: Carsten Emde <cbe@osadl.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
- block/blk-softirq.c | 3 +++
+ block/blk-softirq.c | 2 ++
include/linux/preempt.h | 3 +++
lib/irq_poll.c | 5 +++++
net/core/dev.c | 7 +++++++
- 4 files changed, 18 insertions(+)
+ 4 files changed, 17 insertions(+)
--- a/block/blk-softirq.c
+++ b/block/blk-softirq.c
-@@ -53,6 +53,7 @@ static void trigger_softirq(void *data)
- raise_softirq_irqoff(BLOCK_SOFTIRQ);
-
- local_irq_restore(flags);
-+ preempt_check_resched_rt();
- }
-
- /*
-@@ -91,6 +92,7 @@ static int blk_softirq_cpu_dead(unsigned
+@@ -87,6 +87,7 @@ static int blk_softirq_cpu_dead(unsigned
this_cpu_ptr(&blk_cpu_done));
raise_softirq_irqoff(BLOCK_SOFTIRQ);
local_irq_enable();
@@ -39,7 +31,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return 0;
}
-@@ -142,6 +144,7 @@ void __blk_complete_request(struct reque
+@@ -138,6 +139,7 @@ void __blk_complete_request(struct reque
goto do_local;
local_irq_restore(flags);
@@ -49,9 +41,9 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static __init int blk_softirq_init(void)
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
-@@ -193,8 +193,10 @@ do { \
+@@ -189,8 +189,10 @@ do { \
- #ifdef CONFIG_PREEMPT_RT_BASE
+ #ifdef CONFIG_PREEMPT_RT
# define preempt_enable_no_resched() sched_preempt_enable_no_resched()
+# define preempt_check_resched_rt() preempt_check_resched()
#else
@@ -60,14 +52,14 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#endif
#define preemptible() (preempt_count() == 0 && !irqs_disabled())
-@@ -281,6 +283,7 @@ do { \
+@@ -261,6 +263,7 @@ do { \
#define preempt_disable_notrace() barrier()
#define preempt_enable_no_resched_notrace() barrier()
#define preempt_enable_notrace() barrier()
+#define preempt_check_resched_rt() barrier()
#define preemptible() 0
- #define migrate_disable() barrier()
+ #endif /* CONFIG_PREEMPT_COUNT */
--- a/lib/irq_poll.c
+++ b/lib/irq_poll.c
@@ -37,6 +37,7 @@ void irq_poll_sched(struct irq_poll *iop
@@ -112,7 +104,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -2750,6 +2750,7 @@ static void __netif_reschedule(struct Qd
+@@ -2675,6 +2675,7 @@ static void __netif_reschedule(struct Qd
sd->output_queue_tailp = &q->next_sched;
raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_restore(flags);
@@ -120,7 +112,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
void __netif_schedule(struct Qdisc *q)
-@@ -2812,6 +2813,7 @@ void __dev_kfree_skb_irq(struct sk_buff
+@@ -2737,6 +2738,7 @@ void __dev_kfree_skb_irq(struct sk_buff
__this_cpu_write(softnet_data.completion_queue, skb);
raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_restore(flags);
@@ -128,7 +120,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
EXPORT_SYMBOL(__dev_kfree_skb_irq);
-@@ -4298,6 +4300,7 @@ static int enqueue_to_backlog(struct sk_
+@@ -4217,6 +4219,7 @@ static int enqueue_to_backlog(struct sk_
rps_unlock(sd);
local_irq_restore(flags);
@@ -136,7 +128,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
atomic_long_inc(&skb->dev->rx_dropped);
kfree_skb(skb);
-@@ -5903,12 +5906,14 @@ static void net_rps_action_and_irq_enabl
+@@ -5840,12 +5843,14 @@ static void net_rps_action_and_irq_enabl
sd->rps_ipi_list = NULL;
local_irq_enable();
@@ -151,7 +143,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
static bool sd_has_rps_ipi_waiting(struct softnet_data *sd)
-@@ -5986,6 +5991,7 @@ void __napi_schedule(struct napi_struct
+@@ -5923,6 +5928,7 @@ void __napi_schedule(struct napi_struct
local_irq_save(flags);
____napi_schedule(this_cpu_ptr(&softnet_data), n);
local_irq_restore(flags);
@@ -159,7 +151,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
}
EXPORT_SYMBOL(__napi_schedule);
-@@ -9517,6 +9523,7 @@ static int dev_cpu_dead(unsigned int old
+@@ -9873,6 +9879,7 @@ static int dev_cpu_dead(unsigned int old
raise_softirq_irqoff(NET_TX_SOFTIRQ);
local_irq_enable();
diff --git a/debian/patches-rt/spinlock-types-separate-raw.patch b/debian/patches-rt/spinlock-types-separate-raw.patch
index db7c1ee2dfec..7aa8e8fe7f2c 100644
--- a/debian/patches-rt/spinlock-types-separate-raw.patch
+++ b/debian/patches-rt/spinlock-types-separate-raw.patch
@@ -1,7 +1,7 @@
Subject: spinlock: Split the lock types header
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 29 Jun 2011 19:34:01 +0200
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Split raw_spinlock into its own file and the remaining spinlock_t into
its own non-RT header. The non-RT header will be replaced later by sleeping
diff --git a/debian/patches-rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch b/debian/patches-rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch
index eeeb0e2d8648..d1bde857fc41 100644
--- a/debian/patches-rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch
+++ b/debian/patches-rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch
@@ -2,7 +2,7 @@ From: Julia Cartwright <julia@ni.com>
Date: Mon, 7 May 2018 08:58:57 -0500
Subject: [PATCH] squashfs: make use of local lock in multi_cpu
decompressor
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Currently, the squashfs multi_cpu decompressor makes use of
get_cpu_ptr()/put_cpu_ptr(), which unconditionally disable preemption
diff --git a/debian/patches-rt/srcu-replace-local_irqsave-with-a-locallock.patch b/debian/patches-rt/srcu-replace-local_irqsave-with-a-locallock.patch
index dd053c4845b7..792bae9d979a 100644
--- a/debian/patches-rt/srcu-replace-local_irqsave-with-a-locallock.patch
+++ b/debian/patches-rt/srcu-replace-local_irqsave-with-a-locallock.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 12 Oct 2017 18:37:12 +0200
Subject: [PATCH] srcu: replace local_irqsave() with a locallock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
There are two instances which disable interrupts in order to become a
stable this_cpu_ptr() pointer. The restore part is coupled with
@@ -49,7 +49,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* No local callbacks, so probabalistically probe global state.
-@@ -850,7 +852,7 @@ void __call_srcu(struct srcu_struct *ssp
+@@ -850,7 +852,7 @@ static void __call_srcu(struct srcu_stru
}
rhp->func = func;
idx = srcu_read_lock(ssp);
@@ -58,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
sdp = this_cpu_ptr(ssp->sda);
spin_lock_rcu_node(sdp);
rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp, false);
-@@ -866,7 +868,8 @@ void __call_srcu(struct srcu_struct *ssp
+@@ -866,7 +868,8 @@ static void __call_srcu(struct srcu_stru
sdp->srcu_gp_seq_needed_exp = s;
needexp = true;
}
diff --git a/debian/patches-rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch b/debian/patches-rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch
index 1b22fa44176f..098b5e7952ec 100644
--- a/debian/patches-rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch
+++ b/debian/patches-rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch
@@ -1,7 +1,7 @@
From: Mike Galbraith <umgwanakikbuti@gmail.com>
Date: Wed, 18 Feb 2015 16:05:28 +0100
Subject: sunrpc: Make svc_xprt_do_enqueue() use get_cpu_light()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915
|in_atomic(): 1, irqs_disabled(): 0, pid: 3194, name: rpc.nfsd
diff --git a/debian/patches-rt/sysfs-realtime-entry.patch b/debian/patches-rt/sysfs-realtime-entry.patch
index 8113bf95cb36..96746425f0a8 100644
--- a/debian/patches-rt/sysfs-realtime-entry.patch
+++ b/debian/patches-rt/sysfs-realtime-entry.patch
@@ -1,7 +1,7 @@
Subject: sysfs: Add /sys/kernel/realtime entry
From: Clark Williams <williams@redhat.com>
Date: Sat Jul 30 21:55:53 2011 -0500
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Add a /sys/kernel entry to indicate that the kernel is a
realtime kernel.
@@ -24,7 +24,7 @@ Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
#endif /* CONFIG_CRASH_CORE */
-+#if defined(CONFIG_PREEMPT_RT_FULL)
++#if defined(CONFIG_PREEMPT_RT)
+static ssize_t realtime_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
@@ -40,7 +40,7 @@ Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
&rcu_expedited_attr.attr,
&rcu_normal_attr.attr,
#endif
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ &realtime_attr.attr,
+#endif
NULL
diff --git a/debian/patches-rt/thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch b/debian/patches-rt/thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch
index 9b644bfb0495..fbf831409f3a 100644
--- a/debian/patches-rt/thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch
+++ b/debian/patches-rt/thermal-x86_pkg_temp-make-pkg_temp_lock-a-raw-spinlo.patch
@@ -1,11 +1,11 @@
From: Clark Williams <williams@redhat.com>
Date: Mon, 15 Jul 2019 15:25:00 -0500
-Subject: [PATCH] thermal/x86_pkg_temp: make pkg_temp_lock a raw spinlock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Subject: [PATCH] thermal/x86_pkg_temp: Make pkg_temp_lock a raw_spinlock_t
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
The spinlock pkg_temp_lock has the potential of being taken in atomic
-context on v5.2-rt PREEMPT_RT. It's static and limited scope so
-go ahead and make it a raw spinlock.
+context because it can be acquired from the thermal IRQ vector.
+It's static and limited scope so go ahead and make it a raw spinlock.
Signed-off-by: Clark Williams <williams@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
@@ -15,16 +15,16 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
-@@ -63,7 +63,7 @@ static int max_packages __read_mostly;
- /* Array of package pointers */
- static struct pkg_device **packages;
+@@ -63,7 +63,7 @@ static int max_id __read_mostly;
+ /* Array of zone pointers */
+ static struct zone_device **zones;
/* Serializes interrupt notification, work and hotplug */
-static DEFINE_SPINLOCK(pkg_temp_lock);
+static DEFINE_RAW_SPINLOCK(pkg_temp_lock);
/* Protects zone operation in the work function against hotplug removal */
static DEFINE_MUTEX(thermal_zone_mutex);
-@@ -279,12 +279,12 @@ static void pkg_temp_thermal_threshold_w
+@@ -266,12 +266,12 @@ static void pkg_temp_thermal_threshold_w
u64 msr_val, wr_val;
mutex_lock(&thermal_zone_mutex);
@@ -32,14 +32,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ raw_spin_lock_irq(&pkg_temp_lock);
++pkg_work_cnt;
- pkgdev = pkg_temp_thermal_get_dev(cpu);
- if (!pkgdev) {
+ zonedev = pkg_temp_thermal_get_dev(cpu);
+ if (!zonedev) {
- spin_unlock_irq(&pkg_temp_lock);
+ raw_spin_unlock_irq(&pkg_temp_lock);
mutex_unlock(&thermal_zone_mutex);
return;
}
-@@ -298,7 +298,7 @@ static void pkg_temp_thermal_threshold_w
+@@ -285,7 +285,7 @@ static void pkg_temp_thermal_threshold_w
}
enable_pkg_thres_interrupt();
@@ -48,8 +48,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* If tzone is not NULL, then thermal_zone_mutex will prevent the
-@@ -323,7 +323,7 @@ static int pkg_thermal_notify(u64 msr_va
- struct pkg_device *pkgdev;
+@@ -310,7 +310,7 @@ static int pkg_thermal_notify(u64 msr_va
+ struct zone_device *zonedev;
unsigned long flags;
- spin_lock_irqsave(&pkg_temp_lock, flags);
@@ -57,8 +57,8 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
++pkg_interrupt_cnt;
disable_pkg_thres_interrupt();
-@@ -335,7 +335,7 @@ static int pkg_thermal_notify(u64 msr_va
- pkg_thermal_schedule_work(pkgdev->cpu, &pkgdev->work);
+@@ -322,7 +322,7 @@ static int pkg_thermal_notify(u64 msr_va
+ pkg_thermal_schedule_work(zonedev->cpu, &zonedev->work);
}
- spin_unlock_irqrestore(&pkg_temp_lock, flags);
@@ -66,19 +66,19 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 0;
}
-@@ -381,9 +381,9 @@ static int pkg_temp_thermal_device_add(u
- pkgdev->msr_pkg_therm_high);
+@@ -368,9 +368,9 @@ static int pkg_temp_thermal_device_add(u
+ zonedev->msr_pkg_therm_high);
- cpumask_set_cpu(cpu, &pkgdev->cpumask);
+ cpumask_set_cpu(cpu, &zonedev->cpumask);
- spin_lock_irq(&pkg_temp_lock);
+ raw_spin_lock_irq(&pkg_temp_lock);
- packages[pkgid] = pkgdev;
+ zones[id] = zonedev;
- spin_unlock_irq(&pkg_temp_lock);
+ raw_spin_unlock_irq(&pkg_temp_lock);
return 0;
}
-@@ -420,7 +420,7 @@ static int pkg_thermal_cpu_offline(unsig
+@@ -407,7 +407,7 @@ static int pkg_thermal_cpu_offline(unsig
}
/* Protect against work and interrupts */
@@ -87,20 +87,20 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/*
* Check whether this cpu was the current target and store the new
-@@ -452,9 +452,9 @@ static int pkg_thermal_cpu_offline(unsig
+@@ -439,9 +439,9 @@ static int pkg_thermal_cpu_offline(unsig
* To cancel the work we need to drop the lock, otherwise
* we might deadlock if the work needs to be flushed.
*/
- spin_unlock_irq(&pkg_temp_lock);
+ raw_spin_unlock_irq(&pkg_temp_lock);
- cancel_delayed_work_sync(&pkgdev->work);
+ cancel_delayed_work_sync(&zonedev->work);
- spin_lock_irq(&pkg_temp_lock);
+ raw_spin_lock_irq(&pkg_temp_lock);
/*
* If this is not the last cpu in the package and the work
* did not run after we dropped the lock above, then we
-@@ -465,7 +465,7 @@ static int pkg_thermal_cpu_offline(unsig
- pkg_thermal_schedule_work(target, &pkgdev->work);
+@@ -452,7 +452,7 @@ static int pkg_thermal_cpu_offline(unsig
+ pkg_thermal_schedule_work(target, &zonedev->work);
}
- spin_unlock_irq(&pkg_temp_lock);
diff --git a/debian/patches-rt/timekeeping-split-jiffies-lock.patch b/debian/patches-rt/timekeeping-split-jiffies-lock.patch
index b42402d8e8f7..b00aa877d6b5 100644
--- a/debian/patches-rt/timekeeping-split-jiffies-lock.patch
+++ b/debian/patches-rt/timekeeping-split-jiffies-lock.patch
@@ -1,7 +1,7 @@
Subject: timekeeping: Split jiffies seqlock
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 14 Feb 2013 22:36:59 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Replace jiffies_lock seqlock with a simple seqcounter and a rawlock so
it can be taken in atomic context on RT.
@@ -115,7 +115,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return period;
}
-@@ -659,10 +664,10 @@ static ktime_t tick_nohz_next_event(stru
+@@ -661,10 +666,10 @@ static ktime_t tick_nohz_next_event(stru
/* Read jiffies and the time when jiffies were updated last */
do {
@@ -130,7 +130,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
-@@ -2392,8 +2392,10 @@ EXPORT_SYMBOL(hardpps);
+@@ -2397,8 +2397,10 @@ EXPORT_SYMBOL(hardpps);
*/
void xtime_update(unsigned long ticks)
{
diff --git a/debian/patches-rt/timers-Drop-expiry-lock-after-each-timer-invocation.patch b/debian/patches-rt/timers-Drop-expiry-lock-after-each-timer-invocation.patch
deleted file mode 100644
index 1a9f6a76f5e2..000000000000
--- a/debian/patches-rt/timers-Drop-expiry-lock-after-each-timer-invocation.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-From: Anna-Maria Gleixner <anna-maria@linutronix.de>
-Date: Thu, 10 Jan 2019 13:00:07 +0100
-Subject: [PATCH] timers: Drop expiry lock after each timer invocation
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The ->expiry_lock lock is held until every timer is expired. So if a
-__del_timer_sync() caller blocks on the lock then it has to wait until
-every timer callback has completed.
-
-Therefore drop the lock and acquire it after expiring the timer. To be
-able to remove the timer, when it was expired, the running_timer struct
-member has to be resetted to NULL as well. This happens after the timer
-was expired. It is ok to do this lockless, because the only problem
-could be that when a check is done too early, the old expired timer is
-stored in there.
-
-Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
-[bigeasy: Patch description reworded]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/timer.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
---- a/kernel/time/timer.c
-+++ b/kernel/time/timer.c
-@@ -1384,10 +1384,16 @@ static void expire_timers(struct timer_b
- if (timer->flags & TIMER_IRQSAFE) {
- raw_spin_unlock(&base->lock);
- call_timer_fn(timer, fn, baseclk);
-+ base->running_timer = NULL;
-+ spin_unlock(&base->expiry_lock);
-+ spin_lock(&base->expiry_lock);
- raw_spin_lock(&base->lock);
- } else {
- raw_spin_unlock_irq(&base->lock);
- call_timer_fn(timer, fn, baseclk);
-+ base->running_timer = NULL;
-+ spin_unlock(&base->expiry_lock);
-+ spin_lock(&base->expiry_lock);
- raw_spin_lock_irq(&base->lock);
- }
- }
-@@ -1709,7 +1715,6 @@ static inline void __run_timers(struct t
- while (levels--)
- expire_timers(base, heads + levels);
- }
-- base->running_timer = NULL;
- raw_spin_unlock_irq(&base->lock);
- spin_unlock(&base->expiry_lock);
- }
diff --git a/debian/patches-rt/timers-Introduce-expiry-spin-lock.patch b/debian/patches-rt/timers-Introduce-expiry-spin-lock.patch
deleted file mode 100644
index 94a5e12d4cbb..000000000000
--- a/debian/patches-rt/timers-Introduce-expiry-spin-lock.patch
+++ /dev/null
@@ -1,153 +0,0 @@
-From: Anna-Maria Gleixner <anna-maria@linutronix.de>
-Date: Thu, 10 Jan 2019 13:00:06 +0100
-Subject: [PATCH] timers: Introduce expiry spin lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-When del_timer_sync() is called, it is possible, that the CPU has to
-spin, because the timer is marked as running. The function will
-repeatedly try to delete the timer until the timer callback completes
-and the function succeeds.
-On a virtual machine this spinning can waste CPU cycles if the vCPU
-invoking the timer callback is not scheduled by the host (and making no
-progress).
-
-The spinning and time wasting, could be prevented by using PARAVIRT_SPINLOCKS
-and introducing a per timer base spin lock for expiry. The lock is hold during
-expiring the timers of a base. When the deletion of a timer wasn't successful,
-because the timer is running at the moment, the expiry lock is trying to
-accessed instead of cpu_realax(). The lock is already held by the CPU expiring
-the timers, so the CPU could be scheduled out instead of spinning until the lock
-is released, because of the PARAVIRT_SPINLOCKS code. Thereby wasting time
-spinning around is prevented.
-
-The code isn't done conditionally on PARAVIRT_SPINLOCKS. The lock is taken only
-at two places. In one of them the lock is directly dropped after accessing
-it. So the probability for a slowpath when taking the lock is very low. But this
-keeps the code cleaner than introducing several CONFIG_PARAVIRT_SPINLOCKS
-dependend code paths and struct members.
-
-Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
-[bigeasy: Patch description reworded]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/time/timer.c | 57 ++++++++++++++++++++++++++++++++++++++--------------
- 1 file changed, 42 insertions(+), 15 deletions(-)
-
---- a/kernel/time/timer.c
-+++ b/kernel/time/timer.c
-@@ -196,6 +196,7 @@ EXPORT_SYMBOL(jiffies_64);
- struct timer_base {
- raw_spinlock_t lock;
- struct timer_list *running_timer;
-+ spinlock_t expiry_lock;
- unsigned long clk;
- unsigned long next_expiry;
- unsigned int cpu;
-@@ -1201,14 +1202,8 @@ int del_timer(struct timer_list *timer)
- }
- EXPORT_SYMBOL(del_timer);
-
--/**
-- * try_to_del_timer_sync - Try to deactivate a timer
-- * @timer: timer to delete
-- *
-- * This function tries to deactivate a timer. Upon successful (ret >= 0)
-- * exit the timer is not queued and the handler is not running on any CPU.
-- */
--int try_to_del_timer_sync(struct timer_list *timer)
-+static int __try_to_del_timer_sync(struct timer_list *timer,
-+ struct timer_base **basep)
- {
- struct timer_base *base;
- unsigned long flags;
-@@ -1216,7 +1211,7 @@ int try_to_del_timer_sync(struct timer_l
-
- debug_assert_init(timer);
-
-- base = lock_timer_base(timer, &flags);
-+ *basep = base = lock_timer_base(timer, &flags);
-
- if (base->running_timer != timer)
- ret = detach_if_pending(timer, base, true);
-@@ -1225,9 +1220,42 @@ int try_to_del_timer_sync(struct timer_l
-
- return ret;
- }
-+
-+/**
-+ * try_to_del_timer_sync - Try to deactivate a timer
-+ * @timer: timer to delete
-+ *
-+ * This function tries to deactivate a timer. Upon successful (ret >= 0)
-+ * exit the timer is not queued and the handler is not running on any CPU.
-+ */
-+int try_to_del_timer_sync(struct timer_list *timer)
-+{
-+ struct timer_base *base;
-+
-+ return __try_to_del_timer_sync(timer, &base);
-+}
- EXPORT_SYMBOL(try_to_del_timer_sync);
-
- #ifdef CONFIG_SMP
-+static int __del_timer_sync(struct timer_list *timer)
-+{
-+ struct timer_base *base;
-+ int ret;
-+
-+ for (;;) {
-+ ret = __try_to_del_timer_sync(timer, &base);
-+ if (ret >= 0)
-+ return ret;
-+
-+ /*
-+ * When accessing the lock, timers of base are no longer expired
-+ * and so timer is no longer running.
-+ */
-+ spin_lock(&base->expiry_lock);
-+ spin_unlock(&base->expiry_lock);
-+ }
-+}
-+
- /**
- * del_timer_sync - deactivate a timer and wait for the handler to finish.
- * @timer: the timer to be deactivated
-@@ -1283,12 +1311,8 @@ int del_timer_sync(struct timer_list *ti
- * could lead to deadlock.
- */
- WARN_ON(in_irq() && !(timer->flags & TIMER_IRQSAFE));
-- for (;;) {
-- int ret = try_to_del_timer_sync(timer);
-- if (ret >= 0)
-- return ret;
-- cpu_relax();
-- }
-+
-+ return __del_timer_sync(timer);
- }
- EXPORT_SYMBOL(del_timer_sync);
- #endif
-@@ -1658,6 +1682,7 @@ static inline void __run_timers(struct t
- if (!time_after_eq(jiffies, base->clk))
- return;
-
-+ spin_lock(&base->expiry_lock);
- raw_spin_lock_irq(&base->lock);
-
- /*
-@@ -1686,6 +1711,7 @@ static inline void __run_timers(struct t
- }
- base->running_timer = NULL;
- raw_spin_unlock_irq(&base->lock);
-+ spin_unlock(&base->expiry_lock);
- }
-
- /*
-@@ -1930,6 +1956,7 @@ static void __init init_timer_cpu(int cp
- base->cpu = cpu;
- raw_spin_lock_init(&base->lock);
- base->clk = jiffies;
-+ spin_lock_init(&base->expiry_lock);
- }
- }
-
diff --git a/debian/patches-rt/timers-prepare-for-full-preemption.patch b/debian/patches-rt/timers-prepare-for-full-preemption.patch
deleted file mode 100644
index 7a6dd5a23fb5..000000000000
--- a/debian/patches-rt/timers-prepare-for-full-preemption.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From: Ingo Molnar <mingo@elte.hu>
-Date: Fri, 3 Jul 2009 08:29:34 -0500
-Subject: timers: Prepare for full preemption
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-When softirqs can be preempted we need to make sure that cancelling
-the timer from the active thread can not deadlock vs. a running timer
-callback. Add a waitqueue to resolve that.
-
-Signed-off-by: Ingo Molnar <mingo@elte.hu>
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
----
- include/linux/timer.h | 2 +-
- kernel/time/timer.c | 5 +++--
- 2 files changed, 4 insertions(+), 3 deletions(-)
-
---- a/include/linux/timer.h
-+++ b/include/linux/timer.h
-@@ -172,7 +172,7 @@ extern void add_timer(struct timer_list
-
- extern int try_to_del_timer_sync(struct timer_list *timer);
-
--#ifdef CONFIG_SMP
-+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
- extern int del_timer_sync(struct timer_list *timer);
- #else
- # define del_timer_sync(t) del_timer(t)
---- a/kernel/time/timer.c
-+++ b/kernel/time/timer.c
-@@ -1236,7 +1236,7 @@ int try_to_del_timer_sync(struct timer_l
- }
- EXPORT_SYMBOL(try_to_del_timer_sync);
-
--#ifdef CONFIG_SMP
-+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
- static int __del_timer_sync(struct timer_list *timer)
- {
- struct timer_base *base;
-@@ -1381,7 +1381,8 @@ static void expire_timers(struct timer_b
-
- fn = timer->function;
-
-- if (timer->flags & TIMER_IRQSAFE) {
-+ if (!IS_ENABLED(CONFIG_PREEMPT_RT_FULL) &&
-+ timer->flags & TIMER_IRQSAFE) {
- raw_spin_unlock(&base->lock);
- call_timer_fn(timer, fn, baseclk);
- base->running_timer = NULL;
diff --git a/debian/patches-rt/tpm-remove-tpm_dev_wq_lock.patch b/debian/patches-rt/tpm-remove-tpm_dev_wq_lock.patch
index fb8ef54ddd70..3468a18bf1c4 100644
--- a/debian/patches-rt/tpm-remove-tpm_dev_wq_lock.patch
+++ b/debian/patches-rt/tpm-remove-tpm_dev_wq_lock.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 11 Feb 2019 11:33:11 +0100
Subject: [PATCH] tpm: remove tpm_dev_wq_lock
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Added in commit
diff --git a/debian/patches-rt/tpm_tis-fix-stall-after-iowrite-s.patch b/debian/patches-rt/tpm_tis-fix-stall-after-iowrite-s.patch
index 3a4c242e1cc9..de92d6b590f2 100644
--- a/debian/patches-rt/tpm_tis-fix-stall-after-iowrite-s.patch
+++ b/debian/patches-rt/tpm_tis-fix-stall-after-iowrite-s.patch
@@ -1,14 +1,14 @@
From: Haris Okanovic <haris.okanovic@ni.com>
Date: Tue, 15 Aug 2017 15:13:08 -0500
Subject: [PATCH] tpm_tis: fix stall after iowrite*()s
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
ioread8() operations to TPM MMIO addresses can stall the cpu when
immediately following a sequence of iowrite*()'s to the same region.
For example, cyclitest measures ~400us latency spikes when a non-RT
usermode application communicates with an SPI-based TPM chip (Intel Atom
-E3940 system, PREEMPT_RT_FULL kernel). The spikes are caused by a
+E3940 system, PREEMPT_RT kernel). The spikes are caused by a
stalling ioread8() operation following a sequence of 30+ iowrite8()s to
the same address. I believe this happens because the write sequence is
buffered (in cpu or somewhere along the bus), and gets flushed on the
@@ -30,7 +30,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return container_of(data, struct tpm_tis_tcg_phy, priv);
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+/*
+ * Flushes previous write operations to chip so that a subsequent
+ * ioread*()s won't stall a cpu.
diff --git a/debian/patches-rt/tty-serial-pl011-warning-about-uninitialized.patch b/debian/patches-rt/tty-serial-pl011-warning-about-uninitialized.patch
index 049e2f934812..6deb9f5b3796 100644
--- a/debian/patches-rt/tty-serial-pl011-warning-about-uninitialized.patch
+++ b/debian/patches-rt/tty-serial-pl011-warning-about-uninitialized.patch
@@ -4,7 +4,7 @@ Subject: [PATCH] tty: serial: pl011: explicitly initialize the flags variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Silence the following gcc warning:
@@ -27,7 +27,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
-@@ -2211,7 +2211,7 @@ pl011_console_write(struct console *co,
+@@ -2209,7 +2209,7 @@ pl011_console_write(struct console *co,
{
struct uart_amba_port *uap = amba_ports[co->index];
unsigned int old_cr = 0, new_cr;
diff --git a/debian/patches-rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch b/debian/patches-rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch
index 57e4f0f093e8..4da37c1e0556 100644
--- a/debian/patches-rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch
+++ b/debian/patches-rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch
@@ -1,7 +1,7 @@
Subject: net: Remove preemption disabling in netif_rx()
From: Priyanka Jain <Priyanka.Jain@freescale.com>
Date: Thu, 17 May 2012 09:35:11 +0530
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
1)enqueue_to_backlog() (called from netif_rx) should be
bind to a particluar CPU. This can be achieved by
@@ -14,7 +14,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.
kfree_skb() is called. But in RT, kfree_skb() might
gets scheduled out, so it expects non atomic context.
-3)When CONFIG_PREEMPT_RT_FULL is not defined,
+3)When CONFIG_PREEMPT_RT is not defined,
migrate_enable(), migrate_disable() maps to
preempt_enable() and preempt_disable(), so no
change in functionality in case of non-RT.
@@ -38,7 +38,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/net/core/dev.c
+++ b/net/core/dev.c
-@@ -4519,7 +4519,7 @@ static int netif_rx_internal(struct sk_b
+@@ -4438,7 +4438,7 @@ static int netif_rx_internal(struct sk_b
struct rps_dev_flow voidflow, *rflow = &voidflow;
int cpu;
@@ -47,7 +47,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
rcu_read_lock();
cpu = get_rps_cpu(skb->dev, skb, &rflow);
-@@ -4529,14 +4529,14 @@ static int netif_rx_internal(struct sk_b
+@@ -4448,14 +4448,14 @@ static int netif_rx_internal(struct sk_b
ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
rcu_read_unlock();
diff --git a/debian/patches-rt/wait.h-include-atomic.h.patch b/debian/patches-rt/wait.h-include-atomic.h.patch
index 6f9c5f441e1d..bd23023e2374 100644
--- a/debian/patches-rt/wait.h-include-atomic.h.patch
+++ b/debian/patches-rt/wait.h-include-atomic.h.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 28 Oct 2013 12:19:57 +0100
Subject: wait.h: include atomic.h
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
| CC init/main.o
|In file included from include/linux/mmzone.h:9:0,
diff --git a/debian/patches-rt/watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch b/debian/patches-rt/watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch
index 0ed20e9f6063..6e39706a3398 100644
--- a/debian/patches-rt/watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch
+++ b/debian/patches-rt/watchdog-prevent-deferral-of-watchdogd-wakeup-on-RT.patch
@@ -1,19 +1,19 @@
From: Julia Cartwright <julia@ni.com>
Date: Fri, 28 Sep 2018 21:03:51 +0000
Subject: [PATCH] watchdog: prevent deferral of watchdogd wakeup on RT
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
-When PREEMPT_RT_FULL is enabled, all hrtimer expiry functions are
-deferred for execution into the context of ktimersoftd unless otherwise
+When PREEMPT_RT is enabled, all hrtimer expiry functions are
+deferred for execution into the context of ksoftirqd unless otherwise
annotated.
Deferring the expiry of the hrtimer used by the watchdog core, however,
is a waste, as the callback does nothing but queue a kthread work item
and wakeup watchdogd.
-It's worst then that, too: the deferral through ktimersoftd also means
+It's worst then that, too: the deferral through ksoftirqd also means
that for correct behavior a user must adjust the scheduling parameters
-of both watchdogd _and_ ktimersoftd, which is unnecessary and has other
+of both watchdogd _and_ ksoftirqd, which is unnecessary and has other
side effects (like causing unrelated expiry functions to execute at
potentially elevated priority).
@@ -37,7 +37,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
-@@ -147,7 +147,7 @@ static inline void watchdog_update_worke
+@@ -158,7 +158,7 @@ static inline void watchdog_update_worke
ktime_t t = watchdog_next_keepalive(wdd);
if (t > 0)
@@ -46,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
} else {
hrtimer_cancel(&wd_data->timer);
}
-@@ -166,7 +166,7 @@ static int __watchdog_ping(struct watchd
+@@ -177,7 +177,7 @@ static int __watchdog_ping(struct watchd
if (ktime_after(earliest_keepalive, now)) {
hrtimer_start(&wd_data->timer,
ktime_sub(earliest_keepalive, now),
@@ -55,7 +55,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
return 0;
}
-@@ -945,7 +945,7 @@ static int watchdog_cdev_register(struct
+@@ -971,7 +971,7 @@ static int watchdog_cdev_register(struct
return -ENODEV;
kthread_init_work(&wd_data->work, watchdog_ping_work);
@@ -64,7 +64,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
wd_data->timer.function = watchdog_timer_expired;
if (wdd->id == 0) {
-@@ -992,7 +992,7 @@ static int watchdog_cdev_register(struct
+@@ -1019,7 +1019,7 @@ static int watchdog_cdev_register(struct
__module_get(wdd->ops->owner);
kref_get(&wd_data->kref);
if (handle_boot_enabled)
diff --git a/debian/patches-rt/workqueue-Convert-for_each_wq-to-use-built-in-list-c.patch b/debian/patches-rt/workqueue-Convert-for_each_wq-to-use-built-in-list-c.patch
new file mode 100644
index 000000000000..ce3c1cfa8653
--- /dev/null
+++ b/debian/patches-rt/workqueue-Convert-for_each_wq-to-use-built-in-list-c.patch
@@ -0,0 +1,46 @@
+From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
+Date: Thu, 15 Aug 2019 10:18:42 -0400
+Subject: [PATCH] workqueue: Convert for_each_wq to use built-in list check
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Because list_for_each_entry_rcu() can now check for holding a
+lock as well as for being in an RCU read-side critical section,
+this commit replaces the workqueue_sysfs_unregister() function's
+use of assert_rcu_or_wq_mutex() and list_for_each_entry_rcu() with
+list_for_each_entry_rcu() augmented with a lockdep_is_held() optional
+argument.
+
+Acked-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
+Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/workqueue.c | 10 ++--------
+ 1 file changed, 2 insertions(+), 8 deletions(-)
+
+--- a/kernel/workqueue.c
++++ b/kernel/workqueue.c
+@@ -364,11 +364,6 @@ static void workqueue_sysfs_unregister(s
+ !lockdep_is_held(&wq_pool_mutex), \
+ "RCU or wq_pool_mutex should be held")
+
+-#define assert_rcu_or_wq_mutex(wq) \
+- RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
+- !lockdep_is_held(&wq->mutex), \
+- "RCU or wq->mutex should be held")
+-
+ #define assert_rcu_or_wq_mutex_or_pool_mutex(wq) \
+ RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
+ !lockdep_is_held(&wq->mutex) && \
+@@ -425,9 +420,8 @@ static void workqueue_sysfs_unregister(s
+ * ignored.
+ */
+ #define for_each_pwq(pwq, wq) \
+- list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \
+- if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \
+- else
++ list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \
++ lockdep_is_held(&(wq->mutex)))
+
+ #ifdef CONFIG_DEBUG_OBJECTS_WORK
+
diff --git a/debian/patches-rt/workqueue-Make-alloc-apply-free_workqueue_attrs-stat.patch b/debian/patches-rt/workqueue-Make-alloc-apply-free_workqueue_attrs-stat.patch
deleted file mode 100644
index 3f70da84b846..000000000000
--- a/debian/patches-rt/workqueue-Make-alloc-apply-free_workqueue_attrs-stat.patch
+++ /dev/null
@@ -1,65 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Tue, 21 May 2019 16:35:12 +0200
-Subject: [PATCH] workqueue: Make alloc/apply/free_workqueue_attrs() static
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-None of those functions have any users outside of workqueue.c. Confine
-them.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- include/linux/workqueue.h | 4 ----
- kernel/workqueue.c | 7 +++----
- 2 files changed, 3 insertions(+), 8 deletions(-)
-
---- a/include/linux/workqueue.h
-+++ b/include/linux/workqueue.h
-@@ -435,10 +435,6 @@ struct workqueue_struct *alloc_workqueue
-
- extern void destroy_workqueue(struct workqueue_struct *wq);
-
--struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask);
--void free_workqueue_attrs(struct workqueue_attrs *attrs);
--int apply_workqueue_attrs(struct workqueue_struct *wq,
-- const struct workqueue_attrs *attrs);
- int workqueue_set_unbound_cpumask(cpumask_var_t cpumask);
-
- extern bool queue_work_on(int cpu, struct workqueue_struct *wq,
---- a/kernel/workqueue.c
-+++ b/kernel/workqueue.c
-@@ -3329,7 +3329,7 @@ EXPORT_SYMBOL_GPL(execute_in_process_con
- *
- * Undo alloc_workqueue_attrs().
- */
--void free_workqueue_attrs(struct workqueue_attrs *attrs)
-+static void free_workqueue_attrs(struct workqueue_attrs *attrs)
- {
- if (attrs) {
- free_cpumask_var(attrs->cpumask);
-@@ -3346,7 +3346,7 @@ void free_workqueue_attrs(struct workque
- *
- * Return: The allocated new workqueue_attr on success. %NULL on failure.
- */
--struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask)
-+static struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask)
- {
- struct workqueue_attrs *attrs;
-
-@@ -4033,7 +4033,7 @@ static int apply_workqueue_attrs_locked(
- *
- * Return: 0 on success and -errno on failure.
- */
--int apply_workqueue_attrs(struct workqueue_struct *wq,
-+static int apply_workqueue_attrs(struct workqueue_struct *wq,
- const struct workqueue_attrs *attrs)
- {
- int ret;
-@@ -4044,7 +4044,6 @@ int apply_workqueue_attrs(struct workque
-
- return ret;
- }
--EXPORT_SYMBOL_GPL(apply_workqueue_attrs);
-
- /**
- * wq_update_unbound_numa - update NUMA affinity of a wq for CPU hot[un]plug
diff --git a/debian/patches-rt/workqueue-Remove-GPF-argument-from-alloc_workqueue_a.patch b/debian/patches-rt/workqueue-Remove-GPF-argument-from-alloc_workqueue_a.patch
deleted file mode 100644
index de76e600e583..000000000000
--- a/debian/patches-rt/workqueue-Remove-GPF-argument-from-alloc_workqueue_a.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Tue, 21 May 2019 16:39:56 +0200
-Subject: [PATCH] workqueue: Remove GPF argument from
- alloc_workqueue_attrs()
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-All callers use GFP_KERNEL. No point in having that argument.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- kernel/workqueue.c | 23 +++++++++++------------
- 1 file changed, 11 insertions(+), 12 deletions(-)
-
---- a/kernel/workqueue.c
-+++ b/kernel/workqueue.c
-@@ -3339,21 +3339,20 @@ static void free_workqueue_attrs(struct
-
- /**
- * alloc_workqueue_attrs - allocate a workqueue_attrs
-- * @gfp_mask: allocation mask to use
- *
- * Allocate a new workqueue_attrs, initialize with default settings and
- * return it.
- *
- * Return: The allocated new workqueue_attr on success. %NULL on failure.
- */
--static struct workqueue_attrs *alloc_workqueue_attrs(gfp_t gfp_mask)
-+static struct workqueue_attrs *alloc_workqueue_attrs(void)
- {
- struct workqueue_attrs *attrs;
-
-- attrs = kzalloc(sizeof(*attrs), gfp_mask);
-+ attrs = kzalloc(sizeof(*attrs), GFP_KERNEL);
- if (!attrs)
- goto fail;
-- if (!alloc_cpumask_var(&attrs->cpumask, gfp_mask))
-+ if (!alloc_cpumask_var(&attrs->cpumask, GFP_KERNEL))
- goto fail;
-
- cpumask_copy(attrs->cpumask, cpu_possible_mask);
-@@ -3431,7 +3430,7 @@ static int init_worker_pool(struct worke
- pool->refcnt = 1;
-
- /* shouldn't fail above this point */
-- pool->attrs = alloc_workqueue_attrs(GFP_KERNEL);
-+ pool->attrs = alloc_workqueue_attrs();
- if (!pool->attrs)
- return -ENOMEM;
- return 0;
-@@ -3896,8 +3895,8 @@ apply_wqattrs_prepare(struct workqueue_s
-
- ctx = kzalloc(struct_size(ctx, pwq_tbl, nr_node_ids), GFP_KERNEL);
-
-- new_attrs = alloc_workqueue_attrs(GFP_KERNEL);
-- tmp_attrs = alloc_workqueue_attrs(GFP_KERNEL);
-+ new_attrs = alloc_workqueue_attrs();
-+ tmp_attrs = alloc_workqueue_attrs();
- if (!ctx || !new_attrs || !tmp_attrs)
- goto out_free;
-
-@@ -4241,7 +4240,7 @@ struct workqueue_struct *alloc_workqueue
- return NULL;
-
- if (flags & WQ_UNBOUND) {
-- wq->unbound_attrs = alloc_workqueue_attrs(GFP_KERNEL);
-+ wq->unbound_attrs = alloc_workqueue_attrs();
- if (!wq->unbound_attrs)
- goto err_free_wq;
- }
-@@ -5394,7 +5393,7 @@ static struct workqueue_attrs *wq_sysfs_
-
- lockdep_assert_held(&wq_pool_mutex);
-
-- attrs = alloc_workqueue_attrs(GFP_KERNEL);
-+ attrs = alloc_workqueue_attrs();
- if (!attrs)
- return NULL;
-
-@@ -5816,7 +5815,7 @@ static void __init wq_numa_init(void)
- return;
- }
-
-- wq_update_unbound_numa_attrs_buf = alloc_workqueue_attrs(GFP_KERNEL);
-+ wq_update_unbound_numa_attrs_buf = alloc_workqueue_attrs();
- BUG_ON(!wq_update_unbound_numa_attrs_buf);
-
- /*
-@@ -5891,7 +5890,7 @@ int __init workqueue_init_early(void)
- for (i = 0; i < NR_STD_WORKER_POOLS; i++) {
- struct workqueue_attrs *attrs;
-
-- BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL)));
-+ BUG_ON(!(attrs = alloc_workqueue_attrs()));
- attrs->nice = std_nice[i];
- unbound_std_wq_attrs[i] = attrs;
-
-@@ -5900,7 +5899,7 @@ int __init workqueue_init_early(void)
- * guaranteed by max_active which is enforced by pwqs.
- * Turn off NUMA so that dfl_pwq is used for all nodes.
- */
-- BUG_ON(!(attrs = alloc_workqueue_attrs(GFP_KERNEL)));
-+ BUG_ON(!(attrs = alloc_workqueue_attrs()));
- attrs->nice = std_nice[i];
- attrs->no_numa = true;
- ordered_wq_attrs[i] = attrs;
diff --git a/debian/patches-rt/x86-Disable-HAVE_ARCH_JUMP_LABEL.patch b/debian/patches-rt/x86-Disable-HAVE_ARCH_JUMP_LABEL.patch
index 23992d21305c..d0c61e6ba575 100644
--- a/debian/patches-rt/x86-Disable-HAVE_ARCH_JUMP_LABEL.patch
+++ b/debian/patches-rt/x86-Disable-HAVE_ARCH_JUMP_LABEL.patch
@@ -4,7 +4,7 @@ Subject: [PATCH] x86: Disable HAVE_ARCH_JUMP_LABEL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
__text_poke() does:
| local_irq_save(flags);
@@ -20,14 +20,14 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
-@@ -127,8 +127,8 @@ config X86
+@@ -132,8 +132,8 @@ config X86
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
select HAVE_ARCH_AUDITSYSCALL
select HAVE_ARCH_HUGE_VMAP if X86_64 || X86_PAE
- select HAVE_ARCH_JUMP_LABEL
- select HAVE_ARCH_JUMP_LABEL_RELATIVE
-+ select HAVE_ARCH_JUMP_LABEL if !PREEMPT_RT_FULL
-+ select HAVE_ARCH_JUMP_LABEL_RELATIVE if !PREEMPT_RT_FULL
++ select HAVE_ARCH_JUMP_LABEL if !PREEMPT_RT
++ select HAVE_ARCH_JUMP_LABEL_RELATIVE if !PREEMPT_RT
select HAVE_ARCH_KASAN if X86_64
select HAVE_ARCH_KGDB
select HAVE_ARCH_MMAP_RND_BITS if MMU
diff --git a/debian/patches-rt/x86-Enable-RT-also-on-32bit.patch b/debian/patches-rt/x86-Enable-RT-also-on-32bit.patch
new file mode 100644
index 000000000000..c4250852586a
--- /dev/null
+++ b/debian/patches-rt/x86-Enable-RT-also-on-32bit.patch
@@ -0,0 +1,28 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Thu, 7 Nov 2019 17:49:20 +0100
+Subject: [PATCH] x86: Enable RT also on 32bit
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/x86/Kconfig | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/x86/Kconfig
++++ b/arch/x86/Kconfig
+@@ -25,7 +25,6 @@ config X86_64
+ # Options that are inherently 64-bit kernel only:
+ select ARCH_HAS_GIGANTIC_PAGE
+ select ARCH_SUPPORTS_INT128
+- select ARCH_SUPPORTS_RT
+ select ARCH_USE_CMPXCHG_LOCKREF
+ select HAVE_ARCH_SOFT_DIRTY
+ select MODULES_USE_ELF_RELA
+@@ -91,6 +90,7 @@ config X86
+ select ARCH_SUPPORTS_ACPI
+ select ARCH_SUPPORTS_ATOMIC_RMW
+ select ARCH_SUPPORTS_NUMA_BALANCING if X86_64
++ select ARCH_SUPPORTS_RT
+ select ARCH_USE_BUILTIN_BSWAP
+ select ARCH_USE_QUEUED_RWLOCKS
+ select ARCH_USE_QUEUED_SPINLOCKS
diff --git a/debian/patches-rt/x86-Enable-RT.patch b/debian/patches-rt/x86-Enable-RT.patch
new file mode 100644
index 000000000000..dc7d7a6eb865
--- /dev/null
+++ b/debian/patches-rt/x86-Enable-RT.patch
@@ -0,0 +1,22 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Wed, 7 Aug 2019 18:15:38 +0200
+Subject: [PATCH] x86: Allow to enable RT
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+Allow to select RT.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/x86/Kconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/arch/x86/Kconfig
++++ b/arch/x86/Kconfig
+@@ -25,6 +25,7 @@ config X86_64
+ # Options that are inherently 64-bit kernel only:
+ select ARCH_HAS_GIGANTIC_PAGE
+ select ARCH_SUPPORTS_INT128
++ select ARCH_SUPPORTS_RT
+ select ARCH_USE_CMPXCHG_LOCKREF
+ select HAVE_ARCH_SOFT_DIRTY
+ select MODULES_USE_ELF_RELA
diff --git a/debian/patches-rt/x86-crypto-reduce-preempt-disabled-regions.patch b/debian/patches-rt/x86-crypto-reduce-preempt-disabled-regions.patch
index 574d69063050..542c2dbe9204 100644
--- a/debian/patches-rt/x86-crypto-reduce-preempt-disabled-regions.patch
+++ b/debian/patches-rt/x86-crypto-reduce-preempt-disabled-regions.patch
@@ -1,7 +1,7 @@
Subject: x86: crypto: Reduce preempt disabled regions
From: Peter Zijlstra <peterz@infradead.org>
Date: Mon, 14 Nov 2011 18:19:27 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Restrict the preempt disabled regions to the actual floating point
operations and enable preemption for the administrative actions.
@@ -19,7 +19,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
-@@ -402,14 +402,14 @@ static int ecb_encrypt(struct skcipher_r
+@@ -387,14 +387,14 @@ static int ecb_encrypt(struct skcipher_r
err = skcipher_walk_virt(&walk, req, true);
@@ -36,7 +36,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return err;
}
-@@ -424,14 +424,14 @@ static int ecb_decrypt(struct skcipher_r
+@@ -409,14 +409,14 @@ static int ecb_decrypt(struct skcipher_r
err = skcipher_walk_virt(&walk, req, true);
@@ -53,7 +53,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return err;
}
-@@ -446,14 +446,14 @@ static int cbc_encrypt(struct skcipher_r
+@@ -431,14 +431,14 @@ static int cbc_encrypt(struct skcipher_r
err = skcipher_walk_virt(&walk, req, true);
@@ -70,7 +70,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return err;
}
-@@ -468,14 +468,14 @@ static int cbc_decrypt(struct skcipher_r
+@@ -453,14 +453,14 @@ static int cbc_decrypt(struct skcipher_r
err = skcipher_walk_virt(&walk, req, true);
@@ -87,7 +87,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
return err;
}
-@@ -525,18 +525,20 @@ static int ctr_crypt(struct skcipher_req
+@@ -510,18 +510,20 @@ static int ctr_crypt(struct skcipher_req
err = skcipher_walk_virt(&walk, req, true);
diff --git a/debian/patches-rt/x86-highmem-add-a-already-used-pte-check.patch b/debian/patches-rt/x86-highmem-add-a-already-used-pte-check.patch
index 8550e4e8553f..0e4a3b37bf7f 100644
--- a/debian/patches-rt/x86-highmem-add-a-already-used-pte-check.patch
+++ b/debian/patches-rt/x86-highmem-add-a-already-used-pte-check.patch
@@ -1,7 +1,7 @@
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Mon, 11 Mar 2013 17:09:55 +0100
Subject: x86/highmem: Add a "already used pte" check
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
This is a copy from kmap_atomic_prot().
@@ -18,6 +18,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+ WARN_ON(!pte_none(*(kmap_pte - idx)));
+
- #ifdef CONFIG_PREEMPT_RT_FULL
+ #ifdef CONFIG_PREEMPT_RT
current->kmap_pte[type] = pte;
#endif
diff --git a/debian/patches-rt/x86-ioapic-Don-t-let-setaffinity-unmask-threaded-EOI.patch b/debian/patches-rt/x86-ioapic-Don-t-let-setaffinity-unmask-threaded-EOI.patch
deleted file mode 100644
index 16c12882c03c..000000000000
--- a/debian/patches-rt/x86-ioapic-Don-t-let-setaffinity-unmask-threaded-EOI.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-From: Thomas Gleixner <tglx@linutronix.de>
-Date: Tue, 17 Jul 2018 18:25:31 +0200
-Subject: [PATCH] x86/ioapic: Don't let setaffinity unmask threaded EOI
- interrupt too early
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-There is an issue with threaded interrupts which are marked ONESHOT
-and using the fasteoi handler.
-
- if (IS_ONESHOT())
- mask_irq();
-
- ....
- ....
-
- cond_unmask_eoi_irq()
- chip->irq_eoi();
-
-So if setaffinity is pending then the interrupt will be moved and then
-unmasked, which is wrong as it should be kept masked up to the point where
-the threaded handler finished. It's not a real problem, the interrupt will
-just be able to fire before the threaded handler has finished, though the irq
-masked state will be wrong for a bit.
-
-The patch below should cure the issue. It also renames the horribly
-misnomed functions so it becomes clear what they are supposed to do.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-[bigeasy: add the body of the patch, use the same functions in both
- ifdef paths (spotted by Andy Shevchenko)]
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/x86/kernel/apic/io_apic.c | 23 +++++++++++++----------
- 1 file changed, 13 insertions(+), 10 deletions(-)
-
---- a/arch/x86/kernel/apic/io_apic.c
-+++ b/arch/x86/kernel/apic/io_apic.c
-@@ -1724,19 +1724,20 @@ static bool io_apic_level_ack_pending(st
- return false;
- }
-
--static inline bool ioapic_irqd_mask(struct irq_data *data)
-+static inline bool ioapic_prepare_move(struct irq_data *data)
- {
- /* If we are moving the irq we need to mask it */
- if (unlikely(irqd_is_setaffinity_pending(data))) {
-- mask_ioapic_irq(data);
-+ if (!irqd_irq_masked(data))
-+ mask_ioapic_irq(data);
- return true;
- }
- return false;
- }
-
--static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
-+static inline void ioapic_finish_move(struct irq_data *data, bool moveit)
- {
-- if (unlikely(masked)) {
-+ if (unlikely(moveit)) {
- /* Only migrate the irq if the ack has been received.
- *
- * On rare occasions the broadcast level triggered ack gets
-@@ -1765,15 +1766,17 @@ static inline void ioapic_irqd_unmask(st
- */
- if (!io_apic_level_ack_pending(data->chip_data))
- irq_move_masked_irq(data);
-- unmask_ioapic_irq(data);
-+ /* If the irq is masked in the core, leave it */
-+ if (!irqd_irq_masked(data))
-+ unmask_ioapic_irq(data);
- }
- }
- #else
--static inline bool ioapic_irqd_mask(struct irq_data *data)
-+static inline bool ioapic_prepare_move(struct irq_data *data)
- {
- return false;
- }
--static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
-+static inline void ioapic_finish_move(struct irq_data *data, bool moveit)
- {
- }
- #endif
-@@ -1782,11 +1785,11 @@ static void ioapic_ack_level(struct irq_
- {
- struct irq_cfg *cfg = irqd_cfg(irq_data);
- unsigned long v;
-- bool masked;
-+ bool moveit;
- int i;
-
- irq_complete_move(cfg);
-- masked = ioapic_irqd_mask(irq_data);
-+ moveit = ioapic_prepare_move(irq_data);
-
- /*
- * It appears there is an erratum which affects at least version 0x11
-@@ -1841,7 +1844,7 @@ static void ioapic_ack_level(struct irq_
- eoi_ioapic_pin(cfg->vector, irq_data->chip_data);
- }
-
-- ioapic_irqd_unmask(irq_data, masked);
-+ ioapic_finish_move(irq_data, moveit);
- }
-
- static void ioapic_ir_ack_level(struct irq_data *irq_data)
diff --git a/debian/patches-rt/x86-ioapic-Prevent-inconsistent-state-when-moving-an.patch b/debian/patches-rt/x86-ioapic-Prevent-inconsistent-state-when-moving-an.patch
new file mode 100644
index 000000000000..c27214c1b262
--- /dev/null
+++ b/debian/patches-rt/x86-ioapic-Prevent-inconsistent-state-when-moving-an.patch
@@ -0,0 +1,73 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 17 Oct 2019 12:19:01 +0200
+Subject: [PATCH] x86/ioapic: Prevent inconsistent state when moving an
+ interrupt
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+There is an issue with threaded interrupts which are marked ONESHOT
+and using the fasteoi handler:
+
+ if (IS_ONESHOT())
+ mask_irq();
+ ....
+ cond_unmask_eoi_irq()
+ chip->irq_eoi();
+ if (setaffinity_pending) {
+ mask_ioapic();
+ ...
+ move_affinity();
+ unmask_ioapic();
+ }
+
+So if setaffinity is pending the interrupt will be moved and then
+unconditionally unmasked at the ioapic level, which is wrong in two
+aspects:
+
+ 1) It should be kept masked up to the point where the threaded handler
+ finished.
+
+ 2) The physical chip state and the software masked state are inconsistent
+
+Guard both the mask and the unmask with a check for the software masked
+state. If the line is marked masked then the ioapic line is also masked, so
+both mask_ioapic() and unmask_ioapic() can be skipped safely.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Sebastian Siewior <bigeasy@linutronix.de>
+Fixes: 3aa551c9b4c4 ("genirq: add threaded interrupt handler support")
+Link: https://lkml.kernel.org/r/20191017101938.321393687@linutronix.de
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/x86/kernel/apic/io_apic.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/kernel/apic/io_apic.c
++++ b/arch/x86/kernel/apic/io_apic.c
+@@ -1727,9 +1727,10 @@ static bool io_apic_level_ack_pending(st
+
+ static inline bool ioapic_irqd_mask(struct irq_data *data)
+ {
+- /* If we are moving the irq we need to mask it */
++ /* If we are moving the IRQ we need to mask it */
+ if (unlikely(irqd_is_setaffinity_pending(data))) {
+- mask_ioapic_irq(data);
++ if (!irqd_irq_masked(data))
++ mask_ioapic_irq(data);
+ return true;
+ }
+ return false;
+@@ -1766,7 +1767,9 @@ static inline void ioapic_irqd_unmask(st
+ */
+ if (!io_apic_level_ack_pending(data->chip_data))
+ irq_move_masked_irq(data);
+- unmask_ioapic_irq(data);
++ /* If the IRQ is masked in the core, leave it: */
++ if (!irqd_irq_masked(data))
++ unmask_ioapic_irq(data);
+ }
+ }
+ #else
diff --git a/debian/patches-rt/x86-ioapic-Rename-misnamed-functions.patch b/debian/patches-rt/x86-ioapic-Rename-misnamed-functions.patch
new file mode 100644
index 000000000000..35132f7719c8
--- /dev/null
+++ b/debian/patches-rt/x86-ioapic-Rename-misnamed-functions.patch
@@ -0,0 +1,87 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 17 Oct 2019 12:19:02 +0200
+Subject: [PATCH] x86/ioapic: Rename misnamed functions
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
+
+ioapic_irqd_[un]mask() are misnomers as both functions do way more than
+masking and unmasking the interrupt line. Both deal with the moving the
+affinity of the interrupt within interrupt context. The mask/unmask is just
+a tiny part of the functionality.
+
+Rename them to ioapic_prepare/finish_move(), fixup the call sites and
+rename the related variables in the code to reflect what this is about.
+
+No functional change.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Sebastian Siewior <bigeasy@linutronix.de>
+Link: https://lkml.kernel.org/r/20191017101938.412489856@linutronix.de
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ arch/x86/kernel/apic/io_apic.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/arch/x86/kernel/apic/io_apic.c
++++ b/arch/x86/kernel/apic/io_apic.c
+@@ -1725,7 +1725,7 @@ static bool io_apic_level_ack_pending(st
+ return false;
+ }
+
+-static inline bool ioapic_irqd_mask(struct irq_data *data)
++static inline bool ioapic_prepare_move(struct irq_data *data)
+ {
+ /* If we are moving the IRQ we need to mask it */
+ if (unlikely(irqd_is_setaffinity_pending(data))) {
+@@ -1736,9 +1736,9 @@ static inline bool ioapic_irqd_mask(stru
+ return false;
+ }
+
+-static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
++static inline void ioapic_finish_move(struct irq_data *data, bool moveit)
+ {
+- if (unlikely(masked)) {
++ if (unlikely(moveit)) {
+ /* Only migrate the irq if the ack has been received.
+ *
+ * On rare occasions the broadcast level triggered ack gets
+@@ -1773,11 +1773,11 @@ static inline void ioapic_irqd_unmask(st
+ }
+ }
+ #else
+-static inline bool ioapic_irqd_mask(struct irq_data *data)
++static inline bool ioapic_prepare_move(struct irq_data *data)
+ {
+ return false;
+ }
+-static inline void ioapic_irqd_unmask(struct irq_data *data, bool masked)
++static inline void ioapic_finish_move(struct irq_data *data, bool moveit)
+ {
+ }
+ #endif
+@@ -1786,11 +1786,11 @@ static void ioapic_ack_level(struct irq_
+ {
+ struct irq_cfg *cfg = irqd_cfg(irq_data);
+ unsigned long v;
+- bool masked;
++ bool moveit;
+ int i;
+
+ irq_complete_move(cfg);
+- masked = ioapic_irqd_mask(irq_data);
++ moveit = ioapic_prepare_move(irq_data);
+
+ /*
+ * It appears there is an erratum which affects at least version 0x11
+@@ -1845,7 +1845,7 @@ static void ioapic_ack_level(struct irq_
+ eoi_ioapic_pin(cfg->vector, irq_data->chip_data);
+ }
+
+- ioapic_irqd_unmask(irq_data, masked);
++ ioapic_finish_move(irq_data, moveit);
+ }
+
+ static void ioapic_ir_ack_level(struct irq_data *irq_data)
diff --git a/debian/patches-rt/x86-kvm-require-const-tsc-for-rt.patch b/debian/patches-rt/x86-kvm-require-const-tsc-for-rt.patch
index 453ed056179e..26672624af0f 100644
--- a/debian/patches-rt/x86-kvm-require-const-tsc-for-rt.patch
+++ b/debian/patches-rt/x86-kvm-require-const-tsc-for-rt.patch
@@ -1,7 +1,7 @@
Subject: x86: kvm Require const tsc for RT
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 06 Nov 2011 12:26:18 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Non constant TSC is a nightmare on bare metal already, but with
virtualization it becomes a complete disaster because the workarounds
@@ -15,11 +15,11 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
-@@ -7025,6 +7025,14 @@ int kvm_arch_init(void *opaque)
+@@ -7207,6 +7207,14 @@ int kvm_arch_init(void *opaque)
goto out;
}
-+#ifdef CONFIG_PREEMPT_RT_FULL
++#ifdef CONFIG_PREEMPT_RT
+ if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
+ pr_err("RT requires X86_FEATURE_CONSTANT_TSC\n");
+ r = -EOPNOTSUPP;
diff --git a/debian/patches-rt/x86-ldt-Initialize-the-context-lock-for-init_mm.patch b/debian/patches-rt/x86-ldt-Initialize-the-context-lock-for-init_mm.patch
deleted file mode 100644
index 9aa9603a6f4b..000000000000
--- a/debian/patches-rt/x86-ldt-Initialize-the-context-lock-for-init_mm.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Mon, 1 Jul 2019 17:53:13 +0200
-Subject: [PATCH] x86/ldt: Initialize the context lock for init_mm
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-The mutex mm->context->lock for init_mm is not initialized for init_mm.
-This wasn't a problem because it remained unused. This changed however
-since commit
- 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")
-
-Initialize the mutex for init_mm.
-
-Fixes: 4fc19708b165c ("x86/alternatives: Initialize temporary mm for patching")
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/x86/include/asm/mmu.h | 1 +
- 1 file changed, 1 insertion(+)
-
---- a/arch/x86/include/asm/mmu.h
-+++ b/arch/x86/include/asm/mmu.h
-@@ -59,6 +59,7 @@ typedef struct {
- #define INIT_MM_CONTEXT(mm) \
- .context = { \
- .ctx_id = 1, \
-+ .lock = __MUTEX_INITIALIZER(mm.context.lock), \
- }
-
- void leave_mm(int cpu);
diff --git a/debian/patches-rt/x86-preempt-Check-preemption-level-before-looking-at.patch b/debian/patches-rt/x86-preempt-Check-preemption-level-before-looking-at.patch
deleted file mode 100644
index 25d3f0bdc783..000000000000
--- a/debian/patches-rt/x86-preempt-Check-preemption-level-before-looking-at.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-Date: Wed, 14 Aug 2019 17:08:58 +0200
-Subject: [PATCH] x86: preempt: Check preemption level before looking at
- lazy-preempt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-Before evaluating the lazy-preempt state it must be ensure that the
-preempt-count is zero.
-
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/x86/include/asm/preempt.h | 2 ++
- 1 file changed, 2 insertions(+)
-
---- a/arch/x86/include/asm/preempt.h
-+++ b/arch/x86/include/asm/preempt.h
-@@ -99,6 +99,8 @@ static __always_inline bool __preempt_co
- if (____preempt_count_dec_and_test())
- return true;
- #ifdef CONFIG_PREEMPT_LAZY
-+ if (preempt_count())
-+ return false;
- if (current_thread_info()->preempt_lazy_count)
- return false;
- return test_thread_flag(TIF_NEED_RESCHED_LAZY);
diff --git a/debian/patches-rt/x86-preempt-lazy.patch b/debian/patches-rt/x86-preempt-lazy.patch
index b35d3a52330e..85fc4e0e244a 100644
--- a/debian/patches-rt/x86-preempt-lazy.patch
+++ b/debian/patches-rt/x86-preempt-lazy.patch
@@ -1,7 +1,7 @@
Subject: x86: Support for lazy preemption
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 01 Nov 2012 11:03:47 +0100
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
Implement the x86 pieces for lazy preempt.
@@ -9,16 +9,16 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/Kconfig | 1 +
arch/x86/entry/common.c | 4 ++--
- arch/x86/entry/entry_32.S | 17 +++++++++++++++++
+ arch/x86/entry/entry_32.S | 18 ++++++++++++++++++
arch/x86/entry/entry_64.S | 16 ++++++++++++++++
- arch/x86/include/asm/preempt.h | 31 ++++++++++++++++++++++++++++++-
+ arch/x86/include/asm/preempt.h | 33 ++++++++++++++++++++++++++++++++-
arch/x86/include/asm/thread_info.h | 11 +++++++++++
- arch/x86/kernel/asm-offsets.c | 2 ++
- 7 files changed, 79 insertions(+), 3 deletions(-)
+ arch/x86/kernel/asm-offsets.c | 5 +++++
+ 7 files changed, 85 insertions(+), 3 deletions(-)
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
-@@ -192,6 +192,7 @@ config X86
+@@ -200,6 +200,7 @@ config X86
select HAVE_PCI
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
@@ -28,7 +28,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
-@@ -135,7 +135,7 @@ static long syscall_trace_enter(struct p
+@@ -130,7 +130,7 @@ static long syscall_trace_enter(struct p
#define EXIT_TO_USERMODE_LOOP_FLAGS \
(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE | \
@@ -37,7 +37,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags)
{
-@@ -150,7 +150,7 @@ static void exit_to_usermode_loop(struct
+@@ -145,7 +145,7 @@ static void exit_to_usermode_loop(struct
/* We have work to do. */
local_irq_enable();
@@ -48,31 +48,32 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#ifdef ARCH_RT_DELAYS_SIGNAL_SEND
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
-@@ -768,8 +768,25 @@ END(ret_from_exception)
- #ifdef CONFIG_PREEMPT
- ENTRY(resume_kernel)
+@@ -1106,8 +1106,26 @@ ENTRY(entry_INT80_32)
+ restore_all_kernel:
+ #ifdef CONFIG_PREEMPTION
DISABLE_INTERRUPTS(CLBR_ANY)
+ # preempt count == 0 + NEED_RS set?
cmpl $0, PER_CPU_VAR(__preempt_count)
+#ifndef CONFIG_PREEMPT_LAZY
- jnz restore_all_kernel
+ jnz .Lno_preempt
+#else
+ jz test_int_off
+
+ # atleast preempt count == 0 ?
+ cmpl $_PREEMPT_ENABLED,PER_CPU_VAR(__preempt_count)
-+ jne restore_all_kernel
++ jne .Lno_preempt
+
+ movl PER_CPU_VAR(current_task), %ebp
+ cmpl $0,TASK_TI_preempt_lazy_count(%ebp) # non-zero preempt_lazy_count ?
-+ jnz restore_all_kernel
++ jnz .Lno_preempt
+
+ testl $_TIF_NEED_RESCHED_LAZY, TASK_TI_flags(%ebp)
-+ jz restore_all_kernel
++ jz .Lno_preempt
++
+test_int_off:
+#endif
testl $X86_EFLAGS_IF, PT_EFLAGS(%esp) # interrupts off (exception path) ?
- jz restore_all_kernel
+ jz .Lno_preempt
call preempt_schedule_irq
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -102,7 +103,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
#endif
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
-@@ -89,17 +89,46 @@ static __always_inline void __preempt_co
+@@ -89,17 +89,48 @@ static __always_inline void __preempt_co
* a decrement which hits zero means we have no preempt_count and should
* reschedule.
*/
@@ -117,6 +118,8 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ if (____preempt_count_dec_and_test())
+ return true;
+#ifdef CONFIG_PREEMPT_LAZY
++ if (preempt_count())
++ return false;
+ if (current_thread_info()->preempt_lazy_count)
+ return false;
+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
@@ -132,7 +135,6 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
{
+#ifdef CONFIG_PREEMPT_LAZY
+ u32 tmp;
-+
+ tmp = raw_cpu_read_4(__preempt_count);
+ if (tmp == preempt_offset)
+ return true;
@@ -141,6 +143,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ tmp &= ~PREEMPT_NEED_RESCHED;
+ if (tmp != preempt_offset)
+ return false;
++ /* XXX PREEMPT_LOCK_OFFSET */
+ if (current_thread_info()->preempt_lazy_count)
+ return false;
+ return test_thread_flag(TIF_NEED_RESCHED_LAZY);
@@ -149,7 +152,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+#endif
}
- #ifdef CONFIG_PREEMPT
+ #ifdef CONFIG_PREEMPTION
--- a/arch/x86/include/asm/thread_info.h
+++ b/arch/x86/include/asm/thread_info.h
@@ -56,17 +56,24 @@ struct task_struct;
@@ -204,15 +207,18 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
/*
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
-@@ -39,6 +39,7 @@ static void __used common(void)
+@@ -38,6 +38,10 @@ static void __used common(void)
+ #endif
BLANK();
- OFFSET(TASK_TI_flags, task_struct, thread_info.flags);
++#ifdef CONFIG_PREEMPT_LAZY
++ OFFSET(TASK_TI_flags, task_struct, thread_info.flags);
+ OFFSET(TASK_TI_preempt_lazy_count, task_struct, thread_info.preempt_lazy_count);
++#endif
OFFSET(TASK_addr_limit, task_struct, thread.addr_limit);
BLANK();
-@@ -92,6 +93,7 @@ static void __used common(void)
+@@ -92,6 +96,7 @@ static void __used common(void)
BLANK();
DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
diff --git a/debian/patches-rt/x86-signal-delay-calling-signals-on-32bit.patch b/debian/patches-rt/x86-signal-delay-calling-signals-on-32bit.patch
deleted file mode 100644
index 0c175d32a4d3..000000000000
--- a/debian/patches-rt/x86-signal-delay-calling-signals-on-32bit.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From: Yang Shi <yang.shi@linaro.org>
-Date: Thu, 10 Dec 2015 10:58:51 -0800
-Subject: x86/signal: delay calling signals on 32bit
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
-
-When running some ptrace single step tests on x86-32 machine, the below problem
-is triggered:
-
-BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917
-in_atomic(): 1, irqs_disabled(): 0, pid: 1041, name: dummy2
-Preemption disabled at:[<c100326f>] do_debug+0x1f/0x1a0
-
-CPU: 10 PID: 1041 Comm: dummy2 Tainted: G W 4.1.13-rt13 #1
-Call Trace:
- [<c1aa8306>] dump_stack+0x46/0x5c
- [<c1080517>] ___might_sleep+0x137/0x220
- [<c1ab0eff>] rt_spin_lock+0x1f/0x80
- [<c1064b5a>] do_force_sig_info+0x2a/0xc0
- [<c106567d>] force_sig_info+0xd/0x10
- [<c1010cff>] send_sigtrap+0x6f/0x80
- [<c10033b1>] do_debug+0x161/0x1a0
- [<c1ab2921>] debug_stack_correct+0x2e/0x35
-
-This happens since 959274753857 ("x86, traps: Track entry into and exit
-from IST context") which was merged in v4.1-rc1.
-
-Signed-off-by: Yang Shi <yang.shi@linaro.org>
-Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
----
- arch/x86/include/asm/signal.h | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
---- a/arch/x86/include/asm/signal.h
-+++ b/arch/x86/include/asm/signal.h
-@@ -37,7 +37,7 @@ typedef struct {
- * TIF_NOTIFY_RESUME and set up the signal to be sent on exit of the
- * trap.
- */
--#if defined(CONFIG_PREEMPT_RT_FULL) && defined(CONFIG_X86_64)
-+#if defined(CONFIG_PREEMPT_RT_FULL)
- #define ARCH_RT_DELAYS_SIGNAL_SEND
- #endif
-
diff --git a/debian/patches-rt/x86-stackprot-no-random-on-rt.patch b/debian/patches-rt/x86-stackprot-no-random-on-rt.patch
index e52c032a95f3..89dbb5d3bb18 100644
--- a/debian/patches-rt/x86-stackprot-no-random-on-rt.patch
+++ b/debian/patches-rt/x86-stackprot-no-random-on-rt.patch
@@ -1,7 +1,7 @@
From: Thomas Gleixner <tglx@linutronix.de>
Date: Thu, 16 Dec 2010 14:25:18 +0100
Subject: x86: stackprotector: Avoid random pool on rt
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz
CPU bringup calls into the random pool to initialize the stack
canary. During boot that works nicely even on RT as the might sleep
@@ -38,7 +38,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+ * due to locking constraints. We just leave canary
+ * uninitialized and use the TSC based randomness on top of it.
*/
-+#ifndef CONFIG_PREEMPT_RT_FULL
++#ifndef CONFIG_PREEMPT_RT
get_random_bytes(&canary, sizeof(canary));
+#endif
tsc = rdtsc();