Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1206230imm; Thu, 4 Oct 2018 09:44:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV62kYUvijqvETEEz5nK7er4WeUdtGrWWpU9G9k/RYGxEicVTeFnl77BxQfBII77QcmLAH0k2 X-Received: by 2002:a17:902:b695:: with SMTP id c21-v6mr7491668pls.167.1538671481938; Thu, 04 Oct 2018 09:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538671481; cv=none; d=google.com; s=arc-20160816; b=O8UgZjsQ9EUAR4JPkV6TTcZsyMLMsG8NSHKVQbRVzdblms9DOXfuygzm3VNqvaaxz5 5hl6ARHdS/YyZoAPBengQtm60SqPN4IQJeAemDVoBTOTyqj8B4g5jTkG/bpGi9diVXPQ ArZe1/XCdSvX10icQ24a1jzH/RCNhZyt9oAomwP/GgnG9wkmTdCaEDPikgTMt/joEMLQ e0RW0GaE9ocmLRBtqs5J2UZZbYqXzqtnDt9T35za74ZzWVG3z8KE6Zpfj2gUd1deQ4DE Gnc/hHZMea09oDnnOHutz+PJ5IzXxqmpuOGsHNACLaYBkCwGdEOuVtOqsAlfN3YMvwpQ zfXw== 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; bh=YvEWVmK9sGEMSS5V7PofB9fAuaz45nwbVW6PW8ipRy0=; b=q1JUSCOY7kOXO8AHVkM32dQZ1gGYoiNW1Gd2opiQFB+9CzogEByux15yZZaCkyIUU7 zBz+6U87Sl0Ny0jJDTvCVnomL2OH2a0EFCn3XvO3mGHttV5/HAb4AcEd0SyoSvW+nlLO LXpZtOo4WKO0bJlMHSfF5eOhiTDMk0emIiffJW9hyjlKtPiN1362gwrIpaXXUlXJvwH0 iXUNoSICf4/82TFsnLdMe2WfMneimRb6L9L/qqF4HxrXsJ5snst+PZftGVLcGjRwxsCO QMyho2Ly9vMr17XrLypodNuUbmEUe5muU3BnIKPE4v2nkNBXQeQQkbHlSSVeBotXbUaM 7PZQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12-v6si4406688pgr.98.2018.10.04.09.44.25; Thu, 04 Oct 2018 09:44:41 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727761AbeJDXh5 (ORCPT + 99 others); Thu, 4 Oct 2018 19:37:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39554 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727526AbeJDXh5 (ORCPT ); Thu, 4 Oct 2018 19:37:57 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1588723D9; Thu, 4 Oct 2018 16:43:52 +0000 (UTC) Received: from amt.cnet (ovpn-112-3.gru2.redhat.com [10.97.112.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77B2D9E8C9; Thu, 4 Oct 2018 16:43:51 +0000 (UTC) Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id DEDEB105143; Thu, 4 Oct 2018 13:37:17 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.7/8.14.7/Submit) id w94Gb6hF028089; Thu, 4 Oct 2018 13:37:06 -0300 Date: Thu, 4 Oct 2018 13:37:05 -0300 From: Marcelo Tosatti To: Andy Lutomirski Cc: Thomas Gleixner , Paolo Bonzini , Radim Krcmar , Wanpeng Li , LKML , X86 ML , Peter Zijlstra , Matt Rickard , Stephen Boyd , John Stultz , Florian Weimer , KY Srinivasan , Vitaly Kuznetsov , devel@linuxdriverproject.org, Linux Virtualization , Arnd Bergmann , Juergen Gross Subject: Re: [patch 00/11] x86/vdso: Cleanups, simmplifications and CLOCK_TAI support Message-ID: <20181004163705.GA25129@amt.cnet> References: <20180914125006.349747096@linutronix.de> <20181003190026.GB21381@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 04 Oct 2018 16:43:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 03, 2018 at 03:32:08PM -0700, Andy Lutomirski wrote: > On Wed, Oct 3, 2018 at 12:01 PM Marcelo Tosatti wrote: > > > > On Tue, Oct 02, 2018 at 10:15:49PM -0700, Andy Lutomirski wrote: > > > Hi Vitaly, Paolo, Radim, etc., > > > > > > On Fri, Sep 14, 2018 at 5:52 AM Thomas Gleixner wrote: > > > > > > > > Matt attempted to add CLOCK_TAI support to the VDSO clock_gettime() > > > > implementation, which extended the clockid switch case and added yet > > > > another slightly different copy of the same code. > > > > > > > > Especially the extended switch case is problematic as the compiler tends to > > > > generate a jump table which then requires to use retpolines. If jump tables > > > > are disabled it adds yet another conditional to the existing maze. > > > > > > > > This series takes a different approach by consolidating the almost > > > > identical functions into one implementation for high resolution clocks and > > > > one for the coarse grained clock ids by storing the base data for each > > > > clock id in an array which is indexed by the clock id. > > > > > > > > > > I was trying to understand more of the implications of this patch > > > series, and I was again reminded that there is an entire extra copy of > > > the vclock reading code in arch/x86/kvm/x86.c. And the purpose of > > > that code is very, very opaque. > > > > > > Can one of you explain what the code is even doing? From a couple of > > > attempts to read through it, it's a whole bunch of > > > probably-extremely-buggy code that, > > > > Yes, probably. > > > > > drumroll please, tries to atomically read the TSC value and the time. And decide whether the > > > result is "based on the TSC". > > > > I think "based on the TSC" refers to whether TSC clocksource is being > > used. > > > > > And then synthesizes a TSC-to-ns > > > multiplier and shift, based on *something other than the actual > > > multiply and shift used*. > > > > > > IOW, unless I'm totally misunderstanding it, the code digs into the > > > private arch clocksource data intended for the vDSO, uses a poorly > > > maintained copy of the vDSO code to read the time (instead of doing > > > the sane thing and using the kernel interfaces for this), and > > > propagates a totally made up copy to the guest. > > > > I posted kernel interfaces for this, and it was suggested to > > instead write a "in-kernel user of pvclock data". > > > > If you can get kernel interfaces to replace that, go for it. I prefer > > kernel interfaces as well. > > > > > And gets it entirely > > > wrong when doing nested virt, since, unless there's some secret in > > > this maze, it doesn't acutlaly use the scaling factor from the host > > > when it tells the guest what to do. > > > > > > I am really, seriously tempted to send a patch to simply delete all > > > this code. > > > > If your patch which deletes the code gets the necessary features right, > > sure, go for it. > > > > > The correct way to do it is to hook > > > > Can you expand on the correct way to do it? > > > > > And I don't see how it's even possible to pass kvmclock correctly to > > > the L2 guest when L0 is hyperv. KVM could pass *hyperv's* clock, but > > > L1 isn't notified when the data structure changes, so how the heck is > > > it supposed to update the kvmclock structure? > > > > I don't parse your question. > > Let me ask it more intelligently: when the "reenlightenment" IRQ > happens, what tells KVM to do its own update for its guests? Update of what, and why it needs to update anything from IRQ? The update i can think of is from host kernel clocksource, which there is a notifier for.