svn commit: r330020 - head/stand/lua

Kyle Evans kevans at FreeBSD.org
Mon Feb 26 15:37:34 UTC 2018


Author: kevans
Date: Mon Feb 26 15:37:32 2018
New Revision: 330020
URL: https://svnweb.freebsd.org/changeset/base/330020

Log:
  lualoader: Re-work menu skipping bits
  
  This is motivated by a want to reduce heap usage if the menu is being
  skipped. Currently, the menu module must be loaded regardless of whether
  it's being skipped or not, which adds a cool ~50-100KB worth of memory
  usage.
  
  Move the menu skip logic out to core (and remove a debug print), then check
  in loader.lua if we should be skipping the menu and avoid loading the menu
  module entirely if so. This keeps our memory usage below ~115KB for a boot
  with the menu stripped.
  
  Also worth noting: with this change, we no longer explicitly invoke autoboot
  if we're skipping the menu. Instead, we let the standard loader behavior
  apply: try to autoboot if we need to, then drop to a loader prompt if not or
  if the autoboot sequence is interrupted. The only thing we still handle
  before dropping to the loader autoboot sequence is loadelf(), so that we can
  still apply any of our kernel loading behavior.

Modified:
  head/stand/lua/core.lua
  head/stand/lua/loader.lua
  head/stand/lua/menu.lua

Modified: head/stand/lua/core.lua
==============================================================================
--- head/stand/lua/core.lua	Mon Feb 26 14:00:23 2018	(r330019)
+++ head/stand/lua/core.lua	Mon Feb 26 15:37:32 2018	(r330020)
@@ -285,6 +285,20 @@ function core.isSystem386()
 	return loader.machine_arch == "i386"
 end
 
+-- Is the menu skipped in the environment in which we've booted?
+function core.isMenuSkipped()
+	if core.isSerialBoot() then
+		return true
+	end
+	local c = string.lower(loader.getenv("console") or "")
+	if c:match("^efi[ ;]") ~= nil or c:match("[ ;]efi[ ;]") ~= nil then
+		return true
+	end
+
+	c = string.lower(loader.getenv("beastie_disable") or "")
+	return c == "yes"
+end
+
 -- This may be a better candidate for a 'utility' module.
 function core.deepCopyTable(tbl)
 	local new_tbl = {}

Modified: head/stand/lua/loader.lua
==============================================================================
--- head/stand/lua/loader.lua	Mon Feb 26 14:00:23 2018	(r330019)
+++ head/stand/lua/loader.lua	Mon Feb 26 15:37:32 2018	(r330020)
@@ -30,8 +30,12 @@
 --
 
 require("cli")
+local core = require("core")
 local config = require("config")
-local menu = require("menu")
+local menu
+if not core.isMenuSkipped() then
+	menu = require("menu")
+end
 local password = require("password")
 
 local result = lfs.attributes("/boot/lua/local.lua")
@@ -42,4 +46,10 @@ end
 
 config.load()
 password.check()
-menu.run()
+-- menu might be disabled
+if menu ~= nil then
+	menu.run()
+else
+	-- Load kernel/modules before we go
+	config.loadelf()
+end

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Mon Feb 26 14:00:23 2018	(r330019)
+++ head/stand/lua/menu.lua	Mon Feb 26 15:37:32 2018	(r330020)
@@ -405,11 +405,6 @@ function menu.process(menudef, keypress)
 end
 
 function menu.run()
-	if menu.skip() then
-		core.autoboot()
-		return
-	end
-
 	menu.draw(menu.default)
 	local autoboot_key = menu.autoboot()
 
@@ -418,20 +413,6 @@ function menu.run()
 
 	screen.defcursor()
 	print("Exiting menu!")
-end
-
-function menu.skip()
-	if core.isSerialBoot() then
-		return true
-	end
-	local c = string.lower(loader.getenv("console") or "")
-	if c:match("^efi[ ;]") ~= nil or c:match("[ ;]efi[ ;]") ~= nil then
-		return true
-	end
-
-	c = string.lower(loader.getenv("beastie_disable") or "")
-	print("beastie_disable", c)
-	return c == "yes"
 end
 
 function menu.autoboot()


More information about the svn-src-head mailing list