Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3058127imm; Mon, 24 Sep 2018 15:05:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV62sy7pafkj/k4msJa/DJfkYj2DkxqwVtK4rBawLlVuD57QLPkcUIpLRVqeCmQCDP0nL3BnA X-Received: by 2002:a62:b0e:: with SMTP id t14-v6mr668215pfi.36.1537826728117; Mon, 24 Sep 2018 15:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537826728; cv=none; d=google.com; s=arc-20160816; b=ugHRL+5UlKyPcCmT8BQ36qotXXI3gHi7L6N15zNb+H5cuP/1P0Zne7YX1CcyfBEh6/ yMae2vmEguKoBR45lkhhGrSuL02eCWxkqO9x5VURX7n2su6Hx0O/PWqSeajFshlRUqfW jxNLgEWcpcWdw8He2qB+4pN94tvrc0iXpfi6xBnK3yYg6zprjbcmF5lRwNViIw+wj24n oELzI61B3RF7ZR5YqKZ/eBx4MhSqcbSmuWlGZrtjgoDykXlf6aKYRzRtbTpHvv8SZd1c prCOf7q/4LifCSVlLClOMIA/Pb2dXEblx0IBkYzTv9EeQ7sM/x2WOZ54DEiCoNGTk7UX BlfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:user-agent:message-id:in-reply-to:date:references:cc :to:from; bh=FrbmNbMPZZeC7a8w9SxoY6umaytwRkEpulfC639fk98=; b=q7Upto41UUtZ+MMLspj/w4SzxquMONH+lHDUDC3u31YZBxWXfSi0J2e/FgmnqvSmuR Nr/vKOEIf0fMu4C4Bo/UyJi2d0lwAtTuZWDHe7JsmACUMI9H3pBJDGKUuphJqsDJ/fCg a5MPQcnwhxSIpBhjJC4vK54oqXsmEaoYRmExzBiRQJnxk3oAIK2NDwXRAIOMU799vQ42 ruUqe2AqU6lwTKH9J8ajUhqjHd8IG3+LqWYEkW4arXf0hTUwAwuRxCBVTkZIDi5z5+ip Ou2tgqBn9E5qHAiHWWT8TI9imcEf9WKtjxw9kLZclE9kea2uYRsbMWs1Yi+6+q9mpFXQ vClg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si461072plp.428.2018.09.24.15.05.13; Mon, 24 Sep 2018 15:05:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbeIYEHQ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 25 Sep 2018 00:07:16 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:49106 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbeIYEHQ (ORCPT ); Tue, 25 Sep 2018 00:07:16 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1g4YwO-0001k3-Eq; Mon, 24 Sep 2018 16:02:52 -0600 Received: from [105.184.227.67] (helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1g4YwM-000365-Rb; Mon, 24 Sep 2018 16:02:52 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Andrey Vagin Cc: Dmitry Safonov , "linux-kernel\@vger.kernel.org" , Dmitry Safonov <0x7f454c46@gmail.com>, Adrian Reber , Andy Lutomirski , Christian Brauner , Cyrill Gorcunov , "H. Peter Anvin" , Ingo Molnar , Jeff Dike , Oleg Nesterov , Pavel Emelianov , Shuah Khan , Thomas Gleixner , "containers\@lists.linux-foundation.org" , "criu\@openvz.org" , "linux-api\@vger.kernel.org" , "x86\@kernel.org" , Alexey Dobriyan , "linux-kselftest\@vger.kernel.org" References: <20180919205037.9574-1-dima@arista.com> <874lej6nny.fsf@xmission.com> <20180924205119.GA14833@outlook.office365.com> Date: Tue, 25 Sep 2018 00:02:32 +0200 In-Reply-To: <20180924205119.GA14833@outlook.office365.com> (Andrey Vagin's message of "Mon, 24 Sep 2018 20:51:33 +0000") Message-ID: <874leezh8n.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-XM-SPF: eid=1g4YwM-000365-Rb;;;mid=<874leezh8n.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=105.184.227.67;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+Ek8QjShmdEPOprpvDDkmNB46PyHdPbc4= X-SA-Exim-Connect-IP: 105.184.227.67 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa04.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.0 required=8.0 tests=ALL_TRUSTED,BAYES_20, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,XMNoVowels,XM_Body_Dirty_Words autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 BAYES_20 BODY: Bayes spam probability is 5 to 20% * [score: 0.1121] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa04 1397; Body=1 Fuz1=1 Fuz2=1] * 0.5 XM_Body_Dirty_Words Contains a dirty word X-Spam-DCC: XMission; sa04 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;Andrey Vagin X-Spam-Relay-Country: X-Spam-Timing: total 455 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 2.7 (0.6%), b_tie_ro: 1.75 (0.4%), parse: 1.00 (0.2%), extract_message_metadata: 18 (4.0%), get_uri_detail_list: 3.3 (0.7%), tests_pri_-1000: 9 (1.9%), tests_pri_-950: 1.20 (0.3%), tests_pri_-900: 1.04 (0.2%), tests_pri_-400: 37 (8.2%), check_bayes: 36 (7.9%), b_tokenize: 13 (2.8%), b_tok_get_all: 12 (2.6%), b_comp_prob: 3.8 (0.8%), b_tok_touch_all: 4.5 (1.0%), b_finish: 0.66 (0.1%), tests_pri_0: 375 (82.4%), check_dkim_signature: 0.70 (0.2%), check_dkim_adsp: 4.5 (1.0%), tests_pri_500: 6 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: [RFC 00/20] ns: Introduce Time Namespace X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrey Vagin writes: > On Fri, Sep 21, 2018 at 02:27:29PM +0200, Eric W. Biederman wrote: >> Dmitry Safonov writes: >> >> > Discussions around time virtualization are there for a long time. >> > The first attempt to implement time namespace was in 2006 by Jeff Dike. >> > From that time, the topic appears on and off in various discussions. >> > >> > There are two main use cases for time namespaces: >> > 1. change date and time inside a container; >> > 2. adjust clocks for a container restored from a checkpoint. >> > >> > “It seems like this might be one of the last major obstacles keeping >> > migration from being used in production systems, given that not all >> > containers and connections can be migrated as long as a time dependency >> > is capable of messing it up.” (by github.com/dav-ell) >> > >> > The kernel provides access to several clocks: CLOCK_REALTIME, >> > CLOCK_MONOTONIC, CLOCK_BOOTTIME. Last two clocks are monotonous, but the >> > start points for them are not defined and are different for each running >> > system. When a container is migrated from one node to another, all >> > clocks have to be restored into consistent states; in other words, they >> > have to continue running from the same points where they have been >> > dumped. >> > >> > The main idea behind this patch set is adding per-namespace offsets for >> > system clocks. When a process in a non-root time namespace requests >> > time of a clock, a namespace offset is added to the current value of >> > this clock on a host and the sum is returned. >> > >> > All offsets are placed on a separate page, this allows up to map it as >> > part of vvar into user processes and use offsets from vdso calls. >> > >> > Now offsets are implemented for CLOCK_MONOTONIC and CLOCK_BOOTTIME >> > clocks. >> > >> > Questions to discuss: >> > >> > * Clone flags exhaustion. Currently there is only one unused clone flag >> > bit left, and it may be worth to use it to extend arguments of the clone >> > system call. >> > >> > * Realtime clock implementation details: >> > Is having a simple offset enough? >> > What to do when date and time is changed on the host? >> > Is there a need to adjust vfs modification and creation times? >> > Implementation for adjtime() syscall. >> >> Overall I support this effort. In my quick skim this code looked good. > > Hi Eric, > > Thank you for the feedback. > >> >> My feeling is that we need to be able to support running ntpd and >> support one namespace doing googles smoothing of leap seconds while >> another namespace takes the leap second. >> >> What I was imagining when I was last thinking about this was one >> instance of struct timekeeper aka tk_core per time namespace. That >> structure already keeps offsets for all of the various clocks from >> the kerne internal time sources. What would be needed would be to >> pass in an appropriate time namespace pointer. >> >> I could be completely wrong as I have not take the time to completely >> trace through the code. Have you looked at pushing the time namespace >> down as far as tk_core? >> >> What I think would be the big advantage (besides ntp working) is that >> the bulk of the code could be reused. Allowing testing of the kernel's >> time code by setting up a new time namespace. So a person in production >> could setup a time namespace with the time set ahead a little bit and >> be able to verify that the kernel handles the upcoming leap second >> properly. >> > > It is an interesting idea, but I have a few questions: > > 1. Does it mean that timekeeping_update() will be called for each > namespace? This functions is called periodically, it updates times on the > timekeeper structure, updates vsyscall_gtod_data, etc. What will be an > overhead of this? I don't know if periodically is a proper characterization. There may be a code path that does that. But from what I can see timekeeping_update is the guts of settimeofday (and a few related functions). So it appears to make sense for timekeeping_update to be per namespace. Hmm. Looking at what is updated in the vsyscall_gtod_data it does look like you would have to periodically update things, but I don't know big that period would be. As long as the period is reasonably large, or the time namespaces were sufficiently deschronized it should not be a problem. But that is the class of problem that could make my ideal impractical if there is measuarable overhead. Where were you seeing timekeeping_update being called periodically? > 2. What will we do with vdso? It looks like we will have to have a > separate vsyscall_gtod_data for each ns and update each of them > separately. Yes. But you don't have to have introduce another variable just make certain vsyscall_gtod_data is a page aligned thing per time namespace. If I read the summary of the existing patchset something very similiar is already going on. Each process would only map one. And unshare of the time namespace would need to act like the pid namespace or be limited to only being allowed when there is only a single task using the mm. Eric