Skip to content

Commit

Permalink
Merge tag 'printk-for-4.18' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/pmladek/printk

Pull printk updates from Petr Mladek:

 - Help userspace log daemons to catch up with a flood of messages. They
   will get woken after each message even if the console is far behind
   and handled by another process.

 - Flush printk safe buffers safely even when panic() happens in the
   normal context.

 - Fix possible va_list reuse when race happened in printk_safe().

 - Remove %pCr printf format to prevent sleeping in the atomic context.

 - Misc vsprintf code cleanup.

* tag 'printk-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk:
  printk: drop in_nmi check from printk_safe_flush_on_panic()
  lib/vsprintf: Remove atomic-unsafe support for %pCr
  serial: sh-sci: Stop using printk format %pCr
  thermal: bcm2835: Stop using printk format %pCr
  clk: renesas: cpg-mssr: Stop using printk format %pCr
  printk: fix possible reuse of va_list variable
  printk: wake up klogd in vprintk_emit
  vsprintf: Tweak pF/pf comment
  lib/vsprintf: Mark expected switch fall-through
  lib/vsprintf: Replace space with '_' before crng is ready
  lib/vsprintf: Deduplicate pointer_string()
  lib/vsprintf: Move pointer_string() upper
  lib/vsprintf: Make flag_spec global
  lib/vsprintf: Make strspec global
  lib/vsprintf: Make dec_spec global
  lib/test_printf: Mark big constant with UL
  • Loading branch information
Linus Torvalds committed Jun 6, 2018
2 parents 0eb0061 + 8bafa2a commit d75ae5b
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 105 deletions.
3 changes: 1 addition & 2 deletions Documentation/core-api/printk-formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,10 @@ struct clk

%pC pll1
%pCn pll1
%pCr 1560000000

For printing struct clk structures. %pC and %pCn print the name
(Common Clock Framework) or address (legacy clock framework) of the
structure; %pCr prints the current clock rate.
structure.

Passed by reference.

Expand Down
9 changes: 5 additions & 4 deletions drivers/clk/renesas/renesas-cpg-mssr.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ struct clk *cpg_mssr_clk_src_twocell_get(struct of_phandle_args *clkspec,
dev_err(dev, "Cannot get %s clock %u: %ld", type, clkidx,
PTR_ERR(clk));
else
dev_dbg(dev, "clock (%u, %u) is %pC at %pCr Hz\n",
clkspec->args[0], clkspec->args[1], clk, clk);
dev_dbg(dev, "clock (%u, %u) is %pC at %lu Hz\n",
clkspec->args[0], clkspec->args[1], clk,
clk_get_rate(clk));
return clk;
}

Expand Down Expand Up @@ -326,7 +327,7 @@ static void __init cpg_mssr_register_core_clk(const struct cpg_core_clk *core,
if (IS_ERR_OR_NULL(clk))
goto fail;

dev_dbg(dev, "Core clock %pC at %pCr Hz\n", clk, clk);
dev_dbg(dev, "Core clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
priv->clks[id] = clk;
return;

Expand Down Expand Up @@ -392,7 +393,7 @@ static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod,
if (IS_ERR(clk))
goto fail;

dev_dbg(dev, "Module clock %pC at %pCr Hz\n", clk, clk);
dev_dbg(dev, "Module clock %pC at %lu Hz\n", clk, clk_get_rate(clk));
priv->clks[id] = clk;
priv->smstpcr_saved[clock->index / 32].mask |= BIT(clock->index % 32);
return;
Expand Down
4 changes: 2 additions & 2 deletions drivers/thermal/broadcom/bcm2835_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ static int bcm2835_thermal_probe(struct platform_device *pdev)
rate = clk_get_rate(data->clk);
if ((rate < 1920000) || (rate > 5000000))
dev_warn(&pdev->dev,
"Clock %pCn running at %pCr Hz is outside of the recommended range: 1.92 to 5MHz\n",
data->clk, data->clk);
"Clock %pCn running at %lu Hz is outside of the recommended range: 1.92 to 5MHz\n",
data->clk, rate);

/* register of thermal sensor and get info from DT */
tz = thermal_zone_of_sensor_register(&pdev->dev, 0, data,
Expand Down
4 changes: 2 additions & 2 deletions drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2724,8 +2724,8 @@ static int sci_init_clocks(struct sci_port *sci_port, struct device *dev)
dev_dbg(dev, "failed to get %s (%ld)\n", clk_names[i],
PTR_ERR(clk));
else
dev_dbg(dev, "clk %s is %pC rate %pCr\n", clk_names[i],
clk, clk);
dev_dbg(dev, "clk %s is %pC rate %lu\n", clk_names[i],
clk, clk_get_rate(clk));
sci_port->clks[i] = IS_ERR(clk) ? NULL : clk;
}
return 0;
Expand Down
14 changes: 2 additions & 12 deletions kernel/printk/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,7 @@ asmlinkage int vprintk_emit(int facility, int level,
preempt_enable();
}

wake_up_klogd();
return printed_len;
}
EXPORT_SYMBOL(vprintk_emit);
Expand Down Expand Up @@ -2289,9 +2290,7 @@ void console_unlock(void)
{
static char ext_text[CONSOLE_EXT_LOG_MAX];
static char text[LOG_LINE_MAX + PREFIX_MAX];
static u64 seen_seq;
unsigned long flags;
bool wake_klogd = false;
bool do_cond_resched, retry;

if (console_suspended) {
Expand Down Expand Up @@ -2335,11 +2334,6 @@ void console_unlock(void)

printk_safe_enter_irqsave(flags);
raw_spin_lock(&logbuf_lock);
if (seen_seq != log_next_seq) {
wake_klogd = true;
seen_seq = log_next_seq;
}

if (console_seq < log_first_seq) {
len = sprintf(text, "** %u printk messages dropped **\n",
(unsigned)(log_first_seq - console_seq));
Expand Down Expand Up @@ -2397,7 +2391,7 @@ void console_unlock(void)

if (console_lock_spinning_disable_and_check()) {
printk_safe_exit_irqrestore(flags);
goto out;
return;
}

printk_safe_exit_irqrestore(flags);
Expand Down Expand Up @@ -2429,10 +2423,6 @@ void console_unlock(void)

if (retry && console_trylock())
goto again;

out:
if (wake_klogd)
wake_up_klogd();
}
EXPORT_SYMBOL(console_unlock);

Expand Down
7 changes: 5 additions & 2 deletions kernel/printk/printk_safe.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s,
{
int add;
size_t len;
va_list ap;

again:
len = atomic_read(&s->len);
Expand All @@ -100,7 +101,9 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s,
if (!len)
smp_rmb();

add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
va_copy(ap, args);
add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap);
va_end(ap);
if (!add)
return 0;

Expand Down Expand Up @@ -278,7 +281,7 @@ void printk_safe_flush_on_panic(void)
* Make sure that we could access the main ring buffer.
* Do not risk a double release when more CPUs are up.
*/
if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) {
if (raw_spin_is_locked(&logbuf_lock)) {
if (num_online_cpus() > 1)
return;

Expand Down
2 changes: 1 addition & 1 deletion lib/test_printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ test_string(void)
#if BITS_PER_LONG == 64

#define PTR_WIDTH 16
#define PTR ((void *)0xffff0123456789ab)
#define PTR ((void *)0xffff0123456789abUL)
#define PTR_STR "ffff0123456789ab"
#define ZEROS "00000000" /* hex 32 zero bits */

Expand Down
Loading

0 comments on commit d75ae5b

Please sign in to comment.