Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3577108ybh; Tue, 17 Mar 2020 02:41:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vumPG/xUQeJ4RbxFibSpiDVP3AMSCtJFio7XDfAR8Ujlevz8E3uwn2lez8906XNs+bw0ocs X-Received: by 2002:a05:6830:1697:: with SMTP id k23mr3120301otr.155.1584438068087; Tue, 17 Mar 2020 02:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584438068; cv=none; d=google.com; s=arc-20160816; b=bX/B7TeuLvn7JFyVpxOR3w664HisSS+NRYT2oFgCTGPN4C9cAkWJB5iHfpoef+0oUh EdlGKzEHsV4MF5Vmevcn+I4LEckdSs8CYsSBfSbWhrGOFAE+777x5yr1WzGHUEqm2xxV ObIj2mc/KPsAjRh1SLL6oKQe/GOjDaW1tJzBEZe8gyALzMuIHCyJRowDU9HPBI+Uj38P cO0oRc9fmqMfc9NqvoaWJ63veFtAjM4LYEFfieZsfzuVDQbHaNGKrMDSmxxUShvUuhwI svHT3bC1MXBgyKSXLRQnABAqygz89Xnr8XOZefbNysE91B+7v5UBNbsKtIEgBZSnDsBC 6P7A== 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 :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=Z+fnHPmjTvYVaCbry35HAxtdpXdWo4RD3OIz+px6SGc=; b=yLouwg3AoGTqZajfYMERzTskV4YAYSD9ztftmEoeaFCie3IazE4svXTd7stf8TJcQR LAYDJ50kZaFfxgpVXo05kIn9pJh3QsRGHTdx7+PGiYnAfTXNs3WcSYzsDk8J0mHmJoOg /xfGCq28qr1sdGaC3ah6etS5XKRVyFrkL/36J91PyUgbiK590f74451Ki5gEdY0VuiGO +DJTrfYqGNfBqI9VYBClmOoAdsHcsE+3js1vjr58E6k8afXLDaG2AG3VzzcsJMccaf8q HfkdGs7zoXV1Qvoumoq0ntTPitdUS7dGf8EoKi//NjP9QXAPeQjt2BUu8Nd/bvx7vXfB 2/wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wd8arqk+; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t21si1403363otq.93.2020.03.17.02.40.56; Tue, 17 Mar 2020 02:41:08 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wd8arqk+; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbgCQJkP (ORCPT + 99 others); Tue, 17 Mar 2020 05:40:15 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:33464 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbgCQJkN (ORCPT ); Tue, 17 Mar 2020 05:40:13 -0400 Received: by mail-ed1-f68.google.com with SMTP id z65so25528161ede.0; Tue, 17 Mar 2020 02:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=Z+fnHPmjTvYVaCbry35HAxtdpXdWo4RD3OIz+px6SGc=; b=Wd8arqk+ky/rUkkIYXPsVMQ1m9DliRq56vGPcryGaIl9nl1q7/V2snm5rdly3z8Oec iRXiFwNg1xdkDZi7oiR4VIA1SaAr1V6j9pCvbgvBv+Mt+AH4XCxUrEh7hK2rs5WHKIHt qFW3M59FVVbcG6mZWmCFljtEzMWJblCi6pydhLeZQptGynR2kJqWicJBBXNUGDUBKcW6 9vWGH1JBpfXGwBstUKPHgLrYHHvTwP8Zj1h+MiD01ebw/DmvPg5VBGO8kMeVBpIYnxuK qrXtZak/ruwGq0wAvfVSunWfIVZBw4lsSPAk5ijYvTogzCCFsahhqd7aJPK7KVG3RPgt f8SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=Z+fnHPmjTvYVaCbry35HAxtdpXdWo4RD3OIz+px6SGc=; b=UxPsa/21QrvfcMOxopvOuRo1fWpaA2L/nbbht3xXFzrXqFpC/Rz3lpUnpYwqhlBpB/ gwRVKCgZplewCxNaihjf6TyCu8nI64u06W3uZHgkn4FxVhxzQZ3X5wZHM2qwXdlOXLSi EUivFJkak02930ry7d1Tfo1/nkNzDPc/QKm6yjYTf7Nc8t7pZazQwkIN/OFJUn7dJh9d +85vEQD/NSw0skAADXaO3m5gtm2vY+QzzoJzu2ryWzk554lcTAl2/CzH5IshOwfebtoK eCYLZ2tzlNCHVnBcG0BvzxI4iSxji2uJHoniRStBphV3Jxn5lW0uP+K/pXXO02+q0vcU v/zA== X-Gm-Message-State: ANhLgQ2qIN3lEiG4QMZI2M5KJ6vYyx66U8YlLTYcWVbHmExO3SsP6YrE R/898AoYShIRLwezjsLMG7bQghV5TD7fSmoaa+8= X-Received: by 2002:a17:906:70c9:: with SMTP id g9mr3284339ejk.243.1584438011180; Tue, 17 Mar 2020 02:40:11 -0700 (PDT) MIME-Version: 1.0 References: <20200317083043.226593-1-areber@redhat.com> In-Reply-To: <20200317083043.226593-1-areber@redhat.com> Reply-To: mtk.manpages@gmail.com From: "Michael Kerrisk (man-pages)" Date: Tue, 17 Mar 2020 10:40:00 +0100 Message-ID: Subject: Re: clone3: allow creation of time namespace with offset To: Adrian Reber Cc: Christian Brauner , Eric Biederman , Pavel Emelyanov , Oleg Nesterov , Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , lkml , Mike Rapoport , Radostin Stoyanov , Arnd Bergmann , Cyrill Gorcunov , Thomas Gleixner , Linux API 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 [CC += linux-api; please CC on future versions] On Tue, 17 Mar 2020 at 09:32, Adrian Reber wrote: > > This is an attempt to add time namespace support to clone3(). I am not > really sure which way clone3() should handle time namespaces. The time > namespace through /proc cannot be used with clone3() because the offsets > for the time namespace need to be written before a process has been > created in that time namespace. This means it is necessary to somehow > tell clone3() the offsets for the clocks. > > The time namespace offers the possibility to set offsets for > CLOCK_MONOTONIC and CLOCK_BOOTTIME. My first approach was to extend > 'struct clone_args` with '__aligned_u64 monotonic_offset' and > '__aligned_u64 boottime_offset'. The problem with this approach was that > it was not possible to set nanoseconds for the clocks in the time > namespace. > > One of the motivations for clone3() with CLONE_NEWTIME was to enable > CRIU to restore a process in a time namespace with the corresponding > offsets. And although the nanosecond value can probably never be > restored to the same value it had during checkpointing, because the > clock keeps on running between CRIU pausing all processes and CRIU > actually reading the value of the clocks, the nanosecond value is still > necessary for CRIU to not restore a process where the clock jumps back > due to CRIU restoring it with a nanonsecond value that is too small. > > Requiring nanoseconds as well as seconds for two clocks during clone3() > means that it would require 4 additional members to 'struct clone_args': > > __aligned_u64 tls; > __aligned_u64 set_tid; > __aligned_u64 set_tid_size; > + __aligned_u64 boottime_offset_seconds; > + __aligned_u64 boottime_offset_nanoseconds; > + __aligned_u64 monotonic_offset_seconds; > + __aligned_u64 monotonic_offset_nanoseconds; > }; > > To avoid four additional members to 'struct clone_args' this patchset > uses another approach: > > __aligned_u64 tls; > __aligned_u64 set_tid; > __aligned_u64 set_tid_size; > + __aligned_u64 timens_offset; > + __aligned_u64 timens_offset_size; > }; > > timens_offset is a pointer to an array just as previously done with > set_tid and timens_offset_size is the size of the array. > > The timens_offset array is expected to contain a struct like this: > > struct set_timens_offset { > int clockid; > struct timespec val; > }; > > This way it is possible to pass the information of multiple clocks with > seconds and nanonseconds to clone3(). > > To me this seems the better approach, but I am not totally convinced > that it is the right thing. If there are other ideas how to pass two > clock offsets with seconds and nanonseconds to clone3() I would be happy > to hear other ideas. > > Adrian > > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/