Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbdHUIkn (ORCPT ); Mon, 21 Aug 2017 04:40:43 -0400 Received: from mail-eopbgr30116.outbound.protection.outlook.com ([40.107.3.116]:14336 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753008AbdHUIkj (ORCPT ); Mon, 21 Aug 2017 04:40:39 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=dplotnikov@virtuozzo.com; Subject: Re: [PATCH v4 00/10] make L2's kvm-clock stable, get rid of pvclock_gtod_copy in KVM To: John Stultz Cc: Paolo Bonzini , Radim Krcmar , kvm list , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , lkml , "x86@kernel.org" , rkagan@virtuozzo.com, den@virtuozzo.com, Marcelo Tosatti References: <1501684690-211093-1-git-send-email-dplotnikov@virtuozzo.com> From: Denis Plotnikov Message-ID: Date: Mon, 21 Aug 2017 11:40:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: VI1PR0102CA0031.eurprd01.prod.exchangelabs.com (2603:10a6:802::44) To AM4PR0802MB2211.eurprd08.prod.outlook.com (2603:10a6:200:5e::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82c108a2-f6c7-4745-3e24-08d4e8704b12 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:AM4PR0802MB2211; X-Microsoft-Exchange-Diagnostics: 1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Ro/UJbzNVn9wWOam7kaT7yYkm2UkRe18XJAGWFH8QIudIRNHaZRBFlJpVZ0OwAQe46tlMyghNB2Xrj+8YVgwVe+ihgEY9US/meq5VHmRwDgmBRfxfqs8xeJejZBhPpuTdXTKWX9fPVq+A01vtSDRrHNfl8i2Q4GApXA4Wr2o63nUw3qtDPlVgo7PoPFBqyLyKyan2nEWjOCU3Rms9mExoYLTBg5JRosZH60eTz30vr3vRhbFyUYJHl8buskhR8annqX1u3ZqFHwOq5zYk=;4:smInFKX8l/4A3tMP89pD2uCGMu4i51c8k7F9o9fa32IgDxO58PSzsUzEEHeOp9L9xMEXu9uBGauxq+sqRywF/1gKTwKHPjQIhdgO0utnsy1FQId6iCpuL+r7qhfLmaqBwqYPpGD6X1nnd5BJOL4vzWwT8wbCXOgB0fMOc64oOY1sy5BzSfBfp/IsAb4g1fFokcZIUJgoKqluTxVceftlVViS+6QWBW7CGOcUnzOgQW4AoR2ghfd1KxKV8QIDgmVbe/EG+BclDdaztcaqsmSRqHpJs5zpckxSkmiiBl+zDZo= X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(6041248)(20161123555025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM4PR0802MB2211;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM4PR0802MB2211; X-Forefront-PRVS: 040655413E X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(7370300001)(6049001)(6009001)(39830400002)(377454003)(199003)(189002)(24454002)(54906002)(4326008)(4001350100001)(64126003)(5660300001)(36756003)(7350300001)(2906002)(7416002)(53936002)(65826007)(77096006)(101416001)(47776003)(6486002)(50986999)(189998001)(6916009)(65806001)(53546010)(478600001)(6116002)(7736002)(305945005)(6666003)(2950100002)(229853002)(31686004)(23676002)(3846002)(25786009)(8676002)(50466002)(42186005)(106356001)(33646002)(110136004)(68736007)(105586002)(83506001)(230700001)(86362001)(76176999)(66066001)(65956001)(54356999)(31696002)(6246003)(81166006)(81156014)(97736004)(26583001);DIR:OUT;SFP:1102;SCL:1;SRVR:AM4PR0802MB2211;H:[172.16.25.217];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTRQUjA4MDJNQjIyMTE7MjM6bUxJZDhlWFRieTZWNnd0UlJ1T09BeVdS?= =?utf-8?B?eWRvUWhNMTFEWEdVVXdIOUxqdG9sT2xWYy9QdzdRTkxtY3R2a0Fhcm4zNU5O?= =?utf-8?B?Qkx6U21obEFjUW9HZ29nRDk1THM5MXNjdFBlTFd2NEtVWGxqUWtRSGRWenRM?= =?utf-8?B?SXVENEE1Mk9MLzBzYWc1SEJZRHR6YWg4MHArb0NhM3ZoMGw2QitPM1p3c3Vo?= =?utf-8?B?TVFqdno1emJoYkdIQlkxTUlzYU91L1F3ekNIRlFacGl3SFROOWNiNW1oTGJ0?= =?utf-8?B?cHhHd0tpdGVKRXptYkwvZ28xR3hSc2FRQzBkNU1aT2trNGg4WUVaZWNmdCtB?= =?utf-8?B?TkdOUGhVYThZNVdTK0IyVXgrVGpSRjY4QmlRaWxHQ0dwVFJFT0hNNzgvNzkr?= =?utf-8?B?TjFLWC8xb2xEZzdjaXA0Z2VXbTNkeEZjOVVQdmF2ZnBBZTkzdWoyUFMyOXJR?= =?utf-8?B?T2I0TkpzaFg5d295akU1czNha1F5eklleEJYTHByR1g2OHlDL0FiY3NNekhi?= =?utf-8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qKb91RejjAufe+OKiZ3peNz5ZzDBbEuzCK8MesdcaT4+H5wsweT5PmZ/TChJHoRYqrCajE2XfpDNaR/z2/x4mslBORkBdWja18Ew7g==;24:Osq+1yMdYUJavzvfpIdX9tgCewwp7JuZ1IZ+F6XZF/kDZJfukFVfkBVs7lvGtoIoQMIJMw3Bz1aI5Td5vBEjNfNroG6ajvjR+QpU+S2Jszg=;7:LQAa14IvY2aE4cnvQulpaGDWQywNe5ADZjNfWFJVRv+rqnLUQiEnMRum4O0nQ5oK+MmimbjWqpdvPwLVKHj0BUIuT0zkpszcdabCwC1GzGVQIIiTOcmW/eOydOQRgRdL1SZuH8zZMo9E8mjymAYa6Af6bC33S9NMlsBDTEKs7cKlJe3w4TUrvRzS2c8/OXBtRoQN+S1OL6kb+tlgbCN3xOOY4C5L+/oPnJ2/Oo14p2w= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM4PR0802MB2211;20:5ZjKiB3YwIVaE6SScIoRHIgyz9G5Bn/u2/m2taKZOaVOVJJAN9EB5tZ3bOSXD6Bwr4crsr7S5wSn2VT/mXOX61lhHu9hLG5yW4DsndX/Ew+l/IA9yd7OpQIPgzs4X2a8pvgkXNQcolg2z4TIe5WbMj8iBtJolcy4kLlywfrxLY0= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2017 08:40:34.7519 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0802MB2211 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3774 Lines: 87 ping! On 02.08.2017 20:11, Paolo Bonzini wrote: > On 02/08/2017 18:49, John Stultz wrote: >> On Wed, Aug 2, 2017 at 7:38 AM, Denis Plotnikov >> wrote: >>> V4: >>> * removed "is stable" function with vague definition of stability >>> there is the only function which does time with cycle stamp getting >>> * some variables renamed >>> * some patches split into smaller once >>> * atomic64_t usage is replaced with atomic_t >>> >>> V3: >>> Changing the timekeeper interface for clocksource reading looks like >>> an overkill to achive the goal of getting cycles stamp for KVM. >>> Instead extend the timekeeping interface and add functions which provide >>> necessary data: read clocksource with cycles stamp, check whether the >>> clock source is stable. >>> >>> Use those functions and improve existing timekeeper functionality to >>> replace pvclock_gtod_copy scheme in masterclock data calculation. >>> >>> V2: >>> The main goal is to make L2 kvm-clock be stable when it's running over L1 >>> with stable kvm-clock. >>> >>> The patch series is for x86 architecture only. If the series is approved >>> I'll do changes for other architectures but I don't have an ability to >>> compile and check for every single on (help needed) >>> >>> The patch series do the following: >>> >>> * change timekeeper interface to get cycles stamp value from >>> the timekeeper >>> * get rid of pvclock copy in KVM by using the changed timekeeper >>> interface: get time and cycles right from the timekeeper >>> * make KVM recognize a stable kvm-clock as stable clocksource >>> and use the KVM masterclock in this case, which means making >>> L2 stable when running over stable L1 kvm-clock >> >> So, from a brief skim, I'm not a big fan of this patchset. Though this >> is likely in part due to that I haven't seen anything about *why* >> these changes are needed. > > From my selfish KVM maintainer point of view, one advantage is that it > drops knowledge of internal timekeeping functioning from KVM, using > ktime_get_snapshot instead. These are patches 1-5. Structuring the > series like this was my idea so I take the blame. > > As to patches 6-10, KVM is currently only able to provide vsyscalls if > the host is using the TSC. However, when using nested virtualization > you have > > L0: bare-metal hypervisor (uses TSC) > L1: nested hypervisor (uses kvmclock, can use vsyscall) > L2: nested guest > > and L2 cannot use vsyscall because it is not using the TSC. This series > lets you use the vsyscall in L2 as long as L1 can. > > There is one point where I couldn't help Denis as much as I wanted. > That's a definition of what's a "good" clocksource that can be used by > KVM to provide the vsyscall. I know why the patch is correct, but I > couldn't really define the concept. > > In ktime_get_snapshot and struct system_counterval_t's users, they seem > to use "cycles" to map from TSC to ART; this is not unlike kvmclock's > use of "cycles" to map from TSC to nanoseconds at an origin point. > However, it's not clear to me whether "cycles" may be used by > adjust_historical_crosststamp even for non-TSC clocksources (or > non-kvmclock after this series). It doesn't help that > adjust_historical_crosststamp is essentially dead code, since > get_device_system_crosststamp is always called with a NULL history argument. > > I'm also CCing Marcelo who wrote the KVM vsyscall code. > > Paolo > >> Can you briefly explain the issue you're trying to solve, and why you >> think this approach is the way to go? >> (Its usually a good idea to have such rational included in the patchset) > -- Best, Denis