Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 14:21:57 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329576 - head/stand/lua
Message-ID:  <201802191421.w1JELv5A026289@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802191421.w1JELv5A026289>