From owner-freebsd-current@freebsd.org Fri Feb 24 04:15:57 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EE442CEB92E for ; Fri, 24 Feb 2017 04:15:57 +0000 (UTC) (envelope-from jiashiun@gmail.com) Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A92A18EB; Fri, 24 Feb 2017 04:15:57 +0000 (UTC) (envelope-from jiashiun@gmail.com) Received: by mail-qk0-x242.google.com with SMTP id x71so1538270qkb.0; Thu, 23 Feb 2017 20:15:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=H+hHptrhsuEr6+t53+0RmpxcjVOy2es08tlwA4gFpSI=; b=pi4+O8GyTKAtgo3wXSgjMM9a9WzS12cU8rjjBtCluuoZFafiFMNmMYOKqDTkXZHFOT qnuKexGg9t/tkfVkJyvaTqXrgeF1ACEoxwOI5+WyMoki2rUI0aZGTPu9a3FtqciQ1Yke zLMzDD194kjhS5Eh2K4BJsBbIDpciLAbPT8z4LIx1mS/0QnJTVBN90tPx2ZROxCmSyU0 /BJLYy1OZSay7IyFwOizzoftCRQOC2OXisoFNZEtjq5h5ikNRLPIJQ+Mw/9zBTfWwRc1 ferOiPR8ut9t4+07X4+BIKKNYMDoewQzMsfjcuuK8bO3WRE4FHACFauKOugUyCut+kjU crPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=H+hHptrhsuEr6+t53+0RmpxcjVOy2es08tlwA4gFpSI=; b=l/Z6DLob2B8vaevPr1DYA3gqkgK5G6PXYo4m9NAcOD52J3dbDUnu4oSxg+mxURlCqH F4CjRoZhgdp5pz6VDjwI83eU0Tn/Iw5yRuZo6P2aTW1rVjpoIUp18tiO8aJTa+8zw2YF F92fHOVrDh7pFG9yI+UwQMCvKXFtjQv/oCATE54X4sHwXWggRInXG8UmFrkffFkbi9i6 /w/qgHkcNeWfrowPC/X59neC1zMAXor0OPpxrWI1K2pStlaeToJY4LugHeFJPppcgeFs IVYHfvCFvFM1q+QnOrPh4yHZ3fozYAnMp+cM+NqAIAOyzCiiTyzWnBqONmRvk1LUW2QR i1lA== X-Gm-Message-State: AMke39n9wp4zf+gD1JFjJO+W0WR0ZbeM4jfMj4JiT56InEzCIvnXjtZywMgA2SJiuP19SMoTpZS/gJQ3rdhMAg== X-Received: by 10.55.46.2 with SMTP id u2mr686255qkh.231.1487909756720; Thu, 23 Feb 2017 20:15:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.104.8 with HTTP; Thu, 23 Feb 2017 20:15:26 -0800 (PST) In-Reply-To: <2204246.QKzIRnxiUQ@ralph.baldwin.cx> References: <20170113120534.GC2349@kib.kiev.ua> <20170223100829.GR2092@kib.kiev.ua> <2204246.QKzIRnxiUQ@ralph.baldwin.cx> From: Jia-Shiun Li Date: Fri, 24 Feb 2017 12:15:26 +0800 Message-ID: Subject: Re: TSC as timecounter makes system lag To: John Baldwin Cc: Konstantin Belousov , freebsd-current , Konstantin Belousov Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 24 Feb 2017 04:15:58 -0000 On Fri, Feb 24, 2017 at 12:55 AM, John Baldwin wrote: > On Thursday, February 23, 2017 11:04:58 PM Jia-Shiun Li wrote: > > > > > > This does not work. > > > > I added a printf before the outer if clause, and it says > > > > init_TSC_tc:546: deepest 00000000 vendor 00008086 amd_pminfo 00000000 > > > > full boot dmesg attached. Looks init_TSC_tc() is called too early before > > acpi_cpu_attach() initializing cpu_deepest_sleep. Maybe it should be put > > after > > driver initialization, since it depends on probed ACPI C states? > > We don't actually need cpu_deepest_sleep. We could just set C2STOP always. > It doesn't hurt to have the flag set if the system only supports C1 except > that you get the printf in a verbose boot. > > Try this slight variation of Konstantin's patch. If this works we can > remove > cpu_deepest_sleep entirely as a followup since it will no longer be used: > > Index: tsc.c > =================================================================== > --- tsc.c (revision 314113) > +++ tsc.c (working copy) > @@ -542,9 +542,11 @@ init_TSC_tc(void) > * result incorrect runtimes for kernel idle threads (but not > * for any non-idle threads). > */ > - if (cpu_deepest_sleep >= 2 && cpu_vendor_id == CPU_VENDOR_INTEL && > + if (cpu_vendor_id == CPU_VENDOR_INTEL && > (amd_pminfo & AMDPM_TSC_INVARIANT) == 0) { > tsc_timecounter.tc_flags |= TC_FLAGS_C2STOP; > + if (timecounter == &tsc_timecounter) > + cpu_disable_c2_sleep++; > if (bootverbose) > printf("TSC timecounter disables C2 and C3.\n"); > } > Tested working on E7400 against r313909. And changing timecounter from/to TSC correctly enables/disables C2. The latter part cpu_disable_c2_sleep++ is not needed. When init_TSC_tc() got called timecounter is not yet tsc_timecounter. inittimecounter() later will do the work calling tc_windup(). -Jia-Shiun.