From owner-svn-src-head@freebsd.org Wed Apr 24 18:24:24 2019 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 E8694159FEA3; Wed, 24 Apr 2019 18:24:23 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8FFE4734E5; Wed, 24 Apr 2019 18:24:23 +0000 (UTC) (envelope-from cem@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 69D38180CA; Wed, 24 Apr 2019 18:24:23 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3OIONXP007618; Wed, 24 Apr 2019 18:24:23 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3OIONL2007617; Wed, 24 Apr 2019 18:24:23 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201904241824.x3OIONL2007617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Wed, 24 Apr 2019 18:24:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346643 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 346643 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8FFE4734E5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Wed, 24 Apr 2019 18:24:24 -0000 Author: cem Date: Wed Apr 24 18:24:22 2019 New Revision: 346643 URL: https://svnweb.freebsd.org/changeset/base/346643 Log: x86: Halt non-BSP CPUs on panic IPI_STOP We may need the BSP to reboot, but we don't need any AP CPU that isn't the panic thread. Any CPU landing in this routine during panic isn't the panic thread, so we can just detect !BSP && panic and shut down the logical core. The savings can be demonstrated in a bhyve guest with multiple cores; before this change, N guest threads would spin at 100% CPU. After this change, only one or two threads spin (depending on if the panicing CPU was the BSP or not). Konstantin points out that this may break any future patches which allow switching ddb(4) CPUs after panic and examining CPU-local state that cannot be inspected remotely. In the event that such a mechanism is incorporated, this behavior could be made configurable by tunable/sysctl. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D20019 Modified: head/sys/x86/x86/mp_x86.c Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Wed Apr 24 17:30:50 2019 (r346642) +++ head/sys/x86/x86/mp_x86.c Wed Apr 24 18:24:22 2019 (r346643) @@ -1406,8 +1406,17 @@ cpustop_handler(void) CPU_SET_ATOMIC(cpu, &stopped_cpus); /* Wait for restart */ - while (!CPU_ISSET(cpu, &started_cpus)) - ia32_pause(); + while (!CPU_ISSET(cpu, &started_cpus)) { + ia32_pause(); + + /* + * Halt non-BSP CPUs on panic -- we're never going to need them + * again, and might as well save power / release resources + * (e.g., overprovisioned VM infrastructure). + */ + while (__predict_false(!IS_BSP() && panicstr != NULL)) + halt(); + } cpustop_handler_post(cpu); }