1. 27 Apr, 2018 2 commits
  2. 31 Mar, 2018 1 commit
  3. 29 Mar, 2018 1 commit
  4. 28 Mar, 2018 1 commit
  5. 20 Mar, 2018 1 commit
  6. 09 Mar, 2018 1 commit
    • Boqun Feng's avatar
      rtmutex: Make rt_mutex_futex_unlock() safe for irq-off callsites · 6b0ef92f
      Boqun Feng authored
      When running rcutorture with TREE03 config, CONFIG_PROVE_LOCKING=y, and
      kernel cmdline argument "rcutorture.gp_exp=1", lockdep reports a
      HARDIRQ-safe->HARDIRQ-unsafe deadlock:
       WARNING: inconsistent lock state
       4.16.0-rc4+ #1 Not tainted
       inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
       {IN-HARDIRQ-W} state was registered at:
       other info that might help us debug this:
        Possible unsafe locking scenario:
        *** DEADLOCK ***
       1 lock held by rcu_torture_rea/724:
       stack backtrace:
       CPU: 2 PID: 724 Comm: rcu_torture_rea Not tainted 4.16.0-rc4+ #1
       Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
       Call Trace:
        ? __schedule+0xbe/0xaf0
        ? __schedule+0xbe/0xaf0
       RIP: 0010:rcu_read_unlock_special+0x0/0x680
        ? rcu_torture_read_unlock+0x60/0x60
        ? rcutorture_booster_init+0x110/0x110
        ? rcu_torture_stall+0x230/0x230
        ? kthread+0x10e/0x130
        ? kthread_create_worker_on_cpu+0x70/0x70
        ? call_usermodehelper_exec_async+0x11a/0x150
      This happens with the following even sequence:
      	    local_irq_disable(); // irq off
      		  raw_spin_unlock_irqrestore(...,flags); // irq remains off
      	            raw_spin_unlock_irq(); // accidentally set irq on
      	    <return to __schedule()>
      	      raw_spin_lock(); // acquiring rq->lock with irq on
      which means rq->lock becomes a HARDIRQ-unsafe lock, which can cause
      deadlocks in scheduler code.
      This problem was introduced by commit 02a7c234 ("rcu: Suppress
      lockdep false-positive ->boost_mtx complaints"). That brought the user
      of rt_mutex_futex_unlock() with irq off.
      To fix this, replace the *lock_irq() in rt_mutex_futex_unlock() with
      *lock_irq{save,restore}() to make it safe to call rt_mutex_futex_unlock()
      with irq off.
      Fixes: 02a7c234
       ("rcu: Suppress lockdep false-positive ->boost_mtx complaints")
      Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Lai Jiangshan <jiangshanlai@gmail.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com>
      Link: https://lkml.kernel.org/r/20180309065630.8283-1-boqun.feng@gmail.com
  7. 28 Feb, 2018 1 commit
  8. 13 Feb, 2018 2 commits
    • Will Deacon's avatar
      locking/qspinlock: Ensure node->count is updated before initialising node · 11dc1322
      Will Deacon authored
      When queuing on the qspinlock, the count field for the current CPU's head
      node is incremented. This needn't be atomic because locking in e.g. IRQ
      context is balanced and so an IRQ will return with node->count as it
      found it.
      However, the compiler could in theory reorder the initialisation of
      node[idx] before the increment of the head node->count, causing an
      IRQ to overwrite the initialised node and potentially corrupt the lock
      Avoid the potential for this harmful compiler reordering by placing a
      barrier() between the increment of the head node->count and the subsequent
      node initialisation.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1518528177-19169-3-git-send-email-will.deacon@arm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    • Will Deacon's avatar
      locking/qspinlock: Ensure node is initialised before updating prev->next · 95bcade3
      Will Deacon authored
      When a locker ends up queuing on the qspinlock locking slowpath, we
      initialise the relevant mcs node and publish it indirectly by updating
      the tail portion of the lock word using xchg_tail. If we find that there
      was a pre-existing locker in the queue, we subsequently update their
      ->next field to point at our node so that we are notified when it's our
      turn to take the lock.
      This can be roughly illustrated as follows:
        /* Initialise the fields in node and encode a pointer to node in tail */
        tail = initialise_node(node);
         * Exchange tail into the lockword using an atomic read-modify-write
         * operation with release semantics
        old = xchg_tail(lock, tail);
        /* If there was a pre-existing waiter ... */
        if (old & _Q_TAIL_MASK) {
      	prev = decode_tail(old);
      	/* ... then update their ->next field to point to node.
      	WRITE_ONCE(prev->next, node);
      The conditional update of prev->next therefore relies on the address
      dependency from the result of xchg_tail ensuring order against the
      prior initialisation of node. However, since the release semantics of
      the xchg_tail operation apply only to the write portion of the RmW,
      then this ordering is not guaranteed and it is possible for the CPU
      to return old before the writes to node have been published, consequently
      allowing us to point prev->next to an uninitialised node.
      This patch fixes the problem by making the update of prev->next a RELEASE
      operation, which also removes the reliance on dependency ordering.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1518528177-19169-2-git-send-email-will.deacon@arm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
  9. 24 Jan, 2018 1 commit
  10. 18 Jan, 2018 2 commits
  11. 14 Jan, 2018 1 commit
    • Peter Zijlstra's avatar
      futex: Avoid violating the 10th rule of futex · c1e2f0ea
      Peter Zijlstra authored
      Julia reported futex state corruption in the following scenario:
         waiter                                  waker                                            stealer (prio > waiter)
         futex(WAIT_REQUEUE_PI, uaddr, uaddr2,
               timeout=[N ms])
                  <scheduled out>
                                                 futex(LOCK_PI, uaddr2)
                                                 futex(CMP_REQUEUE_PI, uaddr,
                                                       uaddr2, 1, 0)
                                                    /* requeues waiter to uaddr2 */
                                                 futex(UNLOCK_PI, uaddr2)
                                                          cmp_futex_value_locked(uaddr2, waiter)
                 <woken by waker>
                 <hrtimer_wakeup() fires,
                  clears sleeper->task>
                                                                                                 futex(LOCK_PI, uaddr2)
                                                                                                       try_to_take_rt_mutex() /* steals lock */
                                                                                                          rt_mutex_set_owner(lock, stealer)
               <scheduled in>
                     try_to_take_rt_mutex() /* fails, lock held by stealer */
                     if (timeout && !timeout->task)
                        return -ETIMEDOUT;
                     /* lock wasn't acquired, so,
                        fixup_pi_state_owner skipped */
         return -ETIMEDOUT;
         /* At this point, we've returned -ETIMEDOUT to userspace, but the
          * futex word shows waiter to be the owner, and the pi_mutex has
          * stealer as the owner */
         futex_lock(LOCK_PI, uaddr2)
           -> bails with EDEADLK, futex word says we're owner.
      And suggested that what commit:
        73d786bd ("futex: Rework inconsistent rt_mutex/futex_q state")
      removes from fixup_owner() looks to be just what is needed. And indeed
      it is -- I completely missed that requeue_pi could also result in this
      case. So we need to restore that, except that subsequent patches, like
        16ffa12d ("futex: Pull rt_mutex_futex_unlock() out from under hb->lock")
      changed all the locking rules. Even without that, the sequence:
      -               if (rt_mutex_futex_trylock(&q->pi_state->pi_mutex)) {
      -                       locked = 1;
      -                       goto out;
      -               }
      -               raw_spin_lock_irq(&q->pi_state->pi_mutex.wait_lock);
      -               owner = rt_mutex_owner(&q->pi_state->pi_mutex);
      -               if (!owner)
      -                       owner = rt_mutex_next_owner(&q->pi_state->pi_mutex);
      -               raw_spin_unlock_irq(&q->pi_state->pi_mutex.wait_lock);
      -               ret = fixup_pi_state_owner(uaddr, q, owner);
      already suggests there were races; otherwise we'd never have to look
      at next_owner.
      So instead of doing 3 consecutive wait_lock sections with who knows
      what races, we do it all in a single section. Additionally, the usage
      of pi_state->owner in fixup_owner() was only safe because only the
      rt_mutex owner would modify it, which this additional case wrecks.
      Luckily the values can only change away and not to the value we're
      testing, this means we can do a speculative test and double check once
      we have the wait_lock.
      Fixes: 73d786bd
       ("futex: Rework inconsistent rt_mutex/futex_q state")
      Reported-by: default avatarJulia Cartwright <julia@ni.com>
      Reported-by: default avatarGratian Crisan <gratian.crisan@ni.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarJulia Cartwright <julia@ni.com>
      Tested-by: default avatarGratian Crisan <gratian.crisan@ni.com>
      Cc: Darren Hart <dvhart@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20171208124939.7livp7no2ov65rrc@hirez.programming.kicks-ass.net
  12. 12 Dec, 2017 3 commits
    • Ingo Molnar's avatar
      locking/lockdep: Remove the cross-release locking checks · e966eaee
      Ingo Molnar authored
      while it found a number of old bugs initially, was also causing too many
      false positives that caused people to disable lockdep - which is arguably
      a worse overall outcome.
      If we disable cross-release by default but keep the code upstream then
      in practice the most likely outcome is that we'll allow the situation
      to degrade gradually, by allowing entropy to introduce more and more
      false positives, until it overwhelms maintenance capacity.
      Another bad side effect was that people were trying to work around
      the false positives by uglifying/complicating unrelated code. There's
      a marked difference between annotating locking operations and
      uglifying good code just due to bad lock debugging code ...
      This gradual decrease in quality happened to a number of debugging
      facilities in the kernel, and lockdep is pretty complex already,
      so we cannot risk this outcome.
      Either cross-release checking can be done right with no false positives,
      or it should not be included in the upstream kernel.
      ( Note that it might make sense to maintain it out of tree and go through
        the false positives every now and then and see whether new bugs were
        introduced. )
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    • Will Deacon's avatar
      locking/core: Remove break_lock field when CONFIG_GENERIC_LOCKBREAK=y · d89c7035
      Will Deacon authored
      When CONFIG_GENERIC_LOCKBEAK=y, locking structures grow an extra int ->break_lock
      field which is used to implement raw_spin_is_contended() by setting the field
      to 1 when waiting on a lock and clearing it to zero when holding a lock.
      However, there are a few problems with this approach:
        - There is a write-write race between a CPU successfully taking the lock
          (and subsequently writing break_lock = 0) and a waiter waiting on
          the lock (and subsequently writing break_lock = 1). This could result
          in a contended lock being reported as uncontended and vice-versa.
        - On machines with store buffers, nothing guarantees that the writes
          to break_lock are visible to other CPUs at any particular time.
        - READ_ONCE/WRITE_ONCE are not used, so the field is potentially
          susceptible to harmful compiler optimisations,
      Consequently, the usefulness of this field is unclear and we'd be better off
      removing it and allowing architectures to implement raw_spin_is_contended() by
      providing a definition of arch_spin_is_contended(), as they can when
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1511894539-7988-3-git-send-email-will.deacon@arm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    • Will Deacon's avatar
      locking/core: Fix deadlock during boot on systems with GENERIC_LOCKBREAK · f87f3a32
      Will Deacon authored
       ("locking/core: Remove {read,spin,write}_can_lock()")
      removed the definition of raw_spin_can_lock(), causing the GENERIC_LOCKBREAK
      spin_lock() routines to poll the ->break_lock field when waiting on a lock.
      This has been reported to cause a deadlock during boot on s390, because
      the ->break_lock field is also set by the waiters, and can potentially
      remain set indefinitely if no other CPUs come in to take the lock after
      it has been released.
      This patch removes the explicit spinning on ->break_lock from the waiters,
      instead relying on the outer trylock() operation to determine when the
      lock is available.
      Reported-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
      Tested-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: a8a217c2 ("locking/core: Remove {read,spin,write}_can_lock()")
      Link: http://lkml.kernel.org/r/1511894539-7988-2-git-send-email-will.deacon@arm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
  13. 11 Dec, 2017 4 commits
  14. 06 Dec, 2017 1 commit
  15. 04 Dec, 2017 1 commit
  16. 16 Nov, 2017 1 commit
    • Levin, Alexander (Sasha Levin)'s avatar
      kmemcheck: remove annotations · 49502766
      Levin, Alexander (Sasha Levin) authored
      Patch series "kmemcheck: kill kmemcheck", v2.
      As discussed at LSF/MM, kill kmemcheck.
      KASan is a replacement that is able to work without the limitation of
      kmemcheck (single CPU, slow).  KASan is already upstream.
      We are also not aware of any users of kmemcheck (or users who don't
      consider KASan as a suitable replacement).
      The only objection was that since KASAN wasn't supported by all GCC
      versions provided by distros at that time we should hold off for 2
      years, and try again.
      Now that 2 years have passed, and all distros provide gcc that supports
      KASAN, kill kmemcheck again for the very same reasons.
      This patch (of 4):
      Remove kmemcheck annotations, and calls to kmemcheck from the kernel.
      [alexander.levin@verizon.com: correctly remove kmemcheck call from dma_map_sg_attrs]
        Link: http://lkml.kernel.org/r/20171012192151.26531-1-alexander.levin@verizon.com
      Link: http://lkml.kernel.org/r/20171007030159.22241-2-alexander.levin@verizon.com
      Signed-off-by: Sasha Levin <alexa...
  17. 08 Nov, 2017 1 commit
    • Waiman Long's avatar
      locking/pvqspinlock: Implement hybrid PV queued/unfair locks · 11752adb
      Waiman Long authored
      Currently, all the lock waiters entering the slowpath will do one
      lock stealing attempt to acquire the lock. That helps performance,
      especially in VMs with over-committed vCPUs. However, the current
      pvqspinlocks still don't perform as good as unfair locks in many cases.
      On the other hands, unfair locks do have the problem of lock starvation
      that pvqspinlocks don't have.
      This patch combines the best attributes of an unfair lock and a
      pvqspinlock into a hybrid lock with 2 modes - queued mode & unfair
      mode. A lock waiter goes into the unfair mode when there are waiters
      in the wait queue but the pending bit isn't set. Otherwise, it will
      go into the queued mode waiting in the queue for its turn.
      On a 2-socket 36-core E5-2699 v3 system (HT off), a kernel build
      (make -j<n>) was done in a VM with unpinned vCPUs 3 times with the
      best time selected and <n> is the number of vCPUs available. The build
      times of the original pvqspinlock, hybrid pvqspinlock and unfair lock
      with various number of vCPUs are as follows:
        vCPUs    pvqlock     hybrid pvqlock    unfair lock
        -----    -------     --------------    -----------
          30      342.1s         329.1s          329.1s
          36      314.1s         305.3s          307.3s
          45      345.0s         302.1s          306.6s
          54      365.4s         308.6s          307.8s
          72      358.9s         293.6s          303.9s
         108      343.0s         285.9s          304.2s
      The hybrid pvqspinlock performs better or comparable to the unfair
      By turning on QUEUED_LOCK_STAT, the table below showed the number
      of lock acquisitions in unfair mode and queue mode after a kernel
      build with various number of vCPUs.
        vCPUs    queued mode  unfair mode
        -----    -----------  -----------
          30      9,130,518      294,954
          36     10,856,614      386,809
          45      8,467,264   11,475,373
          54      6,409,987   19,670,855
          72      4,782,063   25,712,180
      It can be seen that as the VM became more and more over-committed,
      the ratio of locks acquired in unfair mode increases. This is all
      done automatically to get the best overall performance as possible.
      Using a kernel locking microbenchmark with number of locking
      threads equals to the number of vCPUs available on the same machine,
      the minimum, average and maximum (min/avg/max) numbers of locking
      operations done per thread in a 5-second testing interval are shown
        vCPUs         hybrid pvqlock             unfair lock
        -----         --------------             -----------
          36     822,135/881,063/950,363    75,570/313,496/  690,465
          54     542,435/581,664/625,937    35,460/204,280/  457,172
          72     397,500/428,177/499,299    17,933/150,679/  708,001
         108     257,898/288,150/340,871     3,085/181,176/1,257,109
      It can be seen that the hybrid pvqspinlocks are more fair and
      performant than the unfair locks in this test.
      The table below shows the kernel build times on a smaller 2-socket
      16-core 32-thread E5-2620 v4 system.
        vCPUs    pvqlock     hybrid pvqlock    unfair lock
        -----    -------     --------------    -----------
          16      436.8s         433.4s          435.6s
          36      366.2s         364.8s          364.5s
          48      423.6s         376.3s          370.2s
          64      433.1s         376.6s          376.8s
      Again, the performance of the hybrid pvqspinlock was comparable to
      that of the unfair lock.
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarEduardo Valentin <eduval@amazon.com>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1510089486-3466-1-git-send-email-longman@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
  18. 07 Nov, 2017 1 commit
  19. 02 Nov, 2017 1 commit
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      How this work was done:
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      Further patches will be generated in subsequent months to fix up cases
      where non-standard...
  20. 25 Oct, 2017 5 commits
  21. 10 Oct, 2017 3 commits
    • Will Deacon's avatar
      locking/core: Remove {read,spin,write}_can_lock() · a8a217c2
      Will Deacon authored
      Outside of the locking code itself, {read,spin,write}_can_lock() have no
      users in tree. Apparmor (the last remaining user of write_can_lock()) got
      moved over to lockdep by the previous patch.
      This patch removes the use of {read,spin,write}_can_lock() from the
      BUILD_LOCK_OPS macro, deferring to the trylock operation for testing the
      lock status, and subsequently removes the unused macros altogether. They
      aren't guaranteed to work in a concurrent environment and can give
      incorrect results in the case of qrwlock.
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: paulmck@linux.vnet.ibm.com
      Link: http://lkml.kernel.org/r/1507055129-12300-2-git-send-email-will.deacon@arm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    • Kirill Tkhai's avatar
      locking/rwsem: Add down_read_killable() · 76f8507f
      Kirill Tkhai authored
      Similar to down_read() and down_write_killable(),
      add killable version of down_read(), based on
      __down_read_killable() function, added in previous
      Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: arnd@arndb.de
      Cc: avagin@virtuozzo.com
      Cc: davem@davemloft.net
      Cc: fenghua.yu@intel.com
      Cc: gorcunov@virtuozzo.com
      Cc: heiko.carstens@de.ibm.com
      Cc: hpa@zytor.com
      Cc: ink@jurassic.park.msu.ru
      Cc: mattst88@gmail.com
      Cc: rientjes@google.com
      Cc: rth@twiddle.net
      Cc: schwidefsky@de.ibm.com
      Cc: tony.luck@intel.com
      Cc: viro@zeniv.linux.org.uk
      Link: http://lkml.kernel.org/r/150670119884.23930.2585570605960763239.stgit@localhost.localdomain
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    • Peter Zijlstra's avatar
      locking/lockdep: Fix stacktrace mess · 8b405d5c
      Peter Zijlstra authored
      There is some complication between check_prevs_add() and
      check_prev_add() wrt. saving stack traces. The problem is that we want
      to be frugal with saving stack traces, since it consumes static
      We'll only know in check_prev_add() if we need the trace, but we can
      call into it multiple times. So we want to do on-demand and re-use.
      A further complication is that check_prev_add() can drop graph_lock
      and mess with our static resources.
      In any case, the current state; after commit:
       ("locking/lockdep: Make check_prev_add() able to handle external stack_trace")
      is that we'll assume the trace contains valid data once
      check_prev_add() returns '2'. However, as noted by Josh, this is
      false, check_prev_add() can return '2' before having saved a trace,
      this then result in the possibility of using uninitialized data.
      Testing, as reported by Wu, shows a NULL deref.
      So simplify.
      Since the graph_lock() thing is a debug path that hasn't
      really been used in a long while, take it out back and avoid the
      Further initialize the stack_trace to a known 'empty' state; as long
      as nr_entries == 0, nothing should deref entries. We can then use the
      'entries == NULL' test for a valid trace / on-demand saving.
      Analyzed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: ce07a941
       ("locking/lockdep: Make check_prev_add() able to handle external stack_trace")
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
  22. 29 Sep, 2017 1 commit
    • Prateek Sood's avatar
      locking/rwsem-xadd: Fix missed wakeup due to reordering of load · 9c29c318
      Prateek Sood authored
      If a spinner is present, there is a chance that the load of
      rwsem_has_spinner() in rwsem_wake() can be reordered with
      respect to decrement of rwsem count in __up_write() leading
      to wakeup being missed:
       spinning writer                  up_write caller
       ---------------                  -----------------------
       [S] osq_unlock()                 [L] osq
      Reordering of atomic_long_sub_return_release() in __up_write()
      and rwsem_has_spinner() in rwsem_wake() can cause missing of
      wakeup in up_write() context. In spinning writer, sem->count
      and local variable count is 0XFFFFFFFE00000001. It would result
      in rwsem_try_write_lock() failing to acquire rwsem and spinning
      writer going to sleep in rwsem_down_write_failed().
      The smp_rmb() will make sure that the spinner state is
      consulted after sem->count is updated in up_write context.
      Signed-off-by: default avatarPrateek Sood <prsood@codeaurora.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: dave@stgolabs.net
      Cc: longman@redhat.com
      Cc: parri.andrea@gmail.com
      Cc: sramana@codeaurora.org
      Link: http://lkml.kernel.org/r/1504794658-15397-1-git-send-email-prsood@codeaurora.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
  23. 14 Sep, 2017 1 commit
    • Michal Hocko's avatar
      mm: treewide: remove GFP_TEMPORARY allocation flag · 0ee931c4
      Michal Hocko authored
      GFP_TEMPORARY was introduced by commit e12ba74d ("Group short-lived
      and reclaimable kernel allocations") along with __GFP_RECLAIMABLE.  It's
      primary motivation was to allow users to tell that an allocation is
      short lived and so the allocator can try to place such allocations close
      together and prevent long term fragmentation.  As much as this sounds
      like a reasonable semantic it becomes much less clear when to use the
      highlevel GFP_TEMPORARY allocation flag.  How long is temporary? Can the
      context holding that memory sleep? Can it take locks? It seems there is
      no good answer for those questions.
      The current implementation of GFP_TEMPORARY is basically GFP_KERNEL |
      __GFP_RECLAIMABLE which in itself is tricky because basically none of
      the existing caller provide a way to reclaim the allocated memory.  So
      this is rather misleading and hard to evaluate for any benefits.
      I have checked some random users and none of them has added the flag
      with a specific...
  24. 09 Sep, 2017 1 commit
  25. 29 Aug, 2017 2 commits