From owner-freebsd-stable@freebsd.org Mon Aug 14 16:47:32 2017 Return-Path: Delivered-To: freebsd-stable@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 D3D69DD664B for ; Mon, 14 Aug 2017 16:47:32 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-lf0-x230.google.com (mail-lf0-x230.google.com [IPv6:2a00:1450:4010:c07::230]) (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 5460364F40 for ; Mon, 14 Aug 2017 16:47:32 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-lf0-x230.google.com with SMTP id o85so42057254lff.3 for ; Mon, 14 Aug 2017 09:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Fff90SlDBODRlkyixInCCvfpqr3VjeBxiP7Gc4MUh30=; b=d/F8i4Q3rJOkPp7UokNzoVWuSfF3vSvEiExDgtnailve9JFlRM52nKe6kRYHiXDjBZ spbltCgC/365iOfiRF07KIoIvfJYYUtLPnu8dRHXnTazqnXGXa7KGjbhTKTdprqnn1CQ xTiNyGsFUlbetouSXjQpxPCacMdR77UgmcjILl1QTY3iJGGaPyaJWJAuO/9g2hdB1AbP FpMUbTN6SaU0Yk8u9gpcPWVTJu7LDThBXvjyU3Im73d+hJzdIeZZPWTqR7vbdCh6Iwsy M5OPSu+ScufxkjV9S48wI0NbvOSZOCstvLxQTa99SKTykW2S/JE8clSr5AZ1AlPMe/zW 0jNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Fff90SlDBODRlkyixInCCvfpqr3VjeBxiP7Gc4MUh30=; b=UXs2aRDrG55cufSxlEKWoU7ie16camaGuv4AKL+9A0zIeaX8qYFMo4JHkSkVlQdfI9 /HBMGeq9olTVhfmHSlyGbEWcsxI3U3G9BSaYt4UMxt2Reo0aYwkCrFJnQNSRiXaIdNp/ G+Mz91zTD7FQp50XnxKcP9hRSMa+UdAPVEC262Df2zO++DNNhEOGTMznUQOrbhg4GEBF NQAE7lu8h/r2tdhUR33GgzXCt3x56t1J+nmU4MWsT8Fub+mhSLCMkyCCvv9cgoQJfgJG v8UxkfKe+C8wj+UJEtjIi7LE3QdMt4bcniqEmKBmeXbRtiKg5soIALr3b0UhMjmhbX3U /AAg== X-Gm-Message-State: AHYfb5gUDZR9T4Im05+BQ+l0nmh6U5l0DeklmUe0Y8iM8BFNEFOSf+W5 z1RLLOLlu8VeI+wi2kc= X-Received: by 10.25.92.132 with SMTP id u4mr8813073lfi.7.1502729249956; Mon, 14 Aug 2017 09:47:29 -0700 (PDT) Received: from spectre.mavhome.dp.ua ([134.249.139.101]) by smtp.gmail.com with ESMTPSA id q77sm1555743lfb.60.2017.08.14.09.47.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Aug 2017 09:47:27 -0700 (PDT) Sender: Alexander Motin Subject: Re: TSC timekeeping and cpu states To: Ian Smith , Aristedes Maniatis Cc: Kevin Oberman , freebsd-stable References: <2ef99f5e-46f5-a185-2ac3-67d6afe68c89@ish.com.au> <20170815010943.B12950@sola.nimnet.asn.au> From: Alexander Motin Message-ID: <96ecb63f-0c69-5ed7-d521-0fa826d78d39@FreeBSD.org> Date: Mon, 14 Aug 2017 19:47:25 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170815010943.B12950@sola.nimnet.asn.au> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Aug 2017 16:47:32 -0000 On 14.08.2017 18:38, Ian Smith wrote: > On Mon, 14 Aug 2017 17:16:22 +1000, Aristedes Maniatis wrote: > > On 14/8/17 3:08PM, Kevin Oberman wrote: > > > Again, the documentation lags reality. The default was changed for > > > 11.0. It is still conservative. In ALMOST all cases, Cmax will yield > > > the bast results. However, on large systems with many cores, Cmax > > > will trigger very poor results, so the default is C2, just to be > > > safe. > > Given it's a server, anything beyond C2 is likely not worth trying. > OTOH, C2 is perhaps not worth avoiding; it's probably low latency and > should result in lower power consumption, so heat, and unlikely to hurt. > > Or at least, I suspect that's the case .. cc'ing Alexander, as the wiki > article you referenced was his doing, so he's among those best placed. C-states controlled here are ACPI C-states, which have limited relation to real CPU C-states. There are systems where they map exactly, but there are also systems where ACPI C1/C2/C3 states map to CPU C1/C3/C6, so it is difficult to make general recommendations. Approximately the map can be guessed looking on latency value (last of three) reported in sysctl dev.cpu.0.cx_supported: 1 is usually CPU C1, 2+ is likely CPU C2, 100+ can be C3, 500+ can be C6, but all that is very approximately and I guess depends on BIOS writer mood. What's about recommendations from me, I'd say that CPU C2 state should not hurt in most cases, unless something is broken, but benefit is rather small (often just covered by C1E enabled in BIOS); CPU C3 state gives significant power saving, but can either hurt performance due to higher enter/exit latency or slightly improve it due to TurboBoost activation (require CPU frequency to be set to max value); CPU C6 is probably useful only for laptops, since it saves not so much power power, while exit latency can be in milliseconds range. > > > As far as possible TSC impact, I think older processors had TSC > > > issues when not all cores ran with the same clock speed. That said, > > > I am not remotely expert on such issues, so don't take this too > > > seriously. > > I wasn't aware that FreeBSD could yet do different freqs on different > cores? But I'm less expert than Kevin, and certainly behind the times. On old CPUs TSC frequency was related to CPU frequency and so could fluctuate with frequency change. On modern CPUs it is always constant, equal to base CPU frequency. What's about different frequency for different cores, IIRC ACPI allows that, but up to recent time neither FreeBSD nor hardware could do that. I have feeling I heard that some very new CPUs may allow that, but to be efficient it would require very tight interoperation between power manager and CPU scheduler, otherwise performance may suffer. -- Alexander Motin