From owner-freebsd-arch Mon Mar 24 11: 9:12 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C10A537B408 for ; Mon, 24 Mar 2003 11:09:05 -0800 (PST) Received: from mail.speakeasy.net (mail17.speakeasy.net [216.254.0.217]) by mx1.FreeBSD.org (Postfix) with ESMTP id 27BA743FB1 for ; Mon, 24 Mar 2003 11:09:05 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 19059 invoked from network); 24 Mar 2003 19:09:10 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail17.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 24 Mar 2003 19:09:10 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.8/8.12.8) with ESMTP id h2OJ92Ov093096; Mon, 24 Mar 2003 14:09:02 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200303240823.48262.wes@softweyr.com> Date: Mon, 24 Mar 2003 14:09:02 -0500 (EST) From: John Baldwin To: Wes Peters Subject: RE: Patch to protect process from pageout killing Cc: freebsd-arch@freebsd.org X-Spam-Status: No, hits=-19.5 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 24-Mar-2003 Wes Peters wrote: > As promised, here's the patch to protect a process from being killed when > pageout is in memory shortage. This allows a process to specify that it > is important enough to be skipped when pageout is looking for the largest > process to kill. > > My needs are simple. We make a box that is a web proxy and runs from a > memory disk, using flash for permanent storage. The flash is mounted > only when a configuration write is needed, the box runs from the memory > disk. We've experienced a problem at certain customer sites where bind > will consume a lot (~30 MB) of ram and then pageout will kill the largest > process, which is usually either named or squid. This pretty much kills > the box. We'd much rather have pageout kill off some of the squid worker > processes, we can recover from that. > > Is this a good approach to the problem? Feedback welcome. I think that adopting the SIGDANGER approach would be better rather than rolling our own private interface. > @@ -625,6 +625,15 @@ > if (limp->rlim_max < 1) > limp->rlim_max = 1; > break; > + > + case RLIMIT_PROTECT: > + mtx_lock_spin(&sched_lock); > + if (limp->rlim_cur) > + p->p_flag |= P_PROTECTED; > + else > + p->p_flag &= ~P_PROTECTED; > + mtx_unlock_spin(&sched_lock); > + break; p_flag is protected by PROC_LOCK, not sched_lock. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message