From owner-svn-src-stable-10@freebsd.org Tue Mar 15 10:45:57 2016 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 058D9ACF2F2; Tue, 15 Mar 2016 10:45:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 D5FCE216; Tue, 15 Mar 2016 10:45:56 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2FAjtCf082142; Tue, 15 Mar 2016 10:45:55 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2FAjtK2082138; Tue, 15 Mar 2016 10:45:55 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201603151045.u2FAjtK2082138@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 15 Mar 2016 10:45:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r296896 - in stable/10/sys: kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2016 10:45:57 -0000 Author: kib Date: Tue Mar 15 10:45:55 2016 New Revision: 296896 URL: https://svnweb.freebsd.org/changeset/base/296896 Log: MFC r296320: Adjust _callout_stop_safe() return value for the subr_sleepqueue.c needs when migrating callout was blocked, but running one was not. PR: 200992 Modified: stable/10/sys/kern/kern_timeout.c stable/10/sys/kern/subr_sleepqueue.c stable/10/sys/sys/callout.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/kern_timeout.c ============================================================================== --- stable/10/sys/kern/kern_timeout.c Tue Mar 15 10:37:19 2016 (r296895) +++ stable/10/sys/kern/kern_timeout.c Tue Mar 15 10:45:55 2016 (r296896) @@ -1114,9 +1114,9 @@ callout_schedule(struct callout *c, int } int -_callout_stop_safe(c, safe) +_callout_stop_safe(c, flags) struct callout *c; - int safe; + int flags; { struct callout_cpu *cc, *old_cc; struct lock_class *class; @@ -1127,7 +1127,7 @@ _callout_stop_safe(c, safe) * Some old subsystems don't hold Giant while running a callout_stop(), * so just discard this check for the moment. */ - if (!safe && c->c_lock != NULL) { + if ((flags & CS_DRAIN) == 0 && c->c_lock != NULL) { if (c->c_lock == &Giant.lock_object) use_lock = mtx_owned(&Giant); else { @@ -1207,7 +1207,7 @@ again: return (0); } - if (safe) { + if ((flags & CS_DRAIN) != 0) { /* * The current callout is running (or just * about to run) and blocking is allowed, so @@ -1319,7 +1319,7 @@ again: CTR3(KTR_CALLOUT, "postponing stop %p func %p arg %p", c, c->c_func, c->c_arg); CC_UNLOCK(cc); - return (0); + return ((flags & CS_MIGRBLOCK) != 0); } CTR3(KTR_CALLOUT, "failed to stop %p func %p arg %p", c, c->c_func, c->c_arg); Modified: stable/10/sys/kern/subr_sleepqueue.c ============================================================================== --- stable/10/sys/kern/subr_sleepqueue.c Tue Mar 15 10:37:19 2016 (r296895) +++ stable/10/sys/kern/subr_sleepqueue.c Tue Mar 15 10:45:55 2016 (r296896) @@ -572,7 +572,8 @@ sleepq_check_timeout(void) * another CPU, so synchronize with it to avoid having it * accidentally wake up a subsequent sleep. */ - else if (callout_stop(&td->td_slpcallout) == 0) { + else if (_callout_stop_safe(&td->td_slpcallout, CS_MIGRBLOCK) + == 0) { td->td_flags |= TDF_TIMEOUT; TD_SET_SLEEPING(td); mi_switch(SW_INVOL | SWT_SLEEPQTIMO, NULL); Modified: stable/10/sys/sys/callout.h ============================================================================== --- stable/10/sys/sys/callout.h Tue Mar 15 10:37:19 2016 (r296895) +++ stable/10/sys/sys/callout.h Tue Mar 15 10:45:55 2016 (r296896) @@ -62,6 +62,12 @@ struct callout_handle { struct callout *callout; }; +/* Flags for callout_stop_safe() */ +#define CS_DRAIN 0x0001 /* callout_drain(), wait allowed */ +#define CS_MIGRBLOCK 0x0002 /* Block migration, return value + indicates that the callout was + executing */ + #ifdef _KERNEL /* * Note the flags field is actually *two* fields. The c_flags @@ -81,7 +87,7 @@ struct callout_handle { */ #define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) #define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) -#define callout_drain(c) _callout_stop_safe(c, 1) +#define callout_drain(c) _callout_stop_safe(c, CS_DRAIN) void callout_init(struct callout *, int); void _callout_init_lock(struct callout *, struct lock_object *, int); #define callout_init_mtx(c, mtx, flags) \