Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4389726ybi; Tue, 30 Jul 2019 01:09:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwItubIzBrzKPeagJU444mIqgdto3DHIEc4sWZLIGLsbQXVBhD2jQh9zakAFsTVxBOZ0Dac X-Received: by 2002:a17:90a:32c7:: with SMTP id l65mr116040849pjb.1.1564474155821; Tue, 30 Jul 2019 01:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564474155; cv=none; d=google.com; s=arc-20160816; b=yIbTkZgAabFzdAQzLYwvgdvnYFNAb/2Qci7V+aLdsNlztnP8iS729qCs4HwDp5Nzk/ a5OJzAl1bGIP+6UyGZny8biFyvGa4GGm1EOLqEq4Pqtoqn8Q2VwL5SD3UToQqmf4STrB SgYqABQ6uSJ1bnMuyMWOjpfpWdAIuVRreI9O9r82ChPzDTfMTmRfaPLg/GfSyBi1lsAC AlqMb1fMH6Db7AmysVNFKqV5iDhA1HC/8qfO8+5d1Sm1MOhSQPhDm3VIz0y/zEQRTI5w LIAQ0I2bcrqHVqlEI4HLgo7SVIhl/IZCzBwnDDvVBy29zYmwUIyyRyjQgCO0LI1V0KwG 5jKw== 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=BzI1c4S4tFT63UI7YPB9gsR1IIQ/vTV7lGWF1y4YU4Iaq+m9fVgeJxaMGN4UZby/Xv WzqGDJKFvzHKq3UBG70V/AzbOBo74X4OmScUhsY0hqvDytEOH2fUTJc+PLQYeCMWiEku Z4k+dMSch1fE6SLOGGNs6YgHRFNMF37hbrkRN2WzNIarnnryYhbnoaz3/82Mc9KhmHuS D/NXtRu6GH6A83bI/AXa9aER7gSh4XWfx2HpVaxmy78aPNlFBqA1G8Ctx52LV1oYaMWo Rb8OG4pmlTwYBTpCLPSwXA+GSc51t1y/EOkx+jD39T9UUz9NjrEWjtIBvdEDHiPMr7tU CcSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=ON4VHzES; 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 h33si26664214pje.95.2019.07.30.01.09.01; Tue, 30 Jul 2019 01:09:15 -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=ON4VHzES; 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 S1729015AbfG2V6X (ORCPT + 99 others); Mon, 29 Jul 2019 17:58:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33220 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbfG2V6T (ORCPT ); Mon, 29 Jul 2019 17:58:19 -0400 Received: by mail-wr1-f65.google.com with SMTP id n9so63568974wru.0 for ; Mon, 29 Jul 2019 14:58:18 -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=ON4VHzES+B/jfG7vTOtWjSgEGPQD0zrGmt6jz5giNgVQbhqIMvOUOlN1gM3JzvUWe/ IGqMM+pYFQ78AaNJ9Hsa3w8YxDkSggEmShReMrE3WotwdxfcPAHGELp2Z80/g0iLM77/ wSrKM5XBdZ0uxHW/6eMOUBRWn4YeC1ab6BgVoHXwqx6I49mzpZhSVuqq8m2vv9SLoTO6 zr0MsayJMMyNQ/5pc+UiVp3rjnytJIvrcPhuzdNWyij3bZpks8ed8L+PMhy3b2ZVWCBV 3bIC8zze+cAte15hHO5VIBL434b7TtsT9s2GJyYaNewFiy9I3KpZdy/hUdSh2TWmy0Bk lTyQ== 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=YSCFtqikMaTT9juHCY/MYIrYQjdqyWJJAsFDl4f5oJAgq3LVo9t6beLxvCO8IyYU9D OVXiCxvggxLK9cmJz/Cqzlp35SB50Uk6rG4dQq9HDsdxChFcCujyqIw0fq+s73kfIXzI ixVtLx+AfX/RbsUE0onkvY/GGhR0dlz+yx6uOmnUMl8i+jiilixguotKJrHlx4HA8eKZ Jq3rMnBA5x0+dxz6xhMKP8KsXy1QjXi8XonsBjhGgL3zHKWFgx+5AIzj2No9W9egKf05 IldXGRBQejwjweC0VIHEOxrLKx3Bq0uXCF2hxb9PSwkj/0EvU4db730mMOxhACBXuItB PG1A== X-Gm-Message-State: APjAAAW3152cibgatTgchEZ0QyEtFMV/9xE6wkQdvrKkO90y4uSoM/WQ sKehqL9Y/zuHl7R/gTvmHDIeAC2ThlXTfRSj1i94D75dfJhq4TXs5buW+8K/bMrVAZE+MEOvteL jK6/EQGRltZMACQk73Feu84z5suRDhTspiue6058AZgp690GvwefF+3yjb7ZtMRSve/AH5fKVUy wMMWnAeODiIpneWcKFvw1JnFRAN+qAbhccGXisOQU= X-Received: by 2002:a5d:4950:: with SMTP id r16mr19690168wrs.136.1564437498092; Mon, 29 Jul 2019 14:58:18 -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.58.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 14:58:17 -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:56:55 +0100 Message-Id: <20190729215758.28405-14-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