From owner-freebsd-current Thu Feb 7 20: 3:37 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail11.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by hub.freebsd.org (Postfix) with ESMTP id E191B37B421 for ; Thu, 7 Feb 2002 20:03:33 -0800 (PST) Received: (qmail 13647 invoked from network); 8 Feb 2002 04:03:32 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([65.91.155.186]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 8 Feb 2002 04:03:32 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <3C632DEA.F522339D@mindspring.com> Date: Thu, 07 Feb 2002 23:03:31 -0500 (EST) From: John Baldwin To: Terry Lambert Subject: Re: ucred for threads Cc: current@freebsd.org, Julian Elischer Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 08-Feb-02 Terry Lambert wrote: > Since the reference count is positive in both cases, an > unlocked pointer comparison is fine. In the case where > there is a race on a credential change in the unlocked > value, that race exists in the calling code, anyway. The > failure case in a change for->to instead of to->from is > also safe, since the pointers will be inequal during the > update, the lock will be held during the update, so the > subsequent release and regrab with the increment never > dropping below 1. No, an unlocked compare is _not_ ok. What if the p_ucred pointer was changed on some other processor by another thread from this processor? Without a lock you don't have a guarantee that that other processor's writes are visible to you. We really don't want to be using stale credentials for syscalls given the past history of race conditions involving credentials. If in the future it is deemed that getting a stale cred is an acceptable race, then this can be optimized then, but for now we had better get it right. FreeBSD doesn't run on just the i386 anymore, we have Alpha, ia64, and sparc64 SMP machines to deal with as well. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message