Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jun 2009 06:55:32 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r193301 - head/sys/kern
Message-ID:  <200906020655.n526tWQH005450@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jeff
Date: Tue Jun  2 06:55:32 2009
New Revision: 193301
URL: http://svn.freebsd.org/changeset/base/193301

Log:
   - Use an acquire barrier to increment f_count in fget_unlocked and
     remove the volatile cast.  Describe the reason in detail in a comment.
  
  Discussed with:	bde, jhb

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Tue Jun  2 05:13:02 2009	(r193300)
+++ head/sys/kern/kern_descrip.c	Tue Jun  2 06:55:32 2009	(r193301)
@@ -2075,9 +2075,13 @@ fget_unlocked(struct filedesc *fdp, int 
 		count = fp->f_count;
 		if (count == 0)
 			continue;
-		if (atomic_cmpset_int(&fp->f_count, count, count + 1) != 1)
+		/*
+		 * Use an acquire barrier to prevent caching of fd_ofiles
+		 * so it is refreshed for verification.
+		 */
+		if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1)
 			continue;
-		if (fp == ((struct file *volatile*)fdp->fd_ofiles)[fd])
+		if (fp == fdp->fd_ofiles[fd])
 			break;
 		fdrop(fp, curthread);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906020655.n526tWQH005450>