1. 24 4月, 2020 1 次提交
  2. 06 11月, 2019 1 次提交
    • F
      sched/vtime: Fix guest/system mis-accounting on task switch · 2cd003a8
      Frederic Weisbecker 提交于
      [ Upstream commit 68e7a4d66b0ce04bf18ff2ffded5596ab3618585 ]
      
      vtime_account_system() assumes that the target task to account cputime
      to is always the current task. This is most often true indeed except on
      task switch where we call:
      
      	vtime_common_task_switch(prev)
      		vtime_account_system(prev)
      
      Here prev is the scheduling-out task where we account the cputime to. It
      doesn't match current that is already the scheduling-in task at this
      stage of the context switch.
      
      So we end up checking the wrong task flags to determine if we are
      accounting guest or system time to the previous task.
      
      As a result the wrong task is used to check if the target is running in
      guest mode. We may then spuriously account or leak either system or
      guest time on task switch.
      
      Fix this assumption and also turn vtime_guest_enter/exit() to use the
      task passed in parameter as well to avoid future similar issues.
      Signed-off-by: NFrederic Weisbecker <frederic@kernel.org>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wanpeng Li <wanpengli@tencent.com>
      Fixes: 2a42eb95 ("sched/cputime: Accumulate vtime on top of nsec clocksource")
      Link: https://lkml.kernel.org/r/20190925214242.21873-1-frederic@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2cd003a8
  3. 04 3月, 2018 1 次提交
    • I
      sched/headers: Simplify and clean up header usage in the scheduler · 325ea10c
      Ingo Molnar 提交于
      Do the following cleanups and simplifications:
      
       - sched/sched.h already includes <asm/paravirt.h>, so no need to
         include it in sched/core.c again.
      
       - order the <linux/sched/*.h> headers alphabetically
      
       - add all <linux/sched/*.h> headers to kernel/sched/sched.h
      
       - remove all unnecessary includes from the .c files that
         are already included in kernel/sched/sched.h.
      
      Finally, make all scheduler .c files use a single common header:
      
        #include "sched.h"
      
      ... which now contains a union of the relied upon headers.
      
      This makes the various .c files easier to read and easier to handle.
      
      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>
      325ea10c
  4. 03 3月, 2018 1 次提交
    • I
      sched: Clean up and harmonize the coding style of the scheduler code base · 97fb7a0a
      Ingo Molnar 提交于
      A good number of small style inconsistencies have accumulated
      in the scheduler core, so do a pass over them to harmonize
      all these details:
      
       - fix speling in comments,
      
       - use curly braces for multi-line statements,
      
       - remove unnecessary parentheses from integer literals,
      
       - capitalize consistently,
      
       - remove stray newlines,
      
       - add comments where necessary,
      
       - remove invalid/unnecessary comments,
      
       - align structure definitions and other data types vertically,
      
       - add missing newlines for increased readability,
      
       - fix vertical tabulation where it's misaligned,
      
       - harmonize preprocessor conditional block labeling
         and vertical alignment,
      
       - remove line-breaks where they uglify the code,
      
       - add newline after local variable definitions,
      
      No change in functionality:
      
        md5:
           1191fa0a890cfa8132156d2959d7e9e2  built-in.o.before.asm
           1191fa0a890cfa8132156d2959d7e9e2  built-in.o.after.asm
      
      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>
      97fb7a0a
  5. 08 11月, 2017 1 次提交
  6. 26 9月, 2017 1 次提交
  7. 25 9月, 2017 2 次提交
  8. 14 7月, 2017 1 次提交
    • W
      sched/cputime: Don't use smp_processor_id() in preemptible context · 0e4097c3
      Wanpeng Li 提交于
      Recent kernels trigger this warning:
      
       BUG: using smp_processor_id() in preemptible [00000000] code: 99-trinity/181
       caller is debug_smp_processor_id+0x17/0x19
       CPU: 0 PID: 181 Comm: 99-trinity Not tainted 4.12.0-01059-g2a42eb95 #1
       Call Trace:
        dump_stack+0x82/0xb8
        check_preemption_disabled()
        debug_smp_processor_id()
        vtime_delta()
        task_cputime()
        thread_group_cputime()
        thread_group_cputime_adjusted()
        wait_consider_task()
        do_wait()
        SYSC_wait4()
        do_syscall_64()
        entry_SYSCALL64_slow_path()
      
      As Frederic pointed out:
      
      | Although those sched_clock_cpu() things seem to only matter when the
      | sched_clock() is unstable. And that stability is a condition for nohz_full
      | to work anyway. So probably sched_clock() alone would be enough.
      
      This patch fixes it by replacing sched_clock_cpu() with sched_clock() to
      avoid calling smp_processor_id() in a preemptible context.
      Reported-by: NXiaolong Ye <xiaolong.ye@intel.com>
      Signed-off-by: NWanpeng Li <wanpeng.li@hotmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1499586028-7402-1-git-send-email-wanpeng.li@hotmail.com
      [ Prettified the changelog. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      0e4097c3
  9. 05 7月, 2017 5 次提交
  10. 04 7月, 2017 1 次提交
    • I
      Revert "sched/cputime: Refactor the cputime_adjust() code" · 3b9c08ae
      Ingo Molnar 提交于
      This reverts commit 72298e5c.
      
      As Peter explains:
      
      > Argh, no... That code was perfectly fine. The new code otoh is
      > convoluted.
      >
      > The old code had the following form:
      >
      >         if (exception1)
      >           deal with exception1
      >
      >         if (execption2)
      >           deal with exception2
      >
      >         do normal stuff
      >
      > Which is as simple and straight forward as it gets.
      >
      > The new code otoh reads like:
      >
      >         if (!exception1) {
      >                 if (exception2)
      >                   deal with exception 2
      >                 else
      >                   do normal stuff
      >         }
      
      So restore the old form.
      
      Also fix the comment describing the logic, as it was confusing.
      Requested-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Gustavo A. R. Silva <garsilva@embeddedor.com>
      Cc: Frans Klaver <fransklaver@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Stanislaw Gruszka <sgruszka@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wanpeng Li <wanpeng.li@hotmail.com>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      3b9c08ae
  11. 30 6月, 2017 1 次提交
  12. 27 4月, 2017 1 次提交
  13. 02 3月, 2017 2 次提交
  14. 01 2月, 2017 11 次提交
  15. 14 1月, 2017 3 次提交
  16. 15 11月, 2016 3 次提交
  17. 30 9月, 2016 4 次提交