From tim@robbins.dropbear.id.au  Sun Mar 16 03:07:22 2003
Return-Path: <tim@robbins.dropbear.id.au>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 4D28B37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Mar 2003 03:07:22 -0800 (PST)
Received: from smtp01.syd.iprimus.net.au (smtp01.syd.iprimus.net.au [210.50.30.70])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4EEB243FB1
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Mar 2003 03:07:21 -0800 (PST)
	(envelope-from tim@robbins.dropbear.id.au)
Received: from dilbert.robbins.dropbear.id.au ([210.50.221.219]) by smtp01.syd.iprimus.net.au with Microsoft SMTPSVC(5.0.2195.5600);
	 Sun, 16 Mar 2003 22:07:15 +1100
Received: from dilbert.robbins.dropbear.id.au (260g6rid71x8xsf8@localhost [127.0.0.1])
	by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6) with ESMTP id h2GB77JK084190
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 16 Mar 2003 22:07:09 +1100 (EST)
	(envelope-from tim@dilbert.robbins.dropbear.id.au)
Received: (from tim@localhost)
	by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6/Submit) id h2GB7712084189;
	Sun, 16 Mar 2003 22:07:07 +1100 (EST)
	(envelope-from tim)
Message-Id: <200303161107.h2GB7712084189@dilbert.robbins.dropbear.id.au>
Date: Sun, 16 Mar 2003 22:07:07 +1100 (EST)
From: Tim Robbins <tim@robbins.dropbear.id.au>
Reply-To: Tim Robbins <tim@robbins.dropbear.id.au>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Kernel threads and init have incorrect start time
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50045
>Category:       kern
>Synopsis:       Kernel threads and init have incorrect start time
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    phk
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 16 03:10:06 PST 2003
>Closed-Date:    Thu Apr 24 15:02:57 PDT 2003
>Last-Modified:  Thu Apr 24 15:04:32 PDT 2003
>Originator:     Tim Robbins
>Release:        FreeBSD 5.0-RELEASE
>Organization:
The FreeBSD Project
>Environment:
System: FreeBSD 5.0-RELEASE

	
>Description:
The start time, as shown by ps -aux, is incorrect for kernel threads and
init. The times are shown as January 1, 1970, instead of the system boot
time.
>How-To-Repeat:
ps -aux
>Fix:

The problem seems to occur because inittodr() is not called early
enough. I think revision 1.888 of init_main.c is the culprit:

revision 1.188
date: 2002/03/08 10:33:11;  author: phk;  state: Exp;  lines: +2 -0
Move the mount of the root filesystem to happen in the init process before
the exec if /sbin/init.

This allows the scheduler to get started and kthreads a chance to run
before we start filesystem operations.

This patch makes the start times for kernel threads + init as correct as
they are on RELENG_4 by calling inittodr() from inittimecounter().
It has only been tested on i386.

Index: kern_tc.c
===================================================================
RCS file: /x/freebsd/src/sys/kern/kern_tc.c,v
retrieving revision 1.145
diff -u -r1.145 kern_tc.c
--- kern_tc.c	16 Jan 2003 20:06:45 -0000	1.145
+++ kern_tc.c	17 Jan 2003 11:45:07 -0000
@@ -692,6 +692,9 @@
 	/* warm up new timecounter (again) and get rolling. */
 	(void)timecounter->tc_get_timecount(timecounter);
 	(void)timecounter->tc_get_timecount(timecounter);
+
+	/* Initialise the time of day register. */
+	inittodr(0);
 }
 
 SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL)
>Release-Note:
>Audit-Trail:

From: "Tim Robbins" <tim@robbins.dropbear.id.au>
To: <FreeBSD-gnats-submit@FreeBSD.org>
Cc:  
Subject: kern/50045: Kernel threads and init have incorrect start time
Date: Sun, 16 Mar 2003 22:07:07 +1100 (EST)

 >Number:         50045
 >Category:       kern
 >Synopsis:       Kernel threads and init have incorrect start time
 >Confidential:   no
 >Severity:       non-critical
 >Priority:       medium
 >Responsible:    freebsd-bugs
 >State:          open
 >Quarter:        
 >Keywords:       
 >Date-Required:
 >Class:          sw-bug
 >Submitter-Id:   current-users
 >Arrival-Date:   Sun Mar 16 03:10:06 PST 2003
 >Closed-Date:
 >Last-Modified:
 >Originator:     Tim Robbins
 >Release:        FreeBSD 5.0-RELEASE
 >Organization:
 The FreeBSD Project
 >Environment:
 System: FreeBSD 5.0-RELEASE
 
 =09
 >Description:
 The start time, as shown by ps -aux, is incorrect for kernel threads and
 init. The times are shown as January 1, 1970, instead of the system boot
 time.
 >How-To-Repeat:
 ps -aux
 >Fix:
 
 The problem seems to occur because inittodr() is not called early
 enough. I think revision 1.888 of init_main.c is the culprit:
 
 revision 1.188
 date: 2002/03/08 10:33:11;  author: phk;  state: Exp;  lines: +2 -0
 Move the mount of the root filesystem to happen in the init process before
 the exec if /sbin/init.
 
 This allows the scheduler to get started and kthreads a chance to run
 before we start filesystem operations.
 
 This patch makes the start times for kernel threads + init as correct as
 they are on RELENG_4 by calling inittodr() from inittimecounter().
 It has only been tested on i386.
 
 Index: kern_tc.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /x/freebsd/src/sys/kern/kern_tc.c,v
 retrieving revision 1.145
 diff -u -r1.145 kern_tc.c
 --- kern_tc.c=0916 Jan 2003 20:06:45 -0000=091.145
 +++ kern_tc.c=0917 Jan 2003 11:45:07 -0000
 @@ -692,6 +692,9 @@
  =09/* warm up new timecounter (again) and get rolling. */
  =09(void)timecounter->tc_get_timecount(timecounter);
  =09(void)timecounter->tc_get_timecount(timecounter);
 +
 +=09/* Initialise the time of day register. */
 +=09inittodr(0);
  }
  
  SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL=
 )
 >Release-Note:
 >Audit-Trail:
 >Unformatted:
 
 To Unsubscribe: send mail to majordomo@FreeBSD.org
 with "unsubscribe freebsd-bugs" in the body of the message
Responsible-Changed-From-To: freebsd-bugs->phk 
Responsible-Changed-By: tjr 
Responsible-Changed-When: Tue Apr 8 03:26:48 PDT 2003 
Responsible-Changed-Why:  
Over to phk. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50045 
State-Changed-From-To: open->closed 
State-Changed-By: gordon 
State-Changed-When: Thu Apr 24 15:02:29 PDT 2003 
State-Changed-Why:  
This was fixed by DES in src/sys/kern/kern_proc.c rev 1.180 and rev 1.182

http://www.freebsd.org/cgi/query-pr.cgi?pr=50045 
>Unformatted:
