Re: [PATCH v2] locktorture: Fix NULL pointer when torture_type is invalid

From: Kefeng Wang
Date: Sun Jan 31 2016 - 22:34:43 EST




On 2016/2/1 11:02, Davidlohr Bueso wrote:
> On Mon, 01 Feb 2016, Kefeng Wang wrote:
>
>> Hi Davidlohr,
>>
[...]
>>
>> Yes, it works, but what you are doing is to revert commit a36a99618b1adb2d6ca0b7e08e3a656a04e477fe
>
> Oh, I see. I was definitely not aware of that one.
>
> [...]
>
>> And what Paul wanted is something that would print the full statistics
>> at the end regardless of the periodic statistics.
>>
>> I prefer my version 2, here is some log with my patch v2, it is keep consistent
>> with rcutorture.
>> -------------------------------------------------------
>> -bash-4.3# insmod locktorture.ko torture_type=mutex
>> [ 190.845067] lock-torture: invalid torture type: "mutex"
>> [ 190.845748] lock-torture types:
>> [ 190.846099] lock_busted spin_lock
>> [ 190.863211] spin_lock_irq rw_lock
>> [ 190.863668] rw_lock_irq mutex_lock
>> [ 190.864049] rtmutex_lock rwsem_lock
>> [ 190.864390] percpu_rwsem_lock[ 190.864686]
>> [ 190.865662] Writes: Total: 0 Max/Min: 0/0 Fail: 0
>> [ 190.866218] Reads : Total: 0 Max/Min: 0/0 Fail: 0
>> [ 190.875071] mutex-torture:--- End of test: SUCCESS: nwriters_stress=0 nreaders_stress=0 stat_interval=60 verbose=1 shuffle_interval=3 stutter=5 shutdown_secs=0 onoff_interval=0 onoff_holdoff=0
>
> How can the above be a successful run (SUCCESS string) if we didn't pass a
> valid torture_type? iow, there is no test without it. Just think of passing
> the wrong param in a userland application, 99.999% of the tools simply error
> out complaining about the bogus input.
>
> I think the right approach would be to decouple the statistics from the cleanup,
> that way we can still do the required cleanups and avoid any stats.

Just like I mentioned before, keep consistent with rcutortureïI am happy to any
way to solve this issue,

To Paulï what's your advice?

Thanks,
Kefeng

Attached rcutorture log,
----------------------------------------------------------
-bash-4.3# insmod rcutorture.ko torture_type=xxx
[ 3195.103753] rcu-torture: invalid torture type: "xxx"
[ 3195.104328] rcu-torture types:
[ 3195.104610] rcu rcu_bh
[ 3195.104889] rcu_busted srcu
[ 3195.105188] srcud sched
[ 3195.105464] tasks[ 3195.105680]
[ 3196.121026] xxx-torture: rtc: (null) ver: 0 tfle: 1 rta: 0 rtaf: 0 rtf: 0 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 0 onoff: 0/0:0/0 -1,0:-1,0 0:0 (HZ=250) barrier: 0/0:0 cbflood: 0
[ 3196.125066] xxx-torture: Reader Pipe: 0 0 0 0 0 0 0 0 0 0 0
[ 3196.126176] xxx-torture: Reader Batch: 0 0 0 0 0 0 0 0 0 0 0
[ 3196.128884] xxx-torture: Free-Block Circulation: 0 0 0 0 0 0 0 0 0 0 0
[ 3196.129945] xxx-torture:--- End of test: SUCCESS: nreaders=0 nfakewriters=4 stat_interval=60 verbose=1 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4 shutdown_secs=0 stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 onoff_interval=0 onoff_holdoff=0
insmod: ERROR: could not insert module rcutorture.ko: Invalid parameters


-bash-4.3# insmod rcutorture.ko torture_type=rcu
[ 3205.456128] rcu-torture:--- Start of test: nreaders=1 nfakewriters=4 stat_interval=60 verbose=1 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4 shutdown_secs=0 stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 onoff_interval=0 onoff_holdoff=0
[ 3205.474983] rcu-torture: Creating rcu_torture_writer task
[ 3205.478951] rcu-torture: Creating rcu_torture_fakewriter task
[ 3205.479966] rcu-torture: rcu_torture_writer task started
[ 3205.480410] rcu-torture: Grace periods expedited from boot/sysfs for rcu,
[ 3205.480942] rcu-torture: Testing of dynamic grace-period expediting diabled.
[ 3205.482951] rcu-torture: Creating rcu_torture_fakewriter task
[ 3205.483854] rcu-torture: rcu_torture_fakewriter task started
[ 3205.491931] rcu-torture: Creating rcu_torture_fakewriter task
[ 3205.492858] rcu-torture: rcu_torture_fakewriter task started
[ 3205.493613] rcu-torture: Creating rcu_torture_fakewriter task
[ 3205.495176] rcu-torture: rcu_torture_fakewriter task started
[ 3205.499013] rcu-torture: Creating rcu_torture_reader task
[ 3205.499919] rcu-torture: rcu_torture_fakewriter task started
[ 3205.500578] rcu-torture: Creating rcu_torture_stats task
[ 3205.501297] rcu-torture: rcu_torture_reader task started
[ 3205.502903] rcu-torture: Creating torture_shuffle task
[ 3205.503797] rcu-torture: rcu_torture_stats task started
[ 3205.514980] rcu-torture: Creating torture_stutter task
[ 3205.515871] rcu-torture: torture_shuffle task started
[ 3205.520461] rcu-torture: Creating rcu_torture_cbflood task
[ 3205.521379] rcu-torture: torture_stutter task started
[ 3205.529569] rcu-torture: rcu_torture_cbflood task started
-bash-4.3# rmmod rcutorture.ko
[ 3209.438170] rcu-torture: Stopping torture_shuffle task
[ 3209.439312] rcu-torture: Stopping torture_shuffle
[ 3209.440150] rcu-torture: Stopping torture_stutter task
[ 3209.446624] rcu-torture: Stopping torture_stutter
[ 3209.447376] rcu-torture: Stopping rcu_torture_fakewriter
[ 3209.448028] rcu-torture: Stopping rcu_torture_writer task
[ 3209.448594] rcu-torture: Stopping rcu_torture_fakewriter
[ 3209.449088] rcu-torture: Stopping rcu_torture_reader
[ 3209.453865] rcu-torture: Stopping rcu_torture_fakewriter
[ 3209.454995] rcu-torture: Stopping rcu_torture_fakewriter
[ 3209.455551] rcu-torture: Stopping rcu_torture_writer
[ 3209.456288] rcu-torture: Stopping rcu_torture_reader task
[ 3209.457060] rcu-torture: Stopping rcu_torture_fakewriter task
[ 3209.457836] rcu-torture: Stopping rcu_torture_fakewriter task
[ 3209.462206] rcu-torture: Stopping rcu_torture_fakewriter task
[ 3209.463673] rcu-torture: Stopping rcu_torture_fakewriter task
[ 3209.464398] rcu-torture: Stopping rcu_torture_stats task
[ 3209.465139] rcu-torture: rtc: (null) ver: 217 tfle: 0 rta: 217 rtaf: 0 rtf: 206 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 740 onoff: 0/0:0/0 -1,0:-1,0 0:0 (HZ=250) barrier: 0/0:0 cbflood: 3
[ 3209.469436] rcu-torture: Reader Pipe: 776988 96 0 0 0 0 0 0 0 0 0
[ 3209.471702] rcu-torture: Reader Batch: 620212 156872 0 0 0 0 0 0 0 0 0
[ 3209.472626] rcu-torture: Free-Block Circulation: 216 215 214 213 211 210 209 208 207 206 0
[ 3209.473730] rcu-torture: Stopping rcu_torture_stats
[ 3209.474885] rcu-torture: Stopping rcu_torture_cbflood task
[ 3209.539215] rcu-torture: Stopping rcu_torture_cbflood
[ 3209.540049] rcu-torture: rtc: (null) ver: 217 tfle: 0 rta: 217 rtaf: 0 rtf: 206 rtmbe: 0 rtbke: 0 rtbre: 0 rtbf: 0 rtb: 0 nt: 740 onoff: 0/0:0/0 -1,0:-1,0 0:0 (HZ=250) barrier: 0/0:0 cbflood: 4
[ 3209.541674] rcu-torture: Reader Pipe: 776988 96 0 0 0 0 0 0 0 0 0
[ 3209.544527] rcu-torture: Reader Batch: 620212 156872 0 0 0 0 0 0 0 0 0
[ 3209.545288] rcu-torture: Free-Block Circulation: 216 215 214 213 211 210 209 208 207 206 0
[ 3209.548506] rcu-torture:--- End of test: SUCCESS: nreaders=1 nfakewriters=4 stat_interval=60 verbose=1 test_no_idle_hz=1 shuffle_interval=3 stutter=5 irqreader=1 fqs_duration=0 fqs_holdoff=0 fqs_stutter=3 test_boost=1/0 test_boost_interval=7 test_boost_duration=4 shutdown_secs=0 stall_cpu=0 stall_cpu_holdoff=10 n_barrier_cbs=0 onoff_interval=0 onoff_holdoff=0

>
> Thanks,
> Davidlohr
>
> .
>