From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 4 22:30:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B005C106566B for ; Sun, 4 Jul 2010 22:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 720878FC0A for ; Sun, 4 Jul 2010 22:30:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o64MU2hE005429 for ; Sun, 4 Jul 2010 22:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o64MU2RY005428; Sun, 4 Jul 2010 22:30:02 GMT (envelope-from gnats) Resent-Date: Sun, 4 Jul 2010 22:30:02 GMT Resent-Message-Id: <201007042230.o64MU2RY005428@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitry Pryanishnikov Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A239106566B for ; Sun, 4 Jul 2010 22:26:21 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 0E58C8FC1B for ; Sun, 4 Jul 2010 22:26:21 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o64MQKdI079414 for ; Sun, 4 Jul 2010 22:26:20 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o64MQKAk079386; Sun, 4 Jul 2010 22:26:20 GMT (envelope-from nobody) Message-Id: <201007042226.o64MQKAk079386@www.freebsd.org> Date: Sun, 4 Jul 2010 22:26:20 GMT From: Dmitry Pryanishnikov To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/148367: [patch] Add loader tunable to override SC_HISTORY_SIZE X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jul 2010 22:30:02 -0000 >Number: 148367 >Category: kern >Synopsis: [patch] Add loader tunable to override SC_HISTORY_SIZE >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jul 04 22:30:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Dmitry Pryanishnikov >Release: RELENG_8 >Organization: Home >Environment: FreeBSD lynx.homenet 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #0: Sun Jul 4 20:13:03 EEST 2010 dmitry@lynx.homenet:/databig/obj/databig/ftp/RELENG_8/src.100704/sys/lynx i386 >Description: It is useful to keep SC_HISTORY_SIZE value high, however it costs kernel memory. So in order to share the same kernel between machines with big and not-so-big RAM, one should be able to tune the size of back scroll buffer. The attached patch makes it possible via the loader tunable hw.syscons.history_size. Patch works with today's RELENG_8, it also applies to HEAD (and should work there, since schistory.c is the same in HEAD and RELENG_8 except __FBSDID line). >How-To-Repeat: >Fix: Patch attached with submission follows: --- sys/dev/syscons/syscons.h.orig 2010-03-02 03:56:55.000000000 +0200 +++ sys/dev/syscons/syscons.h 2010-07-04 00:43:11.366661343 +0300 @@ -572,6 +572,7 @@ /* schistory.c */ #ifndef SC_NO_HISTORY +void sc_init_history(void); int sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait); void sc_free_history_buffer(scr_stat *scp, int prev_ysize); --- sys/dev/syscons/syscons.c.orig 2010-03-31 18:39:46.000000000 +0300 +++ sys/dev/syscons/syscons.c 2010-07-04 00:43:11.368678117 +0300 @@ -2726,8 +2726,12 @@ int i; /* one time initialization */ - if (init_done == COLD) + if (init_done == COLD) { sc_get_bios_values(&bios_value); +#ifndef SC_NO_HISTORY + sc_init_history(); +#endif + } init_done = WARM; /* --- sys/dev/syscons/schistory.c.orig 2009-08-03 11:13:06.000000000 +0300 +++ sys/dev/syscons/schistory.c 2010-07-04 00:43:11.369673234 +0300 @@ -41,6 +41,7 @@ #include #include #include +#include #if defined(__sparc64__) || defined(__powerpc__) #include @@ -77,17 +78,37 @@ static int extra_history_size = SC_MAX_HISTORY_SIZE - SC_HISTORY_SIZE*MAXCONS; +static int sc_history_size = SC_HISTORY_SIZE; + +SYSCTL_DECL(_hw_syscons); +SYSCTL_INT(_hw_syscons, OID_AUTO, history_size, CTLFLAG_RDTUN, &sc_history_size, 0, + "Number of history buffer lines"); + /* local functions */ static void copy_history(sc_vtb_t *from, sc_vtb_t *to); static void history_to_screen(scr_stat *scp); +/* tune history buffer size */ +void +sc_init_history(void) +{ + + TUNABLE_INT_FETCH("hw.syscons.history_size", &sc_history_size); + if (sc_history_size < ROW * 4) + sc_history_size = ROW * 4; + extra_history_size = + ((sc_history_size * MAXCONS * MAXSC) > SC_MAX_HISTORY_SIZE ? + sc_history_size * MAXCONS * MAXSC : SC_MAX_HISTORY_SIZE) - + sc_history_size * MAXCONS; +} + /* allocate a history buffer */ int sc_alloc_history_buffer(scr_stat *scp, int lines, int prev_ysize, int wait) { /* * syscons unconditionally allocates buffers upto - * SC_HISTORY_SIZE lines or scp->ysize lines, whichever + * sc_history_size lines or scp->ysize lines, whichever * is larger. A value greater than that is allowed, * subject to extra_history_size. */ @@ -98,7 +119,7 @@ int delta; /* lines to put back */ if (lines <= 0) - lines = SC_HISTORY_SIZE; /* use the default value */ + lines = sc_history_size; /* use the default value */ /* make it at least as large as the screen size */ lines = imax(lines, scp->ysize); @@ -111,13 +132,13 @@ delta = 0; if (prev_history) { cur_lines = sc_vtb_rows(history); - min_lines = imax(SC_HISTORY_SIZE, prev_ysize); + min_lines = imax(sc_history_size, prev_ysize); if (cur_lines > min_lines) delta = cur_lines - min_lines; } /* lines upto min_lines are always allowed. */ - min_lines = imax(SC_HISTORY_SIZE, scp->ysize); + min_lines = imax(sc_history_size, scp->ysize); if (lines > min_lines) { if (lines - min_lines > extra_history_size + delta) { /* too many lines are requested */ @@ -196,7 +217,7 @@ return; cur_lines = sc_vtb_rows(history); - min_lines = imax(SC_HISTORY_SIZE, prev_ysize); + min_lines = imax(sc_history_size, prev_ysize); extra_history_size += (cur_lines > min_lines) ? cur_lines - min_lines : 0; --- share/man/man4/syscons.4.orig 2010-03-10 11:38:03.828597000 +0200 +++ share/man/man4/syscons.4 2010-07-04 18:41:03.496277934 +0300 @@ -442,6 +442,20 @@ for a keyboard device if it is not currently attached to one. Otherwise, the driver only probes for a keyboard once during bootup. .El +.Ss Loader Tunables +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Pa /boot/loader.conf . +Some of these tunables also have a matching +.Xr sysctl 8 +entry for access after boot. +.Bl -tag -width indent +.It hw.syscons.history_size +Override the size of back scroll buffer (specified by the +.Dv SC_HISTORY_SIZE +option). +.El .Sh FILES .Bl -tag -width /usr/share/syscons/xxxxyyyyzzz -compact .It Pa /dev/console >Release-Note: >Audit-Trail: >Unformatted: