From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424314AbcFMV3h (ORCPT ); Mon, 13 Jun 2016 17:29:37 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36429 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422758AbcFMV3g (ORCPT ); Mon, 13 Jun 2016 17:29:36 -0400 Subject: Re: [RFC 02/18] cgroup_pids: track maximum pids To: Tejun Heo References: <1465847065-3577-1-git-send-email-toiwoton@gmail.com> <1465847065-3577-3-git-send-email-toiwoton@gmail.com> <20160613211227.GG31708@htj.duckdns.org> Cc: linux-kernel@vger.kernel.org, Li Zefan , Johannes Weiner , "open list:CONTROL GROUP (CGROUP)" From: Topi Miettinen Openpgp: id=A0F2EB0D8452DA908BEC8E911CF9ADDBD610E936 Message-ID: <17cb1a37-47b1-dbd4-6835-efad3cf6c12f@gmail.com> Date: Mon, 13 Jun 2016 21:29:32 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.1.0 MIME-Version: 1.0 In-Reply-To: <20160613211227.GG31708@htj.duckdns.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/13/16 21:12, Tejun Heo wrote: > Hello, > > On Mon, Jun 13, 2016 at 10:44:09PM +0300, Topi Miettinen wrote: >> Track maximum pids in the cgroup, present it in cgroup pids.current_max. > > "max" is often used for maximum limits in cgroup. I think "watermark" > or "high_watermark" would be a lot clearer. OK, I have no preference. > >> @@ -236,6 +246,14 @@ static void pids_free(struct task_struct *task) >> pids_uncharge(pids, 1); >> } >> >> +static void pids_fork(struct task_struct *task) >> +{ >> + struct pids_cgroup *pids = css_pids(task_css(task, pids_cgrp_id)); >> + >> + if (atomic64_read(&pids->cur_max) < atomic64_read(&pids->counter)) >> + atomic64_set(&pids->cur_max, atomic64_read(&pids->counter)); >> +} > > Wouldn't it make more sense to track high watermark from the charge > functions instead? I don't get why this requires a separate fork > callback. Also, racing atomic64_set's are racy. The counter can end > up with a lower number than it should be. > I used fork callback as I don't want to lower the watermark in all cases where the charge can be lowered, so I'd update the watermark only when the fork really happens. Is there a better way to compare and set? I don't think atomic_cmpxchg() does what's needed, >> @@ -300,6 +326,11 @@ static struct cftype pids_files[] = { >> .read_s64 = pids_current_read, >> .flags = CFTYPE_NOT_ON_ROOT, >> }, >> + { >> + .name = "current_max", > > Please make this "high_watermark" field in pids.stats file. > > Thanks. > OK. -Topi