From owner-svn-src-all@freebsd.org Sun Jan 12 09:00:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D53ED22982A; Sun, 12 Jan 2020 09:00:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47wVzs42YKz49hj; Sun, 12 Jan 2020 09:00:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id 00C90Adm029140 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 12 Jan 2020 11:00:13 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 00C90Adm029140 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 00C90Apm029138; Sun, 12 Jan 2020 11:00:10 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 12 Jan 2020 11:00:10 +0200 From: Konstantin Belousov To: Mateusz Guzik 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> References: <202001120609.00C69Anp050819@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202001120609.00C69Anp050819@repo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.3 X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on tom.home X-Rspamd-Queue-Id: 47wVzs42YKz49hj X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 09:00:25 -0000 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 */