1. 03 3月, 2018 1 次提交
  2. 21 2月, 2018 10 次提交
    • F
      sched/nohz: Remove the 1 Hz tick code · dcdedb24
      Frederic Weisbecker 提交于
      Now that the 1Hz tick is offloaded to workqueues, we can safely remove
      the residual code that used to handle it locally.
      Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Link: http://lkml.kernel.org/r/1519186649-3242-7-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      dcdedb24
    • F
      sched/isolation: Offload residual 1Hz scheduler tick · d84b3131
      Frederic Weisbecker 提交于
      When a CPU runs in full dynticks mode, a 1Hz tick remains in order to
      keep the scheduler stats alive. However this residual tick is a burden
      for bare metal tasks that can't stand any interruption at all, or want
      to minimize them.
      
      The usual boot parameters "nohz_full=" or "isolcpus=nohz" will now
      outsource these scheduler ticks to the global workqueue so that a
      housekeeping CPU handles those remotely. The sched_class::task_tick()
      implementations have been audited and look safe to be called remotely
      as the target runqueue and its current task are passed in parameter
      and don't seem to be accessed locally.
      
      Note that in the case of using isolcpus, it's still up to the user to
      affine the global workqueues to the housekeeping CPUs through
      /sys/devices/virtual/workqueue/cpumask or domains isolation
      "isolcpus=nohz,domain".
      Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Link: http://lkml.kernel.org/r/1519186649-3242-6-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      d84b3131
    • F
      sched/isolation: Isolate workqueues when "nohz_full=" is set · 1bda3f80
      Frederic Weisbecker 提交于
      As we prepare for offloading the residual 1hz scheduler ticks to
      workqueue, let's affine those to housekeepers so that they don't
      interrupt the CPUs that don't want to be disturbed.
      Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Link: http://lkml.kernel.org/r/1519186649-3242-5-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1bda3f80
    • F
      sched/core: Rename init_rq_hrtick() to hrtick_rq_init() · 77a021be
      Frederic Weisbecker 提交于
      Do that rename in order to normalize the hrtick namespace.
      Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Wanpeng Li <kernellwp@gmail.com>
      Link: http://lkml.kernel.org/r/1519186649-3242-2-git-send-email-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      77a021be
    • M
      sched/numa: Delay retrying placement for automatic NUMA balance after wake_affine() · 7347fc87
      Mel Gorman 提交于
      If wake_affine() pulls a task to another node for any reason and the node is
      no longer preferred then temporarily stop automatic NUMA balancing pulling
      the task back. Otherwise, tasks with a strong waker/wakee relationship
      may constantly fight automatic NUMA balancing over where a task should
      be placed.
      
      Once again netperf is interesting here. The performance barely changes
      but automatic NUMA balancing is interesting:
      
       Hmean     send-64         354.67 (   0.00%)      352.15 (  -0.71%)
       Hmean     send-128        702.91 (   0.00%)      693.84 (  -1.29%)
       Hmean     send-256       1350.07 (   0.00%)     1344.19 (  -0.44%)
       Hmean     send-1024      5124.38 (   0.00%)     4941.24 (  -3.57%)
       Hmean     send-2048      9687.44 (   0.00%)     9624.45 (  -0.65%)
       Hmean     send-3312     14577.64 (   0.00%)    14514.35 (  -0.43%)
       Hmean     send-4096     16393.62 (   0.00%)    16488.30 (   0.58%)
       Hmean     send-8192     26877.26 (   0.00%)    26431.63 (  -1.66%)
       Hmean     send-16384    38683.43 (   0.00%)    38264.91 (  -1.08%)
       Hmean     recv-64         354.67 (   0.00%)      352.15 (  -0.71%)
       Hmean     recv-128        702.91 (   0.00%)      693.84 (  -1.29%)
       Hmean     recv-256       1350.07 (   0.00%)     1344.19 (  -0.44%)
       Hmean     recv-1024      5124.38 (   0.00%)     4941.24 (  -3.57%)
       Hmean     recv-2048      9687.43 (   0.00%)     9624.45 (  -0.65%)
       Hmean     recv-3312     14577.59 (   0.00%)    14514.35 (  -0.43%)
       Hmean     recv-4096     16393.55 (   0.00%)    16488.20 (   0.58%)
       Hmean     recv-8192     26876.96 (   0.00%)    26431.29 (  -1.66%)
       Hmean     recv-16384    38682.41 (   0.00%)    38263.94 (  -1.08%)
      
       NUMA alloc hit                 1465986     1423090
       NUMA alloc miss                      0           0
       NUMA interleave hit                  0           0
       NUMA alloc local               1465897     1423003
       NUMA base PTE updates             1473        1420
       NUMA huge PMD updates                0           0
       NUMA page range updates           1473        1420
       NUMA hint faults                  1383        1312
       NUMA hint local faults             451         124
       NUMA hint local percent             32           9
      
      There is a slight degrading in performance but there are slightly fewer
      NUMA faults. There is a large drop in the percentage of local faults but
      the bulk of migrations for netperf are in small shared libraries so it's
      reflecting the fact that automatic NUMA balancing has backed off. This is
      a case where despite wake_affine() and automatic NUMA balancing fighting
      for placement that there is a marginal benefit to rescheduling to local
      data quickly. However, it should be noted that wake_affine() and automatic
      NUMA balancing fighting each other constantly is undesirable.
      
      However, the benefit in other cases is large. This is the result for NAS
      with the D class sizing on a 4-socket machine:
      
       nas-mpi
                                 4.15.0                 4.15.0
                           sdnuma-v1r23       delayretry-v1r23
       Time cg.D      557.00 (   0.00%)      431.82 (  22.47%)
       Time ep.D       77.83 (   0.00%)       79.01 (  -1.52%)
       Time is.D       26.46 (   0.00%)       26.64 (  -0.68%)
       Time lu.D      727.14 (   0.00%)      597.94 (  17.77%)
       Time mg.D      191.35 (   0.00%)      146.85 (  23.26%)
      
                     4.15.0      4.15.0
               sdnuma-v1r23delayretry-v1r23
       User        75665.20    70413.30
       System      20321.59     8861.67
       Elapsed       766.13      634.92
      
       Minor Faults                  16528502     7127941
       Major Faults                      4553        5068
       NUMA alloc local               6963197     6749135
       NUMA base PTE updates        366409093   107491434
       NUMA huge PMD updates           687556      198880
       NUMA page range updates      718437765   209317994
       NUMA hint faults              13643410     4601187
       NUMA hint local faults         9212593     3063996
       NUMA hint local percent             67          66
      
      Note the massive reduction in system CPU usage even though the percentage
      of local faults is barely affected. There is a massive reduction in the
      number of PTE updates showing that automatic NUMA balancing has backed off.
      A critical observation is also that there is a massive reduction in minor
      faults which is due to far fewer NUMA hinting faults being trapped.
      
      There were questions on NAS OMP and how it behaved related to threads
      being bound to CPUs. First, there are more gains than losses with this
      patch applied and a reduction in system CPU usage:
      
      nas-omp
                            4.16.0-rc1             4.16.0-rc1
                           sdnuma-v2r1        delayretry-v2r1
      Time bt.D      436.71 (   0.00%)      430.05 (   1.53%)
      Time cg.D      201.02 (   0.00%)      180.87 (  10.02%)
      Time ep.D       32.84 (   0.00%)       32.68 (   0.49%)
      Time is.D        9.63 (   0.00%)        9.64 (  -0.10%)
      Time lu.D      331.20 (   0.00%)      304.80 (   7.97%)
      Time mg.D       54.87 (   0.00%)       52.72 (   3.92%)
      Time sp.D     1108.78 (   0.00%)      917.10 (  17.29%)
      Time ua.D      378.81 (   0.00%)      398.83 (  -5.28%)
      
                4.16.0-rc1  4.16.0-rc1
               sdnuma-v2r1delayretry-v2r1
      User       305633.08   296751.91
      System        451.75      357.80
      Elapsed      2595.73     2368.13
      
      However, it does not close the gap between binding and being unbound. There
      is negligible difference between the performance of the baseline and a
      patched kernel when threads are bound so it is not presented here:
      
                            4.16.0-rc1             4.16.0-rc1
                       delayretry-bind     delayretry-unbound
      Time bt.D      385.02 (   0.00%)      430.05 ( -11.70%)
      Time cg.D      144.02 (   0.00%)      180.87 ( -25.59%)
      Time ep.D       32.85 (   0.00%)       32.68 (   0.52%)
      Time is.D       10.52 (   0.00%)        9.64 (   8.37%)
      Time lu.D      285.31 (   0.00%)      304.80 (  -6.83%)
      Time mg.D       43.21 (   0.00%)       52.72 ( -22.01%)
      Time sp.D      820.24 (   0.00%)      917.10 ( -11.81%)
      Time ua.D      337.09 (   0.00%)      398.83 ( -18.32%)
      
                4.16.0-rc1  4.16.0-rc1
              delayretry-binddelayretry-unbound
      User       277731.25   296751.91
      System        261.29      357.80
      Elapsed      2100.55     2368.13
      
      Unfortunately, while performance is improved by the patch, there is still
      quite a long way to go before it's equivalent to hard binding.
      
      Other workloads like hackbench, tbench, dbench and schbench are barely
      affected. dbench shows a mix of gains and losses depending on the machine
      although in general, the results are more stable.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-7-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      7347fc87
    • M
      sched/fair: Consider SD_NUMA when selecting the most idle group to schedule on · 2c833627
      Mel Gorman 提交于
      find_idlest_group() compares a local group with each other group to select
      the one that is most idle. When comparing groups in different NUMA domains,
      a very slight imbalance is enough to select a remote NUMA node even if the
      runnable load on both groups is 0 or close to 0. This ignores the cost of
      remote accesses entirely and is a problem when selecting the CPU for a
      newly forked task to run on.  This is problematic when a forking server
      is almost guaranteed to run on a remote node incurring numerous remote
      accesses and potentially causing automatic NUMA balancing to try migrate
      the task back or migrate the data to another node. Similar weirdness is
      observed if a basic shell command pipes output to another as each process
      in the pipeline is likely to start on different nodes and then get adjusted
      later by wake_affine().
      
      This patch adds imbalance to remote domains when considering whether to
      select CPUs from remote domains. If the local domain is selected, imbalance
      will still be used to try select a CPU from a lower scheduler domain's group
      instead of stacking tasks on the same CPU.
      
      A variety of workloads and machines were tested and as expected, there is no
      difference on UMA. The difference on NUMA can be dramatic. This is a comparison
      of elapsed times running the git regression test suite. It's fork-intensive with
      short-lived processes:
      
                                        4.15.0                 4.15.0
                                  noexit-v1r23           sdnuma-v1r23
       Elapsed min          1706.06 (   0.00%)     1435.94 (  15.83%)
       Elapsed mean         1709.53 (   0.00%)     1436.98 (  15.94%)
       Elapsed stddev          2.16 (   0.00%)        1.01 (  53.38%)
       Elapsed coeffvar        0.13 (   0.00%)        0.07 (  44.54%)
       Elapsed max          1711.59 (   0.00%)     1438.01 (  15.98%)
      
                     4.15.0      4.15.0
               noexit-v1r23 sdnuma-v1r23
       User         5434.12     5188.41
       System       4878.77     3467.09
       Elapsed     10259.06     8624.21
      
      That shows a considerable reduction in elapsed times. It's important to
      note that automatic NUMA balancing does not affect this load as processes
      are too short-lived.
      
      There is also a noticable impact on hackbench such as this example using
      processes and pipes:
      
       hackbench-process-pipes
                                     4.15.0                 4.15.0
                               noexit-v1r23           sdnuma-v1r23
       Amean     1        1.0973 (   0.00%)      0.9393 (  14.40%)
       Amean     4        1.3427 (   0.00%)      1.3730 (  -2.26%)
       Amean     7        1.4233 (   0.00%)      1.6670 ( -17.12%)
       Amean     12       3.0250 (   0.00%)      3.3013 (  -9.13%)
       Amean     21       9.0860 (   0.00%)      9.5343 (  -4.93%)
       Amean     30      14.6547 (   0.00%)     13.2433 (   9.63%)
       Amean     48      22.5447 (   0.00%)     20.4303 (   9.38%)
       Amean     79      29.2010 (   0.00%)     26.7853 (   8.27%)
       Amean     110     36.7443 (   0.00%)     35.8453 (   2.45%)
       Amean     141     45.8533 (   0.00%)     42.6223 (   7.05%)
       Amean     172     55.1317 (   0.00%)     50.6473 (   8.13%)
       Amean     203     64.4420 (   0.00%)     58.3957 (   9.38%)
       Amean     234     73.2293 (   0.00%)     67.1047 (   8.36%)
       Amean     265     80.5220 (   0.00%)     75.7330 (   5.95%)
       Amean     296     88.7567 (   0.00%)     82.1533 (   7.44%)
      
      It's not a universal win as there are occasions when spreading wide and
      quickly is a benefit but it's more of a win than it is a loss. For other
      workloads, there is little difference but netperf is interesting. Without
      the patch, the server and client starts on different nodes but quickly get
      migrated due to wake_affine. Hence, the difference is overall performance
      is marginal but detectable:
      
                                            4.15.0                 4.15.0
                                      noexit-v1r23           sdnuma-v1r23
       Hmean     send-64         349.09 (   0.00%)      354.67 (   1.60%)
       Hmean     send-128        699.16 (   0.00%)      702.91 (   0.54%)
       Hmean     send-256       1316.34 (   0.00%)     1350.07 (   2.56%)
       Hmean     send-1024      5063.99 (   0.00%)     5124.38 (   1.19%)
       Hmean     send-2048      9705.19 (   0.00%)     9687.44 (  -0.18%)
       Hmean     send-3312     14359.48 (   0.00%)    14577.64 (   1.52%)
       Hmean     send-4096     16324.20 (   0.00%)    16393.62 (   0.43%)
       Hmean     send-8192     26112.61 (   0.00%)    26877.26 (   2.93%)
       Hmean     send-16384    37208.44 (   0.00%)    38683.43 (   3.96%)
       Hmean     recv-64         349.09 (   0.00%)      354.67 (   1.60%)
       Hmean     recv-128        699.16 (   0.00%)      702.91 (   0.54%)
       Hmean     recv-256       1316.34 (   0.00%)     1350.07 (   2.56%)
       Hmean     recv-1024      5063.99 (   0.00%)     5124.38 (   1.19%)
       Hmean     recv-2048      9705.16 (   0.00%)     9687.43 (  -0.18%)
       Hmean     recv-3312     14359.42 (   0.00%)    14577.59 (   1.52%)
       Hmean     recv-4096     16323.98 (   0.00%)    16393.55 (   0.43%)
       Hmean     recv-8192     26111.85 (   0.00%)    26876.96 (   2.93%)
       Hmean     recv-16384    37206.99 (   0.00%)    38682.41 (   3.97%)
      
      However, what is very interesting is how automatic NUMA balancing behaves.
      Each netperf instance runs long enough for balancing to activate:
      
       NUMA base PTE updates             4620        1473
       NUMA huge PMD updates                0           0
       NUMA page range updates           4620        1473
       NUMA hint faults                  4301        1383
       NUMA hint local faults            1309         451
       NUMA hint local percent             30          32
       NUMA pages migrated               1335         491
       AutoNUMA cost                      21%          6%
      
      There is an unfortunate number of remote faults although tracing indicated
      that the vast majority are in shared libraries. However, the tendency to
      start tasks on the same node if there is capacity means that there were
      far fewer PTE updates and faults incurred overall.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-6-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      2c833627
    • P
      sched/fair: Do not migrate due to a sync wakeup on exit · 24d0c1d6
      Peter Zijlstra 提交于
      When a task exits, it notifies the parent that it has exited. This is a
      sync wakeup and the exiting task may pull the parent towards the wakers
      CPU. For simple workloads like using a shell, it was observed that the
      shell is pulled across nodes by exiting processes. This is daft as the
      parent may be long-lived and properly placed. This patch special cases a
      sync wakeup on exit to avoid pulling tasks across nodes. Testing on a range
      of workloads and machines showed very little differences in performance
      although there was a small 3% boost on some machines running a shellscript
      intensive workload (git regression test suite).
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-5-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      24d0c1d6
    • M
      sched/fair: Do not migrate on wake_affine_weight() if weights are equal · 082f764a
      Mel Gorman 提交于
      wake_affine_weight() will consider migrating a task to, or near, the current
      CPU if there is a load imbalance. If the CPUs share LLC then either CPU
      is valid as a search-for-idle-sibling target and equally appropriate for
      stacking two tasks on one CPU if an idle sibling is unavailable. If they do
      not share cache then a cross-node migration potentially impacts locality
      so while they are equal from a CPU capacity point of view, they are not
      equal in terms of memory locality. In either case, it's more appropriate
      to migrate only if there is a difference in their effective load.
      
      This patch modifies wake_affine_weight() to only consider migrating a task
      if there is a load imbalance for normal wakeups but will allow potential
      stacking if the loads are equal and it's a sync wakeup.
      
      For the most part, the different in performance is marginal. For example,
      on a 4-socket server running netperf UDP_STREAM on localhost the differences
      are as follows:
      
                                            4.15.0                 4.15.0
                                             16rc0          noequal-v1r23
       Hmean     send-64         355.47 (   0.00%)      349.50 (  -1.68%)
       Hmean     send-128        697.98 (   0.00%)      693.35 (  -0.66%)
       Hmean     send-256       1328.02 (   0.00%)     1318.77 (  -0.70%)
       Hmean     send-1024      5051.83 (   0.00%)     5051.11 (  -0.01%)
       Hmean     send-2048      9637.02 (   0.00%)     9601.34 (  -0.37%)
       Hmean     send-3312     14355.37 (   0.00%)    14414.51 (   0.41%)
       Hmean     send-4096     16464.97 (   0.00%)    16301.37 (  -0.99%)
       Hmean     send-8192     26722.42 (   0.00%)    26428.95 (  -1.10%)
       Hmean     send-16384    38137.81 (   0.00%)    38046.11 (  -0.24%)
       Hmean     recv-64         355.47 (   0.00%)      349.50 (  -1.68%)
       Hmean     recv-128        697.98 (   0.00%)      693.35 (  -0.66%)
       Hmean     recv-256       1328.02 (   0.00%)     1318.77 (  -0.70%)
       Hmean     recv-1024      5051.83 (   0.00%)     5051.11 (  -0.01%)
       Hmean     recv-2048      9636.95 (   0.00%)     9601.30 (  -0.37%)
       Hmean     recv-3312     14355.32 (   0.00%)    14414.48 (   0.41%)
       Hmean     recv-4096     16464.74 (   0.00%)    16301.16 (  -0.99%)
       Hmean     recv-8192     26721.63 (   0.00%)    26428.17 (  -1.10%)
       Hmean     recv-16384    38136.00 (   0.00%)    38044.88 (  -0.24%)
       Stddev    send-64           7.30 (   0.00%)        4.75 (  34.96%)
       Stddev    send-128         15.15 (   0.00%)       22.38 ( -47.66%)
       Stddev    send-256         13.99 (   0.00%)       19.14 ( -36.81%)
       Stddev    send-1024       105.73 (   0.00%)       67.38 (  36.27%)
       Stddev    send-2048       294.57 (   0.00%)      223.88 (  24.00%)
       Stddev    send-3312       302.28 (   0.00%)      271.74 (  10.10%)
       Stddev    send-4096       195.92 (   0.00%)      121.10 (  38.19%)
       Stddev    send-8192       399.71 (   0.00%)      563.77 ( -41.04%)
       Stddev    send-16384     1163.47 (   0.00%)     1103.68 (   5.14%)
       Stddev    recv-64           7.30 (   0.00%)        4.75 (  34.96%)
       Stddev    recv-128         15.15 (   0.00%)       22.38 ( -47.66%)
       Stddev    recv-256         13.99 (   0.00%)       19.14 ( -36.81%)
       Stddev    recv-1024       105.73 (   0.00%)       67.38 (  36.27%)
       Stddev    recv-2048       294.59 (   0.00%)      223.89 (  24.00%)
       Stddev    recv-3312       302.24 (   0.00%)      271.75 (  10.09%)
       Stddev    recv-4096       196.03 (   0.00%)      121.14 (  38.20%)
       Stddev    recv-8192       399.86 (   0.00%)      563.65 ( -40.96%)
       Stddev    recv-16384     1163.79 (   0.00%)     1103.86 (   5.15%)
      
      The difference in overall performance is marginal but note that most
      measurements are less variable. There were similar observations for other
      netperf comparisons. hackbench with sockets or threads with processes or
      threads showed minor difference with some reduction of migration. tbench
      showed only marginal differences that were within the noise. dbench,
      regardless of filesystem, showed minor differences all of which are
      within noise. Multiple machines, both UMA and NUMA were tested without
      any regressions showing up.
      
      The biggest risk with a patch like this is affecting wakeup latencies.
      However, the schbench load from Facebook which is very sensitive to wakeup
      latency showed a mixed result with mostly improvements in wakeup latency:
      
                                            4.15.0                 4.15.0
                                             16rc0          noequal-v1r23
       Lat 50.00th-qrtle-1        38.00 (   0.00%)       38.00 (   0.00%)
       Lat 75.00th-qrtle-1        49.00 (   0.00%)       41.00 (  16.33%)
       Lat 90.00th-qrtle-1        52.00 (   0.00%)       50.00 (   3.85%)
       Lat 95.00th-qrtle-1        54.00 (   0.00%)       51.00 (   5.56%)
       Lat 99.00th-qrtle-1        63.00 (   0.00%)       60.00 (   4.76%)
       Lat 99.50th-qrtle-1        66.00 (   0.00%)       61.00 (   7.58%)
       Lat 99.90th-qrtle-1        78.00 (   0.00%)       65.00 (  16.67%)
       Lat 50.00th-qrtle-2        38.00 (   0.00%)       38.00 (   0.00%)
       Lat 75.00th-qrtle-2        42.00 (   0.00%)       43.00 (  -2.38%)
       Lat 90.00th-qrtle-2        46.00 (   0.00%)       48.00 (  -4.35%)
       Lat 95.00th-qrtle-2        49.00 (   0.00%)       50.00 (  -2.04%)
       Lat 99.00th-qrtle-2        55.00 (   0.00%)       57.00 (  -3.64%)
       Lat 99.50th-qrtle-2        58.00 (   0.00%)       60.00 (  -3.45%)
       Lat 99.90th-qrtle-2        65.00 (   0.00%)       68.00 (  -4.62%)
       Lat 50.00th-qrtle-4        41.00 (   0.00%)       41.00 (   0.00%)
       Lat 75.00th-qrtle-4        45.00 (   0.00%)       46.00 (  -2.22%)
       Lat 90.00th-qrtle-4        50.00 (   0.00%)       50.00 (   0.00%)
       Lat 95.00th-qrtle-4        54.00 (   0.00%)       53.00 (   1.85%)
       Lat 99.00th-qrtle-4        61.00 (   0.00%)       61.00 (   0.00%)
       Lat 99.50th-qrtle-4        65.00 (   0.00%)       64.00 (   1.54%)
       Lat 99.90th-qrtle-4        76.00 (   0.00%)       82.00 (  -7.89%)
       Lat 50.00th-qrtle-8        48.00 (   0.00%)       46.00 (   4.17%)
       Lat 75.00th-qrtle-8        55.00 (   0.00%)       54.00 (   1.82%)
       Lat 90.00th-qrtle-8        60.00 (   0.00%)       59.00 (   1.67%)
       Lat 95.00th-qrtle-8        63.00 (   0.00%)       63.00 (   0.00%)
       Lat 99.00th-qrtle-8        71.00 (   0.00%)       69.00 (   2.82%)
       Lat 99.50th-qrtle-8        74.00 (   0.00%)       73.00 (   1.35%)
       Lat 99.90th-qrtle-8        98.00 (   0.00%)       90.00 (   8.16%)
       Lat 50.00th-qrtle-16       56.00 (   0.00%)       55.00 (   1.79%)
       Lat 75.00th-qrtle-16       68.00 (   0.00%)       67.00 (   1.47%)
       Lat 90.00th-qrtle-16       77.00 (   0.00%)       78.00 (  -1.30%)
       Lat 95.00th-qrtle-16       82.00 (   0.00%)       84.00 (  -2.44%)
       Lat 99.00th-qrtle-16       90.00 (   0.00%)       93.00 (  -3.33%)
       Lat 99.50th-qrtle-16       93.00 (   0.00%)       97.00 (  -4.30%)
       Lat 99.90th-qrtle-16      110.00 (   0.00%)      110.00 (   0.00%)
       Lat 50.00th-qrtle-32       68.00 (   0.00%)       62.00 (   8.82%)
       Lat 75.00th-qrtle-32       90.00 (   0.00%)       83.00 (   7.78%)
       Lat 90.00th-qrtle-32      110.00 (   0.00%)      100.00 (   9.09%)
       Lat 95.00th-qrtle-32      122.00 (   0.00%)      111.00 (   9.02%)
       Lat 99.00th-qrtle-32      145.00 (   0.00%)      133.00 (   8.28%)
       Lat 99.50th-qrtle-32      154.00 (   0.00%)      143.00 (   7.14%)
       Lat 99.90th-qrtle-32     2316.00 (   0.00%)      515.00 (  77.76%)
       Lat 50.00th-qrtle-35       69.00 (   0.00%)       72.00 (  -4.35%)
       Lat 75.00th-qrtle-35       92.00 (   0.00%)       95.00 (  -3.26%)
       Lat 90.00th-qrtle-35      111.00 (   0.00%)      114.00 (  -2.70%)
       Lat 95.00th-qrtle-35      122.00 (   0.00%)      124.00 (  -1.64%)
       Lat 99.00th-qrtle-35      142.00 (   0.00%)      144.00 (  -1.41%)
       Lat 99.50th-qrtle-35      150.00 (   0.00%)      154.00 (  -2.67%)
       Lat 99.90th-qrtle-35     6104.00 (   0.00%)     5640.00 (   7.60%)
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-4-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      082f764a
    • M
      sched/fair: Defer calculation of 'prev_eff_load' in wake_affine_weight() until needed · eeb60398
      Mel Gorman 提交于
      On sync wakeups, the previous CPU effective load may not be used so delay
      the calculation until it's needed.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-3-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      eeb60398
    • M
      sched/fair: Avoid an unnecessary lookup of current CPU ID during wake_affine · 7ebb66a1
      Mel Gorman 提交于
      The only caller of wake_affine() knows the CPU ID. Pass it in instead of
      rechecking it.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Giovanni Gherdovich <ggherdovich@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180213133730.24064-2-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      7ebb66a1
  3. 13 2月, 2018 5 次提交
  4. 07 2月, 2018 1 次提交
  5. 06 2月, 2018 13 次提交
    • M
      sched/fair: Use a recently used CPU as an idle candidate and the basis for SIS · 32e839dd
      Mel Gorman 提交于
      The select_idle_sibling() (SIS) rewrite in commit:
      
        10e2f1ac ("sched/core: Rewrite and improve select_idle_siblings()")
      
      ... replaced a domain iteration with a search that broadly speaking
      does a wrapped walk of the scheduler domain sharing a last-level-cache.
      
      While this had a number of improvements, one consequence is that two tasks
      that share a waker/wakee relationship push each other around a socket. Even
      though two tasks may be active, all cores are evenly used. This is great from
      a search perspective and spreads a load across individual cores, but it has
      adverse consequences for cpufreq. As each CPU has relatively low utilisation,
      cpufreq may decide the utilisation is too low to used a higher P-state and
      overall computation throughput suffers.
      
      While individual cpufreq and cpuidle drivers may compensate by artifically
      boosting P-state (at c0) or avoiding lower C-states (during idle), it does
      not help if hardware-based cpufreq (e.g. HWP) is used.
      
      This patch tracks a recently used CPU based on what CPU a task was running
      on when it last was a waker a CPU it was recently using when a task is a
      wakee. During SIS, the recently used CPU is used as a target if it's still
      allowed by the task and is idle.
      
      The benefit may be non-obvious so consider an example of two tasks
      communicating back and forth. Task A may be an application doing IO where
      task B is a kworker or kthread like journald. Task A may issue IO, wake
      B and B wakes up A on completion.  With the existing scheme this may look
      like the following (potentially different IDs if SMT is in use but similar
      principal applies).
      
       A (cpu 0)	wake	B (wakes on cpu 1)
       B (cpu 1)	wake	A (wakes on cpu 2)
       A (cpu 2)	wake	B (wakes on cpu 3)
       etc.
      
      A careful reader may wonder why CPU 0 was not idle when B wakes A the
      first time and it's simply due to the fact that A can be rescheduled to
      another CPU and the pattern is that prev == target when B tries to wakeup A
      and the information about CPU 0 has been lost.
      
      With this patch, the pattern is more likely to be:
      
       A (cpu 0)	wake	B (wakes on cpu 1)
       B (cpu 1)	wake	A (wakes on cpu 0)
       A (cpu 0)	wake	B (wakes on cpu 1)
       etc
      
      i.e. two communicating casts are more likely to use just two cores instead
      of all available cores sharing a LLC.
      
      The most dramatic speedup was noticed on dbench using the XFS filesystem on
      UMA as clients interact heavily with workqueues in that configuration. Note
      that a similar speedup is not observed on ext4 as the wakeup pattern
      is different:
      
                                4.15.0-rc9             4.15.0-rc9
                                 waprev-v1        biasancestor-v1
       Hmean      1      287.54 (   0.00%)      817.01 ( 184.14%)
       Hmean      2     1268.12 (   0.00%)     1781.24 (  40.46%)
       Hmean      4     1739.68 (   0.00%)     1594.47 (  -8.35%)
       Hmean      8     2464.12 (   0.00%)     2479.56 (   0.63%)
       Hmean     64     1455.57 (   0.00%)     1434.68 (  -1.44%)
      
      The results can be less dramatic on NUMA where automatic balancing interferes
      with the test. It's also known that network benchmarks running on localhost
      also benefit quite a bit from this patch (roughly 10% on netperf RR for UDP
      and TCP depending on the machine). Hackbench also seens small improvements
      (6-11% depending on machine and thread count). The facebook schbench was also
      tested but in most cases showed little or no different to wakeup latencies.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180130104555.4125-5-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      32e839dd
    • M
      sched/fair: Do not migrate if the prev_cpu is idle · 806486c3
      Mel Gorman 提交于
      wake_affine_idle() prefers to move a task to the current CPU if the
      wakeup is due to an interrupt. The expectation is that the interrupt
      data is cache hot and relevant to the waking task as well as avoiding
      a search. However, there is no way to determine if there was cache hot
      data on the previous CPU that may exceed the interrupt data. Furthermore,
      round-robin delivery of interrupts can migrate tasks around a socket where
      each CPU is under-utilised.  This can interact badly with cpufreq which
      makes decisions based on per-cpu data. It has been observed on machines
      with HWP that p-states are not boosted to their maximum levels even though
      the workload is latency and throughput sensitive.
      
      This patch uses the previous CPU for the task if it's idle and cache-affine
      with the current CPU even if the current CPU is idle due to the wakup
      being related to the interrupt. This reduces migrations at the cost of
      the interrupt data not being cache hot when the task wakes.
      
      A variety of workloads were tested on various machines and no adverse
      impact was noticed that was outside noise. dbench on ext4 on UMA showed
      roughly 10% reduction in the number of CPU migrations and it is a case
      where interrupts are frequent for IO competions. In most cases, the
      difference in performance is quite small but variability is often
      reduced. For example, this is the result for pgbench running on a UMA
      machine with different numbers of clients.
      
                                4.15.0-rc9             4.15.0-rc9
                                  baseline              waprev-v1
       Hmean     1     22096.28 (   0.00%)    22734.86 (   2.89%)
       Hmean     4     74633.42 (   0.00%)    75496.77 (   1.16%)
       Hmean     7    115017.50 (   0.00%)   113030.81 (  -1.73%)
       Hmean     12   126209.63 (   0.00%)   126613.40 (   0.32%)
       Hmean     16   131886.91 (   0.00%)   130844.35 (  -0.79%)
       Stddev    1       636.38 (   0.00%)      417.11 (  34.46%)
       Stddev    4       614.64 (   0.00%)      583.24 (   5.11%)
       Stddev    7       542.46 (   0.00%)      435.45 (  19.73%)
       Stddev    12      173.93 (   0.00%)      171.50 (   1.40%)
       Stddev    16      671.42 (   0.00%)      680.30 (  -1.32%)
       CoeffVar  1         2.88 (   0.00%)        1.83 (  36.26%)
      
      Note that the different in performance is marginal but for low utilisation,
      there is less variability.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180130104555.4125-4-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      806486c3
    • M
      sched/fair: Restructure wake_affine*() to return a CPU id · 3b76c4a3
      Mel Gorman 提交于
      This is a preparation patch that has wake_affine*() return a CPU ID instead of
      a boolean. The intent is to allow the wake_affine() helpers to be avoided
      if a decision is already made. This patch has no functional change.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180130104555.4125-3-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      3b76c4a3
    • M
      sched/fair: Remove unnecessary parameters from wake_affine_idle() · 89a55f56
      Mel Gorman 提交于
      wake_affine_idle() takes parameters it never uses so clean it up.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180130104555.4125-2-mgorman@techsingularity.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      89a55f56
    • W
      sched/rt: Make update_curr_rt() more accurate · e7ad2031
      Wen Yang 提交于
      rq->clock_task may be updated between the two calls of
      rq_clock_task() in update_curr_rt(). Calling rq_clock_task() only
      once makes it more accurate and efficient, taking update_curr() as
      reference.
      Signed-off-by: NWen Yang <wen.yang99@zte.com.cn>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NJiang Biao <jiang.biao2@zte.com.cn>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: zhong.weidong@zte.com.cn
      Link: http://lkml.kernel.org/r/1517800721-42092-1-git-send-email-wen.yang99@zte.com.cnSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e7ad2031
    • S
      sched/rt: Up the root domain ref count when passing it around via IPIs · 364f5665
      Steven Rostedt (VMware) 提交于
      When issuing an IPI RT push, where an IPI is sent to each CPU that has more
      than one RT task scheduled on it, it references the root domain's rto_mask,
      that contains all the CPUs within the root domain that has more than one RT
      task in the runable state. The problem is, after the IPIs are initiated, the
      rq->lock is released. This means that the root domain that is associated to
      the run queue could be freed while the IPIs are going around.
      
      Add a sched_get_rd() and a sched_put_rd() that will increment and decrement
      the root domain's ref count respectively. This way when initiating the IPIs,
      the scheduler will up the root domain's ref count before releasing the
      rq->lock, ensuring that the root domain does not go away until the IPI round
      is complete.
      Reported-by: NPavan Kondeti <pkondeti@codeaurora.org>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 4bdced5c ("sched/rt: Simplify the IPI based RT balancing logic")
      Link: http://lkml.kernel.org/r/CAEU1=PkiHO35Dzna8EQqNSKW1fr1y1zRQ5y66X117MG06sQtNA@mail.gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      364f5665
    • S
      sched/rt: Use container_of() to get root domain in rto_push_irq_work_func() · ad0f1d9d
      Steven Rostedt (VMware) 提交于
      When the rto_push_irq_work_func() is called, it looks at the RT overloaded
      bitmask in the root domain via the runqueue (rq->rd). The problem is that
      during CPU up and down, nothing here stops rq->rd from changing between
      taking the rq->rd->rto_lock and releasing it. That means the lock that is
      released is not the same lock that was taken.
      
      Instead of using this_rq()->rd to get the root domain, as the irq work is
      part of the root domain, we can simply get the root domain from the irq work
      that is passed to the routine:
      
       container_of(work, struct root_domain, rto_push_work)
      
      This keeps the root domain consistent.
      Reported-by: NPavan Kondeti <pkondeti@codeaurora.org>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 4bdced5c ("sched/rt: Simplify the IPI based RT balancing logic")
      Link: http://lkml.kernel.org/r/CAEU1=PkiHO35Dzna8EQqNSKW1fr1y1zRQ5y66X117MG06sQtNA@mail.gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ad0f1d9d
    • P
      sched/core: Optimize update_stats_*() · 2ed41a55
      Peter Zijlstra 提交于
      These functions are already gated by schedstats_enabled(), there is no
      point in then issuing another static_branch for every individual
      update in them.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2ed41a55
    • P
      sched/core: Optimize ttwu_stat() · b85c8b71
      Peter Zijlstra 提交于
      The whole of ttwu_stat() is guarded by a single schedstat_enabled(),
      there is absolutely no point in then issuing another static_branch for
      every single schedstat_inc() in there.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b85c8b71
    • M
      membarrier: Provide core serializing command, *_SYNC_CORE · 70216e18
      Mathieu Desnoyers 提交于
      Provide core serializing membarrier command to support memory reclaim
      by JIT.
      
      Each architecture needs to explicitly opt into that support by
      documenting in their architecture code how they provide the core
      serializing instructions required when returning from the membarrier
      IPI, and after the scheduler has updated the curr->mm pointer (before
      going back to user-space). They should then select
      ARCH_HAS_MEMBARRIER_SYNC_CORE to enable support for that command on
      their architecture.
      
      Architectures selecting this feature need to either document that
      they issue core serializing instructions when returning to user-space,
      or implement their architecture-specific sync_core_before_usermode().
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrea Parri <parri.andrea@gmail.com>
      Cc: Andrew Hunter <ahh@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Avi Kivity <avi@scylladb.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dave Watson <davejwatson@fb.com>
      Cc: David Sehr <sehr@google.com>
      Cc: Greg Hackmann <ghackmann@google.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Maged Michael <maged.michael@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-api@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180129202020.8515-9-mathieu.desnoyers@efficios.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      70216e18
    • M
      membarrier: Provide GLOBAL_EXPEDITED command · c5f58bd5
      Mathieu Desnoyers 提交于
      Allow expedited membarrier to be used for data shared between processes
      through shared memory.
      
      Processes wishing to receive the membarriers register with
      MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED. Those which want to issue
      membarrier invoke MEMBARRIER_CMD_GLOBAL_EXPEDITED.
      
      This allows extremely simple kernel-level implementation: we have almost
      everything we need with the PRIVATE_EXPEDITED barrier code. All we need
      to do is to add a flag in the mm_struct that will be used to check
      whether we need to send the IPI to the current thread of each CPU.
      
      There is a slight downside to this approach compared to targeting
      specific shared memory users: when performing a membarrier operation,
      all registered "global" receivers will get the barrier, even if they
      don't share a memory mapping with the sender issuing
      MEMBARRIER_CMD_GLOBAL_EXPEDITED.
      
      This registration approach seems to fit the requirement of not
      disturbing processes that really deeply care about real-time: they
      simply should not register with MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED.
      
      In order to align the membarrier command names, the "MEMBARRIER_CMD_SHARED"
      command is renamed to "MEMBARRIER_CMD_GLOBAL", keeping an alias of
      MEMBARRIER_CMD_SHARED to MEMBARRIER_CMD_GLOBAL for UAPI header backward
      compatibility.
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrea Parri <parri.andrea@gmail.com>
      Cc: Andrew Hunter <ahh@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Avi Kivity <avi@scylladb.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dave Watson <davejwatson@fb.com>
      Cc: David Sehr <sehr@google.com>
      Cc: Greg Hackmann <ghackmann@google.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Maged Michael <maged.michael@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-api@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180129202020.8515-5-mathieu.desnoyers@efficios.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c5f58bd5
    • M
      membarrier: Document scheduler barrier requirements · 306e0604
      Mathieu Desnoyers 提交于
      Document the membarrier requirement on having a full memory barrier in
      __schedule() after coming from user-space, before storing to rq->curr.
      It is provided by smp_mb__after_spinlock() in __schedule().
      
      Document that membarrier requires a full barrier on transition from
      kernel thread to userspace thread. We currently have an implicit barrier
      from atomic_dec_and_test() in mmdrop() that ensures this.
      
      The x86 switch_mm_irqs_off() full barrier is currently provided by many
      cpumask update operations as well as write_cr3(). Document that
      write_cr3() provides this barrier.
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrea Parri <parri.andrea@gmail.com>
      Cc: Andrew Hunter <ahh@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Avi Kivity <avi@scylladb.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dave Watson <davejwatson@fb.com>
      Cc: David Sehr <sehr@google.com>
      Cc: Greg Hackmann <ghackmann@google.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Maged Michael <maged.michael@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-api@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180129202020.8515-4-mathieu.desnoyers@efficios.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      306e0604
    • M
      powerpc, membarrier: Skip memory barrier in switch_mm() · 3ccfebed
      Mathieu Desnoyers 提交于
      Allow PowerPC to skip the full memory barrier in switch_mm(), and
      only issue the barrier when scheduling into a task belonging to a
      process that has registered to use expedited private.
      
      Threads targeting the same VM but which belong to different thread
      groups is a tricky case. It has a few consequences:
      
      It turns out that we cannot rely on get_nr_threads(p) to count the
      number of threads using a VM. We can use
      (atomic_read(&mm->mm_users) == 1 && get_nr_threads(p) == 1)
      instead to skip the synchronize_sched() for cases where the VM only has
      a single user, and that user only has a single thread.
      
      It also turns out that we cannot use for_each_thread() to set
      thread flags in all threads using a VM, as it only iterates on the
      thread group.
      
      Therefore, test the membarrier state variable directly rather than
      relying on thread flags. This means
      membarrier_register_private_expedited() needs to set the
      MEMBARRIER_STATE_PRIVATE_EXPEDITED flag, issue synchronize_sched(), and
      only then set MEMBARRIER_STATE_PRIVATE_EXPEDITED_READY which allows
      private expedited membarrier commands to succeed.
      membarrier_arch_switch_mm() now tests for the
      MEMBARRIER_STATE_PRIVATE_EXPEDITED flag.
      Signed-off-by: NMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Andrea Parri <parri.andrea@gmail.com>
      Cc: Andrew Hunter <ahh@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Avi Kivity <avi@scylladb.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dave Watson <davejwatson@fb.com>
      Cc: David Sehr <sehr@google.com>
      Cc: Greg Hackmann <ghackmann@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Maged Michael <maged.michael@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: linux-api@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lkml.kernel.org/r/20180129202020.8515-3-mathieu.desnoyers@efficios.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      3ccfebed
  6. 24 1月, 2018 1 次提交
  7. 16 1月, 2018 1 次提交
    • J
      delayacct: Account blkio completion on the correct task · c96f5471
      Josh Snyder 提交于
      Before commit:
      
        e33a9bba ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler")
      
      delayacct_blkio_end() was called after context-switching into the task which
      completed I/O.
      
      This resulted in double counting: the task would account a delay both waiting
      for I/O and for time spent in the runqueue.
      
      With e33a9bba, delayacct_blkio_end() is called by try_to_wake_up().
      In ttwu, we have not yet context-switched. This is more correct, in that
      the delay accounting ends when the I/O is complete.
      
      But delayacct_blkio_end() relies on 'get_current()', and we have not yet
      context-switched into the task whose I/O completed. This results in the
      wrong task having its delay accounting statistics updated.
      
      Instead of doing that, pass the task_struct being woken to delayacct_blkio_end(),
      so that it can update the statistics of the correct task.
      Signed-off-by: NJosh Snyder <joshs@netflix.com>
      Acked-by: NTejun Heo <tj@kernel.org>
      Acked-by: NBalbir Singh <bsingharora@gmail.com>
      Cc: <stable@vger.kernel.org>
      Cc: Brendan Gregg <bgregg@netflix.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-block@vger.kernel.org
      Fixes: e33a9bba ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler")
      Link: http://lkml.kernel.org/r/1513613712-571-1-git-send-email-joshs@netflix.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c96f5471
  8. 10 1月, 2018 8 次提交