commit f251a0b01aff0334d292fac83b94aebc3467245c Author: Alexandre Frade Date: Tue Jun 16 11:29:44 2020 -0300 Linux 5.6.17-rt10-xanmod1 Signed-off-by: Alexandre Frade commit 19c2a2773d8454681c11b4216b6a3e8e313e57d2 Merge: ab0bcbec9231 56b416f1aee1 Author: Alexandre Frade Date: Tue Jun 16 11:27:12 2020 -0300 Merge tag 'v5.6.17-rt10' into 5.6-rt v5.6.17-rt10 commit ab0bcbec923153782a5c1b73838c79617b7c3125 Author: graysky Date: Tue Jun 16 11:17:42 2020 -0300 x86/kconfig: Enable additional cpu optimizations for gcc v10.1+ kernel v5.5-v5.6 WARNING This patch works with gcc versions 10.1+ and with kernel versions 5.5-5.6 and should NOT be applied when compiling on older versions of gcc due to key name changes of the march flags introduced with the version 4.9 release of gcc.[1] Use the older version of this patch hosted on the same github for older versions of gcc. FEATURES This patch adds additional CPU options to the Linux kernel accessible under: Processor type and features ---> Processor family ---> The expanded microarchitectures include: * AMD Improved K8-family * AMD K10-family * AMD Family 10h (Barcelona) * AMD Family 14h (Bobcat) * AMD Family 16h (Jaguar) * AMD Family 15h (Bulldozer) * AMD Family 15h (Piledriver) * AMD Family 15h (Steamroller) * AMD Family 15h (Excavator) * AMD Family 17h (Zen) * AMD Family 17h (Zen 2) * Intel Silvermont low-power processors * Intel Goldmont low-power processors (Apollo Lake and Denverton) * Intel Goldmont Plus low-power processors (Gemini Lake) * Intel 1st Gen Core i3/i5/i7 (Nehalem) * Intel 1.5 Gen Core i3/i5/i7 (Westmere) * Intel 2nd Gen Core i3/i5/i7 (Sandybridge) * Intel 3rd Gen Core i3/i5/i7 (Ivybridge) * Intel 4th Gen Core i3/i5/i7 (Haswell) * Intel 5th Gen Core i3/i5/i7 (Broadwell) * Intel 6th Gen Core i3/i5/i7 (Skylake) * Intel 6th Gen Core i7/i9 (Skylake X) * Intel 8th Gen Core i3/i5/i7 (Cannon Lake) * Intel 10th Gen Core i7/i9 (Ice Lake) * Intel Xeon (Cascade Lake) * Intel Xeon (Cooper Lake) * Intel 3rd Gen 10nm++ i3/i5/i7/i9-family (Tiger Lake) It also offers to compile passing the 'native' option which, "selects the CPU to generate code for at compilation time by determining the processor type of the compiling machine. Using -march=native enables all instruction subsets supported by the local machine and will produce code optimized for the local machine under the constraints of the selected instruction set."[2] Do NOT try using the 'native' option on AMD Piledriver, Steamroller, or Excavator CPUs (-march=bdver{2,3,4} flag). The build will error out due the kernel's objtool issue with these.[3a,b] MINOR NOTES This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9 changes. Note that upstream is using the deprecated 'match=atom' flags when I believe it should use the newer 'march=bonnell' flag for atom processors.[4] It is not recommended to compile on Atom-CPUs with the 'native' option.[5] The recommendation is to use the 'atom' option instead. BENEFITS Small but real speed increases are measurable using a make endpoint comparing a generic kernel to one built with one of the respective microarchs. See the following experimental evidence supporting this statement: https://github.com/graysky2/kernel_gcc_patch REQUIREMENTS linux version 5.5 and 5.6 gcc version >=10.1 ACKNOWLEDGMENTS This patch builds on the seminal work by Jeroen.[6] REFERENCES 1. https://gcc.gnu.org/gcc-4.9/changes.html 2. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html 3a. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95671#c11 3b. https://github.com/graysky2/kernel_gcc_patch/issues/55 4. https://bugzilla.kernel.org/show_bug.cgi?id=77461 5. https://github.com/graysky2/kernel_gcc_patch/issues/15 6. http://www.linuxforge.net/docs/linux/linux-gcc.php Signed-off-by: Alexandre Frade commit c91e255f9748296a46ba1e8496331698751d84a7 Author: Alexandre Frade Date: Tue Jun 16 11:17:23 2020 -0300 Revert "x86/kconfig: Enable additional cpu optimizations for gcc v9.1+" This reverts commit 856538feaba63de84aa3ca71d7b0e12dcc7f5b43. commit 56b416f1aee1b05d33ed2bdfc31d3f354f037403 Author: Sebastian Andrzej Siewior Date: Tue Jun 16 13:37:06 2020 +0200 v5.6.17-rt10 Signed-off-by: Sebastian Andrzej Siewior commit 6076f77843a67c6bf5075a7e38a5c9ff0554680b Author: Sebastian Andrzej Siewior Date: Fri Jun 12 16:51:50 2020 +0200 rwsem: Provide down_read_non_owner() and up_read_non_owner() for -RT The rwsem implementation on -RT allows multiple reader and there is no owner tracking anymore. We can provide down_read_non_owner() and up_read_non_owner() by skipping the owner check bits which are only available in the !RT implementation. Signed-off-by: Sebastian Andrzej Siewior commit 262a25ed2ec4c8f98327e258e770e6905c3b8655 Author: Sebastian Andrzej Siewior Date: Wed Sep 14 17:36:35 2016 +0200 net/Qdisc: use a seqlock instead seqcount 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 scheduled out. The seqlock on the other hand will serialize / sleep on the lock while writer is active. Signed-off-by: Sebastian Andrzej Siewior commit 2e0d0e66055897388d03496f1a7462587d6c1a63 Author: Sebastian Andrzej Siewior Date: Fri Oct 20 11:29:53 2017 +0200 fs/dcache: disable preemption on i_dir_seq's write side 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 held. The problem is that during the write process on RT the preemption is still enabled and if this process is interrupted by a reader with RT priority then we lock up. To avoid that lock up I am disabling the preemption during the update. The rename of i_dir_seq is here to ensure to catch new write sides in future. Cc: stable-rt@vger.kernel.org Reported-by: Oleg.Karfich@wago.com Signed-off-by: Sebastian Andrzej Siewior commit 43cd59012be6715dfaab399ce59ef5dc1a4e4189 Author: Sebastian Andrzej Siewior Date: Wed Sep 14 14:35:49 2016 +0200 fs/dcache: use swait_queue instead of waitqueue __d_lookup_done() invokes wake_up_all() while holding a hlist_bl_lock() which disables preemption. As a workaround convert it to swait. Signed-off-by: Sebastian Andrzej Siewior commit 4a90fbefff00ade907bad97c44c448976943b665 Author: Sebastian Andrzej Siewior Date: Wed Jun 10 17:57:04 2020 +0200 seqlock: Don't include linux/rwlock.h Signed-off-by: Sebastian Andrzej Siewior commit 4d7a7901686f077e9587d2d37d902c3149fa6b32 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:22 2020 +0200 xfrm: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Upstream-status: The xfrm locking used for seqcoun writer serialization appears to be broken. If that's the case, a proper fix will need to be submitted upstream. (e.g. make the seqcount per network namespace?) Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 0cd32a8017b46a11b3f66abfb8655f2c4995d6ab Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:21 2020 +0200 seqlock: PREEMPT_RT: Do not starve writers Preemption must be disabled before entering a sequence counter write side critical section. This cannot be done for PREEMPT_RT. With disabled preemption: - The writer cannot be preempted by a task with higher priority - The writer cannot acquire a spinlock_t since it's a sleeping lock. This would invalidate the existing, and non-PREEMPT_RT valid, code pattern of acquiring a spinlock_t inside the seqcount write side critical section. To remain preemptible, while avoiding a livelock caused by the reader preempting the writer, use a different technique: - If the sequence counter is even upon entering a read side section, then no writer is in progress, and the reader did not preempt any write side sections. It can continue. - If the counter is odd, a writer is in progress and the reader may have preempted a write side section. Let the reader acquire the lock used for seqcount writer serialization, which is already held by the writer. The higher-priority reader will block on the lock, and the lower priority preempted writer will make progress until it finishes its write serialization lock critical section. Once the reader has the writer serialization lock acquired, the writer is finished and the counter is even. Drop the writer serialization lock and re-read the sequence counter. Implement this technique for all PREEMPT_RT sleeping locks. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit f78bb7e0b5946a3e278fbbdd8a92222f490ed1ea Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:20 2020 +0200 hrtimer: Use sequence counter with associated raw spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_raw_spinlock_t data type, which allows to associate a raw spinlock with the sequence counter. This enables lockdep to verify that the raw spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 9f087bac2d9b3be177dd0207b57659fa81403395 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:19 2020 +0200 kvm/eventfd: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Acked-by: Paolo Bonzini Signed-off-by: Sebastian Andrzej Siewior commit d84a737eaca84b592ca30cd0947d24a914dafdcf Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:18 2020 +0200 userfaultfd: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit c0ec30a148906827091cb01d9cd5a692aee63ce7 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:17 2020 +0200 NFSv4: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit ca9dcef5342284cae6acf2d6a7a17b73c60e31aa Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:16 2020 +0200 iocost: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 7661b6a8d21f577fa7c0462bfc2bd52c1ded650b Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:15 2020 +0200 raid5: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit a068dfcf5c8c7572a836dd63354d808b238cdda3 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:14 2020 +0200 vfs: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit cb167d22bc247d72a10f4496f129624b81ab00dc Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:13 2020 +0200 timekeeping: Use sequence counter with associated raw spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_raw_spinlock_t data type, which allows to associate a raw spinlock with the sequence counter. This enables lockdep to verify that the raw spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 91008b6fb0311c7665d71671abfc32782c02f0b8 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:12 2020 +0200 xfrm: policy: Use sequence counters with associated lock A sequence counter write side critical section must be protected by some form of locking to serialize writers. If the serialization primitive is not disabling preemption implicitly, preemption has to be explicitly disabled before entering the sequence counter write side critical section. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t and seqcount_mutex_t data types instead, which allow to associate a lock with the sequence counter. This enables lockdep to verify that the lock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 43fb0dd9b9e0916d636b7e7c23556f7cdace1385 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:11 2020 +0200 netfilter: nft_set_rbtree: Use sequence counter with associated rwlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_rwlock_t data type, which allows to associate a rwlock with the sequence counter. This enables lockdep to verify that the rwlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit c07c01230d3f027e1f6f5b8025bfc77910149cf2 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:10 2020 +0200 netfilter: conntrack: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 00b57404b507dc5fd4597ace03cd4133ba8a5fa1 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:09 2020 +0200 sched: tasks: Use sequence counter with associated spinlock A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 8b02cb9102914f663fc42c6484605c1f554101d6 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:08 2020 +0200 dma-buf: Use sequence counter with associated wound/wait mutex A sequence counter write side critical section must be protected by some form of locking to serialize writers. If the serialization primitive is not disabling preemption implicitly, preemption has to be explicitly disabled before entering the sequence counter write side critical section. The dma-buf reservation subsystem uses plain sequence counters to manage updates to reservations. Writer serialization is accomplished through a wound/wait mutex. Acquiring a wound/wait mutex does not disable preemption, so this needs to be done manually before and after the write side critical section. Use the newly-added seqcount_ww_mutex_t instead: - It associates the ww_mutex with the sequence count, which enables lockdep to validate that the write side critical section is properly serialized. - It removes the need to explicitly add preempt_disable/enable() around the write side critical section because the write_begin/end() functions for this new data type automatically do this. If lockdep is disabled this ww_mutex lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Acked-by: Daniel Vetter Signed-off-by: Sebastian Andrzej Siewior commit 9a193af85af7a9b3493fe2cbf5bcacd3b17deb23 Author: Ahmed S. Darwish Date: Mon Jun 8 02:57:15 2020 +0200 seqlock: Extend seqcount API with associated locks A sequence counter write side critical section must be protected by some form of locking to serialize writers. If the serialization primitive is not disabling preemption implicitly, preemption has to be explicitly disabled before entering the write side critical section. There is no built-in debugging mechanism to verify that the lock used for writer serialization is held and preemption is disabled. Some usage sites like dma-buf have explicit lockdep checks for the writer-side lock, but this covers only a small portion of the sequence counter usage in the kernel. Add new sequence counter types which allows to associate a lock to the sequence counter at initialization time. The seqcount API functions are extended to provide appropriate lockdep assertions depending on the seqcount/lock type. For sequence counters with associated locks that do not implicitly disable preemption, preemption protection is enforced in the sequence counter write side functions. This removes the need to explicitly add preempt_disable/enable() around the write side critical sections: the write_begin/end() functions for these new sequence counter types automatically do this. Introduce the following seqcount types with associated locks: seqcount_spinlock_t seqcount_raw_spinlock_t seqcount_rwlock_t seqcount_mutex_t seqcount_ww_mutex_t Extend the seqcount read and write functions to branch out to the specific seqcount_LOCKTYPE_t implementation at compile-time. This avoids kernel API explosion per each new seqcount_LOCKTYPE_t added. Add such compile-time type detection logic into a new, internal, seqlock header. Document the proper seqcount_LOCKTYPE_t usage, and rationale, at Documentation/locking/seqlock.rst. If lockdep is disabled, this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 73e466dc69d8a89c76bc47fca78f2050a69ec59f Author: Ahmed S. Darwish Date: Mon Jun 8 02:57:14 2020 +0200 seqlock: Add missing kernel-doc annotations A small number of the the exported seqlock.h functions are kernel-doc annotated. Since seqlock.h is now included by the kernel's RST documentation, add kernel-doc annotations for all of the remaining functions. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 909b3c29ef6027f7a83829e6a97e8f91af7b731d Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:04 2020 +0200 seqlock: Properly format kernel-doc code samples Align the code samples and note sections inside kernel-doc comments with tabs. This way they can be properly parsed and rendered by Sphinx. It also makes the code samples easier to read from text editors. Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 240e6b65940ebf361b971423766361a5915edc97 Author: Ahmed S. Darwish Date: Mon Jun 8 02:57:12 2020 +0200 Documentation: locking: Describe seqlock design and usage Proper documentation for the design and usage of sequence counters and sequential locks does not exist. Complete the seqlock.h documentation as follows: - Divide all documentation on a seqcount_t vs. seqlock_t basis. The description for both mechanisms was intermingled, which is incorrect since the usage constrains for each type are vastly different. - Add an introductory paragraph describing the internal design of, and rationale for, sequence counters. - Document seqcount_t writer non-preemptibility requirement, which was not previously documented anywhere, and provide a clear rationale. - Provide template code for seqcount_t and seqlock_t initialization and reader/writer critical sections. - Recommend using seqlock_t by default. It implicitly handles the serialization and non-preemptibility requirements of writers. At seqlock.h: - Remove references to brlocks as they've long been removed from the kernel. - Remove references to gcc-3.x since the kernel's minimum supported gcc version is 4.6. References: 0f6ed63b1707 ("no need to keep brlock macros anymore...") References: cafa0010cd51 ("Raise the minimum required gcc version to 4.6") Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 7d5eb2c8cc2272b8d7b6439bedc0b6270d84d0f2 Author: Ahmed S. Darwish Date: Wed Jun 3 16:49:49 2020 +0200 dma-buf: Remove custom seqcount lockdep class key Commit 3c3b177a9369 ("reservation: add support for read-only access using rcu") introduced a sequence counter to manage updates to reservations. Back then, the reservation object initializer reservation_object_init() was always inlined. Having the sequence counter initialization inlined meant that each of the call sites would have a different lockdep class key, which would've broken lockdep's deadlock detection. The aforementioned commit thus introduced, and exported, a custom seqcount lockdep class key and name. The commit 8735f16803f00 ("dma-buf: cleanup reservation_object_init...") transformed the reservation object initializer to a normal non-inlined C function. seqcount_init(), which automatically defines the seqcount lockdep class key and must be called non-inlined, can now be safely used. Remove the seqcount custom lockdep class key, name, and export. Use seqcount_init() inside the dma reservation object initializer. Signed-off-by: Ahmed S. Darwish Reviewed-by: Sebastian Andrzej Siewior Sigend-off-by: Sebastian Andrzej Siewior commit a4e45824ba7926c22c942d9bdf0ee578aa11b11d Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:02 2020 +0200 block: nr_sects_write(): disable preemption on seqcount write For optimized readers not holding a mutex, the hd_struct "number of sectors" value is protected by a seqcount to avoid 64-bit values tearing on 32-bit architectures. Disable preemption before entering the seqcount write path. Otherwise, a reader can preempt the write-side critical section and spin for the entire tick. If that reader belongs to a real-time scheduling class, it will loop forever and the kernel will livelock. Fixes: c83f6bf98dc1 ("block: add partition resize function to blkpg ioctl") Cc: Signed-off-by: Ahmed S. Darwish Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Jens Axboe (cherry-picked from axboe/linux-block.git commit 15b81ce5abdc4b502aa31dff2d415b79d2349d2f) [a.darwish@linutronix.de: rebase v5.8-rc1 patch on top of v5.6] Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 6890109ca3126bd140db1b960eb858557c497f14 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:01 2020 +0200 net: mdiobus: Disable preemption upon u64_stats update The u64_stats mechanism uses sequence counters to protect against 64-bit values tearing on 32-bit architectures. Updating u64_stats is thus a sequence counter write side critical section where preemption must be disabled. For mdiobus_stats_acct(), disable preemption upon the u64_stats update. It is called from process context through mdiobus_read() and mdiobus_write(). Reported-by: kernel test robot Signed-off-by: Ahmed S. Darwish Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller (cherry picked from v5.8-rc1 commit c7e261d81783387a0502878cd229327e7c54322e) Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 6554eac9ef2bd1c968886b31cc7266b49258a463 Author: Ahmed S. Darwish Date: Wed Jun 10 12:53:00 2020 +0200 net: phy: fixed_phy: Remove unused seqcount Commit bf7afb29d545 ("phy: improve safety of fixed-phy MII register reading") protected the fixed PHY status with a sequence counter. Two years later, commit d2b977939b18 ("net: phy: fixed-phy: remove fixed_phy_update_state()") removed the sequence counter's write side critical section -- neutralizing its read side retry loop. Remove the unused seqcount. Signed-off-by: Ahmed S. Darwish Reviewed-by: Sebastian Andrzej Siewior Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller (cherry picked from v5.8-rc1 commit 79cbb6bc3332da7162c2581e151659ab8ebaa528) Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 1984aa963358ab2b9d553a343a1df7a6eb2712ce Author: Ahmed S. Darwish Date: Wed Jun 10 12:52:59 2020 +0200 net: core: device_rename: Use rwsem instead of a seqcount Sequence counters write paths are critical sections that must never be preempted, and blocking, even for CONFIG_PREEMPTION=n, is not allowed. Commit 5dbe7c178d3f ("net: fix kernel deadlock with interface rename and netdev name retrieval.") handled a deadlock, observed with CONFIG_PREEMPTION=n, where the devnet_rename seqcount read side was infinitely spinning: it got scheduled after the seqcount write side blocked inside its own critical section. To fix that deadlock, among other issues, the commit added a cond_resched() inside the read side section. While this will get the non-preemptible kernel eventually unstuck, the seqcount reader is fully exhausting its slice just spinning -- until TIF_NEED_RESCHED is set. The fix is also still broken: if the seqcount reader belongs to a real-time scheduling policy, it can spin forever and the kernel will livelock. Disabling preemption over the seqcount write side critical section will not work: inside it are a number of GFP_KERNEL allocations and mutex locking through the drivers/base/ :: device_rename() call chain. >From all the above, replace the seqcount with a rwsem. Fixes: 5dbe7c178d3f (net: fix kernel deadlock with interface rename and netdev name retrieval.) Fixes: 30e6c9fa93cf (net: devnet_rename_seq should be a seqcount) Fixes: c91f6df2db49 (sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name) Cc: Reported-by: kbuild test robot [ v1 missing up_read() on error exit ] Reported-by: Dan Carpenter [ v1 missing up_read() on error exit ] Signed-off-by: Ahmed S. Darwish Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller (cherry picked from v5.8-rc1 commit 11d6011c2cf29f7c8181ebde6c8bc0c4d83adcd7) Signed-off-by: Ahmed S. Darwish Signed-off-by: Sebastian Andrzej Siewior commit 3115f1749777dfc9b630a49f33cdb95f977d47e2 Author: Sebastian Andrzej Siewior Date: Tue Jun 16 12:56:01 2020 +0200 Revert seqcount related patches This is an all-in-one patch reverting the following patches: 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 userfaultfd-Use-a-seqlock-instead-of-seqcount.patch fs-nfs-turn-rmdir_sem-into-a-semaphore.patch fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch list_bl.h-make-list-head-locking-RT-safe.patch fscache-initialize-cookie-hash-table-raw-spinlocks.patch fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch fs-dcache-Include-swait.h-header.patch fs-dcache-use-swait_queue-instead-of-waitqueue.patch Signed-off-by: Sebastian Andrzej Siewior