[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <160470524446.397.16379792318716189243.tip-bot2@tip-bot2>
Date: Fri, 06 Nov 2020 23:27:24 -0000
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Christoph Hellwig <hch@....de>,
Andrew Morton <akpm@...ux-foundation.org>,
x86 <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: [tip: core/mm] highmem: Make DEBUG_HIGHMEM functional
The following commit has been merged into the core/mm branch of tip:
Commit-ID: 389755c250814185938f5b04334a4f0184c30647
Gitweb: https://git.kernel.org/tip/389755c250814185938f5b04334a4f0184c30647
Author: Thomas Gleixner <tglx@...utronix.de>
AuthorDate: Tue, 03 Nov 2020 10:27:19 +01:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Fri, 06 Nov 2020 23:14:55 +01:00
highmem: Make DEBUG_HIGHMEM functional
For some obscure reason when CONFIG_DEBUG_HIGHMEM is enabled the stack
depth is increased from 20 to 41. But the only thing DEBUG_HIGHMEM does is
to enable a few BUG_ON()'s in the mapping code.
That's a leftover from the historical mapping code which had fixed entries
for various purposes. DEBUG_HIGHMEM inserted guard mappings between the map
types. But that got all ditched when kmap_atomic() switched to a stack
based map management. Though the WITH_KM_FENCE magic survived without being
functional. All the thing does today is to increase the stack depth.
Add a working implementation to the generic kmap_local* implementation.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Linus Torvalds <torvalds@...uxfoundation.org>
Cc: Christoph Hellwig <hch@....de>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Link: https://lore.kernel.org/r/20201103095857.268258322@linutronix.de
---
mm/highmem.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/mm/highmem.c b/mm/highmem.c
index bb4ce13..67d2d59 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -376,9 +376,19 @@ EXPORT_SYMBOL(kunmap_high);
static DEFINE_PER_CPU(int, __kmap_local_idx);
+/*
+ * With DEBUG_HIGHMEM the stack depth is doubled and every second
+ * slot is unused which acts as a guard page
+ */
+#ifdef CONFIG_DEBUG_HIGHMEM
+# define KM_INCR 2
+#else
+# define KM_INCR 1
+#endif
+
static inline int kmap_local_idx_push(void)
{
- int idx = __this_cpu_inc_return(__kmap_local_idx) - 1;
+ int idx = __this_cpu_add_return(__kmap_local_idx, KM_INCR) - 1;
WARN_ON_ONCE(in_irq() && !irqs_disabled());
BUG_ON(idx >= KM_MAX_IDX);
@@ -392,7 +402,7 @@ static inline int kmap_local_idx(void)
static inline void kmap_local_idx_pop(void)
{
- int idx = __this_cpu_dec_return(__kmap_local_idx);
+ int idx = __this_cpu_sub_return(__kmap_local_idx, KM_INCR);
BUG_ON(idx < 0);
}
Powered by blists - more mailing lists