From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbcGOMtr (ORCPT ); Fri, 15 Jul 2016 08:49:47 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38353 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbcGOMto (ORCPT ); Fri, 15 Jul 2016 08:49:44 -0400 Reply-To: nicolas.dichtel@6wind.com Subject: Re: [PATCH 01/14] resource limits: foundation for resource highwater tracking References: <1468578983-28229-1-git-send-email-toiwoton@gmail.com> <1468578983-28229-2-git-send-email-toiwoton@gmail.com> To: Topi Miettinen , linux-kernel@vger.kernel.org Cc: Jonathan Corbet , Ingo Molnar , Peter Zijlstra , Balbir Singh , "David S. Miller" , Markus Elfring , Thomas Gleixner , Rik van Riel , "open list:DOCUMENTATION" From: Nicolas Dichtel Organization: 6WIND Message-ID: <5788DBE4.50406@6wind.com> Date: Fri, 15 Jul 2016 14:49:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <1468578983-28229-2-git-send-email-toiwoton@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 15/07/2016 12:35, Topi Miettinen a écrit : > There are many basic ways to control processes, including capabilities, > cgroups and resource limits. However, there are far fewer ways to find out > useful values for the limits, except blind trial and error. > > Prepare a foundation for resource highwater tracking. > > The collected highwater marks for the resources can be seen using > taskstats netlink interface. > > This depends on CONFIG_TASK_XACCT. > > Signed-off-by: Topi Miettinen > --- [snip] > @@ -63,6 +65,8 @@ int print_task_context_switch_counts; > /* Maximum number of cpus expected to be specified in a cpumask */ > #define MAX_CPUS 32 > > +#define TASKSTATS_VERSION_WITH_RESOURCE 9 > + > struct msgtemplate { > struct nlmsghdr n; > struct genlmsghdr g; [snip] > @@ -252,6 +276,22 @@ static void print_ioacct(struct taskstats *t) > (unsigned long long)t->cancelled_write_bytes); > } > > +static void print_racct(const struct taskstats *t) > +{ > + int i; > + > + if (t->version < TASKSTATS_VERSION_WITH_RESOURCE) { > + printf("kernel too old (%d < %d)\n", t->version, > + TASKSTATS_VERSION_WITH_RESOURCE); > + return; > + } [snip] > diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h > index 2466e55..8c65194 100644 > --- a/include/uapi/linux/taskstats.h > +++ b/include/uapi/linux/taskstats.h > @@ -33,7 +33,7 @@ > */ > > > -#define TASKSTATS_VERSION 8 > +#define TASKSTATS_VERSION 9 > #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN > * in linux/sched.h */ > > @@ -163,6 +163,14 @@ struct taskstats { > /* Delay waiting for memory reclaim */ > __u64 freepages_count; > __u64 freepages_delay_total; > + /* Per-task storage I/O accounting ends */ > + > +#define TASKSTATS_HAS_LIMIT_ACCOUNTING > + /* Per-task resource accounting starts */ > + __u64 resource_hiwater[RLIM_NLIMITS]; /* high-watermark of > + RLIMIT > + resources */ > + /* Per-task resource accounting ends */ > }; Why playing with version number? It complexifies the (userland) code and existing applications break when the kernel is updated. Goal of netlink is to be easily extensible. By adding a new attribute, existing userspace tools won't break. Regards, Nicolas