Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3175316imu; Mon, 19 Nov 2018 11:53:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/UUr3ZSwHnYBNzccRofvA24LVLSKkFVSrrsStqduTImyG/15SuoOxs/qCnCnFDXVz49X8pC X-Received: by 2002:a17:902:4c85:: with SMTP id b5mr4645645ple.226.1542657195070; Mon, 19 Nov 2018 11:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542657195; cv=none; d=google.com; s=arc-20160816; b=WwxDr4y32vRLiM2LObgRwWfZyY17m1A8wT0h7lIzSEldW4V/MhLDPUUNwoQma6p27r Y/p3mNMKGtl86UMxNH06Ik399q1nRc2k29QvOxRe6F3fkfZU2IFVbm+dEoZJ6aAPSivT 9/uhpTUSqcZoIAI0QVOR2KxV/cTJDvqVGkzs1K7rWlD3M2xyUsLjTxUVYmJHCKM0idZm Rkj2tWixnNHdsdtH9APUTZOvt9vpM2enuMWVO3Uss4k+J3mSifWgHpeVIzn8srmyDWpz njSM797QL4wyDvAOvgf9Ruqr6pLjpeTEKYwpVfN8rZ5kT0qwmF/ky7HfdiI/TKe/635U Nzug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DtGbMXg/9OZqSkmngIeuflXxvZr+oOaOiclVVvpVY7o=; b=fgyMKSVYZ/5Aos26pruVVlE3D2FaS7pLUWsWeZwIdHQG8J2Rra88lqUP4M/qOkzfs9 LjFXBTyBlC9byWp+2OYMRfBwF/xL/5drogkI7hxru4f96gD6eteMxUVGAIeCQpAblWUw nQbTm/8bQaIB7hSzEuDstz+DCMqpqt0U5M46Piam7rrWu0PTettduYUyPZRfSs3dbO/A uV6CgoqutKOWgLN01wlb7Ui6reqmFAgi6COwMlB91T6QzwOlNwaySQpioevaU1wp4DMv KhxIHMgjxvuzHgOjt3MKvtYsn2Um0dTU4vf46wDVPSMQv2mD8t+7FtLrS7SDV9A1kbly dsTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l637roip; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4-v6si1621978pfk.210.2018.11.19.11.53.00; Mon, 19 Nov 2018 11:53:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l637roip; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730413AbeKTGRZ (ORCPT + 99 others); Tue, 20 Nov 2018 01:17:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:60110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbeKTGRZ (ORCPT ); Tue, 20 Nov 2018 01:17:25 -0500 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5085220831 for ; Mon, 19 Nov 2018 19:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542657136; bh=YxP4BKo4PjD6PZZwn6g5wblNOazSfdvH7axyG+0UbAw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=l637roiptSM/8kO+A6m7orRNSWxMwf4fCYKJGXew3Wjh1YseIXsJtn0J82MbU/bjA gEFmsByNGbbOk/RdjDCKoBsYFPDvDDJPVV6WG438zdA50vep83YN93by8hb7aUyugP Zc47DtwCM+/TI9DTvb4SzGEC7eIRmwVoM8bma40k= Received: by mail-wm1-f52.google.com with SMTP id c126so173987wmh.0 for ; Mon, 19 Nov 2018 11:52:16 -0800 (PST) X-Gm-Message-State: AA+aEWbgm5OdZCmzgXNiLMMiMrdZZjYlXsO4b3eAhI8ZN73bHJ0tCrSe Ql1YOv9HgryWyNSD7LPpU5NWSuLi5WM6iNM31zSBPg== X-Received: by 2002:a1c:110b:: with SMTP id 11mr5521748wmr.83.1542657134867; Mon, 19 Nov 2018 11:52:14 -0800 (PST) MIME-Version: 1.0 References: <20181119184556.11479-1-bp@alien8.de> In-Reply-To: <20181119184556.11479-1-bp@alien8.de> From: Andy Lutomirski Date: Mon, 19 Nov 2018 11:52:02 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/TSC: Use RDTSCP To: Borislav Petkov Cc: X86 ML , LKML , Andrew Lutomirski , "H. Peter Anvin" , John Stultz , Tom Lendacky Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 19, 2018 at 10:46 AM Borislav Petkov wrote: > > From: Borislav Petkov > > Currently, the kernel uses > > [LM]FENCE; RDTSC > > in the timekeeping code, to guarantee monotonicity of time where the > *FENCE is selected based on vendor. > > Replace that sequence with RDTSCP which is faster or on-par and gives > the same guarantees. > > A microbenchmark on Intel shows that the change is on-par. > > On AMD, the change is either on-par with the current LFENCE-prefixed > RDTSC and some are slightly better with RDTSCP. > > The comparison is done with the LFENCE-prefixed RDTSC (and not with the > MFENCE-prefixed one, as one would normally expect) because all modern > AMD families make LFENCE serializing and thus avoid the heavy MFENCE by > effectively enabling X86_FEATURE_LFENCE_RDTSC. > I thought I benchmarked this on Intel at some point and found the LFENCE;RDTSC variant to be slightly faster. But I believe you, so: Acked-by: Andy Lutomirski