diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:49:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:49:59 +0000 |
commit | 01997497f915e8f79871f3f2acb55ac465051d24 (patch) | |
tree | 1ce1afd7246e1014199e15cbf854bf7924458e5d /debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch | |
parent | Adding upstream version 6.1.76. (diff) | |
download | linux-01997497f915e8f79871f3f2acb55ac465051d24.tar.xz linux-01997497f915e8f79871f3f2acb55ac465051d24.zip |
Adding debian version 6.1.76-1.debian/6.1.76-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch')
-rw-r--r-- | debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch b/debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch new file mode 100644 index 000000000..1940c66d7 --- /dev/null +++ b/debian/patches-rt/0054-locking-rwbase-Mitigate-indefinite-writer-starvation.patch @@ -0,0 +1,63 @@ +From 8785dde5198dc91cbb518044e1c6d301ef9a9857 Mon Sep 17 00:00:00 2001 +From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Date: Tue, 21 Mar 2023 17:11:40 +0100 +Subject: [PATCH 54/62] locking/rwbase: Mitigate indefinite writer starvation +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.1/older/patches-6.1.69-rt21.tar.xz + +On PREEMPT_RT, rw_semaphore and rwlock_t locks are unfair to writers. +Readers can indefinitely acquire the lock unless the writer fully acquired +the lock, which might never happen if there is always a reader in the +critical section owning the lock. + +Mel Gorman reported that since LTP-20220121 the dio_truncate test case +went from having 1 reader to having 16 readers and that number of readers +is sufficient to prevent the down_write ever succeeding while readers +exist. Eventually the test is killed after 30 minutes as a failure. + +Mel proposed a timeout to limit how long a writer can be blocked until +the reader is forced into the slowpath. + +Thomas argued that there is no added value by providing this timeout. From +a PREEMPT_RT point of view, there are no critical rw_semaphore or rwlock_t +locks left where the reader must be preferred. + +Mitigate indefinite writer starvation by forcing the READER into the +slowpath once the WRITER attempts to acquire the lock. + +Reported-by: Mel Gorman <mgorman@techsingularity.net> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Signed-off-by: Thomas Gleixner <tglx@linutronix.de> +Signed-off-by: Ingo Molnar <mingo@kernel.org> +Acked-by: Mel Gorman <mgorman@techsingularity.net> +Link: https://lore.kernel.org/877cwbq4cq.ffs@tglx +Link: https://lore.kernel.org/r/20230321161140.HMcQEhHb@linutronix.de +Cc: Linus Torvalds <torvalds@linux-foundation.org> +(cherry picked from commit 286deb7ec03d941664ac3ffaff58814b454adf65) +Signed-off-by: Clark Williams <clark.williams@gmail.com> +--- + kernel/locking/rwbase_rt.c | 9 --------- + 1 file changed, 9 deletions(-) + +diff --git a/kernel/locking/rwbase_rt.c b/kernel/locking/rwbase_rt.c +index c201aadb9301..25ec0239477c 100644 +--- a/kernel/locking/rwbase_rt.c ++++ b/kernel/locking/rwbase_rt.c +@@ -72,15 +72,6 @@ static int __sched __rwbase_read_lock(struct rwbase_rt *rwb, + int ret; + + raw_spin_lock_irq(&rtm->wait_lock); +- /* +- * Allow readers, as long as the writer has not completely +- * acquired the semaphore for write. +- */ +- if (atomic_read(&rwb->readers) != WRITER_BIAS) { +- atomic_inc(&rwb->readers); +- raw_spin_unlock_irq(&rtm->wait_lock); +- return 0; +- } + + /* + * Call into the slow lock path with the rtmutex->wait_lock +-- +2.43.0 + |