1. 21 Jan, 2019 10 commits
    • Davidlohr Bueso's avatar
      sched/wake_q: Add branch prediction hint to wake_q_add() cmpxchg · 87ff19cb
      Davidlohr Bueso authored
      The cmpxchg() will fail when the task is already in the process
      of waking up, and as such is an extremely rare occurrence.
      Micro-optimize the call and put an unlikely() around it.
      
      To no surprise, when using CONFIG_PROFILE_ANNOTATED_BRANCHES
      under a number of workloads the incorrect rate was a mere 1-2%.
      Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWaiman Long <longman@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Yongji Xie <elohimes@gmail.com>
      Cc: andrea.parri@amarulasolutions.com
      Cc: lilin24@baidu.com
      Cc: liuqi16@baidu.com
      Cc: nixun@baidu.com
      Cc: xieyongji@baidu.com
      Cc: yuanlinsi01@baidu.com
      Cc: zhangyu31@baidu.com
      Link: https://lkml.kernel.org/r/20181203053130.gwkw6kg72azt2npb@linux-r8p5Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      87ff19cb
    • Ingo Molnar's avatar
    • Xie Yongji's avatar
      locking/rwsem: Fix (possible) missed wakeup · e158488b
      Xie Yongji authored
      Because wake_q_add() can imply an immediate wakeup (cmpxchg failure
      case), we must not rely on the wakeup being delayed. However, commit:
      
        e3851390 ("locking/rwsem: Rework zeroing reader waiter->task")
      
      relies on exactly that behaviour in that the wakeup must not happen
      until after we clear waiter->task.
      
      [ peterz: Added changelog. ]
      Signed-off-by: default avatarXie Yongji <xieyongji@baidu.com>
      Signed-off-by: default avatarZhang Yu <zhangyu31@baidu.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>
      Fixes: e3851390 ("locking/rwsem: Rework zeroing reader waiter->task")
      Link: https://lkml.kernel.org/r/1543495830-2644-1-git-send-email-xieyongji@baidu.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e158488b
    • Peter Zijlstra's avatar
      futex: Fix (possible) missed wakeup · b061c38b
      Peter Zijlstra authored
      We must not rely on wake_q_add() to delay the wakeup; in particular
      commit:
      
        1d0dcb3a ("futex: Implement lockless wakeups")
      
      moved wake_q_add() before smp_store_release(&q->lock_ptr, NULL), which
      could result in futex_wait() waking before observing ->lock_ptr ==
      NULL and going back to sleep again.
      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>
      Fixes: 1d0dcb3a ("futex: Implement lockless wakeups")
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b061c38b
    • Peter Zijlstra's avatar
      sched/wake_q: Fix wakeup ordering for wake_q · 4c4e3731
      Peter Zijlstra authored
      Notable cmpxchg() does not provide ordering when it fails, however
      wake_q_add() requires ordering in this specific case too. Without this
      it would be possible for the concurrent wakeup to not observe our
      prior state.
      
      Andrea Parri provided:
      
        C wake_up_q-wake_q_add
      
        {
      	int next = 0;
      	int y = 0;
        }
      
        P0(int *next, int *y)
        {
      	int r0;
      
      	/* in wake_up_q() */
      
      	WRITE_ONCE(*next, 1);   /* node->next = NULL */
      	smp_mb();               /* implied by wake_up_process() */
      	r0 = READ_ONCE(*y);
        }
      
        P1(int *next, int *y)
        {
      	int r1;
      
      	/* in wake_q_add() */
      
      	WRITE_ONCE(*y, 1);      /* wake_cond = true */
      	smp_mb__before_atomic();
      	r1 = cmpxchg_relaxed(next, 1, 2);
        }
      
        exists (0:r0=0 /\ 1:r1=0)
      
        This "exists" clause cannot be satisfied according to the LKMM:
      
        Test wake_up_q-wake_q_add Allowed
        States 3
        0:r0=0; 1:r1=1;
        0:r0=1; 1:r1=0;
        0:r0=1; 1:r1=1;
        No
        Witnesses
        Positive: 0 Negative: 3
        Condition exists (0:r0=0 /\ 1:r1=0)
        Observation wake_up_q-wake_q_add Never 0 3
      Reported-by: default avatarYongji Xie <elohimes@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4c4e3731
    • Peter Zijlstra's avatar
      sched/wake_q: Document wake_q_add() · e6018c0f
      Peter Zijlstra authored
      The only guarantee provided by wake_q_add() is that a wakeup will
      happen after it, it does _NOT_ guarantee the wakeup will be delayed
      until the matching wake_up_q().
      
      If wake_q_add() fails the cmpxchg() a concurrent wakeup is pending and
      that can happen at any time after the cmpxchg(). This means we should
      not rely on the wakeup happening at wake_q_up(), but should be ready
      for wake_q_add() to issue the wakeup.
      
      The delay; if provided (most likely); should only result in more efficient
      behaviour.
      Reported-by: default avatarYongji Xie <elohimes@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e6018c0f
    • Prateek Sood's avatar
      sched/wait: Fix rcuwait_wake_up() ordering · 6dc080ee
      Prateek Sood authored
      For some peculiar reason rcuwait_wake_up() has the right barrier in
      the comment, but not in the code.
      
      This mistake has been observed to cause a deadlock in the following
      situation:
      
          P1					P2
      
          percpu_up_read()			percpu_down_write()
            rcu_sync_is_idle() // false
      					  rcu_sync_enter()
      					  ...
            __percpu_up_read()
      
      [S] ,-  __this_cpu_dec(*sem->read_count)
          |   smp_rmb();
      [L] |   task = rcu_dereference(w->task) // NULL
          |
          |				    [S]	    w->task = current
          |					    smp_mb();
          |				    [L]	    readers_active_check() // fail
          `-> <store happens here>
      
      Where the smp_rmb() (obviously) fails to constrain the store.
      
      [ peterz: Added changelog. ]
      Signed-off-by: default avatarPrateek Sood <prsood@codeaurora.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarAndrea Parri <andrea.parri@amarulasolutions.com>
      Acked-by: default avatarDavidlohr Bueso <dbueso@suse.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 8f95c90c ("sched/wait, RCU: Introduce rcuwait machinery")
      Link: https://lkml.kernel.org/r/1543590656-7157-1-git-send-email-prsood@codeaurora.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6dc080ee
    • Paul E. McKenney's avatar
      tools/memory-model: Make scripts take "-j" abbreviation for "--jobs" · 910cc959
      Paul E. McKenney authored
      The "--jobs" argument to the litmus-test scripts is similar to the "-jN"
      argument to "make", so this commit allows the "-jN" form as well.  While
      in the area, it also prohibits the various forms of "-j0".
      Suggested-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: akiyks@gmail.com
      Cc: boqun.feng@gmail.com
      Cc: dhowells@redhat.com
      Cc: j.alglave@ucl.ac.uk
      Cc: linux-arch@vger.kernel.org
      Cc: luc.maranget@inria.fr
      Cc: npiggin@gmail.com
      Cc: parri.andrea@gmail.com
      Cc: will.deacon@arm.com
      Link: http://lkml.kernel.org/r/20181203230451.28921-3-paulmck@linux.ibm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      910cc959
    • Paul E. McKenney's avatar
      tools/memory-model: Add scripts to check github litmus tests · b02eb5b0
      Paul E. McKenney authored
      The https://github.com/paulmckrcu/litmus repository contains a large
      number of C-language litmus tests that include "Result:" comments
      predicting the verification result.  This commit adds a number of scripts
      that run tests on these litmus tests:
      
      checkghlitmus.sh:
      	Runs all litmus tests in the https://github.com/paulmckrcu/litmus
              archive that are C-language and that have "Result:" comment lines
      	documenting expected results, comparing the actual results to
      	those expected.  Clones the repository if it has not already
      	been cloned into the "tools/memory-model/litmus" directory.
      
      initlitmushist.sh
      	Run all litmus tests having no more than the specified number
      	of processes given a specified timeout, recording the results in
      	.litmus.out files.  Clones the repository if it has not already
      	been cloned into the "tools/memory-model/litmus" directory.
      
      newlitmushist.sh
      	For all new or updated litmus tests having no more than the
      	specified number of processes given a specified timeout, run
      	and record the results in .litmus.out files.
      
      checklitmushist.sh
      	Run all litmus tests having .litmus.out files from previous
      	initlitmushist.sh or newlitmushist.sh runs, comparing the
      	herd output to that of the original runs.
      
      The above scripts will run litmus tests concurrently, by default with
      one job per available CPU.  Giving any of these scripts the --help
      argument will cause them to print usage information.
      
      This commit also adds a number of helper scripts that are not intended
      to be invoked from the command line:
      
      cmplitmushist.sh: Compare the output of two different runs of the same
      	litmus test.
      
      judgelitmus.sh: Compare the output of a litmus test to its "Result:"
      	comment line.
      
      parseargs.sh: Parse command-line arguments.
      
      runlitmushist.sh: Run the litmus tests whose pathnames are provided one
      	per line on standard input.
      
      While in the area, this commit also makes the existing checklitmus.sh
      and checkalllitmus.sh scripts use parseargs.sh in order to provide a
      bit of uniformity.  In addition, per-litmus-test status output is directed
      to stdout, while end-of-test summary information is directed to stderr.
      Finally, the error flag standardizes on "!!!" to assist those familiar
      with rcutorture output.
      
      The defaults for the parseargs.sh arguments may be overridden by using
      environment variables: LKMM_DESTDIR for --destdir, LKMM_HERD_OPTIONS
      for --herdoptions, LKMM_JOBS for --jobs, LKMM_PROCS for --procs, and
      LKMM_TIMEOUT for --timeout.
      
      [ paulmck: History-check summary-line changes per Alan Stern feedback. ]
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: akiyks@gmail.com
      Cc: boqun.feng@gmail.com
      Cc: dhowells@redhat.com
      Cc: j.alglave@ucl.ac.uk
      Cc: linux-arch@vger.kernel.org
      Cc: luc.maranget@inria.fr
      Cc: npiggin@gmail.com
      Cc: parri.andrea@gmail.com
      Cc: stern@rowland.harvard.edu
      Cc: will.deacon@arm.com
      Link: http://lkml.kernel.org/r/20181203230451.28921-2-paulmck@linux.ibm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b02eb5b0
    • Andrea Parri's avatar
      tools/memory-model: Model smp_mb__after_unlock_lock() · 5b735eb1
      Andrea Parri authored
      The kernel documents smp_mb__after_unlock_lock() the following way:
      
        "Place this after a lock-acquisition primitive to guarantee that
         an UNLOCK+LOCK pair acts as a full barrier.  This guarantee applies
         if the UNLOCK and LOCK are executed by the same CPU or if the
         UNLOCK and LOCK operate on the same lock variable."
      
      Formalize in LKMM the above guarantee by defining (new) mb-links according
      to the law:
      
        ([M] ; po ; [UL] ; (co | po) ; [LKW] ;
      	fencerel(After-unlock-lock) ; [M])
      
      where the component ([UL] ; co ; [LKW]) identifies "UNLOCK+LOCK pairs on
      the same lock variable" and the component ([UL] ; po ; [LKW]) identifies
      "UNLOCK+LOCK pairs executed by the same CPU".
      
      In particular, the LKMM forbids the following two behaviors (the second
      litmus test below is based on:
      
        Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.html
      
      c.f., Section "Tree RCU Grace Period Memory Ordering Building Blocks"):
      
      C after-unlock-lock-same-cpu
      
      (*
       * Result: Never
       *)
      
      {}
      
      P0(spinlock_t *s, spinlock_t *t, int *x, int *y)
      {
      	int r0;
      
      	spin_lock(s);
      	WRITE_ONCE(*x, 1);
      	spin_unlock(s);
      	spin_lock(t);
      	smp_mb__after_unlock_lock();
      	r0 = READ_ONCE(*y);
      	spin_unlock(t);
      }
      
      P1(int *x, int *y)
      {
      	int r0;
      
      	WRITE_ONCE(*y, 1);
      	smp_mb();
      	r0 = READ_ONCE(*x);
      }
      
      exists (0:r0=0 /\ 1:r0=0)
      
      C after-unlock-lock-same-lock-variable
      
      (*
       * Result: Never
       *)
      
      {}
      
      P0(spinlock_t *s, int *x, int *y)
      {
      	int r0;
      
      	spin_lock(s);
      	WRITE_ONCE(*x, 1);
      	r0 = READ_ONCE(*y);
      	spin_unlock(s);
      }
      
      P1(spinlock_t *s, int *y, int *z)
      {
      	int r0;
      
      	spin_lock(s);
      	smp_mb__after_unlock_lock();
      	WRITE_ONCE(*y, 1);
      	r0 = READ_ONCE(*z);
      	spin_unlock(s);
      }
      
      P2(int *z, int *x)
      {
      	int r0;
      
      	WRITE_ONCE(*z, 1);
      	smp_mb();
      	r0 = READ_ONCE(*x);
      }
      
      exists (0:r0=0 /\ 1:r0=0 /\ 2:r0=0)
      Signed-off-by: default avatarAndrea Parri <andrea.parri@amarulasolutions.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.ibm.com>
      Cc: Akira Yokosawa <akiyks@gmail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Daniel Lustig <dlustig@nvidia.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Jade Alglave <j.alglave@ucl.ac.uk>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luc Maranget <luc.maranget@inria.fr>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-arch@vger.kernel.org
      Cc: parri.andrea@gmail.com
      Link: http://lkml.kernel.org/r/20181203230451.28921-1-paulmck@linux.ibm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5b735eb1
  2. 18 Jan, 2019 4 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma · d7393226
      Linus Torvalds authored
      Pull rdma fixes frfom Jason Gunthorpe:
       "Not much so far. We have the usual batch of bugs and two fixes to code
        merged this cycle:
      
         - Restore valgrind support for the ioctl verbs interface merged this
           window, and fix a missed error code on an error path from that
           conversion
      
         - A user reported crash on obsolete mthca hardware
      
         - pvrdma was using the wrong command opcode toward the hypervisor
      
         - NULL pointer crash regression when dumping rdma-cm over netlink
      
         - Be conservative about exposing the global rkey"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
        RDMA/uverbs: Mark ioctl responses with UVERBS_ATTR_F_VALID_OUTPUT
        RDMA/mthca: Clear QP objects during their allocation
        RDMA/vmw_pvrdma: Return the correct opcode when creating WR
        RDMA/cma: Add cm_id restrack resource based on kernel or user cm_id type
        RDMA/nldev: Don't expose unsafe global rkey to regular user
        RDMA/uverbs: Fix post send success return value in case of error
      d7393226
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2019-01-18' of git://anongit.freedesktop.org/drm/drm · 1092a94f
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "The rc3 fixes are a bit scattered:
      
         - meson, sun4i and rockchip all had missing of_node_put.
      
         - qxl and virtio both were advertising dma-buf to userspace when they
           really shouldn't have.
      
        Otherwise:
      
        meson:
         - modesetting regression fix
      
        i915 GVT:
         - one cmd parser failure fix
         - region cleanup fix in vGPU destroy
      
        amdgpu:
         - KFD fixes for arm64 mixed APU/DGPU
         - vega12 powerplay fix
         - raven DC fixes
         - freesync fix"
      
      * tag 'drm-fixes-2019-01-18' of git://anongit.freedesktop.org/drm/drm:
        drm/amd/display: Detach backlight from stream
        drm/sun4i: backend: add missing of_node_puts
        Revert "drm/amdgpu: validate user pitch alignment"
        Revert "drm/amdgpu: validate user GEM object size"
        drm/meson: Fix atomic mode switching regression
        drm/i915/gvt: Fix mmap range check
        drm/i915/gvt: free VFIO region space in vgpu detach
        drm/amd/display: Fix disabled cursor on top screen edge
        drm/amd/display: fix warning on raven hotplug
        drm/amd/display: fix PME notification not working in RV desktop
        drm/amd/display: Only get the connector state for VRR when toggled
        drm/amd/display: Pack DMCU iRAM alignment
        drm/amd/powerplay: run acg btc for Vega12
        drm/amdkfd: Don't assign dGPUs to APU topology devices
        drm/amdkfd: Allow building KFD on ARM64 (v2)
        drm/meson: add missing of_node_put
        drm/virtio: drop prime import/export callbacks
        drm/qxl: drop prime import/export callbacks
        drm/i915/gvt: Allow F_CMD_ACCESS on mmio 0x21f0
        drm/rockchip: add missing of_node_put
      1092a94f
    • Linus Torvalds's avatar
      Merge tag 'led-fix-for-5.0-rc3' of... · 2451f371
      Linus Torvalds authored
      Merge tag 'led-fix-for-5.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
      
      Pull LED fix from Jacek Anaszewski.
      
      * tag 'led-fix-for-5.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
        leds: lp5523: fix a missing check of return value of lp55xx_read
      2451f371
    • Linus Torvalds's avatar
      Merge tag 'hwmon-for-v5.0-rc3' of... · 0a2fbed8
      Linus Torvalds authored
      Merge tag 'hwmon-for-v5.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
      
      Pull hwmon fixes from Guenter Roeck:
       "Minor fixes/regressions"
      
      * tag 'hwmon-for-v5.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
        hwmon: (tmp421) Correct the misspelling of the tmp442 compatible attribute in OF device ID table
        hwmon: (occ) Fix potential integer overflow
        hwmon: (lm80) Fix missing unlock on error in set_fan_div()
        hwmon: (nct6775) Enable IO mapping for NCT6797D and NCT6798D
        hwmon: (nct6775) Fix chip ID for NCT6798D
      0a2fbed8
  3. 17 Jan, 2019 18 commits
  4. 16 Jan, 2019 8 commits