Re: [PATCH 1/2] cgroup_pids: track highwater mark of pids
From: Tejun Heo
Date: Tue Jul 19 2016 - 15:07:31 EST
Hello,
On Sun, Jul 17, 2016 at 11:03:38PM +0300, Topi Miettinen wrote:
> +static void pids_update_highwater_mark(struct pids_cgroup *p)
> +{
> + while (1) {
> + int64_t old_mark, new_mark, cur_mark;
> +
> + old_mark = atomic64_read(&p->highwater_mark);
> + new_mark = atomic64_read(&p->counter);
> + if (old_mark >= new_mark)
> + return;
> + cur_mark = atomic64_cmpxchg(&p->highwater_mark, old_mark,
> + new_mark);
> +
> + /* It's OK if the counter was decreased meanwhile */
> + if (cur_mark == old_mark &&
> + atomic64_read(&p->counter) <= new_mark)
> + return;
> + }
> +}
I think it'd be better to make this part of pids_charge() - maybe use
atomic64_add_return() to get the current value and track the maximum?
> @@ -300,6 +341,11 @@ static struct cftype pids_files[] = {
> .read_s64 = pids_current_read,
> .flags = CFTYPE_NOT_ON_ROOT,
> },
> + {
> + .name = "highwater_mark",
> + .read_s64 = pids_highwater_mark_read,
> + .flags = CFTYPE_NOT_ON_ROOT,
> + },
This should be an entry in the pids.stats file. Please also update
the documentation accordingly.
Thanks.
--
tejun