Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2020 11:00:10 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Guzik <mjg@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r356656 - in head/sys: kern sys
Message-ID:  <20200112090010.GA2068@kib.kiev.ua>
In-Reply-To: <202001120609.00C69Anp050819@repo.freebsd.org>
References:  <202001120609.00C69Anp050819@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 12, 2020 at 06:09:10AM +0000, Mateusz Guzik wrote:
> Author: mjg
> Date: Sun Jan 12 06:09:10 2020
> New Revision: 356656
> URL: https://svnweb.freebsd.org/changeset/base/356656
> 
> Log:
>   Add "panicked" boolean which can be tested instead of panicstr
>   
>   The test is performed all the time and reading entire panicstr to do it
>   wastes space.
What space does it waste ?  The space in the read-mostly section ?

And what is the difference between reading a pointer vs. reading a byte ?
CPU still has to read the whole cache line.

> 
> Modified:
>   head/sys/kern/kern_shutdown.c
>   head/sys/sys/systm.h
> 
> Modified: head/sys/kern/kern_shutdown.c
> ==============================================================================
> --- head/sys/kern/kern_shutdown.c	Sun Jan 12 06:07:54 2020	(r356655)
> +++ head/sys/kern/kern_shutdown.c	Sun Jan 12 06:09:10 2020	(r356656)
> @@ -217,7 +217,8 @@ SYSCTL_INT(_kern, OID_AUTO, kerneldump_gzlevel, CTLFLA
>   * Variable panicstr contains argument to first call to panic; used as flag
>   * to indicate that the kernel has already called panic.
>   */
> -const char __read_mostly *panicstr;
> +const char *panicstr;
> +bool __read_frequently panicked;
>  
>  int __read_mostly dumping;		/* system is dumping */
>  int rebooting;				/* system is rebooting */
> @@ -873,6 +874,7 @@ vpanic(const char *fmt, va_list ap)
>  	else {
>  		bootopt |= RB_DUMP;
>  		panicstr = fmt;
> +		panicked = true;
>  		newpanic = 1;
>  	}
>  
> 
> Modified: head/sys/sys/systm.h
> ==============================================================================
> --- head/sys/sys/systm.h	Sun Jan 12 06:07:54 2020	(r356655)
> +++ head/sys/sys/systm.h	Sun Jan 12 06:09:10 2020	(r356656)
> @@ -53,7 +53,8 @@ extern int cold;		/* nonzero if we are doing a cold bo
>  extern int suspend_blocked;	/* block suspend due to pending shutdown */
>  extern int rebooting;		/* kern_reboot() has been called. */
>  extern const char *panicstr;	/* panic message */
> -#define	KERNEL_PANICKED()	__predict_false(panicstr != NULL)
> +extern bool panicked;
> +#define	KERNEL_PANICKED()	__predict_false(panicked)
>  extern char version[];		/* system version */
>  extern char compiler_version[];	/* compiler version */
>  extern char copyright[];	/* system copyright */



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