From owner-soc-status@FreeBSD.ORG Fri Jun 18 22:08:38 2010 Return-Path: Delivered-To: soc-status@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C5151065673 for ; Fri, 18 Jun 2010 22:08:38 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id CB60C8FC16 for ; Fri, 18 Jun 2010 22:08:37 +0000 (UTC) Received: by wyb33 with SMTP id 33so1442315wyb.13 for ; Fri, 18 Jun 2010 15:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=XO/1W4e5Riv/5kI3KM7VCsJ3MyFhV066o1XS9RAQIxI=; b=KqbARZhSVo3+f/riJAIjrPJTv7BNenBGhaedhz4TpWTZqnOmaPQ5iLbtHiIGeRfMJG /vD5SfxRh+Ol01JcmD1Hj9ximyf/kISnQK86CbxF+7ozrpm97O4zgk8/VTkAzGDxMzkm /Rh/5KCvV87DUu8/XZxN4AzFR59xMBNOAVRNc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=RkPRj8RRostgdO3bKZhbNMDKV/ehd5P7HORVo/NlcdUCo5IAuuRWl/iOHwyWLy8/YV son0ooNFg/LUSWCg1E29QrHiMsZq2ixC3Y5q6tz++Ef2bMh47A5iPh05Xo0SQyrIFu8S rNHSVRofbmo0jeyFi7gQCQW/2x5BGrt0TT9UM= MIME-Version: 1.0 Received: by 10.216.88.144 with SMTP id a16mr1243733wef.77.1276897415067; Fri, 18 Jun 2010 14:43:35 -0700 (PDT) Received: by 10.216.51.78 with HTTP; Fri, 18 Jun 2010 14:43:35 -0700 (PDT) In-Reply-To: <4C1BCB96.4040608@FreeBSD.org> References: <4C1BCB96.4040608@FreeBSD.org> Date: Sat, 19 Jun 2010 01:43:35 +0400 Message-ID: From: pluknet To: Gabor Kovesdan Content-Type: text/plain; charset=ISO-8859-1 Cc: soc-status@freebsd.org Subject: Re: Collective resource limits status report #3 X-BeenThere: soc-status@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Summer of Code Status Reports and Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2010 22:08:38 -0000 On 18 June 2010 23:40, Gabor Kovesdan wrote: > Hello, > > since the last report, I made my code compilable, although it doesn't > completely work yet. Now I'm working on finding what is going wrong. While I > spent time with buildworld/buildkernel compilations, I wrote manual pages > for the syscalls implemented and also extended the test utility a bit. For > next week, my goal is to make these totally work and start to work on actual > resource limits. First step to accomplish this is adding containers for > resource usage accounting. Edward's hrl code will be a big help for this and > I'll consider his work-in-progress project when doing this task, trying to > come up with a more general solution that is also useful for his work and > later improvements on resource limits. > > Bad news is that I've had some problems with Perforce. I used it many many > times, I know how it works but seems that recent client utility is either > buggy or developers broke compatibility and I experienced a very different > behaviour this time. I just sent a mail to developers@ about this, this is > something that we should look at. This made the history in my p4 repo a > total mess but supposedly code is there so you can check out. For easier > review, I'm also providing a patch for head with all the code I wrote. I > know this is not much but it took time to get into the kernel internals and > it also took time to compile the code and eliminating compile errors > one-by-one. Hopefully, as I'm getting into it, I'll progress more and more > quickly. The patch is here: http://kovesdan.org/patches/jobs_current.diff > First, thank you for doing this! Please, let me comment a little (that's rather a thinking aloud, don't take it too seriously). As I see, you decided to follow a bug-for-bug compatibility way and chose to bring in a new error type ENOPKG. That's sort of surprise since, as I know, ENOPKG is an IRIX specific error code meaning that a particular IRIX installation doesn't come with job limit feature installed, and that doesn't fit nicely in to the FreeBSD world. Does it make sense to define it at all? Also, I see no purpose to use it anywhere. Why don't define __jid_t as it's done for uid_t, gid_t, pid_t? Why do jid_t to be 64-bit capable? IMHO it should follow uid_t capacity, as far as jobs are created per uid (and that's noted in makenewjob(2)). I would make something like following (not important parts missed intentionally). [job limits are like struct plimit (both are based on BSD struct rlimit in my variant), so I decided to include jid_t limits (and name it struct ulimit here) into struct uidinfo since that's something similar to stuct plimit, but unlike plimit which is designed to be per process, an ulimit is per uid; hence its name: "user limit". Though I don't like that now there are excessively two new fields in struct uidinfo.] %%% Index: sys/sys/_types.h =================================================================== --- sys/sys/_types.h (revision 209037) +++ sys/sys/_types.h (working copy) @@ -42,7 +42,8 @@ typedef __uint64_t __fsblkcnt_t; typedef __uint64_t __fsfilcnt_t; typedef __uint32_t __gid_t; -typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */ +typedef __int64_t __id_t; /* can hold a gid_t, pid_t, + uid_t, or jid_t */ typedef __uint32_t __ino_t; /* inode number */ typedef long __key_t; /* IPC key (for Sys V IPC) */ typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */ @@ -61,6 +62,7 @@ typedef struct __timer *__timer_t; /* timer_gettime()... */ typedef struct __mq *__mqd_t; /* mq_open()... */ typedef __uint32_t __uid_t; +typedef __uint32_t __jid_t; typedef unsigned int __useconds_t; /* microseconds (unsigned) */ typedef int __cpuwhich_t; /* which parameter for cpuset. */ typedef int __cpulevel_t; /* level parameter for cpuset. */ Index: sys/sys/resource.h =================================================================== --- sys/sys/resource.h (revision 209037) +++ sys/sys/resource.h (working copy) @@ -130,6 +130,16 @@ #define _RLIM_T_DECLARED #endif +#ifndef _JID_T_DECLARED +typedef __jid_t jid_t; +#define _JID_T_DECLARED +#endif + +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; +#define _UID_T_DECLARED +#endif + struct rlimit { rlim_t rlim_cur; /* current (soft) limit */ rlim_t rlim_max; /* maximum value for rlim_cur */ @@ -154,6 +164,37 @@ #define CP_IDLE 4 #define CPUSTATES 5 +/* + * Job limits + */ +#define JLIMIT_CPU 0 +#define JLIMIT_DATA 1 +#define JLIMIT_NOFILE 2 +#define JLIMIT_NUMPROC 3 +#define JLIMIT_NUMTHR 4 +#define JLIMIT_VMEM 5 +#define JLIMIT_PMEM 6 +#define JLIMIT_RSS 7 + +#define JLIM_NLIMITS 8 + +/* + * Job limit string identifiers + */ + +#ifdef _JLIMIT_IDENT +static char *jlimit_ident[JLIM_NLIMITS] = { + "cputime", + "datasize", + "files", + "processes", + "threads", + "vmemory", + "physmem", + "ressetsize", +}; +#endif + #endif /* __BSD_VISIBLE */ #ifdef _KERNEL @@ -165,9 +206,13 @@ __BEGIN_DECLS /* XXX 2nd arg to [gs]etpriority() should be an id_t */ +int getjlimit(jid_t, int, struct rlimit *); int getpriority(int, int); int getrlimit(int, struct rlimit *); int getrusage(int, struct rusage *); +int killjob(jid_t, int); +jid_t makenewjob(jid_t, uid_t); +int setjlimit(jid_t, int, struct rlimit *); int setpriority(int, int, int); int setrlimit(int, const struct rlimit *); __END_DECLS Index: sys/sys/resourcevar.h =================================================================== --- sys/sys/resourcevar.h (revision 209037) +++ sys/sys/resourcevar.h (working copy) @@ -79,6 +79,11 @@ int pl_refcnt; /* number of references */ }; +struct ulimit { + struct rlimit ul_jlimit[JLIM_NLIMITS]; + int ul_refcnt; /* number of references */ +}; + /*- * Per uid resource consumption * @@ -97,6 +102,8 @@ long ui_ptscnt; /* (b) number of pseudo-terminals */ uid_t ui_uid; /* (a) uid */ u_int ui_ref; /* (b) reference count */ + jid_t ui_jid; /* (c) job in which this uid_t lives */ + struct ulimit *ui_limit; }; #define UIDINFO_VMSIZE_LOCK(ui) mtx_lock(&((ui)->ui_vmsize_mtx)) Index: sys/sys/types.h =================================================================== --- sys/sys/types.h (revision 209037) +++ sys/sys/types.h (working copy) @@ -181,7 +181,7 @@ #endif #ifndef _ID_T_DECLARED -typedef __id_t id_t; /* can hold a uid_t or pid_t */ +typedef __id_t id_t; /* can hold a uid_t, pid_t or jid_t */ #define _ID_T_DECLARED #endif @@ -271,6 +271,11 @@ #define _UID_T_DECLARED #endif +#ifndef _JID_T_DECLARED +typedef __jid_t jid_t; /* job id */ +#define _JID_T_DECLARED +#endif + #ifndef _USECONDS_T_DECLARED typedef __useconds_t useconds_t; /* microseconds (unsigned) */ #define _USECONDS_T_DECLARED %%% -- wbr, pluknet