From owner-freebsd-arch@FreeBSD.ORG Mon May 14 22:48:19 2012 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89ECA106564A; Mon, 14 May 2012 22:48:19 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 22E688FC08; Mon, 14 May 2012 22:48:19 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 58B2A1DD65E; Tue, 15 May 2012 00:48:17 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 3E0822847A; Tue, 15 May 2012 00:48:17 +0200 (CEST) Date: Tue, 15 May 2012 00:48:17 +0200 From: Jilles Tjoelker To: Warner Losh Message-ID: <20120514224817.GA31383@stack.nl> References: <20120513220646.GA12826@stack.nl> <4FB0CF88.5010309@FreeBSD.org> <3D895644-0BA5-44F7-AC8F-07323729C1AA@bsdimp.com> <88BE52F2-E8CC-455D-B7AF-CB1F876D48B7@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <88BE52F2-E8CC-455D-B7AF-CB1F876D48B7@bsdimp.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Doug Barton , freebsd-arch@FreeBSD.org Subject: Re: [patch] halt/reboot/shutdown cleanup X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 May 2012 22:48:19 -0000 On Mon, May 14, 2012 at 08:52:44AM -0600, Warner Losh wrote: > On May 14, 2012, at 8:36 AM, Warner Losh wrote: > > On May 14, 2012, at 3:25 AM, Doug Barton wrote: > >> This topic comes up very often as users are confused by the fact that we > >> have 2 different methods for shutdown/reboot, and the ones that seem the > >> most obvious (halt and reboot) are the most pathological. > >> IMO we should maintain the old behavior as binaries with scary names > >> that the anachronists can use in local aliases, and we should modify > >> halt and reboot in a manner similar to what Jilles is suggesting. > > See my other post for a way forward, sans bogusly scary names. The names fastboot and fasthalt could be used for the traditional behaviour. > This may also be a cultural divide between the embedded world, where > halt means halt right now and reboot where reboot means reboot right > now and the server world where users need to be told of things and a > more generic infrastructure needs to be in place. In embedded, when > you decide to reboot, you know everybody else has cleaned up and you > want to give the best experience to the user by doing it as fast as > possible. In the server space, people that are logged in need to be > told, there's a richer framework that needs to run, etc and time to > get back to passing WiFi packets isn't as important. In that embedded case, you may want 'reboot -q', which will remain unchanged. This calls reboot(2) directly so it syncs the disks but does not attempt to terminate any processes cleanly. I have found 4 seconds of useless sleeps in the 'shutdown -r now' process: 2 seconds in shutdown and 2 seconds in init. I have used an init without the delay for quite a while without problems and the delay in shutdown seems useless (between saying the shutdown is "now" and actually signaling init to do it). With those delays removed (patch below), shutting down via shutdown or init may be even faster than via reboot. This is because reboot always waits at least 5 seconds between sending SIGTERM and SIGKILL, while init stops waiting immediately if the last process terminates. Reboot may be faster if something is hung or if rc.shutdown exists and is very slow, which may be the case on embedded platforms. Soft updates syncing at shutdown is also very slow, but that is a kernel issue. > The distaste for extra, useless messages, I'll admit, is a personality > quirk that I share with many people. I don't feel strongly about the messages. Index: sbin/init/init.c =================================================================== --- sbin/init/init.c (revision 235360) +++ sbin/init/init.c (working copy) @@ -646,8 +646,6 @@ if (Reboot) { /* Instead of going single user, let's reboot the machine */ sync(); - alarm(2); - pause(); reboot(howto); _exit(0); } Index: sbin/shutdown/shutdown.c =================================================================== --- sbin/shutdown/shutdown.c (revision 235360) +++ sbin/shutdown/shutdown.c (working copy) @@ -356,7 +356,6 @@ syslog(LOG_NOTICE, "%s by %s: %s", doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" : "shutdown", whom, mbuf); - (void)sleep(2); (void)printf("\r\nSystem shutdown time has arrived\007\007\r\n"); if (killflg) { -- Jilles Tjoelker