From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751876AbcGSTH2 (ORCPT ); Tue, 19 Jul 2016 15:07:28 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35384 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751280AbcGSTHZ (ORCPT ); Tue, 19 Jul 2016 15:07:25 -0400 Date: Tue, 19 Jul 2016 15:07:08 -0400 From: Tejun Heo To: Topi Miettinen Cc: linux-kernel@vger.kernel.org, Li Zefan , Johannes Weiner , "open list:CONTROL GROUP (CGROUP)" Subject: Re: [PATCH 1/2] cgroup_pids: track highwater mark of pids Message-ID: <20160719190708.GO3078@mtj.duckdns.org> References: <1468785820-3960-1-git-send-email-toiwoton@gmail.com> <1468785820-3960-3-git-send-email-toiwoton@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1468785820-3960-3-git-send-email-toiwoton@gmail.com> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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