From owner-svn-src-stable@FreeBSD.ORG Wed May 19 22:36:47 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69BA2106566B; Wed, 19 May 2010 22:36:47 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 58E8B8FC19; Wed, 19 May 2010 22:36:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4JMal43008821; Wed, 19 May 2010 22:36:47 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4JMal3b008816; Wed, 19 May 2010 22:36:47 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201005192236.o4JMal3b008816@svn.freebsd.org> From: Attilio Rao Date: Wed, 19 May 2010 22:36:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org X-SVN-Group: stable-6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208319 - in stable/6/sys: kern sys vm X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2010 22:36:47 -0000 Author: attilio Date: Wed May 19 22:36:46 2010 New Revision: 208319 URL: http://svn.freebsd.org/changeset/base/208319 Log: MFC: r206264 When OOM searches for a process to kill, ignore the processes already killed by OOM. When killed process waits for a page allocation, try to satisfy the request as fast as possible. Sponsored by: Sandvine Incorporated Modified: stable/6/sys/kern/kern_sig.c stable/6/sys/sys/proc.h stable/6/sys/vm/vm_fault.c stable/6/sys/vm/vm_pageout.c Directory Properties: stable/6/sys/ (props changed) stable/6/sys/contrib/pf/ (props changed) stable/6/sys/dev/cxgb/ (props changed) Modified: stable/6/sys/kern/kern_sig.c ============================================================================== --- stable/6/sys/kern/kern_sig.c Wed May 19 22:03:45 2010 (r208318) +++ stable/6/sys/kern/kern_sig.c Wed May 19 22:36:46 2010 (r208319) @@ -2408,6 +2408,7 @@ killproc(p, why) p, p->p_pid, p->p_comm); log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid, p->p_comm, p->p_ucred ? p->p_ucred->cr_uid : -1, why); + p->p_flag |= P_WKILLED; psignal(p, SIGKILL); } Modified: stable/6/sys/sys/proc.h ============================================================================== --- stable/6/sys/sys/proc.h Wed May 19 22:03:45 2010 (r208318) +++ stable/6/sys/sys/proc.h Wed May 19 22:36:46 2010 (r208319) @@ -654,11 +654,13 @@ struct proc { #define P_HWPMC 0x800000 /* Process is using HWPMCs */ #define P_JAILED 0x1000000 /* Process is in jail. */ +#define P_WKILLED 0x2000000 /* Killed, go to kernel/user boundary ASAP. */ #define P_INEXEC 0x4000000 /* Process is in execve(). */ #define P_STATCHILD 0x8000000 /* Child process stopped or exited. */ #define P_STOPPED (P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE) #define P_SHOULDSTOP(p) ((p)->p_flag & P_STOPPED) +#define P_KILLED(p) ((p)->p_flag & P_WKILLED) /* These flags are kept in p_sflag and are protected with sched_lock. */ #define PS_INMEM 0x00001 /* Loaded into memory. */ Modified: stable/6/sys/vm/vm_fault.c ============================================================================== --- stable/6/sys/vm/vm_fault.c Wed May 19 22:03:45 2010 (r208318) +++ stable/6/sys/vm/vm_fault.c Wed May 19 22:36:46 2010 (r208319) @@ -218,7 +218,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr vm_object_t next_object; vm_page_t marray[VM_FAULT_READ]; int hardfault; - int faultcount; + int faultcount, alloc_req; struct faultstate fs; hardfault = 0; @@ -449,11 +449,21 @@ RetryFault:; /* * Allocate a new page for this object/offset pair. + * + * Unlocked read of the p_flag is harmless. At + * worst, the P_KILLED might be not observed + * there, and allocation can fail, causing + * restart and new reading of the p_flag. */ fs.m = NULL; - if (!vm_page_count_severe()) { + if (!vm_page_count_severe() || P_KILLED(curproc)) { + alloc_req = P_KILLED(curproc) ? + VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL; + if (fs.vp == NULL && + fs.object->backing_object == NULL) + alloc_req |= VM_ALLOC_ZERO; fs.m = vm_page_alloc(fs.object, fs.pindex, - (fs.vp || fs.object->backing_object)? VM_ALLOC_NORMAL: VM_ALLOC_ZERO); + alloc_req); } if (fs.m == NULL) { unlock_and_deallocate(&fs); @@ -478,7 +488,8 @@ readrest: int ahead, behind; u_char behavior = vm_map_entry_behavior(fs.entry); - if (behavior == MAP_ENTRY_BEHAV_RANDOM) { + if (behavior == MAP_ENTRY_BEHAV_RANDOM || + P_KILLED(curproc)) { ahead = 0; behind = 0; } else { Modified: stable/6/sys/vm/vm_pageout.c ============================================================================== --- stable/6/sys/vm/vm_pageout.c Wed May 19 22:03:45 2010 (r208318) +++ stable/6/sys/vm/vm_pageout.c Wed May 19 22:36:46 2010 (r208319) @@ -1276,10 +1276,10 @@ vm_pageout_oom(int shortage) if (PROC_TRYLOCK(p) == 0) continue; /* - * If this is a system or protected process, skip it. + * If this is a system, protected or killed process, skip it. */ if ((p->p_flag & (P_INEXEC | P_PROTECTED | P_SYSTEM)) || - (p->p_pid == 1) || + (p->p_pid == 1) || P_KILLED(p) || ((p->p_pid < 48) && (swap_pager_avail != 0))) { PROC_UNLOCK(p); continue;