lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 17 Apr 2020 11:11:34 +0800
From:   Muchun Song <songmuchun@...edance.com>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     mingo@...hat.com, Peter Zijlstra <peterz@...radead.org>,
        juri.lelli@...hat.com,
        Vincent Guittot <vincent.guittot@...aro.org>,
        dietmar.eggemann@....com, Benjamin Segall <bsegall@...gle.com>,
        mgorman@...e.de, mingo@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [External] Re: [PATCH] sched/cpuacct: Fix charge
 cpuacct.usage_sys incorrently.

On Fri, Apr 17, 2020 at 12:01 AM Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Thu, 16 Apr 2020 11:35:02 -0400
> Steven Rostedt <rostedt@...dmis.org> wrote:
>
> > On Thu, 16 Apr 2020 22:18:33 +0800
> > Muchun Song <songmuchun@...edance.com> wrote:
> >
> > > The user_mode(task_pt_regs(tsk)) always return true for
> > > user thread, and false for kernel thread. So it means that
> > > the cpuacct.usage_sys is the time that kernel thread uses
> > > not the time that thread uses in the kernel mode. We can
> > > use get_irq_regs() instead of task_pt_regs() to fix it.
> > >
> > > Signed-off-by: Muchun Song <songmuchun@...edance.com>
> > > ---
> > >  kernel/sched/cpuacct.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
> > > index 6448b0438ffb2..edfc62554648e 100644
> > > --- a/kernel/sched/cpuacct.c
> > > +++ b/kernel/sched/cpuacct.c
> > > @@ -5,6 +5,7 @@
> > >   * Based on the work by Paul Menage (menage@...gle.com) and Balbir Singh
> > >   * (balbir@...ibm.com).
> > >   */
> > > +#include <asm/irq_regs.h>
> > >  #include "sched.h"
> > >
> > >  /* Time spent by the tasks of the CPU accounting group executing in ... */
> > > @@ -339,7 +340,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
> > >  {
> > >     struct cpuacct *ca;
> > >     int index = CPUACCT_STAT_SYSTEM;
> > > -   struct pt_regs *regs = task_pt_regs(tsk);
> > > +   struct pt_regs *regs = get_irq_regs();
> >
> > But get_irq_regs() is only available from interrupt context. This will be
> > NULL most the time, whereas the original way will have regs existing for
> > the task.
>
> Perhaps you want:
>
>         regs = get_irqs_regs();
>         if (!regs)
>                 regs = task_pt_regs(tsk);
>
> ?

Yeah, If regs is NULL, we can get it fall back to task_pt_regs.
Does Anyone else have suggestions?

>
> -- Steve
>
> >
> > >
> > >     if (regs && user_mode(regs))
> > >             index = CPUACCT_STAT_USER;
> >

-- 
Yours,
Muchun

Powered by blists - more mailing lists