Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4139549ybi; Mon, 29 Jul 2019 20:07:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsWVPI4uU/MVzUJiqPcYB/qbjoRiJBa2Z3dua0T2Ty/9s/xFi+oia1VgWywma9/fEa0eOH X-Received: by 2002:a17:902:8649:: with SMTP id y9mr111218960plt.289.1564456044866; Mon, 29 Jul 2019 20:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564456044; cv=none; d=google.com; s=arc-20160816; b=r7njoe3Dyx+wzYa+b5iDVz7hC3NNGhMnWj5YQB33zEzYlceXhrdoOITXpyPw3N4Zfp MaLtRRc+y2DrSKvzaeS6A0K5neVSDrRZrOdm4f4jxCmB/ghj3D0ErpjpqeKrvLA/GduZ Uq2/H8qhKq8RBglC5e3hJQdVwDa5F1+cEoE8vFMyKSuFbu0aKeMVEO+Y3MibtMZwOiyj UGjBOqhpNAtdWPkckwICcJq9flAmG9ppKUEJqmw3Tbh89exG72RF6Z1gu8kMfIK3qEmU ursraMeoDpbdAwPpAxjxy6BNOa/E53XKUcs9bXSDF6aJZMC4KZElK9Mr+BOZfNoYIcAA x+dw== 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=aoCU6uPiHr0PzNNlgylsAXV9auaD7Fl9k+QB3VPTwmU=; b=izaNUK6WckwqOz34nveJXFPV+MP/W949ZRUqi4sbdt5DH8Cpa+qnDhS7LhGWqecYQL Dt2WFEV1sbumdnki/O8dh1uAN7iMIIN2jOUH1HVZ+aLD3WK6juKFiBC/udF8mSjBmCDa c8p2j11vT/m3ZRnLLXZPFfxblyGDA2NrJK/nVNLq3kMTEmvH5WhEANfLxGkcMNq+RiA2 lZAaU3vcAUVTBZsxlmfKkbRd5YOaR24Z6Pk6lOIK+YaSkJ7AF6Suh0ux+x46XqNohQZM bPotFeU5f2LhO1djwkxSesZ5ekSlYjtRn7QbyDUKXtjqmoIUG58MQUgvi/nj2hunaqjq 3INQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=lyIFFZOD; 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 31si25945679plz.290.2019.07.29.20.07.06; Mon, 29 Jul 2019 20:07:24 -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=lyIFFZOD; 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 S1726305AbfG2V7S (ORCPT + 99 others); Mon, 29 Jul 2019 17:59:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41426 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389497AbfG2V7N (ORCPT ); Mon, 29 Jul 2019 17:59:13 -0400 Received: by mail-wr1-f66.google.com with SMTP id c2so60263156wrm.8 for ; Mon, 29 Jul 2019 14:59:12 -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=aoCU6uPiHr0PzNNlgylsAXV9auaD7Fl9k+QB3VPTwmU=; b=lyIFFZOD5gGnj2VKFbxI8Hxm8GCuaJLZOdM1TyAWTYxIPvJazlmaSBv32iCYrkk9A5 DfFEvqo6cOZTHKDRnFIdSlBt8YD/QZ8veboYXgj4rB+mpr//AYCUP4yKtAAzfbm+Nw14 mJ03K6t68W5ENcS05b+wwnmCMlkOaDoX6b03Qe8GTZOa9fy7qFMb3+H7oFCig63RkBEn rlQ36OfCpIKR4G/fJWpg/Qs2MUcYqJTKypbbp4nl7UKrVyZwUDn559vkbLSVW6GIb2F9 jHRXiTd2wswHPS5WdJTjC2JHRc9AQmguOe9J1Xz+EfKWXT4WtQree65HPLVX3qjngW3I o1MA== 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=aoCU6uPiHr0PzNNlgylsAXV9auaD7Fl9k+QB3VPTwmU=; b=jyZkKftqAuwe4nHZufmQ2uwlzUSPJ7nnterZeuMVYvYCM1YLdMd8Yi/p+of6m0XHhA 1U8IqhKfP1IYjYR2bviy0S5Z2HgSZRgU/47RLxbKhxtX0yS6ZqwxKG1zbEO3NP1DQqam +A0Xt2oV8rTIbLd1rSlG9JAipTFXDYAFWQgh4omLDXTNnzoaY8uVJlrK6modDuiLyyLq ngyV7ADnrgsyAWosTjafVW1yvl2cIrGgV8V8MeWp9Bw7jcQWB4g6e9RAwiOFHRH/znnn ActLB9tfAzWi6gV+1BQ0dk7xA3FdolNV9r+WsAhrGq17I7LjJVDovRcec1pPijXU7RDo 65Kg== X-Gm-Message-State: APjAAAVOoXCmh8HbqlvyDA9egUaxnklgch/ZuFXGmYVFV6ZKsg8zuXZg DRUMjB278wPzR2XfiZXgvgIO5DcCsfJVbXzJahuFpJx3xMMrtGojkkn1a4NNbjs0xiI5H7hUkml uDtuqyKQcFBcWAz6M2CG8HfxOQ2FU5JqkM5MPgbdJDucmOFPo1TG9jsNIrZ4NERdBgFKGWI+2QC qZQrv2QrbXwTgF/YBtFBIwO/b+1mNwVk1zg1TCd2w= X-Received: by 2002:adf:aac8:: with SMTP id i8mr17425wrc.56.1564437551664; Mon, 29 Jul 2019 14:59:11 -0700 (PDT) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id x20sm49230728wmc.1.2019.07.29.14.59.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 14:59:11 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Dmitry Safonov , Adrian Reber , Andrei Vagin , 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 Subject: [PATCHv5 13/37] posix-timers: Make timer_settime() time namespace aware Date: Mon, 29 Jul 2019 22:57:33 +0100 Message-Id: <20190729215758.28405-52-dima@arista.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729215758.28405-1-dima@arista.com> References: <20190729215758.28405-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: arista,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrei Vagin Wire timer_settime() syscall into time namespace virtualization. sys_timer_settime() calls the ktime->timer_set() callback. Right now, common_timer_set() is the only implementation for the callback. There user-supplied timer's value is converted from timespec64 to ktime and then timens_ktime_to_host() can be used to convert namespace's time to the host time. Inside a time namespace kernel's time differ on a fixed offset from a user-supplied, but only absolute values (TIMER_ABSTIME) must be converted. Signed-off-by: Andrei Vagin Co-developed-by: Dmitry Safonov Signed-off-by: Dmitry Safonov --- kernel/time/posix-timers.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 265fbc816520..c979e720a5a1 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -857,6 +857,8 @@ int common_timer_set(struct k_itimer *timr, int flags, timr->it_interval = timespec64_to_ktime(new_setting->it_interval); expires = timespec64_to_ktime(new_setting->it_value); + if (flags & TIMER_ABSTIME) + expires = timens_ktime_to_host(timr->it_clock, expires); sigev_none = timr->it_sigev_notify == SIGEV_NONE; kc->timer_arm(timr, expires, flags & TIMER_ABSTIME, sigev_none); -- 2.22.0