<feed xmlns='http://www.w3.org/2005/Atom'>
<title>pm24.git/lib/vsprintf.c, branch v4.18-rc2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<id>https://git.kobert.dev/pm24.git/atom?h=v4.18-rc2</id>
<link rel='self' href='https://git.kobert.dev/pm24.git/atom?h=v4.18-rc2'/>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/'/>
<updated>2018-06-06T23:04:55Z</updated>
<entry>
<title>Merge tag 'printk-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk</title>
<updated>2018-06-06T23:04:55Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2018-06-06T23:04:55Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=d75ae5bdf2353e5c6a1f83da5f6f2d31582f09a3'/>
<id>urn:sha1:d75ae5bdf2353e5c6a1f83da5f6f2d31582f09a3</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>Merge branch 'for-4.18-vsprintf-pcr-removal' into for-4.18</title>
<updated>2018-06-05T11:39:12Z</updated>
<author>
<name>Petr Mladek</name>
<email>pmladek@suse.com</email>
</author>
<published>2018-06-05T11:39:12Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=8bafa2a44ff3647904eaa3c9228bfbd36742b9b4'/>
<id>urn:sha1:8bafa2a44ff3647904eaa3c9228bfbd36742b9b4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>lib/vsprintf: Remove atomic-unsafe support for %pCr</title>
<updated>2018-06-05T07:43:39Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert+renesas@glider.be</email>
</author>
<published>2018-06-01T09:28:22Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=666902e42fd8344b923c02dc5b0f37948ff4f225'/>
<id>urn:sha1:666902e42fd8344b923c02dc5b0f37948ff4f225</id>
<content type='text'>
"%pCr" formats the current rate of a clock, and calls clk_get_rate().
The latter obtains a mutex, hence it must not be called from atomic
context.

Remove support for this rarely-used format, as vsprintf() (and e.g.
printk()) must be callable from any context.

Any remaining out-of-tree users will start seeing the clock's name
printed instead of its rate.

Reported-by: Jia-Ju Bai &lt;baijiaju1990@gmail.com&gt;
Fixes: 900cca2944254edd ("lib/vsprintf: add %pC{,n,r} format specifiers for clocks")
Link: http://lkml.kernel.org/r/1527845302-12159-5-git-send-email-geert+renesas@glider.be
To: Jia-Ju Bai &lt;baijiaju1990@gmail.com&gt;
To: Jonathan Corbet &lt;corbet@lwn.net&gt;
To: Michael Turquette &lt;mturquette@baylibre.com&gt;
To: Stephen Boyd &lt;sboyd@kernel.org&gt;
To: Zhang Rui &lt;rui.zhang@intel.com&gt;
To: Eduardo Valentin &lt;edubezval@gmail.com&gt;
To: Eric Anholt &lt;eric@anholt.net&gt;
To: Stefan Wahren &lt;stefan.wahren@i2se.com&gt;
To: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Sergey Senozhatsky &lt;sergey.senozhatsky.work@gmail.com&gt;
Cc: Petr Mladek &lt;pmladek@suse.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: linux-doc@vger.kernel.org
Cc: linux-clk@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: linux-serial@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Geert Uytterhoeven &lt;geert+renesas@glider.be&gt;
Cc: stable@vger.kernel.org # 4.1+
Signed-off-by: Geert Uytterhoeven &lt;geert+renesas@glider.be&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
<entry>
<title>vsprintf: Replace memory barrier with static_key for random_ptr_key update</title>
<updated>2018-05-16T13:01:41Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2018-05-16T02:24:52Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=85f4f12d51397f1648e1f4350f77e24039b82d61'/>
<id>urn:sha1:85f4f12d51397f1648e1f4350f77e24039b82d61</id>
<content type='text'>
Reviewing Tobin's patches for getting pointers out early before
entropy has been established, I noticed that there's a lone smp_mb() in
the code. As with most lone memory barriers, this one appears to be
incorrectly used.

We currently basically have this:

	get_random_bytes(&amp;ptr_key, sizeof(ptr_key));
	/*
	 * have_filled_random_ptr_key==true is dependent on get_random_bytes().
	 * ptr_to_id() needs to see have_filled_random_ptr_key==true
	 * after get_random_bytes() returns.
	 */
	smp_mb();
	WRITE_ONCE(have_filled_random_ptr_key, true);

And later we have:

	if (unlikely(!have_filled_random_ptr_key))
		return string(buf, end, "(ptrval)", spec);

/* Missing memory barrier here. */

	hashval = (unsigned long)siphash_1u64((u64)ptr, &amp;ptr_key);

As the CPU can perform speculative loads, we could have a situation
with the following:

	CPU0				CPU1
	----				----
				   load ptr_key = 0
   store ptr_key = random
   smp_mb()
   store have_filled_random_ptr_key

				   load have_filled_random_ptr_key = true

				    BAD BAD BAD! (you're so bad!)

Because nothing prevents CPU1 from loading ptr_key before loading
have_filled_random_ptr_key.

But this race is very unlikely, but we can't keep an incorrect smp_mb() in
place. Instead, replace the have_filled_random_ptr_key with a static_branch
not_filled_random_ptr_key, that is initialized to true and changed to false
when we get enough entropy. If the update happens in early boot, the
static_key is updated immediately, otherwise it will have to wait till
entropy is filled and this happens in an interrupt handler which can't
enable a static_key, as that requires a preemptible context. In that case, a
work_queue is used to enable it, as entropy already took too long to
establish in the first place waiting a little more shouldn't hurt anything.

The benefit of using the static key is that the unlikely branch in
vsprintf() now becomes a nop.

Link: http://lkml.kernel.org/r/20180515100558.21df515e@gandalf.local.home

Cc: stable@vger.kernel.org
Fixes: ad67b74d2469d ("printk: hash addresses printed with %p")
Acked-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>vsprintf: Tweak pF/pf comment</title>
<updated>2018-04-18T10:53:52Z</updated>
<author>
<name>Sergey Senozhatsky</name>
<email>sergey.senozhatsky@gmail.com</email>
</author>
<published>2018-04-14T03:00:05Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=cdb7e52d960a59f30de853f5dd85574432d6bb50'/>
<id>urn:sha1:cdb7e52d960a59f30de853f5dd85574432d6bb50</id>
<content type='text'>
Reflect changes that have happened to pf/pF (deprecation)
specifiers in pointer() comment section.

Link: http://lkml.kernel.org/r/20180414030005.25831-1-sergey.senozhatsky@gmail.com
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Joe Perches &lt;joe@perches.com&gt;
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Sergey Senozhatsky &lt;sergey.senozhatsky@gmail.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
<entry>
<title>proc: add seq_put_decimal_ull_width to speed up /proc/pid/smaps</title>
<updated>2018-04-11T17:28:33Z</updated>
<author>
<name>Andrei Vagin</name>
<email>avagin@openvz.org</email>
</author>
<published>2018-04-10T23:31:16Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=d1be35cb6f96975d792a1535d3fe9b75239065ee'/>
<id>urn:sha1:d1be35cb6f96975d792a1535d3fe9b75239065ee</id>
<content type='text'>
seq_put_decimal_ull_w(m, str, val, width) prints a decimal number with a
specified minimal field width.

It is equivalent of seq_printf(m, "%s%*d", str, width, val), but it
works much faster.

== test_smaps.py
  num = 0
  with open("/proc/1/smaps") as f:
          for x in xrange(10000):
                  data = f.read()
                  f.seek(0, 0)
==

== Before patch ==
  $ time python test_smaps.py
  real    0m4.593s
  user    0m0.398s
  sys     0m4.158s

== After patch ==
  $ time python test_smaps.py
  real    0m3.828s
  user    0m0.413s
  sys     0m3.408s

$ perf -g record python test_smaps.py
== Before patch ==
-   79.01%     3.36%  python   [kernel.kallsyms]    [k] show_smap.isra.33
   - 75.65% show_smap.isra.33
      + 48.85% seq_printf
      + 15.75% __walk_page_range
      + 9.70% show_map_vma.isra.23
        0.61% seq_puts

== After patch ==
-   75.51%     4.62%  python   [kernel.kallsyms]    [k] show_smap.isra.33
   - 70.88% show_smap.isra.33
      + 24.82% seq_put_decimal_ull_w
      + 19.78% __walk_page_range
      + 12.74% seq_printf
      + 11.08% show_map_vma.isra.23
      + 1.68% seq_puts

[akpm@linux-foundation.org: fix drivers/of/unittest.c build]
Link: http://lkml.kernel.org/r/20180212074931.7227-1-avagin@openvz.org
Signed-off-by: Andrei Vagin &lt;avagin@openvz.org&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>lib/vsprintf: Mark expected switch fall-through</title>
<updated>2018-04-11T09:19:13Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2018-02-16T21:07:11Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=7e6bd6f3dcf913460a0a0ae7f260a8280001dd80'/>
<id>urn:sha1:7e6bd6f3dcf913460a0a0ae7f260a8280001dd80</id>
<content type='text'>
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Link: http://lkml.kernel.org/r/20180216210711.79901-9-andriy.shevchenko@linux.intel.com
To: "Tobin C . Harding" &lt;me@tobin.cc&gt;
To: linux@rasmusvillemoes.dk
To: Joe Perches &lt;joe@perches.com&gt;
To: linux-kernel@vger.kernel.org
To: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
<entry>
<title>lib/vsprintf: Replace space with '_' before crng is ready</title>
<updated>2018-04-11T09:18:43Z</updated>
<author>
<name>Shunyong Yang</name>
<email>shunyong.yang@hxt-semitech.com</email>
</author>
<published>2018-02-16T21:07:09Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=91efafb1dd8f471177a3dddb4841d75d3df1cc46'/>
<id>urn:sha1:91efafb1dd8f471177a3dddb4841d75d3df1cc46</id>
<content type='text'>
Before crng is ready, output of "%p" composes of "(ptrval)" and
left padding spaces for alignment as no random address can be
generated. This seems a little strange when default string width
is larger than strlen("(ptrval)").

For example, when irq domain names are built with "%p", the nodes
under /sys/kernel/debug/irq/domains like this on AArch64 system,

[root@y irq]# ls domains/
default                   irqchip@        (ptrval)-2
irqchip@        (ptrval)-4  \_SB_.TCS0.QIC1  \_SB_.TCS0.QIC3
irqchip@        (ptrval)  irqchip@        (ptrval)-3
\_SB_.TCS0.QIC0             \_SB_.TCS0.QIC2

The name "irqchip@        (ptrval)-2" is not so readable in console
output.

This patch replaces space with readable "_" when output needs padding.
Following is the output after applying the patch,

[root@y domains]# ls
default                   irqchip@(____ptrval____)-2
irqchip@(____ptrval____)-4  \_SB_.TCS0.QIC1  \_SB_.TCS0.QIC3
irqchip@(____ptrval____)  irqchip@(____ptrval____)-3  \_SB_.TCS0.QIC0
\_SB_.TCS0.QIC2

There is same problem in some subsystem's dmesg output. Moreover,
someone may call "%p" in a similar case. In addition, the timing of
crng initialization done may vary on different system. So, the change
is made in vsprintf.c.

Suggested-by: Rasmus Villemoes &lt;linux@rasmusvillemoes.dk&gt;
Link: http://lkml.kernel.org/r/20180216210711.79901-7-andriy.shevchenko@linux.intel.com
To: "Tobin C . Harding" &lt;me@tobin.cc&gt;
To: linux@rasmusvillemoes.dk
To: Joe Perches &lt;joe@perches.com&gt;
To: linux-kernel@vger.kernel.org
To: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Joey Zheng &lt;yu.zheng@hxt-semitech.com&gt;
Signed-off-by: Shunyong Yang &lt;shunyong.yang@hxt-semitech.com&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
<entry>
<title>lib/vsprintf: Deduplicate pointer_string()</title>
<updated>2018-04-11T09:17:06Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2018-02-16T21:07:08Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=496a9a5f3806d58b14ae06b390d5b1ffa26e9f9a'/>
<id>urn:sha1:496a9a5f3806d58b14ae06b390d5b1ffa26e9f9a</id>
<content type='text'>
There is an exact code at the end of ptr_to_id().
Replace it by calling pointer_string() directly.

This is followup to the commit ad67b74d2469 ("printk: hash addresses
printed with %p").

Cc: Tobin C. Harding &lt;me@tobin.cc&gt;
Link: http://lkml.kernel.org/r/20180216210711.79901-6-andriy.shevchenko@linux.intel.com
To: "Tobin C . Harding" &lt;me@tobin.cc&gt;
To: linux@rasmusvillemoes.dk
To: Joe Perches &lt;joe@perches.com&gt;
To: linux-kernel@vger.kernel.org
To: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
<entry>
<title>lib/vsprintf: Move pointer_string() upper</title>
<updated>2018-04-11T08:32:42Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2018-02-16T21:07:07Z</published>
<link rel='alternate' type='text/html' href='https://git.kobert.dev/pm24.git/commit/?id=558594f3c2a5cd65f18b976faf68143c502b73b2'/>
<id>urn:sha1:558594f3c2a5cd65f18b976faf68143c502b73b2</id>
<content type='text'>
As preparatory patch to further clean up.

No functional change.

Link: http://lkml.kernel.org/r/20180216210711.79901-5-andriy.shevchenko@linux.intel.com
To: "Tobin C . Harding" &lt;me@tobin.cc&gt;
To: linux@rasmusvillemoes.dk
To: Joe Perches &lt;joe@perches.com&gt;
To: linux-kernel@vger.kernel.org
To: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
</content>
</entry>
</feed>
