Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Jul 2020 22:13:15 +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: r363713 - head/sys/sys
Message-ID:  <202007302213.06UMDF6g047264@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Thu Jul 30 22:13:15 2020
New Revision: 363713
URL: https://svnweb.freebsd.org/changeset/base/363713

Log:
  fd: predict in fdrop

Modified:
  head/sys/sys/file.h

Modified: head/sys/sys/file.h
==============================================================================
--- head/sys/sys/file.h	Thu Jul 30 19:11:01 2020	(r363712)
+++ head/sys/sys/file.h	Thu Jul 30 22:13:15 2020	(r363713)
@@ -279,21 +279,22 @@ int fgetvp_read(struct thread *td, int fd, cap_rights_
 int fgetvp_write(struct thread *td, int fd, cap_rights_t *rightsp,
     struct vnode **vpp);
 
-static __inline int
-_fnoop(void)
-{
-
-	return (0);
-}
-
 static __inline __result_use_check bool
 fhold(struct file *fp)
 {
 	return (refcount_acquire_checked(&fp->f_count));
 }
 
-#define	fdrop(fp, td)							\
-	(refcount_release(&(fp)->f_count) ? _fdrop((fp), (td)) : _fnoop())
+#define	fdrop(fp, td)		({				\
+	struct file *_fp;					\
+	int _error;						\
+								\
+	_error = 0;						\
+	_fp = (fp);						\
+	if (__predict_false(refcount_release(&_fp->f_count)))	\
+		_error = _fdrop(_fp, td);			\
+	_error;							\
+})
 
 static __inline fo_rdwr_t	fo_read;
 static __inline fo_rdwr_t	fo_write;



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