Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp299587ybp; Thu, 10 Oct 2019 18:27:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFQ45zRM9Rcche9uadvwizNpme7Ewg17RAXpSaMuYAfZzTxFSL/2DfOHErarNvmvLBb+mz X-Received: by 2002:a17:906:3e50:: with SMTP id t16mr11319997eji.177.1570757270809; Thu, 10 Oct 2019 18:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570757270; cv=none; d=google.com; s=arc-20160816; b=kSexPEcvqQIZo45xOeVWiv4jKEXu8iM5JF7V2zvj7hbR+o1pk142XBSWPBgYeQcGPb v7NJpN6YXoC4iXBdEr41L4MmXxVdqMd+YkZlg3hqeY8nFhWL0oYb202R0ZE8r88wUBEi DIxRbwleku9ZbrbTqn5vpL9lY/gltj8k4CKzrwNNPgcnmEng+V/XeN8iB/wDgW7TXoWl +7KvZco56YMaY82in2K1qneIThihbxanZlecnKe+nHI+2RJdfwuAiMYcBLHA8JQOJq/p kDmpYLEwj6l+czz8UQzNigGESxsZ7e+V72fyz9FrK4gYVCceaITWdTNX1sD+5CuJZ10x TxNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZTJXOS59OFjfZhGAf0OABauGcWj/AQA+X9fA0uhC2aE=; b=gFxkxICVsH8s28wg3mRwrQfmlGX00z1FuWgdTMeJLIXD+hfOw9sPT5NicyjGAU488e 9IAYgLX563P/y9Sd/3Iz103IXZzslJr08nA9W4gLKROjE5blAa8bm5HgmA2zL9GwOnqq Md+J4NQTacn3Y3x7+n4LIJWMXyK3Iap7XtOD9Fh+nA0Z17vezVFi4bWAoai5jSynNUwt t8R8r0i9HssOoSmHZylQFzqBvBi7WyJF9N4/R3oJJ69p6omtMMupy2qtzuRj8Cx49eEs Zw7pFQ8vxuVSy/Udol0aPX0Re8YcpWmwix0VWnoYVVoMrV5cCw+89b29jIacivW6VGsC vS5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=JJNP1fzR; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si4289852edv.405.2019.10.10.18.27.26; Thu, 10 Oct 2019 18:27:50 -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=@arista.com header.s=googlenew header.b=JJNP1fzR; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728128AbfJKBYG (ORCPT + 99 others); Thu, 10 Oct 2019 21:24:06 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33337 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728078AbfJKBYB (ORCPT ); Thu, 10 Oct 2019 21:24:01 -0400 Received: by mail-wm1-f66.google.com with SMTP id r17so8281306wme.0 for ; Thu, 10 Oct 2019 18:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZTJXOS59OFjfZhGAf0OABauGcWj/AQA+X9fA0uhC2aE=; b=JJNP1fzRQ87qa5LHPcmVklQ8YU1G19hNwhR3Z1+9VvYHJsUIp8vnCTH7I6vzhJNR8D kAWTMtA91gsv5NXCFUFbiB8cMCHJ4l3uiv3BcVRc53rAAHm0gdD80GGvBlJgDTT3uoJm DFSBqaFJrbOEvj0eZiVy8BPYl7T1s1pnFnY5cgONQrFWsFhXfNbpM68rl4kp2x/SDAfE yaUl2onek8zw0VWQojjHEiP+dH82CrnGDaeA8MdyizuKU+R5IGoGDXbi04jdXYvHrvxM JWxcpTwe87X+4H7aoa42h/9DkWBS96LHP5nWdNQuwliMO+C1XlRN/4PTOFXdJVplAyHE I/JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZTJXOS59OFjfZhGAf0OABauGcWj/AQA+X9fA0uhC2aE=; b=puXEDDG1YawZ+jquix79JMbQ2GKCFobF0MSF21IrbJ3ju+VE1zpDPedoCQNDaQcuS5 ovt8TdJrJCQappqq20PeoUd8JUUcE3W32doM7kj6nNW/V2JwoiAuYqyBVtIwRzTiBZo3 QZIQMiu+bOuUH/FDsfofY5cZT8YbynB2qn1MFWA9Nl9hF1rWCdtEA6SQOwqSM6FfVfbA SHWCalTQ1UAYWWv3xP6EOE8rQEPxNnEbkjcCzjpvm7bBWho4yF8m+JJZ2qc5y0O11qBl sVTvrmp/EVycHaRT8iaqHQOuw7XtUOIg15aFhpXXIIXC0Id6bKvD78kLOJkPT/KdenLM AJLA== X-Gm-Message-State: APjAAAXYDnABzmNG0FnHB76NMEBUQBpsOuNPxx5z+hPh+MT2SWVH0uhr dvwGhxyuxp1n2PCZRTUgBY3luONZgZA= X-Received: by 2002:a1c:7c13:: with SMTP id x19mr961205wmc.80.1570757038759; Thu, 10 Oct 2019 18:23:58 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:ea2:c100:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id l13sm7699795wmj.25.2019.10.10.18.23.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 18:23:58 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Dmitry Safonov , Adrian Reber , Andy Lutomirski , Arnd Bergmann , Christian Brauner , Cyrill Gorcunov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , Vincenzo Frascino , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org, Andrei Vagin Subject: [PATCHv7 09/33] posix-clocks: Wire up clock_gettime() with timens offsets Date: Fri, 11 Oct 2019 02:23:17 +0100 Message-Id: <20191011012341.846266-10-dima@arista.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191011012341.846266-1-dima@arista.com> References: <20191011012341.846266-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrei Vagin Adjust monotonic and boottime clocks with per-timens offsets. As the result a process inside time namespace will see timers and clocks corrected to offsets that were set on creating namespace. Note that applications usually go through vDSO to get time, which is not yet adjusted. Further changes complete time namespace virtualisation with vDSO support. Signed-off-by: Andrei Vagin Co-developed-by: Dmitry Safonov Signed-off-by: Dmitry Safonov --- kernel/time/alarmtimer.c | 1 + kernel/time/posix-stubs.c | 3 +++ kernel/time/posix-timers.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 9415c83f8cca..c326427bb4cb 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "posix-timers.h" diff --git a/kernel/time/posix-stubs.c b/kernel/time/posix-stubs.c index 67df65f887ac..edaf075d1ee4 100644 --- a/kernel/time/posix-stubs.c +++ b/kernel/time/posix-stubs.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER @@ -77,9 +78,11 @@ int do_clock_gettime(clockid_t which_clock, struct timespec64 *tp) break; case CLOCK_MONOTONIC: ktime_get_ts64(tp); + timens_add_monotonic(tp); break; case CLOCK_BOOTTIME: ktime_get_boottime_ts64(tp); + timens_add_boottime(tp); break; default: return -EINVAL; diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 47a8d43fe1c6..d8b5bd4cbae1 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "timekeeping.h" #include "posix-timers.h" @@ -195,6 +196,7 @@ static int posix_clock_realtime_adj(const clockid_t which_clock, static int posix_get_monotonic_timespec(clockid_t which_clock, struct timespec64 *tp) { ktime_get_ts64(tp); + timens_add_monotonic(tp); return 0; } @@ -209,6 +211,7 @@ static ktime_t posix_get_monotonic_ktime(clockid_t which_clock) static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec64 *tp) { ktime_get_raw_ts64(tp); + timens_add_monotonic(tp); return 0; } @@ -223,6 +226,7 @@ static int posix_get_monotonic_coarse(clockid_t which_clock, struct timespec64 *tp) { ktime_get_coarse_ts64(tp); + timens_add_monotonic(tp); return 0; } @@ -235,6 +239,7 @@ static int posix_get_coarse_res(const clockid_t which_clock, struct timespec64 * int posix_get_boottime_timespec(const clockid_t which_clock, struct timespec64 *tp) { ktime_get_boottime_ts64(tp); + timens_add_boottime(tp); return 0; } -- 2.23.0