mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chenridong <chenridong@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: <lizefan.x@bytedance.com>, <hannes@cmpxchg.org>,
	<longman@redhat.com>, <cgroups@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 -next] cgroup/rstat: add force idle show helper
Date: Wed, 3 Jul 2024 10:30:05 +0800	[thread overview]
Message-ID: <46f19c68-6296-49fe-b684-67625666ca1e@huawei.com> (raw)
In-Reply-To: <ZoQ2ti7nnz9EJSc3@slm.duckdns.org>



On 2024/7/3 1:19, Tejun Heo wrote:
> Hello,
> 
> On Tue, Jul 02, 2024 at 02:28:22AM +0000, Chen Ridong wrote:
> ...
>>   	if (cgroup_parent(cgrp)) {
>>   		cgroup_rstat_flush_hold(cgrp);
>>   		usage = cgrp->bstat.cputime.sum_exec_runtime;
>>   		cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
>>   			       &utime, &stime);
>> -#ifdef CONFIG_SCHED_CORE
>> -		forceidle_time = cgrp->bstat.forceidle_sum;
>> -#endif
>> +		bstat = cgrp->bstat;
> 
> Please don't copy non-trivial struct like this. Maybe add a pointer which
> points to the bstat to use?
> 
> Thanks.
> 

I don't wanna add a pointer. If I add pointer,to prevent the situation 
where a variable is unused when CONFIG_SCHED_CORE is disable, I have to 
add #ifdef CONFIG_SCHED_CORE again.
We do not actually need to define bstat. The cgrp->bstat of root is not 
actually used, maybe we can simply use cgrp->bstat directly as below.

void cgroup_base_stat_cputime_show(struct seq_file *seq)
  {
         struct cgroup *cgrp = seq_css(seq)->cgroup;
         u64 usage, utime, stime;
-       struct cgroup_base_stat bstat;
-#ifdef CONFIG_SCHED_CORE
-       u64 forceidle_time;
-#endif

         if (cgroup_parent(cgrp)) {
                 cgroup_rstat_flush_hold(cgrp);
                 usage = cgrp->bstat.cputime.sum_exec_runtime;
                 cputime_adjust(&cgrp->bstat.cputime, &cgrp->prev_cputime,
                                &utime, &stime);
-#ifdef CONFIG_SCHED_CORE
-               forceidle_time = cgrp->bstat.forceidle_sum;
-#endif
                 cgroup_rstat_flush_release(cgrp);
         } else {
-               root_cgroup_cputime(&bstat);
-               usage = bstat.cputime.sum_exec_runtime;
-               utime = bstat.cputime.utime;
-               stime = bstat.cputime.stime;
-#ifdef CONFIG_SCHED_CORE
-               forceidle_time = bstat.forceidle_sum;
-#endif
+               root_cgroup_cputime(&cgrp->bstat);
+               usage = cgrp->bstat.cputime.sum_exec_runtime;
+               utime = cgrp->bstat.cputime.utime;
+               stime = cgrp->bstat.cputime.stime;
         }

         do_div(usage, NSEC_PER_USEC);
         do_div(utime, NSEC_PER_USEC);
         do_div(stime, NSEC_PER_USEC);
-#ifdef CONFIG_SCHED_CORE
-       do_div(forceidle_time, NSEC_PER_USEC);
-#endif

         seq_printf(seq, "usage_usec %llu\n"
                    "user_usec %llu\n"
                    "system_usec %llu\n",
                    usage, utime, stime);

-#ifdef CONFIG_SCHED_CORE
-       seq_printf(seq, "core_sched.force_idle_usec %llu\n", 
forceidle_time);
-#endif
+       cgroup_force_idle_show(seq, &cgrp->bstat);
  }

      reply	other threads:[~2024-07-03  2:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02  2:28 Chen Ridong
2024-07-02 17:19 ` Tejun Heo
2024-07-03  2:30   ` chenridong [this message]

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=46f19c68-6296-49fe-b684-67625666ca1e@huawei.com \
    --to=chenridong@huawei.com \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=longman@redhat.com \
    --cc=tj@kernel.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®