19 Mar, 2018

1 commit

  • [ Upstream commit 2ce77d16db4240dd2e422fc0a5c26d3e2ec03446 ]

    Things can explode for locktorture if the user does combinations
    of nwriters_stress=0 nreaders_stress=0. Fix this by not assuming
    we always want to torture writer threads.

    Reported-by: Jeremy Linton
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Jeremy Linton
    Tested-by: Jeremy Linton
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Davidlohr Bueso
     

02 Mar, 2017

2 commits


21 Feb, 2017

1 commit

  • Pull locking updates from Ingo Molnar:
    "The main changes in this cycle were:

    - Implement wraparound-safe refcount_t and kref_t types based on
    generic atomic primitives (Peter Zijlstra)

    - Improve and fix the ww_mutex code (Nicolai Hähnle)

    - Add self-tests to the ww_mutex code (Chris Wilson)

    - Optimize percpu-rwsems with the 'rcuwait' mechanism (Davidlohr
    Bueso)

    - Micro-optimize the current-task logic all around the core kernel
    (Davidlohr Bueso)

    - Tidy up after recent optimizations: remove stale code and APIs,
    clean up the code (Waiman Long)

    - ... plus misc fixes, updates and cleanups"

    * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (50 commits)
    fork: Fix task_struct alignment
    locking/spinlock/debug: Remove spinlock lockup detection code
    lockdep: Fix incorrect condition to print bug msgs for MAX_LOCKDEP_CHAIN_HLOCKS
    lkdtm: Convert to refcount_t testing
    kref: Implement 'struct kref' using refcount_t
    refcount_t: Introduce a special purpose refcount type
    sched/wake_q: Clarify queue reinit comment
    sched/wait, rcuwait: Fix typo in comment
    locking/mutex: Fix lockdep_assert_held() fail
    locking/rtmutex: Flip unlikely() branch to likely() in __rt_mutex_slowlock()
    locking/rwsem: Reinit wake_q after use
    locking/rwsem: Remove unnecessary atomic_long_t casts
    jump_labels: Move header guard #endif down where it belongs
    locking/atomic, kref: Implement kref_put_lock()
    locking/ww_mutex: Turn off __must_check for now
    locking/atomic, kref: Avoid more abuse
    locking/atomic, kref: Use kref_get_unless_zero() more
    locking/atomic, kref: Kill kref_sub()
    locking/atomic, kref: Add kref_read()
    locking/atomic, kref: Add KREF_INIT()
    ...

    Linus Torvalds
     

15 Jan, 2017

1 commit

  • When running locktorture module with the below commands with kmemleak enabled:

    $ modprobe locktorture torture_type=rw_lock_irq
    $ rmmod locktorture

    The below kmemleak got caught:

    root@10:~# echo scan > /sys/kernel/debug/kmemleak
    [ 323.197029] kmemleak: 2 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
    root@10:~# cat /sys/kernel/debug/kmemleak
    unreferenced object 0xffffffc07592d500 (size 128):
    comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 c3 7b 02 00 00 00 00 00 .........{......
    00 00 00 00 00 00 00 00 d7 9b 02 00 00 00 00 00 ................
    backtrace:
    [] create_object+0x110/0x288
    [] kmemleak_alloc+0x58/0xa0
    [] __kmalloc+0x234/0x318
    [] 0xffffff80006fa130
    [] do_one_initcall+0x44/0x138
    [] do_init_module+0x68/0x1cc
    [] load_module+0x1a68/0x22e0
    [] SyS_finit_module+0xe0/0xf0
    [] el0_svc_naked+0x24/0x28
    [] 0xffffffffffffffff
    unreferenced object 0xffffffc07592d480 (size 128):
    comm "modprobe", pid 368, jiffies 4294924118 (age 205.824s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 3b 6f 01 00 00 00 00 00 ........;o......
    00 00 00 00 00 00 00 00 23 6a 01 00 00 00 00 00 ........#j......
    backtrace:
    [] create_object+0x110/0x288
    [] kmemleak_alloc+0x58/0xa0
    [] __kmalloc+0x234/0x318
    [] 0xffffff80006fa22c
    [] do_one_initcall+0x44/0x138
    [] do_init_module+0x68/0x1cc
    [] load_module+0x1a68/0x22e0
    [] SyS_finit_module+0xe0/0xf0
    [] el0_svc_naked+0x24/0x28
    [] 0xffffffffffffffff

    It is because cxt.lwsa and cxt.lrsa don't get freed in module_exit, so free
    them in lock_torture_cleanup() and free writer_tasks if reader_tasks is
    failed at memory allocation.

    Signed-off-by: Yang Shi
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Yang Shi
     

14 Jan, 2017

1 commit

  • Although ww_mutexes degenerate into mutexes, it would be useful to
    torture the deadlock handling between multiple ww_mutexes in addition to
    torturing the regular mutexes.

    Signed-off-by: Chris Wilson
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Maarten Lankhorst
    Cc: Nicolai Hähnle
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20161201114711.28697-3-chris@chris-wilson.co.uk
    Signed-off-by: Ingo Molnar

    Chris Wilson
     

28 Apr, 2016

1 commit

  • This commit replaces an #ifdef with IS_ENABLED(), saving five lines.

    Signed-off-by: Paul E. McKenney
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: corbet@lwn.net
    Cc: dave@stgolabs.net
    Cc: dhowells@redhat.com
    Cc: linux-doc@vger.kernel.org
    Cc: will.deacon@arm.com
    Link: http://lkml.kernel.org/r/1461691328-5429-4-git-send-email-paulmck@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Paul E. McKenney
     

13 Apr, 2016

2 commits

  • It has been found that paths that invoke cleanups through
    lock_torture_cleanup() can trigger NULL pointer dereferencing
    bugs during the statistics printing phase. This is mainly
    because we should not be calling into statistics before we are
    sure things have been set up correctly.

    Specifically, early checks (and the need for handling this in
    the cleanup call) only include parameter checks and basic
    statistics allocation. Once we start write/read kthreads
    we then consider the test as started. As such, update the function
    in question to check for cxt.lwsa writer stats, if not set,
    we either have a bogus parameter or -ENOMEM situation and
    therefore only need to deal with general torture calls.

    Reported-and-tested-by: Kefeng Wang
    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney
    Cc: Andrew Morton
    Cc: Davidlohr Bueso
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: bobby.prani@gmail.com
    Cc: dhowells@redhat.com
    Cc: dipankar@in.ibm.com
    Cc: dvhart@linux.intel.com
    Cc: edumazet@google.com
    Cc: fweisbec@gmail.com
    Cc: jiangshanlai@gmail.com
    Cc: josh@joshtriplett.org
    Cc: mathieu.desnoyers@efficios.com
    Cc: oleg@redhat.com
    Cc: rostedt@goodmis.org
    Link: http://lkml.kernel.org/r/1460476038-27060-2-git-send-email-paulmck@linux.vnet.ibm.com
    [ Improved the changelog. ]
    Signed-off-by: Ingo Molnar

    Davidlohr Bueso
     
  • For the case of rtmutex torturing we will randomly call into the
    boost() handler, including upon module exiting when the tasks are
    deboosted before stopping. In such cases the task may or may not have
    already been boosted, and therefore the NULL being explicitly passed
    can occur anywhere. Currently we only assume that the task will is
    at a higher prio, and in consequence, dereference a NULL pointer.

    This patch fixes the case of a rmmod locktorture exploding while
    pounding on the rtmutex lock (partial trace):

    task: ffff88081026cf80 ti: ffff880816120000 task.ti: ffff880816120000
    RSP: 0018:ffff880816123eb0 EFLAGS: 00010206
    RAX: ffff88081026cf80 RBX: ffff880816bfa630 RCX: 0000000000160d1b
    RDX: 0000000000000000 RSI: 0000000000000202 RDI: 0000000000000000
    RBP: ffff88081026cf80 R08: 000000000000001f R09: ffff88017c20ca80
    R10: 0000000000000000 R11: 000000000048c316 R12: ffffffffa05d1840
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
    FS: 0000000000000000(0000) GS:ffff88203f880000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000000008 CR3: 0000000001c0a000 CR4: 00000000000406e0
    Stack:
    ffffffffa05d141d ffff880816bfa630 ffffffffa05d1922 ffff88081e70c2c0
    ffff880816bfa630 ffffffff81095fed 0000000000000000 ffffffff8107bf60
    ffff880816bfa630 ffffffff00000000 ffff880800000000 ffff880816123f08
    Call Trace:
    [] kthread+0xbd/0xe0
    [] ret_from_fork+0x3f/0x70

    This patch ensures that if the random state pointer is not NULL and current
    is not boosted, then do nothing.

    RIP: 0010:[] [] torture_random+0x5/0x60 [torture]
    [] torture_rtmutex_boost+0x1d/0x90 [locktorture]
    [] lock_torture_writer+0xe2/0x170 [locktorture]

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney
    Cc: Andrew Morton
    Cc: Davidlohr Bueso
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: bobby.prani@gmail.com
    Cc: dhowells@redhat.com
    Cc: dipankar@in.ibm.com
    Cc: dvhart@linux.intel.com
    Cc: edumazet@google.com
    Cc: fweisbec@gmail.com
    Cc: jiangshanlai@gmail.com
    Cc: josh@joshtriplett.org
    Cc: mathieu.desnoyers@efficios.com
    Cc: oleg@redhat.com
    Cc: rostedt@goodmis.org
    Link: http://lkml.kernel.org/r/1460476038-27060-1-git-send-email-paulmck@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar

    Davidlohr Bueso
     

08 Oct, 2015

1 commit


07 Oct, 2015

3 commits

  • The locktorture module has a list of torture types, and specifying
    a type not on this list is supposed to cleanly fail the module load.
    Unfortunately, the "fail" happens without the "cleanly". This commit
    therefore adds the needed clean-up after an incorrect torture_type.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • This commit adds percpu_rwsem tests based on the earlier rwsem tests.

    Signed-off-by: Paul E. McKenney
    Cc: Oleg Nesterov
    Cc: Davidlohr Bueso
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • Real time mutexes is one of the few general primitives
    that we do not have in locktorture. Address this -- a few
    considerations:

    o To spice things up, enable competing thread(s) to become
    rt, such that we can stress different prio boosting paths
    in the rtmutex code. Introduce a ->task_boost callback,
    only used by rtmutex-torturer. Tasks will boost/deboost
    around every 50k (arbitrarily) lock/unlock operations.

    o Hold times are similar to what we have for other locks:
    only occasionally having longer hold times (per ~200k ops).
    So we roughly do two full rt boost+deboosting ops with
    short hold times.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Davidlohr Bueso
     

28 May, 2015

2 commits


30 Sep, 2014

4 commits


17 Sep, 2014

8 commits

  • The amount of global variables is getting pretty ugly. Group variables
    related to the execution (ie: not parameters) in a new context structure.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • We can easily do so with our new reader lock support. Just an arbitrary
    design default: readers have higher (5x) critical region latencies than
    writers: 50 ms and 10 ms, respectively.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • Most of it is based on what we already have for writers. This allows
    readers to be very independent (and thus configurable), enabling
    future module parameters to control things such as rw distribution.
    Furthermore, readers have their own delaying function, allowing us
    to test different rw critical region latencies, and stress locking
    internals. Similarly, statistics, for now will only serve for the
    number of lock acquisitions -- as opposed to writers, readers have
    no failure detection.

    In addition, introduce a new nreaders_stress module parameter. The
    default number of readers will be the same number of writers threads.
    Writer threads are interleaved with readers. Documentation is updated,
    respectively.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • When performing module cleanups by calling torture_cleanup() the
    'torture_type' string in nullified However, callers are not necessarily
    done, and might still need to reference the variable. This impacts
    both rcutorture and locktorture, causing printing things like:

    [ 94.226618] (null)-torture: Stopping lock_torture_writer task
    [ 94.226624] (null)-torture: Stopping lock_torture_stats task

    Thus delay this operation until the very end of the cleanup process.
    The consequence (which shouldn't matter for this kid of program) is,
    of course, that we delay the window between rmmod and modprobing,
    for instance in module_torture_begin().

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • The statistics structure can serve well for both reader and writer
    locks, thus simply rename some fields that mention 'write' and leave
    the declaration of lwsa.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • Regular locks are very different than locks with debugging. For instance
    for mutexes, debugging forces to only take the slowpaths. As such, the
    locktorture module should take this into account when printing related
    information -- specifically when printing user passed parameters, it seems
    the right place for such info.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • Add a "mutex_lock" torture test. The main difference with the already
    existing spinlock tests is that the latency of the critical region
    is much larger. We randomly delay for (arbitrarily) either 500 ms or,
    otherwise, 25 ms. While this can considerably reduce the amount of
    writes compared to non blocking locks, if run long enough it can have
    the same torturous effect. Furthermore it is more representative of
    mutex hold times and can stress better things like thrashing.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     
  • ... to just 'torture_runnable'. It follows other variable naming
    and is shorter.

    Signed-off-by: Davidlohr Bueso
    Signed-off-by: Paul E. McKenney

    Davidlohr Bueso
     

04 Jun, 2014

1 commit

  • …/git/tip/tip into next

    Pull scheduler updates from Ingo Molnar:
    "The main scheduling related changes in this cycle were:

    - various sched/numa updates, for better performance

    - tree wide cleanup of open coded nice levels

    - nohz fix related to rq->nr_running use

    - cpuidle changes and continued consolidation to improve the
    kernel/sched/idle.c high level idle scheduling logic. As part of
    this effort I pulled cpuidle driver changes from Rafael as well.

    - standardized idle polling amongst architectures

    - continued work on preparing better power/energy aware scheduling

    - sched/rt updates

    - misc fixlets and cleanups"

    * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (49 commits)
    sched/numa: Decay ->wakee_flips instead of zeroing
    sched/numa: Update migrate_improves/degrades_locality()
    sched/numa: Allow task switch if load imbalance improves
    sched/rt: Fix 'struct sched_dl_entity' and dl_task_time() comments, to match the current upstream code
    sched: Consolidate open coded implementations of nice level frobbing into nice_to_rlimit() and rlimit_to_nice()
    sched: Initialize rq->age_stamp on processor start
    sched, nohz: Change rq->nr_running to always use wrappers
    sched: Fix the rq->next_balance logic in rebalance_domains() and idle_balance()
    sched: Use clamp() and clamp_val() to make sys_nice() more readable
    sched: Do not zero sg->cpumask and sg->sgp->power in build_sched_groups()
    sched/numa: Fix initialization of sched_domain_topology for NUMA
    sched: Call select_idle_sibling() when not affine_sd
    sched: Simplify return logic in sched_read_attr()
    sched: Simplify return logic in sched_copy_attr()
    sched: Fix exec_start/task_hot on migrated tasks
    arm64: Remove TIF_POLLING_NRFLAG
    metag: Remove TIF_POLLING_NRFLAG
    sched/idle: Make cpuidle_idle_call() void
    sched/idle: Reflow cpuidle_idle_call()
    sched/idle: Delay clearing the polling bit
    ...

    Linus Torvalds
     

15 May, 2014

2 commits

  • The torture tests are designed to run in isolation, but do not enforce
    this isolation. This commit therefore checks for concurrent torture
    tests, and refuses to start new tests while old tests are running.

    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     
  • The locktorture module references CONFIG_LOCK_TORTURE_TEST_RUNNABLE,
    which does not exist. Which is a good thing, because otherwise
    randconfig testing could enable both rcutorture and locktorture
    concurrently, which the torture tests are not set up for. This
    commit therefore removes the reference, so that test is runnable
    immediately only when inserted as a module.

    Reported-by: Paul Bolle
    Signed-off-by: Paul E. McKenney
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

14 May, 2014

1 commit

  • The current lock_torture_writer() spends too much time sleeping and not
    enough time hammering locks, as in an eight-CPU test will often only be
    utilizing a CPU or two. This commit therefore makes lock_torture_writer()
    sleep less and hammer more.

    Signed-off-by: Paul E. McKenney

    Paul E. McKenney
     

18 Apr, 2014

1 commit

  • Replace various -20/+19 hardcoded nice values with MIN_NICE/MAX_NICE.

    Signed-off-by: Dongsheng Yang
    Acked-by: Tejun Heo
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/ff13819fd09b7a5dba5ab5ae797f2e7019bdfa17.1394532288.git.yangds.fnst@cn.fujitsu.com
    Cc: devel@driverdev.osuosl.org
    Cc: devicetree@vger.kernel.org
    Cc: fcoe-devel@open-fcoe.org
    Cc: linux390@de.ibm.com
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mm@kvack.org
    Cc: linux-s390@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Cc: nbd-general@lists.sourceforge.net
    Cc: ocfs2-devel@oss.oracle.com
    Cc: openipmi-developer@lists.sourceforge.net
    Cc: qla2xxx-upstream@qlogic.com
    Cc: linux-arch@vger.kernel.org
    [ Consolidated the patches, twiddled the changelog. ]
    Signed-off-by: Ingo Molnar

    Dongsheng Yang
     

24 Feb, 2014

2 commits