Skip to content

Commit

Permalink
Revert "kmsan: printk: remove logbuf_lock_is_locked"
Browse files Browse the repository at this point in the history
This reverts commit 7b8a9a5.
  • Loading branch information
ramosian-glider committed Dec 21, 2018
1 parent 52848d8 commit 6e20099
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ __packed __aligned(4)
*/
DEFINE_RAW_SPINLOCK(logbuf_lock);

// TODO(glider): need to make sure we need logbuf_lock_is_locked at all.
// Maybe things have changed in new Linux versions.
bool logbuf_lock_is_locked = false;

/*
* Helper macros to lock/unlock logbuf_lock and switch between
* printk-safe/unsafe modes.
Expand All @@ -377,10 +381,12 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
do { \
printk_safe_enter_irq(); \
raw_spin_lock(&logbuf_lock); \
logbuf_lock_is_locked = true; \
} while (0)

#define logbuf_unlock_irq() \
do { \
logbuf_lock_is_locked = false; \
raw_spin_unlock(&logbuf_lock); \
printk_safe_exit_irq(); \
} while (0)
Expand All @@ -389,10 +395,12 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
do { \
printk_safe_enter_irqsave(flags); \
raw_spin_lock(&logbuf_lock); \
logbuf_lock_is_locked = true; \
} while (0)

#define logbuf_unlock_irqrestore(flags) \
do { \
logbuf_lock_is_locked = false; \
raw_spin_unlock(&logbuf_lock); \
printk_safe_exit_irqrestore(flags); \
} while (0)
Expand Down Expand Up @@ -2352,6 +2360,8 @@ void console_unlock(void)

printk_safe_enter_irqsave(flags);
raw_spin_lock(&logbuf_lock);
logbuf_lock_is_locked = true;

if (console_seq < log_first_seq) {
len = sprintf(text,
"** %llu printk messages dropped **\n",
Expand Down Expand Up @@ -2400,6 +2410,7 @@ void console_unlock(void)
}
console_idx = log_next(console_idx);
console_seq++;
logbuf_lock_is_locked = false;
raw_spin_unlock(&logbuf_lock);

/*
Expand Down Expand Up @@ -2427,6 +2438,7 @@ void console_unlock(void)

console_locked = 0;

logbuf_lock_is_locked = false;
raw_spin_unlock(&logbuf_lock);

up_console_sem();
Expand All @@ -2438,7 +2450,9 @@ void console_unlock(void)
* flush, no worries.
*/
raw_spin_lock(&logbuf_lock);
logbuf_lock_is_locked = true;
retry = console_seq != log_next_seq;
logbuf_lock_is_locked = false;
raw_spin_unlock(&logbuf_lock);
printk_safe_exit_irqrestore(flags);

Expand Down

0 comments on commit 6e20099

Please sign in to comment.