From owner-svn-src-head@FreeBSD.ORG Mon Jul 14 21:13:00 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 55578B92; Mon, 14 Jul 2014 21:13:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 42C33246D; Mon, 14 Jul 2014 21:13:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6ELD0Cf000296; Mon, 14 Jul 2014 21:13:00 GMT (envelope-from mjg@svn.freebsd.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6ELCx7n000288; Mon, 14 Jul 2014 21:12:59 GMT (envelope-from mjg@svn.freebsd.org) Message-Id: <201407142112.s6ELCx7n000288@svn.freebsd.org> From: Mateusz Guzik Date: Mon, 14 Jul 2014 21:12:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268634 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2014 21:13:00 -0000 Author: mjg Date: Mon Jul 14 21:12:59 2014 New Revision: 268634 URL: http://svnweb.freebsd.org/changeset/base/268634 Log: Manage struct sigacts refcnt with atomics instead of a mutex. MFC after: 1 week Modified: head/sys/kern/kern_sig.c head/sys/sys/signalvar.h Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Jul 14 20:58:57 2014 (r268633) +++ head/sys/kern/kern_sig.c Mon Jul 14 21:12:59 2014 (r268634) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3422,21 +3423,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: head/sys/sys/signalvar.h ============================================================================== --- head/sys/sys/signalvar.h Mon Jul 14 20:58:57 2014 (r268633) +++ head/sys/sys/signalvar.h Mon Jul 14 21:12:59 2014 (r268634) @@ -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; };