Skip to content

Instantly share code, notes, and snippets.

View stffrdhrn's full-sized avatar
🌴
Working on it

Stafford Horne stffrdhrn

🌴
Working on it
View GitHub Profile
@stffrdhrn
stffrdhrn / memcpy_testing.txt
Created March 20, 2016 09:04
memcpy optimisations for openrisc (linux)
# The test is running memcpy to copy an `int src[4096]` to another `int dest[4096]`
# compile test
or1k-elf-gcc -O2 -g -o memcpy_test.elf -mboard=de0_nano memcpy_test.c
# Run sime with trace the grep for loads and stores and sort by counts of each
sim -t -f arch/openrisc/or1ksim.cfg memcpy_test.elf | grep -e '\(l.l\|l.s\)' | cut -d' ' -f 4 | sort | uniq -c | sort -n | tail
# Hello world is a baseline for how many operations happen without any memcpy test
Hello World (baseline)
The Idea is to fix these up:
Summary:
Most of these are the same
~7 warning: format '%zu' expects argument of type 'size_t',
~3 comparison of distinct pointer types lacks a cast (void) (&_min1 == &_min2);
CC mm/percpu.o
In file included from mm/percpu.c:823:0:
mm/percpu-km.c: In function 'pcpu_verify_alloc_info':
c0000000 T _s_kernel_ro
c0000000 T _stext
c0000200 t _dispatch_bus_fault
c0000300 t _dispatch_do_dpage_fault
c0000400 t _dispatch_do_ipage_fault
c0002000 T dtlb_miss_handler
c0002048 t d_pmd_good
c00020bc t d_pmd_none
c00020bc t d_pte_not_present
c0002160 T itlb_miss_handler
==Special Registers==
R9 - link return
R3 - arg[0]
R2 - FP
R1 - SP
GPR01: c02efe54
GPR02: c02fb27c
==Frame Usage==
[239707.650000] Unable to handle kernel access at virtual address 0xbffe2ce0
[239707.650000]
[239707.650000] Oops#: 0000
[239707.650000] CPU #: 0
[239707.650000] PC: bffe2ce0 SR: 00008079 SP: c02efe54
[239707.650000] GPR00: 00000000 GPR01: c02efe54 GPR02: c02fb27c GPR03: 00000000
[239707.650000] GPR04: c02efe5c GPR05: 00000000 GPR06: a0000000 GPR07: c0000000
[239707.650000] GPR08: 00726000 GPR09: c006419c GPR10: c02ee000 GPR11: c02efe5c
[239707.650000] GPR12: c0000000 GPR13: 0000a000 GPR14: 00000000 GPR15: 00000000
[239707.650000] GPR16: 00000000 GPR17: 016d4e81 GPR18: c0303096 GPR19: 00000000
This stack trace has been annotated with perl script found at:
https://github.com/stffrdhrn/linux/blob/openrisc/scripts/annotate-stracktrace.pl
From the stack trace below (and using objdump to look at dissasembly of vmlinux)
we can see that the crash happened in:
Function:
update_ts_time_stats(int cpu, struct tick_sched *ts, ktime_t now, u64 *last_update_time)
With args:
0x00000000000000 - (1) mem start (3) [+kernel start]
0xc0062ce0 <update_ts_time_stats.constprop.26>
c0308000 - free kernel memory
c05a8000 - free kernel memory
0x000000005b64ff - (3) kernel end
0x00000001fc6000-0x00000001fc7fff] flags 0x0 0xc0311cc8 - inode cache
0x00000001fc8000-0x00000001fcbfff] flags 0x0 0xc0311cc8 - dentry cache
0x00000001fcc000-0x00000001fcdfff] flags 0x0 0xc0311a98 - UART
0x00000001fce000-0x00000001fd5fff] flags 0x0 0xc0311cc8 - zone allo
[57682.730000] BUG: Bad page state in process ls pfn:00552
[57682.740000] page:c1fe2a40 count:0 mapcount:-131072 mapping: (null) index:0x0
[57682.750000] flags: 0x0(oot 0 )
[57682.750000] page dumped because: nonzero mapcount
[57682.760000] CPU: 0 PID: 70 Comm: ls Not tainted 4.5.0-de0_nano-01285-gfbb1dea #163
[57682.770000] Stack dump [0xc102bd64]:
[57682.770000] sp + 00: 0xc102bd64 0xc102bd64 ~~~~iCRASH TOP!~~~~
[57682.770000] sp + 04: 0xc1fe2a40 0xc102bd68
[57682.780000] sp + 08: 0xc05b08dc 0xc102bd6c nr_shown.27363
[57682.780000] sp + 12: 0xc05b08d8 0xc102bd70 resume.27362
INFO: Preparing wb_bfm-1.0
INFO: Preparing vlog_tb_utils-1.0
INFO: Preparing fifo-1.0
INFO: Preparing verilog-arbiter-r1
INFO: Preparing stream_utils-1.1
INFO: Preparing wb_common
INFO: Preparing wb_streamer
Completed transaction 100/1000
Completed transaction 200/1000
@stffrdhrn
stffrdhrn / Commands
Last active April 26, 2016 14:50
Running openrisc gdb test suite
# In one terminal start simulator, listening on debug port
or1k-elf-sim --srv=51000
~~~~~~~~~
# In another terminal run tests
# setup directory with boards (site.exp is empty)
# there is also a boards directory with remote-gdbserver.exp
export DEJAGNU=$HOME/openrisc/gdb-testsuite/site.exp