From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Jan Kara <jack@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Petr Mladek <pmladek@suse.cz>, KY Srinivasan <kys@microsoft.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH 5/7] printk: Add config option for disabling printk offloading
Date: Fri, 11 Dec 2015 00:10:25 +0900 [thread overview]
Message-ID: <20151210151025.GD540@swordfish> (raw)
> 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
next reply other threads:[~2015-12-10 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 15:10 Sergey Senozhatsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-10-26 4:52 [PATCH 0/6 v2] printk: Softlockup avoidance Jan Kara
2015-10-26 4:52 ` [PATCH 5/7] printk: Add config option for disabling printk offloading Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151210151025.GD540@swordfish \
--to=sergey.senozhatsky@gmail.com \
--cc=1445835169-8203-6-git-send-email-jack@suse.com \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.cz \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.