From owner-p4-projects@FreeBSD.ORG Mon Jan 29 21:13:22 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9C15E16A405; Mon, 29 Jan 2007 21:13:22 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6ECC116A403 for ; Mon, 29 Jan 2007 21:13:22 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5FF6613C47E for ; Mon, 29 Jan 2007 21:13:22 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0TLDMkY028045 for ; Mon, 29 Jan 2007 21:13:22 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0TLDMBl028032 for perforce@freebsd.org; Mon, 29 Jan 2007 21:13:22 GMT (envelope-from rdivacky@FreeBSD.org) Date: Mon, 29 Jan 2007 21:13:22 GMT Message-Id: <200701292113.l0TLDMBl028032@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 113675 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2007 21:13:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=113675 Change 113675 by rdivacky@rdivacky_witten on 2007/01/29 21:13:01 There is no need to lock p_em in the linux_proc_init CLONE_THREAD case because the process cannot change the address of the p_em->shared because its currently running this code path. And the p_em->shared is the reason for synchronization here. Also protect onlu refs++ with the emul_shared_lock as em is local to our function. Affected files ... .. //depot/projects/linuxolator/src/sys/compat/linux/linux_emul.c#28 edit Differences ... ==== //depot/projects/linuxolator/src/sys/compat/linux/linux_emul.c#28 (text+ko) ==== @@ -114,13 +114,18 @@ if (child != 0) { if (flags & CLONE_THREAD) { /* lookup the parent */ - EMUL_SHARED_WLOCK(&emul_shared_lock); - p_em = em_find(td->td_proc, EMUL_DOLOCK); + /* + * we dont have to lock the p_em because + * its waiting for us in linux_clone so + * there is no chance of it changing the + * p_em->shared address + */ + p_em = em_find(td->td_proc, EMUL_DONTLOCK); KASSERT(p_em != NULL, ("proc_init: parent emuldata not found for CLONE_THREAD\n")); em->shared = p_em->shared; + EMUL_SHARED_WLOCK(&emul_shared_lock); em->shared->refs++; - EMUL_SHARED_WUNLOCK(&emul_shared_lock); - EMUL_UNLOCK(&emul_lock); + EMUL_SHARED_WUNLOCK(&emul_shared_lock); } else { /* * handled earlier to avoid malloc(M_WAITOK) with