summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/highmem.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/mm/highmem.c b/mm/highmem.c
index bb4ce13ee7e7..67d2d5983cb0 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);
}