[PATCH v3] ARC: prevent showing irrelevant exception info in signal message

2018-10-19 Thread Eugeniy Paltsev
We process signals in the end of syscall/exception handler.
It the signal is fatal we print register's content using
show_regs function. show_regs() also prints information about
last exception happened.

In case of multicore system we can catch the situation when we
will print wrong information about exception. See the example:
__
CPU-0: started to handle page fault
CPU-1: sent signal to process, which is executed on CPU-0
CPU-0: ended page fault handle. Started to process signal before
   returnig to userspace. Process signal, which is send from
   CPU-0. As th signal is fatal we call show_regs().
   show_regs() will show information about last exception
   which is *page fault* (instead of "trap" which is used for
   signals and happened on CPU-0)

So we will get message like this:
   # ./waitpid02
  potentially unexpected fatal signal 8.
  Path: /home/waitpid02
  CPU: 0 PID: 100 Comm: waitpid02 Not tainted 4.10.0-rc4 #2
  task: 9f11c200 task.stack: 9f3ae000

  [ECR   ]: 0x00050200 => Invalid Write @ 0x by insn @ 0x000123ec
  [EFA   ]: 0x
  [BLINK ]: 0x123ea
  [ERET  ]: 0x123ec
@off 0x123ec in [/home/waitpid02]
VMA: 0x0001 to 0x00016000
  [STAT32]: 0x80080882 : IE U
  BTA: 0x000123ea  SP: 0x5ffd3db0  FP: 0x
  LPS: 0x20031684 LPE: 0x2003169a LPC: 0x0006
  [-other-info-]

This message is confusing because it show information about page fault
( [ECR   ]: 0x00050200 => Invalid Write ) which is absolutely irrelevant
to signal.

This situation was reproduced with waitpid02 LTP test.
_

So remove printing information about exceptions from show_regs()
to avoid confusing messages. Print information about exceptions
only in required places instead of show_regs()

Now we don't print information about exceptions if signal is simply
send by another userspace app. So in case of waitpid02 we will print
next message:
_
   # ./waitpid02
  potentially unexpected fatal signal 8.
  Path: /root/waitpid02
  CPU: 2 PID: 105 Comm: waitpid02 Not tainted 
4.18.0-rc8-2-gde0f6d6aeb53-dirty #17
  [ECR   ]: 0x00050100
  [EFA   ]: 0x
  [BLINK ]: 0x20001486
  [-other-info-]
_

This patch fix
STAR 9001146055: waitpid02: Invalid Write @ 0x by insn @ 0x000123ec

NOTE:
To be more clear I give examples of different faults (signal-based,
userspace/kernelspace exception-based) with different values of
"/proc/sys/kernel/print-fatal-signals" option.

0) NULL pointer access from user space, print-fatal-signals == 1:
>8---
 # ./arc_hell
Exception: arc_hell[103]: at 0x2003a35c [off 0x2e35c in 
/lib/libuClibc-1.0.18.so, VMA: 2000c000:20072000]
  ECR: 0x00050100 => Invalid Read @ 0x by insn @ 0x2003a35c
potentially unexpected fatal signal 11.
Path: /root/arc_hell
CPU: 1 PID: 103 Comm: arc_hell Not tainted 4.18.0-rc8-2-gde0f6d6aeb53-dirty 
#17
[ECR   ]: 0x00050100
[EFA   ]: 0x
[BLINK ]: 0x20039ef8
[ERET  ]: 0x2003a35c
[STAT32]: 0x80080882 : IE U
BTA: 0x2003a358  SP: 0x5fa27dc4  FP: 0x5fa27de8
LPS: 0x2003a628 LPE: 0x2003a62c LPC: 0x
r00: 0x r01: 0x200740b0 r02: 0x0001
r03: 0x0007 r04: 0x80808080 r05: 0x2f2f2f2f
r06: 0x7c7a2f43 r07: 0x r08: 0x1a131100
r09: 0x2008b1e0 r10: 0x20003a5c r11: 0x20004038
r12: 0x20039ef8 r13: 0x200740b0 r14: 0x
r15: 0x200740b0 r16: 0x r17: 0x0007d468
r18: 0x0009313a r19: 0x r20: 0x0009c22c
r21: 0x0009c23c r22: 0x0009ab64 r23: 0x
r24: 0x0009dfc5 r25: 0x20004b70

Segmentation fault
>8---

1) NULL pointer access from user space, print-fatal-signals == 0:
>8---
 # ./arc_hell
Exception: arc_hell[107]: at 0x2003a35c [off 0x2e35c in 
/lib/libuClibc-1.0.18.so, VMA: 2000c000:20072000]
  ECR: 0x00050100 => Invalid Read @ 0x by insn @ 0x2003a35c
Segmentation fault
>8---

2) Process killed by signal (waitpid02 test), print-fatal-signals == 1:
>8---
 # ./waitpid02
potentially unexpected fatal signal 8.
Path: /root/waitpid02
CPU: 2 PID: 105 Comm: waitpid02 Not tainted 
4.18.0-rc8-2-gde0f6d6aeb53-dirty #17
[ECR   ]: 0x00050100
[EFA   ]: 0x
[BLINK ]: 0x20001486
[ERET  ]: 0x2000146c
[STAT32]: 0x80080082 : IE U
BTA: 0x2fc4  SP: 0x5fa21d64  FP: 0x
LPS: 0x200524a0 LPE: 0x200524b6 LPC: 0x0006
r00: 0x2000c0dc r01: 0x0018 r02: 0x0001159a
r03: 0x0001 r04: 0x r05: 0x0045
r06: 0x004e r07: 0x01010101 r08: 0x00dc
r09: 0x200a31e0 r10: 0x20003a5c r11: 0x20004038
r12: 0x20001486 r13: 0x20004174 r14: 0x07ca2bc0
r15: 0x20004078 r16: 0x r17: 0x20004038
r18: 0x0001 r19: 0x r20: 0x0001159a
r21: 0x0001 r22: 0x r23: 0x0004
r24: 0x2000d1fc r25: 0x20004cd0
>8---

3) Process killed by signal (waitpid02 test), print-fatal-signals == 0:

[RFC] ARC: ARCv2: Introduce SmaRT support

2018-10-19 Thread Eugeniy Paltsev
Add compile-time 'ARC_USE_SMART' option for enabling SmaRT support.

Small real time trace (SmaRT) is an optional on-chip debug hardware
component that captures instruction-trace history. It stores the
address of the most recent non-sequential instructions executed into
internal buffer.

Usually we use MetaWare debugger to enable SmaRT and display trace
information.

This patch allows to display the decoded content of SmaRT buffer
without MetaWare debugger. It is done by extending ordinary exception
message with decoded SmaRT instruction-trace history.

In some cases it's really usefull as it allows to show pre-exception
instruction-trace which was not tainted by exception handler code,
printk code, etc...

Nevertheless this option has negative performance impact due to
implementation as we dump SmaRT buffer content into external memory
buffer in the begining of every slowpath exception handler code.
We choose this implementation as a compromise between performance
impact and SmaRT buffer tainting.
Although the performance impact is not really significant (according
to lmbench) we leave this option disabled by default.

Here is th examples of user-space and kernel-space fault messages with
'ARC_USE_SMART' option enabled:

User-space exception:
--->8-
Exception: u_hell[99]: at 0x103a2 [off 0x103a2 in /root/u_hell, VMA: 
0001:00012000]
  ECR: 0x00050200 => Invalid Write @ 0x by insn @ 0x000103a2
SmaRT (64 entries):
 [   0]V 0x90232358 -> 0x9022ce3c [src do_page_fault+0x2c/0x2d8] [dst 
populate_smart+0x0/0x9c]
 [   1]V 0x9022e3f8 -> 0x9023232c [src EV_TLBProtV+0xec/0xf0] [dst 
do_page_fault+0x0/0x2d8]
 [   2]V 0x90233194 -> 0x9022e30c [src do_slow_path_pf+0x10/0x14] [dst 
EV_TLBProtV+0x0/0xf0]
 [   3]V 0x90233120 -> 0x90233184 [src EV_TLBMissD+0x80/0xe0] [dst 
do_slow_path_pf+0x0/0x14]
 [   4]  E V 0x000103a2 -> 0x902330a0 [off 0x103a2 in /root/u_hell, VMA: 
0001:00012000] [dst EV_TLBMissD+0x0/0xe0]
 [   5] U  V 0x2004f238 -> 0x00010398 [off 0x43238 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x10398 in /root/u_hell, VMA: 0001:00012000]
 [   6] U  V 0x20049a82 -> 0x2004f214 [off 0x3da82 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x43214 in /lib/libuClibc-1.0.18.so, VMA: 
2000c000:20072000]
 [   7] U  V 0x20049a64 -> 0x20049a76 [off 0x3da64 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x3da76 in /lib/libuClibc-1.0.18.so, VMA: 
2000c000:20072000]
 [   8] U  V 0x2001d8e4 -> 0x20049a58 [off 0x118e4 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x3da58 in /lib/libuClibc-1.0.18.so, VMA: 
2000c000:20072000]
 [   9] U  V 0x2001d8f4 -> 0x2001d8a8 [off 0x118f4 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x118a8 in /lib/libuClibc-1.0.18.so, VMA: 
2000c000:20072000]
 [  10] U  V 0x2001d5c8 -> 0x2001d8f0 [off 0x115c8 in /lib/libuClibc-1.0.18.so, 
VMA: 2000c000:20072000] [off 0x118f0 in /lib/libuClibc-1.0.18.so, VMA: 
2000c000:20072000]
...[snip]...
--->8-

Kernel-space exception:
--->8-
Exception: at dw_mci_probe+0xf0/0x944:
  ECR: 0x00050100 => Invalid Read @ 0x by insn @ 0x905e26e0
SmaRT (64 entries):
 [   0]V 0x90232358 -> 0x9022ce3c [src do_page_fault+0x2c/0x2d8] [dst 
populate_smart+0x0/0x9c]
 [   1]V 0x9022e3f8 -> 0x9023232c [src EV_TLBProtV+0xec/0xf0] [dst 
do_page_fault+0x0/0x2d8]
 [   2]V 0x9022e398 -> 0x9022e3a0 [src EV_TLBProtV+0x8c/0xf0] [dst 
EV_TLBProtV+0x94/0xf0]
 [   3]V 0x90233194 -> 0x9022e30c [src do_slow_path_pf+0x10/0x14] [dst 
EV_TLBProtV+0x0/0xf0]
 [   4]V 0x902330dc -> 0x90233184 [src EV_TLBMissD+0x3c/0xe0] [dst 
do_slow_path_pf+0x0/0x14]
 [   5]  E V 0x905e26e0 -> 0x902330a0 [src dw_mci_probe+0xf0/0x944] [dst 
EV_TLBMissD+0x0/0xe0]
 [   6]V 0x904cb940 -> 0x905e26d6 [src clk_get_rate+0xdc/0x208] [dst 
dw_mci_probe+0xe6/0x944]
 [   7]V 0x9074e14a -> 0x904cb932 [src mutex_unlock+0x1e/0x24] [dst 
clk_get_rate+0xce/0x208]
 [   8]V 0x904cb92e -> 0x9074e12c [src clk_get_rate+0xca/0x208] [dst 
mutex_unlock+0x0/0x24]
 [   9]V 0x904cb8ea -> 0x904cb91e [src clk_get_rate+0x86/0x208] [dst 
clk_get_rate+0xba/0x208]
 [  10]V 0x904cb8c2 -> 0x904cb8d0 [src clk_get_rate+0x5e/0x208] [dst 
clk_get_rate+0x6c/0x208]
 [  11]V 0x9074e01a -> 0x904cb884 [src mutex_trylock+0x4e/0x50] [dst 
clk_get_rate+0x20/0x208]
 [  12]V 0x9074e00e -> 0x9074e018 [src mutex_trylock+0x42/0x50] [dst 
mutex_trylock+0x4c/0x50]
 [  13]V 0x9074dfdc -> 0x9074dff0 [src mutex_trylock+0x10/0x50] [dst 
mutex_trylock+0x24/0x50]
 [  14]V 0x904cb880 -> 0x9074dfcc [src clk_get_rate+0x1c/0x208] [dst 
mutex_trylock+0x0/0x50]
 [  15]V 0x905e26d2 -> 0x904cb864 [src dw_mci_probe+0xe2/0x944] [dst 
clk_get_rate+0x0/0x208]
...[snip]...
--->8-

TODO:
  Add runtime procfs options to configure/suspend SmaRT.
  Add SmaR

kisskb: OK linus/axs103_smp_defconfig/arcv2 Sat Oct 20, 03:02

2018-10-19 Thread noreply
OK linus/axs103_smp_defconfig/arcv2 Sat Oct 20, 03:02

http://kisskb.ellerman.id.au/kisskb/buildresult/13556494/

Commit:   Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
  2a96661054452c3016c377d72a38c6d4948ea6ae
Compiler: arc-linux-gcc.br_real (Buildroot 2016.11-git-00613-ge98b4dd) 6.2.1 
20160824

Possible errors
---

 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */

Possible warnings (79)
--

kernel/dma/direct.c:46:5: warning: format '%zu' expects argument of type 
'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
fs/ext4/inode.c:3622:12: warning: format '%zd' expects argument of type 'signed 
size_t', but argument 6 has type 'ssize_t {aka int}' [-Wformat=]
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
fs/ext4/page-io.c:163:5: warning: format '%zd' expects argument of type 'signed 
size_t', but argument 6 has type 'ssize_t {aka int}' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1382:17: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 3 has type 'unsigned int' [-Wformat=]
 #define KERN_WARNING KERN_SOH "4" /* warning conditions */
mm/percpu.c:1948:27: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:32: warning: format '%zu' expects argument of type 'size_t', 
but argument 4 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:37: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:42: warning: format '%zu' expects argument of type 'size_t', 
but argument 6 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:52: warning: format '%zu' expects argument of type 'size_t', 
but argument 7 has type 'unsigned int' [-Wformat=]
mm/percpu.c:1948:56: warning: format '%zu' expects argument of type 'size_t', 
but argument 8 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 6 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 7 has type 'unsigned int' [-Wformat=]
drivers/base/regmap/regmap.c:1507:22: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
drivers/base/component.c:174:24: warning: format '%zu' expects argument of type 
'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
fs/ext4/xattr.c:482:8: warning: format '%zu' expects argument of type 'size_t', 
but argument 6 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zd' expects argument of 
type 'signed size_t', but argument 3 has type 'size_t {aka unsigned int}' 
[-Wformat=]
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:845:29: warning: comparison of distin

kisskb: OK linus/axs101_defconfig/arcompact Sat Oct 20, 03:03

2018-10-19 Thread noreply
OK linus/axs101_defconfig/arcompact Sat Oct 20, 03:03

http://kisskb.ellerman.id.au/kisskb/buildresult/13556495/

Commit:   Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
  2a96661054452c3016c377d72a38c6d4948ea6ae
Compiler: arc-buildroot-linux-uclibc-gcc (Buildroot 2015.08.1) 4.8.4

No errors found in log

Possible warnings (3)
--

include/linux/kernel.h:845:29: warning: comparison of distinct pointer types 
lacks a cast [enabled by default]
arch/arc/include/asm/cmpxchg.h:95:29: warning: value computed is not used 
[-Wunused-value]
net/ipv4/tcp_input.c:4319:49: warning: array subscript is above array bounds 
[-Warray-bounds]


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[RFC] ARC: ARCv2: Introduce SmaRT support : lmbench results

2018-10-19 Thread Eugeniy Paltsev
Lmbench summary with enabled and disabled SmaRT support is attached.

-- 
 Eugeniy Paltsev
 L M B E N C H  3 . 0   S U M M A R Y
 
		 (Alpha software, do not distribute)

Basic system parameters
--
Host OS Description Mhz  tlb  cache  mem   scal
 pages line   par   load
   bytes
- - ---  - - -- 
ena   Linux 4.19.0- ena 1000 8   128 1.75001
ena   Linux 4.19.0- ena 1000 8   1.75001
ena   Linux 4.19.0- ena 1000 8   1.73001
ena   Linux 4.19.0- ena 1000 8   128 1.75001
dis   Linux 4.19.0- dis 1000 8   1.74001
dis   Linux 4.19.0- dis 1000 8   1.75001
dis   Linux 4.19.0- dis 1000 8   128 1.75001
dis   Linux 4.19.0- dis 1000 8   1.74001

Processor, Processes - times in microseconds - smaller is better
--
Host OS  Mhz null null  open slct sig  sig  fork exec sh  
 call  I/O stat clos TCP  inst hndl proc proc proc
- -           
ena   Linux 4.19.0- 1000 0.38 0.59 2.46 4.87 23.4 0.55 2.20 388. 1975 3673
ena   Linux 4.19.0- 1000 0.38 0.59 2.45 4.90 23.4 0.55 2.20 366. 1979 3671
ena   Linux 4.19.0- 1000 0.38 0.59 2.44 4.89 23.4 0.55 2.19 381. 1961 3696
ena   Linux 4.19.0- 1000 0.38 0.59 2.43 5.22 23.4 0.55 2.18 388. 1972 3702
dis   Linux 4.19.0- 1000 0.39 0.61 2.53 4.71 23.6 0.55 2.20 311. 1793 3370
dis   Linux 4.19.0- 1000 0.39 0.59 2.55 4.74 23.6 0.55 2.20 311. 1807 3363
dis   Linux 4.19.0- 1000 0.39 0.59 2.55 4.77 23.5 0.58 2.20 314. 1787 3373
dis   Linux 4.19.0- 1000 0.39 0.59 2.54 4.78 23.5 0.61 2.20 314. 1786 3395

Basic integer operations - times in nanoseconds - smaller is better
---
Host OS  intgr intgr  intgr  intgr  intgr  
  bit   addmuldivmod   
- - -- -- -- -- -- 
ena   Linux 4.19.0- 1. 0.5500  13.0 8.
ena   Linux 4.19.0- 1. 0.5500  13.0 8.0100
ena   Linux 4.19.0- 1. 0.5500  13.0 8.0100
ena   Linux 4.19.0- 1. 0.5500  13.0 8.
dis   Linux 4.19.0- 1. 0.5500  13.0 8.
dis   Linux 4.19.0- 1. 0.5500  13.0 8.
dis   Linux 4.19.0- 1. 0.5500  13.0 8.
dis   Linux 4.19.0- 1. 0.5500  13.0 8.

Basic uint64 operations - times in nanoseconds - smaller is better
--
Host OS int64  int64  int64  int64  int64  
 bitaddmuldivmod   
- - -- -- -- -- -- 
ena   Linux 4.19.0-11.  10.3  116.2   97.0
ena   Linux 4.19.0-12.  10.3  116.2   96.4
ena   Linux 4.19.0-11.  10.3  116.2   96.5
ena   Linux 4.19.0-11.  10.3  116.2   96.4
dis   Linux 4.19.0-12.  10.3  116.2   96.4
dis   Linux 4.19.0-11.  10.3  116.2   96.4
dis   Linux 4.19.0-11.  10.3  116.2   96.5
dis   Linux 4.19.0-11.  10.3  116.2   96.4

Basic float operations - times in nanoseconds - smaller is better
-
Host OS  float  float  float  float
 addmuldivbogo
- - -- -- -- -- 
ena   Linux 4.19.0-  145.2  144.7  288.2  730.9
ena   Linux 4.19.0-  145.9  144.6  288.0  729.0
ena   Linux 4.19.0-  145.9  144.7  288.2  730.2
ena   Linux 4.19.0-  145.9  144.7  288.2  729.6
dis   Linux 4.19.0-  146.0  144.6  288.3  730.2
dis   Linux 4.19.0-  145.2  144.7  288.2  729.0
dis   Linux 4.19.0-  145.4  144.7  288.2  729.9
dis   Linux 4.19.0-  146.0  144.7  288.2  765.1

Basic double operations - times in nanoseconds - smaller is better
--
Host