Hi Arnd,

Thank you so much for such detailed information!

I now have some break through here, still on master branch though, but just for a demonstration.

0. $ make distclean

1. Add following items to arch/arm/configs/omap2plus_defconfig

CONFIG_RCU_TORTURE_TEST=m
CONFIG_RCU_TORTURE_TEST_RUNNABLE=n

2. Make the Kernel (Panda is using uImage), device tree and modules:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap2plus_defconfig
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x80008000 uImage
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap4-panda.dtb
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules

3. Install modules:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=~/linaro/ti/modules/ modules_install

4. Copy module files to rootfs on SD card:

$ sudo cp -R linaro/ti/modules/lib/modules/3.17.0-rc3-00002-g7505cea-dirty/ /rootfs/lib/modules/

5. Copy uImage and dtb file to boot partition on SD card, then boot the board.

The board can be booted up successfully, rcutorture can now be loaded by run:

root@linaro-developer:~# modprobe rcutorture

after above command, the test started automatically:

[  198.794616] rcu-torture:--- Start of test: nreaders=1 nfakewriters=4 stat_interval=60 verbose=1 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqr0
[  198.827484] rcu-torture: Creating rcu_torture_writer task
[  198.834808] rcu-torture: rcu_torture_writer task started
[  198.834808] rcu-torture: Creating rcu_torture_fakewriter task
[  198.835144] rcu-torture: Creating rcu_torture_fakewriter task
[  198.835266] rcu-torture: Creating rcu_torture_fakewriter task
root@linaro-developer:~# [  198.835357] rcu-torture: rcu_torture_fakewriter task started

I then waited for a while and ran:

root@linaro-developer:~# rmmod rcutorture

And the test can be done successfully:

[  823.522430] rcu-torture:--- End of test: SUCCESS: nreaders=1 nfakewriters=4 stat_interval=60 verbose=1 test_no_idle_hz=1 shuffle_interval=3 stutter0

Detailed log can be found in attachment.


On 3 December 2014 at 21:20, Arnd Bergmann <arnd@arndb.de> wrote:
On Wednesday 03 December 2014 19:51:58 Botao Sun wrote:
> Hi Gangs,
>
> Recently I'm working on the rcutorture stuff but have been confused on it
> for a while, so I decided to shoot an email here to seek some professional
> advice.
>
> The story is, a little bit long though, I want to enable the rcutorture
> test and want it be triggered manually, or by my test script at the time I
> want. So far, here is what I have done:
>
> 1. Clone arm-soc git tree and compile it on master branch, with
> omap2plus_defconfig as the "base" config, but added following switcher:
>
> CONFIG_RCU_TORTURE_TEST=y
> CONFIG_TORTURE_TEST=y
> CONFIG_RCU_TORTURE_TEST_RUNNABLE=n
>
> The procedure I walked through is:

Just a few side nodes about the procedure for you (and anyone else
reading this) to consider, as you are being somewhat inefficient here,
although you are not doing anything wrong:

> $ git clone
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/arm/arm-soc.git

My recommendation is to never clone kernel trees multiple times,
to save time and network bandwidth. Just use a single kernel tree
as a work area, and use multiple remotes (see "man git remote").

The above could have been

$ cd linux
$ git remote add arm-soc https://kernel.googlesource.com/pub/scm/linux/kernel/git/arm/arm-soc.git
$ git fetch arm-soc
$ git checkout -b arm-soc arm-soc/for-next

The last step actually checks out the branch you want. The master
branch of this particular tree is not meaningful at all, we don't
use it.

> $ cp arch/arm/configs/omap2plus_defconfig ./
> Add above 3 switchers
> $ mv omap2plus_defconfig .config

I normally use a separate build directory for housekeeping purposes,
so just add "O=obj-arm-soc" to ever "make" invocation and create
an "obj-arm-soc" directory in which you will find the output.

You can use 'alias armsocmake="make ARCH=arm
CROSS_COMPILE=arm-linux-gnueabihf- O=obj-arm-soc"' to create an
armsocmake shortcut for this, and you can have one such command
per output directory, e.g. for testing both omap2plus_defconfig
and multi_v7_defconfig simultaneously.

Instead of copying the defconfig file, just run 'armsocmake
omap2plus_defconfig'.

> $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
> Once the graphic window shows, select exit then answer "Yes" to save.

I sometimes find it hard to find the right options in menuconfig,
and then I edit the obj-arm-soc/.config file with my favorite text
editor to remove the current defaults, and run 'armsocmake oldconfig'
to pick the new options.

> $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage
> $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x80008000
> uImage

I would recommend against using uImage, in particular because of the
awkward LOADADDR handling. If your u-boot is new enough, you can boot
the zImage file directly.

> $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- omap4-panda.dtb

> All above can be done successfully. I noticed that after menuconfig, not
> only above 3 switchers, but many others related to them have been added to
> .config file, which I guess it's because the dependency.

The defconfig file is really only meant as the input to 'make
omap2plus_defconfig', and it only contains the options that are
not defaults. Running 'armsocmake savedefconfig'

> 2. Flash SD card with Linaro ubuntu build 697:
>
> http://snapshots.linaro.org/ubuntu/pre-built/panda/697
>
> 3. Replace uImage and omap4-panda.dtb to the ones I compiled locally.
>
> 4. Boot Panda 4430.
>
> The board can be booted up successfully, although no Ethernet support.
> rcutorture has shown up in boot log, but the thing confused me is the test
> has been triggered automatically in a period of every 60 seconds. According
> to this description page, looks like the switcher
> CONFIG_RCU_TORTURE_TEST_RUNNABLE=n doesn't take the effect:
>
> https://www.kernel.org/doc/Documentation/RCU/torture.txt
>
> root@linaro-developer:~# [  180.881347] rcu-torture: rtc: c1091f98 ver: 1
> tfle: 0 rta: 1 rtaf: 0 rtf: 0 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt:
> 0
> [  180.881347] rcu-torture: Reader Pipe:  2 0 0 0 0 0 0 0 0 0 0
> [  180.881347] rcu-torture: Reader Batch:  2 0 0 0 0 0 0 0 0 0 0
> [  180.881347] rcu-torture: Free-Block Circulation:  0 0 0 0 0 0 0 0 0 0 0
> [  180.881347] ??? Writer stall state 8 g504 c504 f0x0
> [  240.881652] rcu-torture: rtc: c1091f98 ver: 1 tfle: 0 rta: 1 rtaf: 0
> rtf: 0 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 1 onoff: 0/0:0/0
> -1,0:-1,0

Ok, so I suppose this means that you have found a serious bug, and
now it's time to fix that. Anything else is of lower priority at this
point.

What I think the message indicates is that you have hit a stall in
the rcutorture writer process for the RTWS_STUTTER test.

> [  240.881652] rcu-torture: Reader Pipe:  2 0 0 0 0 0 0 0 0 0 0
> [  240.881652] rcu-torture: Reader Batch:  2 0 0 0 0 0 0 0 0 0 0
> [  240.881652] rcu-torture: Free-Block Circulation:  0 0 0 0 0 0 0 0 0 0 0
> [  240.881652] ??? Writer stall state 8 g510 c510 f0x0
> [  301.031066] rcu-torture: rtc: c1091f98 ver: 1 tfle: 0 rta: 1 rtaf: 0
> rtf: 0 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 1 onoff: 0/0:0/0
> -1,0:-1,0
> [  301.031066] rcu-torture: Reader Pipe:  2 0 0 0 0 0 0 0 0 0 0
> [  301.031066] rcu-torture: Reader Batch:  2 0 0 0 0 0 0 0 0 0 0
> [  301.031066] rcu-torture: Free-Block Circulation:  0 0 0 0 0 0 0 0 0 0 0
> [  301.031066] ??? Writer stall state 8 g512 c512 f0x0
> [  361.110931] rcu-torture: rtc: c1091f98 ver: 1 tfle: 0 rta: 1 rtaf: 0
> rtf: 0 rtmbe: 0 rtbke: 0
>
> However that description page itself also confused me as it says:
>
> "It is also possible to specify CONFIG_RCU_TORTURE_TEST=y, which will
> result in the tests being loaded into the base kernel."
>
> But if above is true, then following commands would fail:
>
> # modprobe rcutorture
>
> and this is the case happened:
>
> root@linaro-developer:~# modprobe rcutorture
> modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not
> open moddep file '/lib/modules/3.17.0-rc3-00002-g7505cea/modules.dep.bin'
> root@linaro-developer:~#
>
> And "rmmod" also failed there:
>
> root@linaro-developer:~# rmmod rcutorture
> rmmod: ERROR: Module rcutorture is builtin.
> root@linaro-developer:~#

Your module installation seems wrong, did you run 'make modules_install'
on the target drive?

> So here are my questions:
>
> 1. In order to enable rcutorture in Kernel but disable its automatic run,
> what should I do? I looked at the file that description page mentioned, the
> output is:
>
> root@linaro-developer:~# cat /proc/sys/kernel/rcutorture_runnable
> 0
> root@linaro-developer:~#
>
> I tried to give it "1" but that won't affect the automatic trigger in
> rcutorture. Looks like the file is useless here.

I think part of your problem is that you have the rcutorture test
built-in. The design of this test is based around the idea that it
gets run when you load the module, however when you build it into the
kernel, it will get run automatically at boot time.

> 2. At the end of that description page, it looks like to use the Kernel
> module to control the test start & end. However if I put "y" to switcher
> "CONFIG_RCU_TORTURE_TEST", the test will be automatically built into
> Kernel. So what should I do to let it build to a module which in a way I
> can control it?

Set it to 'm'.

        Arnd