Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp298812ybp; Thu, 10 Oct 2019 18:26:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqs/h0gtxD5bpA2DOn2vbZY2pFbstGIMEmXsuFHh/c7HfQ8Uia6CcNel6cajIrWF3HPbIR X-Received: by 2002:a05:6402:7ca:: with SMTP id u10mr11090157edy.20.1570757208707; Thu, 10 Oct 2019 18:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570757208; cv=none; d=google.com; s=arc-20160816; b=GwAb0OY62uCkNWdnPWX1Zu/XsR0CsPm1ZR9T9szu5G6Qy7r51Kcr/8ErGz5xep3/uf sNr4x8jDF5HCFz/a5TrA2jRP/MtbLhLJusPRmwzifJEH17ZXHW04eInxJ+paDGhqtS+c qwCnFgICut2DqxilfUKw9h8Bxjimpgtno7W2uZCiPaCvGq+BgdlIJHIT1mqBgsdSobOj D3XPYRw00nUDMPg3P8z777gM6spD0RYQVeZfS3s6DDQuzNh01EV59bo6+x+PMEH576bB dA9FCE2HDt40tG9UFAID3hybHtVNcvpi/c54BXG96Hcu4hOdQ3QkjOrM/87HYurYo+cK 26aw== 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=iERz2FP0YlBkmC86yLcDq0+jGuy+OmV9tA9oUfgYUPk=; b=hXErY7Lt5vvpK4H9GErReKq2Cz8qizqtNNRRdB3aRkgwy2Ux97K6nVlbizyUni2Der 6n5TgqGMVhcVS5J3yUyfUYU/fuwU0vu3muLBRqZBCEku1CNj34AeKZFMcniJZrmsbwep FS7H72Baf9HeNpVovOma1FG0tEf01x7ljPi9mQMo7/qibj0Jk8e4xIX/+lHUCqskwH99 MdfTT3qVvB61zMO0SiTyj61D7oP9NcnUs/4i51BxHHftkAc/wfjG6TXeuJAX78BG8M2d 0+Gs4dimhc0rRljamIB/j/otJeJvgIapDR8wwrH//pbBTpMOfOrw+P12oBCHX59yLXPl IGuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=SREuUiH9; 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 f16si4501862edm.54.2019.10.10.18.26.25; Thu, 10 Oct 2019 18:26:48 -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=SREuUiH9; 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 S1728436AbfJKBZd (ORCPT + 99 others); Thu, 10 Oct 2019 21:25:33 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34286 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfJKBYF (ORCPT ); Thu, 10 Oct 2019 21:24:05 -0400 Received: by mail-wr1-f65.google.com with SMTP id j11so9979673wrp.1 for ; Thu, 10 Oct 2019 18:24:04 -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=iERz2FP0YlBkmC86yLcDq0+jGuy+OmV9tA9oUfgYUPk=; b=SREuUiH93YhFhC5Wk6DuJA9lF09LZo9G/0AScXGNMdjd1BAJugvPWp9DnSl59RjMnX qO2tvfFUKsFRHnB2WaGSHnb3jBBJQPhKVQwAanWssnis5KKeFRSsM64yuAWb8DheWK8U aXp4L6DhBB1BdwVZaGR1tACkG5ee/jky6efQuwP3ywWnZvyZPj+voEsEspZoG7JDF0RY UvJnKILLbNjhLJSolk3xGp75sE9yeVobfbJowSY4HQJyqSxCxjc2+/lJ+8KWDPZ/kVFN JZTj0STi6gFrmMQ1Y9L8W8C2QjIuFA705SFattbbMHANa1pUd0hqIsvMltaGmBxQHcFm MUjA== 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=iERz2FP0YlBkmC86yLcDq0+jGuy+OmV9tA9oUfgYUPk=; b=N/340Aqy3BXZ7EcPrlv3z6n9MkzAX/nPeeHm8k7hEjYB+R/JtO9n32O+/z+hwyA+3x 1Uwg/VmNbUK8LNCiJ/JTYzGoybVrFePzt6Yy7nCgACjgzcXh1ZM2nOdPaU65hqlbshVR x332MOZNgDFS3fV64q09j3OGOw94Ljbdal+V1EKa2fVLWDseW6A1J9FkZ7NOGSqUnbap uBM2VoFm5YMOR2pvJSbKrwCp/g8YvKNgYvQlfCECSVZgvVmlS5jXfOk3MYtKovW7Dew7 MLhJMhAEFWPf1Gx2AEEyYWCwIvxpAGSn46iM7c4p28hG7us/DJIkrTrckL4DZFP2LnuC 1yOQ== X-Gm-Message-State: APjAAAVyh+84eBjwLpsXtVU26LB6Hyzbdl806PVF4unGr8Tux5XZaGF6 alz7U3tMwY0fJl3l2hrtqY+Kv+umqn4= X-Received: by 2002:adf:f145:: with SMTP id y5mr153370wro.330.1570757043333; Thu, 10 Oct 2019 18:24:03 -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.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 18:24:02 -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: [PATCHv7 12/33] posix-timers: Make timer_settime() time namespace aware Date: Fri, 11 Oct 2019 02:23:20 +0100 Message-Id: <20191011012341.846266-13-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 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 d8b5bd4cbae1..6e350cc8f600 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -885,6 +885,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.23.0