From owner-svn-src-all@freebsd.org Mon Feb 19 14:21:58 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D90A1F034A8; Mon, 19 Feb 2018 14:21:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8781B777BC; Mon, 19 Feb 2018 14:21:57 +0000 (UTC) (envelope-from kevans@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6845D1BA51; Mon, 19 Feb 2018 14:21:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1JELvDJ026294; Mon, 19 Feb 2018 14:21:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1JELv5A026289; Mon, 19 Feb 2018 14:21:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802191421.w1JELv5A026289@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 19 Feb 2018 14:21:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329576 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329576 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2018 14:21:58 -0000 Author: kevans Date: Mon Feb 19 14:21:56 2018 New Revision: 329576 URL: https://svnweb.freebsd.org/changeset/base/329576 Log: stand/lua: Defer kernel/module loading until boot or menu escape Loading the kernel and modules can be really slow. Loading before the menu draws and every time one changes kernel/boot environment is even more painful. Defer loading until we either boot, auto-boot, or escape to loader prompt. We still need to deal with configuration changes as the boot environment changes, but this is generally much quicker. This commit strips all ELF loading out of config.load/config.reload so that these are purely for configuration. config.loadelf has been created to deal with kernel/module loads. Unloading logic has been ripped out, as we won't need to deal with it in the menu anymore. Discussed in part with: allanjude Modified: head/stand/lua/config.lua head/stand/lua/core.lua head/stand/lua/menu.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Mon Feb 19 12:52:17 2018 (r329575) +++ head/stand/lua/config.lua Mon Feb 19 14:21:56 2018 (r329576) @@ -345,6 +345,9 @@ function config.loadkernel(other_kernel) end end +function config.selectkernel(kernel) + config.kernel_selected = kernel; +end function config.load(file) if (not file) then @@ -367,40 +370,38 @@ function config.load(file) -- Cache the provided module_path at load time for later use config.module_path = loader.getenv("module_path"); +end - print("Loading kernel..."); - config.loadkernel(config.kernel_loaded); - - print("Loading configured modules..."); - if (not config.loadmod(modules)) then - print("Could not load one or more modules!"); - end +-- Reload configuration +function config.reload(file) + -- XXX TODO: We should be doing something more here to clear out env + -- changes that rode in with the last configuration load + modules = {}; + config.load(file); end -function config.reload(kernel) - local kernel_loaded = false; +function config.loadelf() + local kernel = config.kernel_loaded or config.kernel_selected; + local loaded = false; - -- unload all modules - print("Unloading modules..."); - loader.perform("unload"); + print("Loading kernel..."); + loaded = config.loadkernel(kernel); - if (kernel ~= nil) then - print("Trying to load '" .. kernel .. "'") - kernel_loaded = config.loadkernel(kernel); - if (kernel_loaded) then - print("Kernel '" .. kernel .. "' loaded!"); - end + if (not loaded) then + loaded = config.loadkernel(); end - -- failed to load kernel or it is nil - -- then load default - if (not kernel_loaded) then - print("Loading default kernel..."); - config.loadkernel(); + if (not loaded) then + -- Ultimately failed to load kernel + print("Failed to load any kernel"); + return; end - -- load modules - config.loadmod(modules); + print("Loading configured modules..."); + if (not config.loadmod(modules)) then + print("Could not load one or more modules!"); + end end + return config Modified: head/stand/lua/core.lua ============================================================================== --- head/stand/lua/core.lua Mon Feb 19 12:52:17 2018 (r329575) +++ head/stand/lua/core.lua Mon Feb 19 14:21:56 2018 (r329576) @@ -26,6 +26,8 @@ -- $FreeBSD$ -- +local config = require('config'); + local core = {}; -- Commonly appearing constants @@ -180,10 +182,12 @@ function core.setDefaults() end function core.autoboot() + config.loadelf(); loader.perform("autoboot"); end function core.boot() + config.loadelf(); loader.perform("boot"); end Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Mon Feb 19 12:52:17 2018 (r329575) +++ head/stand/lua/menu.lua Mon Feb 19 14:21:56 2018 (r329576) @@ -220,9 +220,7 @@ menu.welcome = { " of " .. #all_choices .. ")"; end, func = function(idx, choice, all_choices) - if (#all_choices > 1) then - config.reload(choice); - end + config.selectkernel(choice); end, alias = {"k", "K"} }, @@ -332,6 +330,7 @@ function menu.run(m) if (m == menu.welcome) then screen.defcursor(); print("Exiting menu!"); + config.loadelf(); return false; end