From owner-freebsd-current@freebsd.org Thu May 17 09:20:09 2018 Return-Path: Delivered-To: freebsd-current@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 A0EE3EE2769 for ; Thu, 17 May 2018 09:20:09 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DC1875718; Thu, 17 May 2018 09:20:09 +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 w4H9JvXR016269 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 17 May 2018 12:20:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w4H9JvXR016269 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w4H9JvRh016268; Thu, 17 May 2018 12:19:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 17 May 2018 12:19:57 +0300 From: Konstantin Belousov To: Andriy Gapon Cc: Johannes Lundberg , freebsd-current Subject: Re: Lag after resume culprit found Message-ID: <20180517091957.GF6887@kib.kiev.ua> References: <4d69b9f6-9406-74ba-1780-ac783adcf107@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4d69b9f6-9406-74ba-1780-ac783adcf107@FreeBSD.org> User-Agent: Mutt/1.9.5 (2018-04-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,FREEMAIL_REPLY,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 May 2018 09:20:09 -0000 On Thu, May 17, 2018 at 11:06:42AM +0300, Andriy Gapon wrote: > On 17/05/2018 10:56, Johannes Lundberg wrote: > > > > > > On Thu, May 17, 2018 at 8:46 AM, Johannes Lundberg > > wrote: > > > > > > > > On Thu, May 17, 2018 at 7:43 AM, Andriy Gapon > > wrote: > > > > On 17/05/2018 02:07, Johannes Lundberg wrote: > > > https://github.com/freebsd/freebsd/commit/66f063557f257baa9c8aeab9f933171eaa6e1cfa > > > > > x86 cpususpend_handler: call wbinvd after setting suspend state bits > > > > That's very interesting and surprising. > > That commit changes something that happens before suspend, it should not > > have > > any effect on the system state after resume. > > > > Does anyone have a theory of what could be wrong? > > > > > > Nope but moving > > ššš ššš CPU_CLR_ATOMIC(cpu, &suspended_cpus); > > back to the end of that scope fixes it. > > š > > > > > > I did some further testing. > > Calling > > CPU_CLR_ATOMIC(cpu, &suspended_cpus); > > before > > pmap_init_pat(); > > šis what "breaks" resume. > > > > Is this Intel only or this it happen on AMD as well (which this patch was > > intended for)? > > Not sure about the PAT part, but fpuresume/npxresume would affect all platforms. > It's a bit puzzling that doing PAT manipulations on one AP while another AP is > being brought up is problematic. Probably there is something that I am missing. Manipulating PAT might affect the cache consistency, since contradicting caching attributes are applied to the line of the suspended_cpus variable which is already cached. It might be not the variable itself that causes the final mis-operation, but some other data sharing the line.