From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 15 Mar 2002 16:10:01 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 15 Mar 2002 16:09:44 -0500 Received: from dell-paw-3.cambridge.redhat.com ([195.224.55.237]:59891 "HELO executor.cambridge.redhat.com") by vger.kernel.org with SMTP id ; Fri, 15 Mar 2002 16:09:27 -0500 To: torvalds@transmeta.com Cc: linux-kernel@vger.kernel.org, mingo@redhat.com Subject: [PATCH] wait4() WIFSTOPPED starvation fix #2/2 User-Agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (=?ISO-8859-4?Q?Unebigory=F2mae?=) APEL/10.3 Emacs/21.1 (i386-redhat-linux-gnu) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Date: Fri, 15 Mar 2002 21:09:26 +0000 Message-ID: <17402.1016226566@warthog.cambridge.redhat.com> From: David Howells Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, This patch actually fixes the starvation bug in sys_wait4() by moving any process which is serviced for stoppage to the end of the child list. David diff -uNr linux-256p1/kernel/exit.c-orig linux-wait-256p1/kernel/exit.c --- linux-wait-256p1/kernel/exit.c-orig Fri Mar 15 19:05:47 2002 +++ linux-wait-256p1/kernel/exit.c Fri Mar 15 20:54:40 2002 @@ -592,6 +592,12 @@ if (!(options & WUNTRACED) && !(p->ptrace & PT_PTRACED)) continue; read_unlock(&tasklist_lock); + + /* move to end of parent's list to avoid starvation */ + write_lock_irq(&tasklist_lock); + list_del(&p->sibling); + list_add_tail(&p->sibling,&p->parent->children); + write_unlock_irq(&tasklist_lock); retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0; if (!retval && stat_addr) retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);