From owner-svn-src-all@FreeBSD.ORG Fri Sep 20 23:16:16 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 14EC8DF0; Fri, 20 Sep 2013 23:16:16 +0000 (UTC) (envelope-from davide@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DD45F28C3; Fri, 20 Sep 2013 23:16:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KNGFTh007196; Fri, 20 Sep 2013 23:16:15 GMT (envelope-from davide@svn.freebsd.org) Received: (from davide@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8KNGFeZ007194; Fri, 20 Sep 2013 23:16:15 GMT (envelope-from davide@svn.freebsd.org) Message-Id: <201309202316.r8KNGFeZ007194@svn.freebsd.org> From: Davide Italiano Date: Fri, 20 Sep 2013 23:16:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r255747 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Sep 2013 23:16:16 -0000 Author: davide Date: Fri Sep 20 23:16:15 2013 New Revision: 255747 URL: http://svnweb.freebsd.org/changeset/base/255747 Log: Fix callout_init_rm() in the shared case, allocating storage for 'struct rm_priotracker' directly in the softclock thread. Now consumers can pass CALLOUT_SHAREDLOCK flag to callout initialization routine safely. The choice of the already existing flags instead of special casing shared rmlocks is done to prevent consumer footshooting. Suggested by: jhb Reviewed by: jhb Approved by: re (delphij) Modified: head/sys/kern/kern_timeout.c Modified: head/sys/kern/kern_timeout.c ============================================================================== --- head/sys/kern/kern_timeout.c Fri Sep 20 23:10:52 2013 (r255746) +++ head/sys/kern/kern_timeout.c Fri Sep 20 23:16:15 2013 (r255747) @@ -597,11 +597,13 @@ softclock_call_cc(struct callout *c, str #endif int direct) { + struct rm_priotracker tracker; void (*c_func)(void *); void *c_arg; struct lock_class *class; struct lock_object *c_lock; - int c_flags, sharedlock; + uintptr_t lock_status; + int c_flags; #ifdef SMP struct callout_cpu *new_cc; void (*new_func)(void *); @@ -620,7 +622,13 @@ softclock_call_cc(struct callout *c, str (CALLOUT_PENDING | CALLOUT_ACTIVE), ("softclock_call_cc: pend|act %p %x", c, c->c_flags)); class = (c->c_lock != NULL) ? LOCK_CLASS(c->c_lock) : NULL; - sharedlock = (c->c_flags & CALLOUT_SHAREDLOCK) ? 0 : 1; + lock_status = 0; + if (c->c_flags & CALLOUT_SHAREDLOCK) { + if (class == &lock_class_rm) + lock_status = (uintptr_t)&tracker; + else + lock_status = 1; + } c_lock = c->c_lock; c_func = c->c_func; c_arg = c->c_arg; @@ -633,7 +641,7 @@ softclock_call_cc(struct callout *c, str cc->cc_exec_entity[direct].cc_cancel = false; CC_UNLOCK(cc); if (c_lock != NULL) { - class->lc_lock(c_lock, sharedlock); + class->lc_lock(c_lock, lock_status); /* * The callout may have been cancelled * while we switched locks.