Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2018 15:37:32 +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: r330020 - head/stand/lua
Message-ID:  <201802261537.w1QFbWlt014007@repo.freebsd.org>

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



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