From owner-freebsd-questions Thu Aug 1 05:50:24 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id FAA13883 for questions-outgoing; Thu, 1 Aug 1996 05:50:24 -0700 (PDT) Received: from relay1.sw.ru (myth.sw.ru [194.190.197.129]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id FAA13878 for ; Thu, 1 Aug 1996 05:50:18 -0700 (PDT) Received: from zeus by relay1.sw.ru (8.6.12/8.6.12/jt) with SMTP id QAA20203; Thu, 1 Aug 1996 16:48:30 +0400 Message-Id: <2.2.32.19960801125434.00ad231c@myth.sw.ru> X-Sender: jt@myth.sw.ru X-Mailer: Windows Eudora Pro Version 2.2 (32) Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Thu, 01 Aug 1996 16:54:34 +0400 To: "Hr.Ladavac" From: Juri Tsibrovski Subject: Re: Considering FreeBSD Cc: dg@root.com, questions@FreeBSD.ORG Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk At 11:35 01.08.96 +0200, Hr.Ladavac wrote: >In his e-mail Juri Tsibrovski wrote: >> At 09:16 31.07.96 -0700, David Greenman wrote: >> >> >> What can prevent me from increasing that number too? I already run modified >> kernel with pids protected <250, and changed to 300 wrapping point. >> > >Since you've already found the places in the kernel, do you think you >could make it sysctl(2) configurable? Or is it far too deep for that? Ok, my quick'n'dirt changes for 2.1.0R follows. It would be wise to add another independent variable for wrapping point, but adding some constant (52 just to preserve defualts) to maxprotpid seems enough for me. *** sys/sysctl.h.old Thu Aug 1 14:52:59 1996 --- sys/sysctl.h Thu Aug 1 15:00:30 1996 *************** struct ctlname { *** 136,142 **** #define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ #define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ #define KERN_DUMPDEV 29 /* dev_t: device to dump on */ ! #define KERN_MAXID 30 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ --- 136,143 ---- #define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ #define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ #define KERN_DUMPDEV 29 /* dev_t: device to dump on */ ! #define KERN_MAXPROTPID 30 /* int: max protected process ID */ ! #define KERN_MAXID 31 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ { 0, 0 }, \ *************** struct ctlname { *** 169,174 **** --- 170,176 ---- { "maxfilesperproc", CTLTYPE_INT }, \ { "maxprocperuid", CTLTYPE_INT }, \ { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \ + { "maxprotpid", CTLTYPE_INT }, \ } /* *** sys/proc.h.old Thu Aug 1 15:30:30 1996 --- sys/proc.h Thu Aug 1 15:18:00 1996 *************** extern struct proc *curproc; /* Current *** 244,249 **** --- 244,250 ---- extern struct proc proc0; /* Process slot for swapper. */ extern int nprocs, maxproc; /* Current and max number of procs. */ extern int maxprocperuid; /* Max procs per uid. */ + extern int maxprotpid; /* Max pid protected from being killed by vm_fault */ extern int pidhashmask; /* In param.c. */ extern volatile struct proc *allproc; /* List of active procs. */ *** conf/param.c.old Thu Aug 1 14:54:04 1996 --- conf/param.c Thu Aug 1 15:01:10 1996 *************** struct timezone tz = { TIMEZONE, DST }; *** 83,88 **** --- 83,89 ---- #define NPROC (20 + 16 * MAXUSERS) int maxproc = NPROC; /* maximum # of processes */ int maxprocperuid = NPROC-1; /* maximum # of processes per user */ + int maxprotpid = 48; /* maximal process id protected from being killed by vm_fault */ int maxfiles = NPROC*2; /* system wide open files limit */ int maxfilesperproc = NPROC*2; /* per-process open files limit */ int ncallout = 16 + NPROC; /* maximum # of timer events */ *** vm/vm_fault.c.old Thu Aug 1 14:51:03 1996 --- vm/vm_fault.c Thu Aug 1 15:37:37 1996 *************** RetryFault:; *** 307,313 **** if (swap_pager_full && !object->shadow && (!object->pager || (object->pager && object->pager->pg_type == PG_SWAP && !vm_pager_has_page(object->pager, offset + object->paging_offset)))) { ! if (vaddr < VM_MAXUSER_ADDRESS && curproc && curproc->p_pid >= 48) { /* XXX */ printf("Process %lu killed by vm_fault -- out of swap\n", (u_long) curproc->p_pid); psignal(curproc, SIGKILL); curproc->p_estcpu = 0; --- 307,313 ---- if (swap_pager_full && !object->shadow && (!object->pager || (object->pager && object->pager->pg_type == PG_SWAP && !vm_pager_has_page(object->pager, offset + object->paging_offset)))) { ! if (vaddr < VM_MAXUSER_ADDRESS && curproc && curproc->p_pid >= maxprotpid) { /* XXX */ printf("Process %lu killed by vm_fault -- out of swap\n", (u_long) curproc->p_pid); psignal(curproc, SIGKILL); curproc->p_estcpu = 0; *** kern/kern_sysctl.c.old Thu Aug 1 14:53:22 1996 --- kern/kern_sysctl.c Thu Aug 1 14:59:37 1996 *************** kern_sysctl(name, namelen, oldp, oldlenp *** 224,229 **** --- 224,231 ---- return (sysctl_int(oldp, oldlenp, newp, newlen, &maxfiles)); case KERN_MAXFILESPERPROC: return (sysctl_int(oldp, oldlenp, newp, newlen, &maxfilesperproc)); + case KERN_MAXPROTPID: + return (sysctl_int(oldp, oldlenp, newp, newlen, &maxprotpid)); case KERN_UPDATEINTERVAL: /* * NB: this simple-minded approach only works because *** kern/kern_fork.c.old Thu Aug 1 14:51:29 1996 --- kern/kern_fork.c Thu Aug 1 16:22:45 1996 *************** retry: *** 128,134 **** * tend to include daemons that don't exit. */ if (nextpid >= PID_MAX) { ! nextpid = 100; pidchecked = 0; } if (nextpid >= pidchecked) { --- 128,134 ---- * tend to include daemons that don't exit. */ if (nextpid >= PID_MAX) { ! nextpid = maxprotpid + 52; pidchecked = 0; } if (nextpid >= pidchecked) { You will also need to remake /usr/sbin/sysctl. >Is it a good idea at all? >From my point of view, yes. --- jt -- just typist :)