From owner-svn-src-head@freebsd.org Mon Feb 26 15:37:33 2018 Return-Path: Delivered-To: svn-src-head@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 B919EF2D9EF; Mon, 26 Feb 2018 15:37:33 +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 6BC417A8EC; Mon, 26 Feb 2018 15:37:33 +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 6213B1D4BB; Mon, 26 Feb 2018 15:37:33 +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 w1QFbXL8014010; Mon, 26 Feb 2018 15:37:33 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1QFbWlt014007; Mon, 26 Feb 2018 15:37:32 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802261537.w1QFbWlt014007@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 26 Feb 2018 15:37:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330020 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 330020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Feb 2018 15:37:34 -0000 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()