Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Aug 2014 07:20:37 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r270092 - in stable/10/sys: kern sys
Message-ID:  <201408170720.s7H7Kbsl041737@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Aug 17 07:20:37 2014
New Revision: 270092
URL: http://svnweb.freebsd.org/changeset/base/270092

Log:
  MFC r268634:
  
  Manage struct sigacts refcnt with atomics instead of a mutex.

Modified:
  stable/10/sys/kern/kern_sig.c
  stable/10/sys/sys/signalvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_sig.c
==============================================================================
--- stable/10/sys/kern/kern_sig.c	Sun Aug 17 07:16:03 2014	(r270091)
+++ stable/10/sys/kern/kern_sig.c	Sun Aug 17 07:20:37 2014	(r270092)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
+#include <sys/refcount.h>
 #include <sys/namei.h>
 #include <sys/proc.h>
 #include <sys/procdesc.h>
@@ -3432,21 +3433,17 @@ void
 sigacts_free(struct sigacts *ps)
 {
 
-	mtx_lock(&ps->ps_mtx);
-	ps->ps_refcnt--;
-	if (ps->ps_refcnt == 0) {
-		mtx_destroy(&ps->ps_mtx);
-		free(ps, M_SUBPROC);
-	} else
-		mtx_unlock(&ps->ps_mtx);
+	if (refcount_release(&ps->ps_refcnt) == 0)
+		return;
+	mtx_destroy(&ps->ps_mtx);
+	free(ps, M_SUBPROC);
 }
 
 struct sigacts *
 sigacts_hold(struct sigacts *ps)
 {
-	mtx_lock(&ps->ps_mtx);
-	ps->ps_refcnt++;
-	mtx_unlock(&ps->ps_mtx);
+
+	refcount_acquire(&ps->ps_refcnt);
 	return (ps);
 }
 

Modified: stable/10/sys/sys/signalvar.h
==============================================================================
--- stable/10/sys/sys/signalvar.h	Sun Aug 17 07:16:03 2014	(r270091)
+++ stable/10/sys/sys/signalvar.h	Sun Aug 17 07:20:37 2014	(r270092)
@@ -63,7 +63,7 @@ struct sigacts {
 	sigset_t ps_osigset;		/* Signals using <= 3.x osigset_t. */
 	sigset_t ps_usertramp;		/* SunOS compat; libc sigtramp. XXX */
 	int	ps_flag;
-	int	ps_refcnt;
+	u_int	ps_refcnt;
 	struct mtx ps_mtx;
 };
 



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