From owner-svn-src-all@FreeBSD.ORG Tue Jan 26 20:48:22 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1BAC2106566C; Tue, 26 Jan 2010 20:48:22 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id C6AC28FC13; Tue, 26 Jan 2010 20:48:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o0QKfYPb076715; Tue, 26 Jan 2010 13:41:34 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 26 Jan 2010 13:42:24 -0700 (MST) Message-Id: <20100126.134224.366306193153347169.imp@bsdimp.com> To: xcllnt@mac.com From: "M. Warner Losh" In-Reply-To: <3023270A-755A-4BCF-AC9A-C1F290052279@mac.com> References: <20100126.130932.722022410132669562.imp@bsdimp.com> <3023270A-755A-4BCF-AC9A-C1F290052279@mac.com> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, jhb@freebsd.org, svn-src-all@freebsd.org, attilio@freebsd.org, marcel@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r202889 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2010 20:48:22 -0000 In message: <3023270A-755A-4BCF-AC9A-C1F290052279@mac.com> Marcel Moolenaar writes: : : On Jan 26, 2010, at 12:09 PM, M. Warner Losh wrote: : > cpu_switch(struct thread *old, struct thread *new, struct mutext *mtx) : > { : > /* Save the registers to the pcb */ : > old->td_lock = mtx; : > #if defined(SMP) && defined(SCHED_ULE) : > /* s/long/int/ if sizeof(long) != sizeof(void *) */ : > /* as we have no 'void *' version of the atomics */ : > while (atomic_load_acq_long(&new->td_lock) == (long)&blocked_lock) : > continue; : > #endif : > /* Switch to new context */ : > } : : Ok. So this is what ia64 has already, except for the atomic_load() : in the while loop. Since td_lock is volatile, I don't think we need : atomic_load(). To be explicit, ia64 has: : : old->td_lock = mtx; : #if defined(SCHED_ULE) && defined(SMP) : /* td_lock is volatile */ : while (new->td_lock == &blocked_lock) : ; : #endif : : Am I right, or am I missing a critical aspect of using atomic load? The Atomic load acq also has a memory barrier after the item is fetched from memory. : > I also think that we should have that code somewhere for reference. : : Since ia64 has a C implementation of cpu_switch(), we could make : that the reference implementation? Most likely :) Warner