Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1710576 > unrolled thread

Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting

Started byTejun Heo <tj@kernel.org>
First post2017-08-13 21:50 +0200
Last post2017-08-14 01:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting Tejun Heo <tj@kernel.org> - 2017-08-13 21:50 +0200
    Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting Waiman Long <longman@redhat.com> - 2017-08-14 01:30 +0200

#1710576 — Re: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting

FromTejun Heo <tj@kernel.org>
Date2017-08-13 21:50 +0200
SubjectRe: [PATCH 3/3] cgroup: Implement cgroup2 basic CPU usage accounting
Message-ID<ue73z-2MD-1@gated-at.bofh.it>
Hello, Waiman.

On Fri, Aug 11, 2017 at 04:19:07PM -0400, Waiman Long wrote:
> > * CPU usage stats are collected and shown in "cgroup.stat" with "cpu."
> >   prefix.  Total usage is collected from scheduling events.  User/sys
> >   breakdown is sourced from tick sampling and adjusted to the usage
> >   using cputime_adjuts().
> 
> Typo: cputime_adjust()

Oops, will fix.

> > +static DEFINE_MUTEX(cgroup_stat_mutex);
> > +static DEFINE_PER_CPU(raw_spinlock_t, cgroup_cpu_stat_lock);
> 
> If the hierarchy is large enough and the stat data hasn't been read
> recently, it may take a while to accumulate all the stat data even for
> one cpu in cgroup_stat_flush_locked(). So I think it will make more
> sense to use regular spinlock_t instead of raw_spinlock_t.

They need to be raw spinlocks because the accounting side may grab
them while scheduling.  If the accumulating latency becomes
problematic, we can test for need_resched and spin_needbreak and break
out as necessary.  The iteration logic is built to allow that and an
earlier revision actually did that but I wasn't sure whether it's
actually necessary and removed it for simplicity.

If the latency ever becomes a problem, resurrecting that isn't
difficult at all.

> > +static struct cgroup *cgroup_cpu_stat_next_updated(struct cgroup *pos,
> > +						   struct cgroup *root, int cpu)
> 
> This function is trying to unwind one cgrp from the updated_children and
> updated_next linkage. It is somewhat like the opposite of
> cgroup_cpu_stat_updated(). I just feel like its name isn't intuitive
> enough to convey what it is doing. Maybe use name like
> cgroup_cpu_stat_unlink_one() to match cgroup_cpu_stat_flush_one().

Hmm... the name comes from it being an iterator - most interators are
named _next.  But, yeah, the name doesn't signifiy that it unlinks as
it goes along.  I'll rename it to cgroup_cpu_stat_pop_updated().

Thanks.

-- 
tejun

[toc] | [next] | [standalone]


#1710587

FromWaiman Long <longman@redhat.com>
Date2017-08-14 01:30 +0200
Message-ID<ueaut-515-1@gated-at.bofh.it>
In reply to#1710576
On 08/13/2017 03:44 PM, Tejun Heo wrote:
> Hello, Waiman.
>
> On Fri, Aug 11, 2017 at 04:19:07PM -0400, Waiman Long wrote:
>>> * CPU usage stats are collected and shown in "cgroup.stat" with "cpu."
>>>   prefix.  Total usage is collected from scheduling events.  User/sys
>>>   breakdown is sourced from tick sampling and adjusted to the usage
>>>   using cputime_adjuts().
>> Typo: cputime_adjust()
> Oops, will fix.
>
>>> +static DEFINE_MUTEX(cgroup_stat_mutex);
>>> +static DEFINE_PER_CPU(raw_spinlock_t, cgroup_cpu_stat_lock);
>> If the hierarchy is large enough and the stat data hasn't been read
>> recently, it may take a while to accumulate all the stat data even for
>> one cpu in cgroup_stat_flush_locked(). So I think it will make more
>> sense to use regular spinlock_t instead of raw_spinlock_t.
> They need to be raw spinlocks because the accounting side may grab
> them while scheduling.  If the accumulating latency becomes
> problematic, we can test for need_resched and spin_needbreak and break
> out as necessary.  The iteration logic is built to allow that and an
> earlier revision actually did that but I wasn't sure whether it's
> actually necessary and removed it for simplicity.
>
> If the latency ever becomes a problem, resurrecting that isn't
> difficult at all.

Right, I forgot they will be used by the scheduler.

I think it is prudent to limit the latency, but it can be another patch
when the need arises.

>>> +static struct cgroup *cgroup_cpu_stat_next_updated(struct cgroup *pos,
>>> +						   struct cgroup *root, int cpu)
>> This function is trying to unwind one cgrp from the updated_children and
>> updated_next linkage. It is somewhat like the opposite of
>> cgroup_cpu_stat_updated(). I just feel like its name isn't intuitive
>> enough to convey what it is doing. Maybe use name like
>> cgroup_cpu_stat_unlink_one() to match cgroup_cpu_stat_flush_one().
> Hmm... the name comes from it being an iterator - most interators are
> named _next.  But, yeah, the name doesn't signifiy that it unlinks as
> it goes along.  I'll rename it to cgroup_cpu_stat_pop_updated().

I am fine with that.

Thanks,
Longman

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web