14 Aug, 2013

6 commits

  • If no CPU is in the full dynticks range, we can avoid the full
    dynticks cputime accounting through generic vtime along with its
    overhead and use the traditional tick based accounting instead.

    Let's do this and nope the off case with static keys.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • We plan to use the context tracking static key on inline
    vtime APIs. For this we need to include the context tracking
    headers from those of vtime.

    However vtime headers need to stay low level because they are
    included in hardirq.h that mostly contains standalone
    definitions. But context_tracking.h includes sched.h for
    a few task_struct references, therefore it wouldn't be sensible
    to include it from vtime.h

    To solve this, lets split the context tracking headers and move
    out the pure state definitions that only require a few low level
    headers. We can safely include that small part in vtime.h later.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • No need for syscall slowpath if no CPU is full dynticks,
    rather nop this in this case.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • Optimize guest entry/exit APIs with static keys. This minimize
    the overhead for those who enable CONFIG_NO_HZ_FULL without
    always using it. Having no range passed to nohz_full= should
    result in the probes overhead to be minimized.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • Optimize user and exception entry/exit APIs with static
    keys. This minimize the overhead for those who enable
    CONFIG_NO_HZ_FULL without always using it. Having no range
    passed to nohz_full= should result in the probes to be nopped
    (at least we hope so...).

    If this proves not be enough in the long term, we'll need
    to bring an exception slow path by re-routing the exception
    handlers.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • Prepare for using a static key in the context tracking subsystem.
    This will help optimizing the off case on its many users:

    * user_enter, user_exit, exception_enter, exception_exit, guest_enter,
    guest_exit, vtime_*()

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     

13 Aug, 2013

3 commits

  • The context tracking subsystem has the ability to selectively
    enable the tracking on any defined subset of CPU. This means that
    we can define a CPU range that doesn't run the context tracking
    and another range that does.

    Now what we want in practice is to enable the tracking on full
    dynticks CPUs only. In order to perform this, we just need to pass
    our full dynticks CPU range selection from the full dynticks
    subsystem to the context tracking.

    This way we can spare the overhead of RCU user extended quiescent
    state and vtime maintainance on the CPUs that are outside the
    full dynticks range. Just keep in mind the raw context tracking
    itself is still necessary everywhere.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • Update a stale comment from the old vtime era and document some
    locking that might be non obvious.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     
  • 1) If context tracking is enabled with native vtime accounting (which
    combo is useless except for dev testing), we call vtime_guest_enter()
    and vtime_guest_exit() on host guest switches. But those are stubs
    in this configurations. As a result, cputime is not correctly flushed
    on kvm context switches.

    2) If context tracking runs but is disabled on some CPUs, those
    CPUs end up calling __guest_enter/__guest_exit which in turn
    call vtime_account_system(). We don't want to call this because we
    run in tick based accounting for these CPUs.

    Refactor the guest_enter/guest_exit code such that all combinations
    finally work.

    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Borislav Petkov
    Cc: Li Zhong
    Cc: Mike Galbraith
    Cc: Kevin Hilman

    Frederic Weisbecker
     

31 May, 2013

1 commit

  • The kvm_host.h header file doesn't handle well
    inclusion when archs don't support KVM.

    This results in build crashes for such archs when they
    want to implement context tracking because this subsystem
    includes kvm_host.h in order to implement the
    guest_enter/exit APIs but it doesn't handle KVM off case.

    To fix this, move the guest_enter()/guest_exit()
    declarations and generic implementation to the context
    tracking headers. These generic APIs actually belong to
    this subsystem, besides other domains boundary tracking
    like user_enter() et al.

    KVM now properly becomes a user of this library, not the
    other buggy way around.

    Reported-by: Kevin Hilman
    Reviewed-by: Kevin Hilman
    Tested-by: Kevin Hilman
    Signed-off-by: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul E. McKenney
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Kevin Hilman
    Cc: Marcelo Tosatti
    Cc: Gleb Natapov
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     

08 Mar, 2013

2 commits

  • On exception exit, we restore the previous context tracking state based on
    the regs of the interrupted frame. Iff that frame is in user mode as
    stated by user_mode() helper, we restore the context tracking user mode.

    However there is a tiny chunck of low level arch code after we pass through
    user_enter() and until the CPU eventually resumes userspace.
    If an exception happens in this tiny area, exception_enter() correctly
    exits the context tracking user mode but exception_exit() won't restore
    it because of the value returned by user_mode(regs).

    As a result we may return to userspace with the wrong context tracking
    state.

    To fix this, change exception_enter() to return the context tracking state
    prior to its call and pass this saved state to exception_exit(). This restores
    the real context tracking state of the interrupted frame.

    (May be this patch was suggested to me, I don't recall exactly. If so,
    sorry for the missing credit).

    Signed-off-by: Frederic Weisbecker
    Cc: Li Zhong
    Cc: Kevin Hilman
    Cc: Mats Liljegren
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Namhyung Kim
    Cc: Andrew Morton
    Cc: Thomas Gleixner
    Cc: Paul E. McKenney

    Frederic Weisbecker
     
  • Exceptions handling on context tracking should share common
    treatment: on entry we exit user mode if the exception triggered
    in that context. Then on exception exit we return to that previous
    context.

    Generalize this to avoid duplication across archs.

    Signed-off-by: Frederic Weisbecker
    Cc: Li Zhong
    Cc: Kevin Hilman
    Cc: Mats Liljegren
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Namhyung Kim
    Cc: Andrew Morton
    Cc: Thomas Gleixner
    Cc: Paul E. McKenney

    Frederic Weisbecker
     

27 Jan, 2013

1 commit

  • Export the context state: whether we run in user / kernel
    from the context tracking subsystem point of view.

    This is going to be used by the generic virtual cputime
    accounting subsystem that is needed to implement the full
    dynticks.

    Signed-off-by: Frederic Weisbecker
    Cc: Andrew Morton
    Cc: Ingo Molnar
    Cc: Li Zhong
    Cc: Namhyung Kim
    Cc: Paul E. McKenney
    Cc: Paul Gortmaker
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner

    Frederic Weisbecker
     

01 Dec, 2012

1 commit

  • Create a new subsystem that probes on kernel boundaries
    to keep track of the transitions between level contexts
    with two basic initial contexts: user or kernel.

    This is an abstraction of some RCU code that use such tracking
    to implement its userspace extended quiescent state.

    We need to pull this up from RCU into this new level of indirection
    because this tracking is also going to be used to implement an "on
    demand" generic virtual cputime accounting. A necessary step to
    shutdown the tick while still accounting the cputime.

    Signed-off-by: Frederic Weisbecker
    Cc: Andrew Morton
    Cc: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Cc: Li Zhong
    Cc: Gilad Ben-Yossef
    Reviewed-by: Steven Rostedt
    [ paulmck: fix whitespace error and email address. ]
    Signed-off-by: Paul E. McKenney

    Frederic Weisbecker