summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2017-10-03 11:22:35 -0400
committerPaul Gortmaker <paul.gortmaker@windriver.com>2017-10-03 11:23:04 -0400
commitf8d128f16ef54665649413589f622ed011cb3aab (patch)
treee51c8e225053d1f6306f3dad400f0f39c18ecea8
parent9de508231834b02a4facc4329cc7d93bf8cbeac2 (diff)
download4.12-rt-patches-f8d128f16ef54665649413589f622ed011cb3aab.tar.gz
zram: new version of patch, needed complete rewrite
Compile tested only. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--patches/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/patches/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch b/patches/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
new file mode 100644
index 00000000000000..d97013b39d0eb1
--- /dev/null
+++ b/patches/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch
@@ -0,0 +1,93 @@
+From 84f3382e0a349c4ad9f6b277b8bc7f2742d380c2 Mon Sep 17 00:00:00 2001
+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
+
+They're nondeterministic, and lead to ___might_sleep() splats in -rt.
+OTOH, they're a lot less wasteful than an rtmutex per page.
+
+Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+[PG: restructure patch for wrappers added in mainline 86c49814d449]
+Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
+
+diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
+index debee952dcc1..b758e3db2e30 100644
+--- a/drivers/block/zram/zram_drv.c
++++ b/drivers/block/zram/zram_drv.c
+@@ -422,6 +422,7 @@ static DEVICE_ATTR_RO(io_stat);
+ static DEVICE_ATTR_RO(mm_stat);
+ static DEVICE_ATTR_RO(debug_stat);
+
++#ifndef CONFIG_PREEMPT_RT_BASE
+ static void zram_slot_lock(struct zram *zram, u32 index)
+ {
+ bit_spin_lock(ZRAM_ACCESS, &zram->table[index].value);
+@@ -431,6 +432,19 @@ static void zram_slot_unlock(struct zram *zram, u32 index)
+ {
+ bit_spin_unlock(ZRAM_ACCESS, &zram->table[index].value);
+ }
++#else /* CONFIG_PREEMPT_RT_BASE */
++static void zram_slot_lock(struct zram *zram, u32 index)
++{
++ spin_lock(&zram->table[index].lock);
++ __set_bit(ZRAM_ACCESS, &zram->table[index].value);
++}
++
++static void zram_slot_unlock(struct zram *zram, u32 index)
++{
++ __clear_bit(ZRAM_ACCESS, &zram->table[index].value);
++ spin_unlock(&zram->table[index].lock);
++}
++#endif /* CONFIG_PREEMPT_RT_BASE */
+
+ static bool zram_same_page_read(struct zram *zram, u32 index,
+ struct page *page,
+@@ -504,6 +518,8 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
+ return false;
+ }
+
++ zram_meta_init_table_locks(zram, disksize);
++
+ return true;
+ }
+
+diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
+index e34e44d02e3e..53c74fed2561 100644
+--- a/drivers/block/zram/zram_drv.h
++++ b/drivers/block/zram/zram_drv.h
+@@ -76,6 +76,9 @@ struct zram_table_entry {
+ unsigned long element;
+ };
+ unsigned long value;
++#ifdef CONFIG_PREEMPT_RT_BASE
++ spinlock_t lock;
++#endif
+ };
+
+ struct zram_stats {
+@@ -116,4 +119,20 @@ struct zram {
+ */
+ bool claim; /* Protected by bdev->bd_mutex */
+ };
++
++#ifndef CONFIG_PREEMPT_RT_BASE
++static inline void zram_meta_init_table_locks(struct zram *zram, u64 disksize) { }
++#else /* CONFIG_PREEMPT_RT_BASE */
++static inline void zram_meta_init_table_locks(struct zram *zram, u64 disksize)
++{
++ size_t num_pages = disksize >> PAGE_SHIFT;
++ size_t index;
++
++ for (index = 0; index < num_pages; index++) {
++ spinlock_t *lock = &zram->table[index].lock;
++ spin_lock_init(lock);
++ }
++}
++#endif /* CONFIG_PREEMPT_RT_BASE */
++
+ #endif
+--
+2.1.4
+