Received: by 2002:a25:d80d:0:0:0:0:0 with SMTP id p13csp292274ybg; Sat, 23 May 2020 14:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlQDYF4C6U23aWBRyGa84HZrqxTboDw2qL+m+oFt1PPZ/G0qiEDhaNAlnM6Njb+hBWtbdM X-Received: by 2002:aa7:c3cb:: with SMTP id l11mr8223531edr.364.1590269691286; Sat, 23 May 2020 14:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590269691; cv=none; d=google.com; s=arc-20160816; b=YsObVfSgAy55SWZtoArB+0La5poiuTod1ziZdUOartIr36YVWSyCmDmJFDXovF2kXL 7qJJI2sCsc/XoMDDazD5BPpMJa04S7jgpK7wOJ05z4g4eZtf3dp8SfNpwF6O8JcVQnSs IAaj7aulXTA85N17lzwUfSHmwsquhl0FNyNdlTKazAHUGf3p8wXDm0oNhm+tnlSYEw3t /vnfIhCyppFZCGGQOlA4WMPOZDp6q4Xe+omQF40J1tw26yl2SunpkREuTg1XRB3lJ7iJ qaw5BzwSfN8Qv6oMhWs9M99bkisZQszYMDxVq5BbXE+wnp47zrV/dG6iB2dkepNUJ4T6 ifmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=euhs23l2LckQQZqClPP1ffQdVbjSsT+bd+0gLo+sW/g=; b=pxdgumogPRBlauDwHWBBGH29YlVmgvdoRgeMW/1FLRLRGAJBSnYqrKVVld4tPopDJn o6M9Aox3EbPMOmwviht23J9sWPX86JtMH2kDXWwb8npyh1tVmhBzoQDwOAB480yfKDh2 +4WOXwrS/MSv5yXwb30S/R2XrjH9opqiBuEHZ3aYIfXRpNYYBOdezB/rRgSUzQi5NJMH BToHpr79O3YGfZJFEt23Q/8DAGptg6mbxdnzOqorN5p06W4Nj/JrDaHHgypwB5/Pmh5j lcDtVFZVccm37oA4XMvqQrSP9tWzA4XHI9u989FMMeC5HtxDBwyGfntCEZ256V9nHRzZ x0Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Q7Sxl+I4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jo2si7416258ejb.197.2020.05.23.14.34.28; Sat, 23 May 2020 14:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Q7Sxl+I4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388034AbgEWVcn (ORCPT + 99 others); Sat, 23 May 2020 17:32:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387847AbgEWVcn (ORCPT ); Sat, 23 May 2020 17:32:43 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69988C061A0E for ; Sat, 23 May 2020 14:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=euhs23l2LckQQZqClPP1ffQdVbjSsT+bd+0gLo+sW/g=; b=Q7Sxl+I4qXTrbIz8BvGb4iRFil QZQoRnqHO1Mz6Wkp21SyoFnG0Ji8aNikGKJt35awZetB2H3MMne3cBHkLncfp/dN+WYEPVzOwpYPE lBq5N0SnpFSutrz90UOxS65ArL74R5W5tL0UMYm/RZp7Fm1dBfXiE9qce5L2gl7VPcdZDFTrrEYk5 ZNi71itYo+xtF/ZJoWmnCBxIlvvahO8GJ8g4cYuxYPbMNtSZ3ug2VNDyodh99QI6QpjhuEv1i/guV t+NqbrNgCBLTILBO46cnwzZkwj70Ae3MGTNShVqbA4SLf/UqBn14BeZN+9VXe7SdM0mnICTjhEzsJ TYdZxkag==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcbkz-0003mK-N4; Sat, 23 May 2020 21:32:37 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 184D69834A2; Sat, 23 May 2020 23:32:35 +0200 (CEST) Date: Sat, 23 May 2020 23:32:35 +0200 From: Peter Zijlstra To: Andy Lutomirski Cc: Thomas Gleixner , LKML , X86 ML Subject: Re: [RFC][PATCH 0/4] x86/entry: disallow #DB more Message-ID: <20200523213235.GB4496@worktop.programming.kicks-ass.net> References: <20200522204738.645043059@infradead.org> <20200523125940.GA2483@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200523125940.GA2483@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 23, 2020 at 02:59:40PM +0200, Peter Zijlstra wrote: > On Fri, May 22, 2020 at 03:13:57PM -0700, Andy Lutomirski wrote: > > This is great, except that the unconditional DR7 write is going to > > seriously hurt perf performance. Fortunately, no one cares about > > perf, right? :) > > Good point, so the trivial optimization is below. I couldn't find > instruction latency numbers for DRn load/stores anywhere. I'm hoping > loads are cheap. + u64 empty = 0, read = 0, write = 0; + unsigned long dr7; + + for (i=0; i<100; i++) { + u64 s; + + s = rdtsc(); + barrier_nospec(); + barrier_nospec(); + empty += rdtsc() - s; + + s = rdtsc(); + barrier_nospec(); + dr7 = native_get_debugreg(7); + barrier_nospec(); + read += rdtsc() - s; + + s = rdtsc(); + barrier_nospec(); + native_set_debugreg(7, 0); + barrier_nospec(); + write += rdtsc() - s; + } + + printk("XXX: %ld %ld %ld\n", empty, read, write); [ 1.628125] XXX: 2800 2404 19600 IOW, reading DR7 is basically free, and certainly cheaper than looking at cpu_dr7 which would probably be an insta cache miss. Which seems to suggest KVM can go pound sand. Maybe they can fix themselves with some paravirt love.