From owner-p4-projects@FreeBSD.ORG Fri Mar 24 21:24:48 2006 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 1125C16A422; Fri, 24 Mar 2006 21:24:48 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD0FE16A400 for ; Fri, 24 Mar 2006 21:24:47 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 771D143D5F for ; Fri, 24 Mar 2006 21:24:47 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2OLOlpX022323 for ; Fri, 24 Mar 2006 21:24:47 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2OLOlf2022320 for perforce@freebsd.org; Fri, 24 Mar 2006 21:24:47 GMT (envelope-from jhb@freebsd.org) Date: Fri, 24 Mar 2006 21:24:47 GMT Message-Id: <200603242124.k2OLOlf2022320@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Cc: Subject: PERFORCE change 93947 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: Fri, 24 Mar 2006 21:24:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=93947 Change 93947 by jhb@jhb_twclab on 2006/03/24 21:23:46 After some help from Peter, make td_state non volatile again and apply the correct magic to make the one check in the adaptive spin treat td_state as volatile. Affected files ... .. //depot/projects/smpng/sys/kern/kern_mutex.c#121 edit .. //depot/projects/smpng/sys/sys/proc.h#169 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_mutex.c#121 (text+ko) ==== @@ -551,8 +551,16 @@ if (m != &Giant && TD_IS_RUNNING(owner)) { #endif turnstile_release(&m->mtx_object); + + /* + * Expanded TD_IS_RUNNING so that we could force + * the compiler to not cache owner->td_state. + * Otherwise, we wouldn't notice when the owning + * thread stopped running. + */ while (mtx_rawowner(m) == owner && - TD_IS_RUNNING(owner)) { + ((volatile struct thread *)owner)->td_state == + TDS_RUNNING) { cpu_spinwait(); } continue; ==== //depot/projects/smpng/sys/sys/proc.h#169 (text+ko) ==== @@ -311,7 +311,7 @@ * or already have been set in the allocator, constructor, etc. */ struct pcb *td_pcb; /* (k) Kernel VA of pcb and kstack. */ - volatile enum { + enum { TDS_INACTIVE = 0x0, TDS_INHIBITED, TDS_CAN_RUN,