From owner-svn-src-all@freebsd.org Fri Apr 20 15:48:51 2018 Return-Path: Delivered-To: svn-src-all@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 82A8AFADD19; Fri, 20 Apr 2018 15:48:51 +0000 (UTC) (envelope-from jtl@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 27720746CE; Fri, 20 Apr 2018 15:48:51 +0000 (UTC) (envelope-from jtl@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 09AEB1A4D4; Fri, 20 Apr 2018 15:48:51 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3KFmo0j098071; Fri, 20 Apr 2018 15:48:50 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3KFmofE098069; Fri, 20 Apr 2018 15:48:50 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201804201548.w3KFmofE098069@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Fri, 20 Apr 2018 15:48:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332830 - in stable/11/sys: dev/acpica x86/x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: jtl X-SVN-Commit-Paths: in stable/11/sys: dev/acpica x86/x86 X-SVN-Commit-Revision: 332830 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 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: Fri, 20 Apr 2018 15:48:51 -0000 Author: jtl Date: Fri Apr 20 15:48:50 2018 New Revision: 332830 URL: https://svnweb.freebsd.org/changeset/base/332830 Log: MFC r313447: Ensure the idle thread's loop services interrupts in a timely way when using the ACPI C1/mwait sleep method. Previously, the mwait instruction would return when an interrupt was pending; however, the idle loop did not actually enable interrupts when this occurred. This led to a situation where the idle loop could quickly spin through the C1/mwait sleep method a number of times when an interrupt was pending. (Eventually, the situation corrected itself when something other than an interrupt triggered the idle loop to either enable interrupts or schedule another thread.) Sponsored by: Netflix, Inc. Modified: stable/11/sys/dev/acpica/acpi_cpu.c stable/11/sys/x86/x86/cpu_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/acpica/acpi_cpu.c ============================================================================== --- stable/11/sys/dev/acpica/acpi_cpu.c Fri Apr 20 15:44:29 2018 (r332829) +++ stable/11/sys/dev/acpica/acpi_cpu.c Fri Apr 20 15:48:50 2018 (r332830) @@ -1151,6 +1151,9 @@ acpi_cpu_idle(sbintime_t sbt) end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate(); if (curthread->td_critnest == 0) end_time = min(end_time, 500000 / hz); + /* acpi_cpu_c1() returns with interrupts enabled. */ + if (cx_next->do_mwait) + ACPI_ENABLE_IRQS(); sc->cpu_prev_sleep = (sc->cpu_prev_sleep * 3 + end_time) / 4; return; } Modified: stable/11/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/11/sys/x86/x86/cpu_machdep.c Fri Apr 20 15:44:29 2018 (r332829) +++ stable/11/sys/x86/x86/cpu_machdep.c Fri Apr 20 15:48:50 2018 (r332830) @@ -146,6 +146,14 @@ acpi_cpu_c1(void) __asm __volatile("sti; hlt"); } +/* + * Use mwait to pause execution while waiting for an interrupt or + * another thread to signal that there is more work. + * + * NOTE: Interrupts will cause a wakeup; however, this function does + * not enable interrupt handling. The caller is responsible to enable + * interrupts. + */ void acpi_cpu_idle_mwait(uint32_t mwait_hint) {