lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 11 Dec 2015 00:10:25 +0900
From:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:	Jan Kara <jack@...e.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Petr Mladek <pmladek@...e.cz>,
	KY Srinivasan <kys@...rosoft.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: Re: [PATCH 5/7] printk: Add config option for disabling printk
 offloading

> Necessity for offloading of printing was observed only for large
> systems. So add a config option (disabled by default) which removes most
> of the overhead added by this functionality.

to be folded:


- add spin_lock_init_print_lock() to be called from zap_lock()
- move PRINTK_OFFLOAD defines up, so zap_lock() sees them

---
 kernel/printk/printk.c | 119 ++++++++++++++++++++++++++-----------------------
 1 file changed, 63 insertions(+), 56 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 2a500a5..86f5abf 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -333,7 +333,66 @@ module_param_cb(offload_chars, &offload_chars_ops, &printk_offload_chars,
 		   S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(offload_chars, "offload printing to console to a different"
 	" cpu after this number of characters");
-#endif
+
+/*
+ * Returns true iff there is other cpu waiting to take over printing. This
+ * function also takes are of setting PRINTK_HANDOVER_B if we want to hand over
+ * printing to some other cpu.
+ */
+static bool cpu_stop_printing(int printed_chars)
+{
+	/* Oops? Print everything now to maximize chances user will see it */
+	if (oops_in_progress)
+		return false;
+	if (!printk_offload_chars || printed_chars < printk_offload_chars)
+		return false;
+	/*
+	 * Make sure we load fresh value of printing_tasks_spinning. Matches
+	 * the barrier in printing_task()
+	 */
+	smp_rmb();
+	if (atomic_read(&printing_tasks_spinning))
+		return true;
+	wake_up(&print_queue);
+
+	return false;
+}
+
+static bool cpu_should_cond_resched(bool do_cond_resched)
+{
+	/* Oops? Print everything now to maximize chances user will see it */
+	if (oops_in_progress)
+		return false;
+	if (!printk_offload_chars && do_cond_resched)
+		return true;
+	return false;
+}
+
+#define spin_lock_print_lock(flags) raw_spin_lock_irqsave(&print_lock, flags)
+
+#define spin_unlock_print_lock(flags) raw_spin_unlock_irqrestore(&print_lock, flags)
+
+#define spin_lock_init_print_lock() raw_spin_lock_init(&print_lock)
+
+#else /* !CONFIG_PRINTK_OFFLOAD */
+
+static bool cpu_stop_printing(int printed_chars)
+{
+	return false;
+}
+
+static bool cpu_should_cond_resched(bool do_cond_resched)
+{
+	return do_cond_resched && !oops_in_progress;
+}
+
+#define spin_lock_print_lock(flags) local_irq_save(flags)
+
+#define spin_unlock_print_lock(flags) local_irq_restore(flags)
+
+#define spin_lock_init_print_lock()
+
+#endif /* CONFIG_PRINTK_OFFLOAD */
 
 /* Return log buffer address */
 char *log_buf_addr_get(void)
@@ -1531,7 +1590,7 @@ static void zap_locks(void)
 	/* If a crash is occurring, make sure we can't deadlock */
 	raw_spin_lock_init(&logbuf_lock);
 	/* And make sure that we print immediately */
-	raw_spin_lock_init(&print_lock);
+	spin_lock_init_print_lock();
 	sema_init(&console_sem, 1);
 }
 
@@ -2265,58 +2324,6 @@ out:
 	raw_spin_unlock_irqrestore(&logbuf_lock, flags);
 }
 
-#ifdef CONFIG_PRINTK_OFFLOAD
-/*
- * Returns true iff there is other cpu waiting to take over printing. This
- * function also takes are of setting PRINTK_HANDOVER_B if we want to hand over
- * printing to some other cpu.
- */
-static bool cpu_stop_printing(int printed_chars)
-{
-	/* Oops? Print everything now to maximize chances user will see it */
-	if (oops_in_progress)
-		return false;
-	if (!printk_offload_chars || printed_chars < printk_offload_chars)
-		return false;
-	/*
-	 * Make sure we load fresh value of printing_tasks_spinning. Matches
-	 * the barrier in printing_task()
-	 */
-	smp_rmb();
-	if (atomic_read(&printing_tasks_spinning))
-		return true;
-	wake_up(&print_queue);
-
-	return false;
-}
-
-static bool cpu_should_cond_resched(bool do_cond_resched)
-{
-	/* Oops? Print everything now to maximize chances user will see it */
-	if (oops_in_progress)
-		return false;
-	if (!printk_offload_chars && do_cond_resched)
-		return true;
-	return false;
-}
-
-#define spin_lock_print_lock(flags) raw_spin_lock_irqsave(&print_lock, flags)
-
-#define spin_unlock_print_lock(flags) raw_spin_unlock_irqrestore(&print_lock, flags)
-
-#else
-
-static bool cpu_stop_printing(int printed_chars)
-{
-	return false;
-}
-
-#define spin_lock_print_lock(flags) local_irq_save(flags)
-
-#define spin_unlock_print_lock(flags) local_irq_restore(flags)
-
-#endif
-
 /**
  * console_unlock - unlock the console system
  *
@@ -2440,9 +2447,9 @@ skip:
 		printed_chars += len;
 
 		if (unlikely(cpu_should_cond_resched(do_cond_resched))) {
-			raw_spin_unlock_irqrestore(&print_lock, flags);
+			spin_unlock_print_lock(flags);
 			cond_resched();
-			raw_spin_lock_irqsave(&print_lock, flags);
+			spin_lock_print_lock(flags);
 		}
 	}
 
-- 
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ