Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2020 18:01:41 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368703 - head/sys/kern
Message-ID:  <202012161801.0BGI1flE006314@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Wed Dec 16 18:01:41 2020
New Revision: 368703
URL: https://svnweb.freebsd.org/changeset/base/368703

Log:
  fd: remove redundant saturation check from fget_unlocked_seq
  
  refcount_acquire_if_not_zero returns true on saturation.
  The case of 0 is handled by looping again, after which the originally
  found pointer will no longer be there.
  
  Noted by:	kib

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Wed Dec 16 17:09:38 2020	(r368702)
+++ head/sys/kern/kern_descrip.c	Wed Dec 16 18:01:41 2020	(r368703)
@@ -3022,13 +3022,6 @@ fget_unlocked_seq(struct filedesc *fdp, int fd, cap_ri
 #endif
 		if (__predict_false(!refcount_acquire_if_not_zero(&fp->f_count))) {
 			/*
-			 * The count was found either saturated or zero.
-			 * This re-read is not any more racy than using the
-			 * return value from fcmpset.
-			 */
-			if (refcount_load(&fp->f_count) != 0)
-				return (EBADF);
-			/*
 			 * Force a reload. Other thread could reallocate the
 			 * table before this fd was closed, so it is possible
 			 * that there is a stale fp pointer in cached version.



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