From owner-svn-src-projects@freebsd.org Thu Aug 27 07:43:31 2015 Return-Path: Delivered-To: svn-src-projects@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 056C59C4CBB for ; Thu, 27 Aug 2015 07:43:31 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.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 E9E421EC5; Thu, 27 Aug 2015 07:43:30 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7R7hURL017606; Thu, 27 Aug 2015 07:43:30 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7R7hUUk017603; Thu, 27 Aug 2015 07:43:30 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201508270743.t7R7hUUk017603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 27 Aug 2015 07:43:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r287194 - in projects/hps_head: share/man/man9 sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 07:43:31 -0000 Author: hselasky Date: Thu Aug 27 07:43:29 2015 New Revision: 287194 URL: https://svnweb.freebsd.org/changeset/base/287194 Log: Update the callout subsystem to reflect the callout API changes in r286880. Document the API changes in the timeout.9 manual page. Modified: projects/hps_head/share/man/man9/timeout.9 projects/hps_head/sys/kern/kern_timeout.c Modified: projects/hps_head/share/man/man9/timeout.9 ============================================================================== --- projects/hps_head/share/man/man9/timeout.9 Thu Aug 27 06:28:42 2015 (r287193) +++ projects/hps_head/share/man/man9/timeout.9 Thu Aug 27 07:43:29 2015 (r287194) @@ -246,9 +246,8 @@ argument. The number of ticks in a second is defined by .Dv hz and can vary from system to system. -This function returns a non-zero value if the given callout was pending and -the callback function was prevented from being called. -Otherwise, a value of zero is returned. +This function has the same return value like +.Fn callout_stop . If a lock is associated with the callout given by the .Fa c argument and it is exclusivly locked when this function is called, this @@ -483,17 +482,25 @@ is undefined. This function is used to stop a timeout function invocation associated with the callout pointed to by the .Fa c argument, in a non-blocking fashion. -This function can be called multiple times in a row with no side effects, even if the callout is already stopped. This function however should not be called before the callout has been initialized. -This function returns a non-zero value if the given callout was pending and -the callback function was prevented from being called. -Else a value of zero is returned. +This function can be called multiple times in a row with no side effects, even if the callout is already stopped. +This function however should not be called before the callout has been initialized. If a lock is associated with the callout given by the .Fa c argument and it is exclusivly locked when this function is called, the .Fn callout_stop function will always ensure that the callback function is never reached. In other words the callout will be atomically stopped. -Else there is no such guarantee. +When a callout is atomically stopped a return value of non-zero is returned. +Else a value of zero is returned. +If there is no lock associated with the callout given by the +.Fa c +argument the return values are slightly different. +If the callout was stopped ahead of the callback function a return +value of non-zero is returned. +If the callback function is currently executing and also if the +callout was restarted before being stopped again, a return value of +zero is returned. +In all other cases a value of zero is returned. .Sh DRAINING CALLOUTS .Ft int .Fn callout_drain "struct callout *c" Modified: projects/hps_head/sys/kern/kern_timeout.c ============================================================================== --- projects/hps_head/sys/kern/kern_timeout.c Thu Aug 27 06:28:42 2015 (r287193) +++ projects/hps_head/sys/kern/kern_timeout.c Thu Aug 27 07:43:29 2015 (r287194) @@ -1028,8 +1028,19 @@ callout_restart_async(struct callout *c, */ if (cc_exec_cancel(cc, direct) == false || (c->c_flags & CALLOUT_DEFRESTART) != 0) { + /* + * MPSAFE callouts should not return they were + * cancelled when the callback is scheduled + * for completion. Even if a deferred callback + * was actually stopped. This helps MPSAFE + * clients decide when they have a pending + * callback or not. + */ cc_exec_cancel(cc, direct) = true; - cancelled = CALLOUT_RET_CANCELLED; + if (c->c_lock == NULL) + cancelled = CALLOUT_RET_NORMAL; + else + cancelled = CALLOUT_RET_CANCELLED; } else { cancelled = CALLOUT_RET_NORMAL; }