From owner-svn-src-head@freebsd.org Tue Jun 28 16:42:41 2016 Return-Path: Delivered-To: svn-src-head@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 7A985B85A4B; Tue, 28 Jun 2016 16:42:41 +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 32C612B46; Tue, 28 Jun 2016 16:42:41 +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 u5SGgeTW061530; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5SGge18061528; Tue, 28 Jun 2016 16:42:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201606281642.u5SGge18061528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 28 Jun 2016 16:42:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302251 - 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-head@freebsd.org X-Mailman-Version: 2.1.22 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: Tue, 28 Jun 2016 16:42:41 -0000 Author: kib Date: Tue Jun 28 16:42:40 2016 New Revision: 302251 URL: https://svnweb.freebsd.org/changeset/base/302251 Log: Do not use Giant to prevent parallel calls to CLOCK_SETTIME(). Use private mtx in resettodr(), no implementation of CLOCK_SETTIME() is allowed to sleep. Reviewed by: imp, jhb Sponsored by: The FreeBSD Foundation Approved by: re (gjb) X-Differential revision: https://reviews.freebsd.org/D6825 Modified: head/sys/kern/subr_clock.c head/sys/kern/subr_rtc.c Modified: head/sys/kern/subr_clock.c ============================================================================== --- head/sys/kern/subr_clock.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_clock.c Tue Jun 28 16:42:40 2016 (r302251) @@ -67,8 +67,8 @@ sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ resettodr(); return (error); } -SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT|CTLFLAG_RW, - &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", +SYSCTL_PROC(_machdep, OID_AUTO, adjkerntz, CTLTYPE_INT | CTLFLAG_RW | + CTLFLAG_MPSAFE, &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "Local offset from UTC in seconds"); static int ct_debug; Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Tue Jun 28 16:41:50 2016 (r302250) +++ head/sys/kern/subr_rtc.c Tue Jun 28 16:42:40 2016 (r302251) @@ -62,6 +62,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #ifdef FFCLOCK #include @@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$"); static device_t clock_dev = NULL; static long clock_res; static struct timespec clock_adj; +static struct mtx resettodr_lock; +MTX_SYSINIT(resettodr_init, &resettodr_lock, "tod2rl", MTX_DEF); /* XXX: should be kern. now, it's no longer machdep. */ static int disable_rtc_set; @@ -168,11 +172,14 @@ resettodr(void) if (disable_rtc_set || clock_dev == NULL) return; + mtx_lock(&resettodr_lock); getnanotime(&ts); timespecadd(&ts, &clock_adj); ts.tv_sec -= utc_offset(); /* XXX: We should really set all registered RTCs */ - if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) + error = CLOCK_SETTIME(clock_dev, &ts); + mtx_unlock(&resettodr_lock); + if (error != 0) printf("warning: clock_settime failed (%d), time-of-day clock " "not adjusted to system time\n", error); }