mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "ning.le" <ning.le@h3c.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
	<juri.lelli@redhat.com>, <vincent.guittot@linaro.org>
Cc: <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>,
	<bsegall@google.com>, <mgorman@suse.de>,
	<linux-kernel@vger.kernel.org>, <he.feng@h3c.com>,
	"ning.le" <ning.le@h3c.com>
Subject: [PATCH] sched/cpuacct:Fix previous bugs submitted in history.
Date: Mon, 3 Aug 2020 15:14:06 +0000	[thread overview]
Message-ID: <20200803151406.59465-1-ning.le@h3c.com> (raw)

Historical submission introduces new issues that When the current cpu
wakes up the thread which works on other cores,the cpuacct module may
add the execution time of thread which on the the other core's rq to
the current core's cpuusage.

Signed-off-by: ning.le <ning.le@h3c.com>
---
 kernel/sched/cpuacct.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/cpuacct.c b/kernel/sched/cpuacct.c
index 941c28cf9738..bd38c9cffdd6 100644
--- a/kernel/sched/cpuacct.c
+++ b/kernel/sched/cpuacct.c
@@ -341,6 +341,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
        struct cpuacct *ca;
        int index = CPUACCT_STAT_SYSTEM;
        struct pt_regs *regs = get_irq_regs() ? : task_pt_regs(tsk);
+ int cpu = task_cpu(tsk);

        if (regs && user_mode(regs))
                index = CPUACCT_STAT_USER;
@@ -348,8 +349,7 @@ void cpuacct_charge(struct task_struct *tsk, u64 cputime)
        rcu_read_lock();

        for (ca = task_ca(tsk); ca; ca = parent_ca(ca))
-               __this_cpu_add(ca->cpuusage->usages[index], cputime);
-
+   per_cpu_ptr(ca->cpuusage, cpu)->usages[index] += cputime;
        rcu_read_unlock();
 }

--
2.17.1

-------------------------------------------------------------------------------------------------------------------------------------
±¾Óʼþ¼°Æä¸½¼þº¬ÓÐлªÈý¼¯Íŵı£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгö
µÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈÎºÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØÐ¹Â¶¡¢¸´ÖÆ¡¢
»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾
Óʼþ£¡
This e-mail and its attachments contain confidential information from New H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!

                 reply	other threads:[~2020-08-03 15:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200803151406.59465-1-ning.le@h3c.com \
    --to=ning.le@h3c.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=he.feng@h3c.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®