Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4137949ybi; Mon, 29 Jul 2019 20:05:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzV5Gk5E3nPO4+UNRrxYbdzfQgM+oym0UAvCHr2S8CJ+RA7wviE3VNHboJIwthXD1+Chce9 X-Received: by 2002:a62:e806:: with SMTP id c6mr40155545pfi.158.1564455929751; Mon, 29 Jul 2019 20:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564455929; cv=none; d=google.com; s=arc-20160816; b=Sy+p9Dy+eodoo49vXqB/5D1PJyYlB3iXZAhRTZyeduKi9kkwH8laQ92G0v7HAyib5H ySoJ22QD9YVn5PSR1cKy9YER0vPXCt5Jj8zvzTDbEDS/o5gvXSb8+m8SAtYxh8HKcSGr 13TzCDKInhERFNJYSlnL5ETf0qhW8Zb1qV+jmbSYq6McGQ373PGRf6j79J9lrBEYXRX9 7wmMilUMvpokeR4P187Y38yYo+7oSw3/Ef1gDh+sxPOoKbldEHw7Gbd2kqtJ7tOmBOEP OJlVWumoEFyxVYotlLfyIiVOGlXlUl1bx7uiSW65p9AmyqHjCvCIe3QXM+W3MWdkeiKB Fk/A== 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=PCttgBL0BPZg1/LiUWIoAnwXTnGYw/Et5KrxphEhxpI=; b=epJtk9OYcKMKNMxPsmrMaMC9F0xLdHDNKRb9eqOKtGTizVPZ1VrW8M4+v9/+IrKBCh 02dr3PdFCskoJmvxq6MGdTpHbyhpdMdwW27Pt6L8LVZ59SgF+cGQlQtM/mCk4bf4P2Ty 7JT38hP8DX2dd6ykJ0e5WY9s3UXHQ4Hmi9Ivvd8vKFzP8MOUvPYqy5VN0MQJzYkJ3lQ4 sG8I8bm4+QnbhYjRgcSPzz4XAO+MtCMbi7qq4ww+WGJ3g+NwV62pJ3z8KzJahIpJ+Ng/ xbZooylYGLEeG4JxzwEODIg8eNHJZgubKNP+JfVAykQilzbe8HB4GXHC0zpG/fBRMZyq xANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=Oc3LPP9t; 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 e14si21774913pgg.442.2019.07.29.20.05.14; Mon, 29 Jul 2019 20:05:29 -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=Oc3LPP9t; 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 S1728424AbfG2V7D (ORCPT + 99 others); Mon, 29 Jul 2019 17:59:03 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46732 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389434AbfG2V7A (ORCPT ); Mon, 29 Jul 2019 17:59:00 -0400 Received: by mail-wr1-f68.google.com with SMTP id z1so63447386wru.13 for ; Mon, 29 Jul 2019 14:58:58 -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=PCttgBL0BPZg1/LiUWIoAnwXTnGYw/Et5KrxphEhxpI=; b=Oc3LPP9t9tXeA7Vlwem9kcPOGufk7lVBVXS65qbF8sbB1DL2hR43j6uvUp83huqyWc KRBt4hKIUG8dqLHhiKTAOOOwl8srID3GEuGEaJoUfvVbJfSvNHBD9r1oeHCHakBfeUDQ ZeurKj5v6daMjNuJhjFUFrYtB21Qe2V4rCGoVG3qJYmed9C1YAlBE6jIJANbSyQMM4tc eZIQFoY21B9i+6XNI6PQi9FGrcxxxBbPkSNoYaIgSB9RhK74I2/o7WidhVNgordFNKV7 FGJ5XNygs5l8RYUzrapzky5oMtsFZq665USPik+qsDMmCc9gsF6K9ZnJw0phEUSL+WGG Xpew== 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=PCttgBL0BPZg1/LiUWIoAnwXTnGYw/Et5KrxphEhxpI=; b=m22SV6ei2lR2nRkQafry4URaKCDc7rtTYPje3iZ9sNi1S/9hkSV+vbOhZsn7SMMtmG datZknN0gg/YGchP7SP2+0R7VrLTQ9v03me6Zb9OOe912//N6s02Y5bHTs0Yji/ualOC ZBkzXXKA/bpO8XgN7wTDdvWc6+wh2ASinAQ24d7GN+gmbisyLd3FJBwhW5czI/MUBSBL 9FYsNqG8vju8WJMeDKJ6HvFUJutD4sg/W8x1o0NOgkZHkVnwGHWYClJryTgFQFMKAtg5 5Vp01DNPzOB+g4e/1QLvlJpYkQ5RoFzRW2vo3IrcEUbPl/HKOOfY2TVYqZO17tw+B90o g2Vg== X-Gm-Message-State: APjAAAVjBQWKZOJdS+a67N8HWRkpHjZHGk71IDCMYfHzTO4BLuvEJ2gZ mVM6Gu6Vpk+GGfSrRQIgL3KK8m211P4pni8LJZsGsAatWV0IAdNXFPu1ZV8oK70R0rtsvPHg4fO em5nTvVY9e0kSo9/UKjyQV0M82Lr6uHmu+tmbwe69f58Dsb41MtZXd7bnaEyBRfmGRIgp3Vmjom y1zqn0lE8/IWuKVcZqYraPsF3uvDyA9YKZU/9I0tU= X-Received: by 2002:adf:aac8:: with SMTP id i8mr16841wrc.56.1564437537385; Mon, 29 Jul 2019 14:58:57 -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.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 29 Jul 2019 14:58:56 -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 03/37] posix-clocks: Rename the clock_get() into clock_get_timespec() Date: Mon, 29 Jul 2019 22:57:23 +0100 Message-Id: <20190729215758.28405-42-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 The upcoming support for time namespaces requires to have access to: - The time in a task's time namespace for sys_clock_gettime() - The time in the root name space for common_timer_get() That adds a valid reason to finally implement a separate callback which returns the time in ktime_t format, rather than in (struct timespec). Rename clock_get() callback into clock_get_timespec() as a preparation for introducing clock_get_ktime(). Suggested-by: Thomas Gleixner Signed-off-by: Andrei Vagin Co-developed-by: Dmitry Safonov Signed-off-by: Dmitry Safonov --- kernel/time/alarmtimer.c | 4 ++-- kernel/time/posix-clock.c | 8 ++++---- kernel/time/posix-cpu-timers.c | 32 ++++++++++++++++---------------- kernel/time/posix-timers.c | 22 +++++++++++----------- kernel/time/posix-timers.h | 4 ++-- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 57518efc3810..cada96fdc615 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -644,7 +644,7 @@ static int alarm_clock_getres(const clockid_t which_clock, struct timespec64 *tp } /** - * alarm_clock_get - posix clock_get interface + * alarm_clock_get - posix clock_get_timespec interface * @which_clock: clockid * @tp: timespec to fill. * @@ -824,7 +824,7 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, const struct k_clock alarm_clock = { .clock_getres = alarm_clock_getres, - .clock_get = alarm_clock_get, + .clock_get_timespec = alarm_clock_get, .timer_create = alarm_timer_create, .timer_set = common_timer_set, .timer_del = common_timer_del, diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c index ec960bb939fd..c8f9c9b1cd82 100644 --- a/kernel/time/posix-clock.c +++ b/kernel/time/posix-clock.c @@ -315,8 +315,8 @@ static int pc_clock_settime(clockid_t id, const struct timespec64 *ts) } const struct k_clock clock_posix_dynamic = { - .clock_getres = pc_clock_getres, - .clock_set = pc_clock_settime, - .clock_get = pc_clock_gettime, - .clock_adj = pc_clock_adjtime, + .clock_getres = pc_clock_getres, + .clock_set = pc_clock_settime, + .clock_get_timespec = pc_clock_gettime, + .clock_adj = pc_clock_adjtime, }; diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 0a426f4e3125..dccf7dfcd36a 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1417,26 +1417,26 @@ static int thread_cpu_timer_create(struct k_itimer *timer) } const struct k_clock clock_posix_cpu = { - .clock_getres = posix_cpu_clock_getres, - .clock_set = posix_cpu_clock_set, - .clock_get = posix_cpu_clock_get, - .timer_create = posix_cpu_timer_create, - .nsleep = posix_cpu_nsleep, - .timer_set = posix_cpu_timer_set, - .timer_del = posix_cpu_timer_del, - .timer_get = posix_cpu_timer_get, - .timer_rearm = posix_cpu_timer_rearm, + .clock_getres = posix_cpu_clock_getres, + .clock_set = posix_cpu_clock_set, + .clock_get_timespec = posix_cpu_clock_get, + .timer_create = posix_cpu_timer_create, + .nsleep = posix_cpu_nsleep, + .timer_set = posix_cpu_timer_set, + .timer_del = posix_cpu_timer_del, + .timer_get = posix_cpu_timer_get, + .timer_rearm = posix_cpu_timer_rearm, }; const struct k_clock clock_process = { - .clock_getres = process_cpu_clock_getres, - .clock_get = process_cpu_clock_get, - .timer_create = process_cpu_timer_create, - .nsleep = process_cpu_nsleep, + .clock_getres = process_cpu_clock_getres, + .clock_get_timespec = process_cpu_clock_get, + .timer_create = process_cpu_timer_create, + .nsleep = process_cpu_nsleep, }; const struct k_clock clock_thread = { - .clock_getres = thread_cpu_clock_getres, - .clock_get = thread_cpu_clock_get, - .timer_create = thread_cpu_timer_create, + .clock_getres = thread_cpu_clock_getres, + .clock_get_timespec = thread_cpu_clock_get, + .timer_create = thread_cpu_timer_create, }; diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index d7f2d91acdac..6c9c0f2d2f1e 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -667,7 +667,7 @@ void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting) * The timespec64 based conversion is suboptimal, but it's not * worth to implement yet another callback. */ - kc->clock_get(timr->it_clock, &ts64); + kc->clock_get_timespec(timr->it_clock, &ts64); now = timespec64_to_ktime(ts64); /* @@ -781,7 +781,7 @@ static void common_hrtimer_arm(struct k_itimer *timr, ktime_t expires, * Posix magic: Relative CLOCK_REALTIME timers are not affected by * clock modifications, so they become CLOCK_MONOTONIC based under the * hood. See hrtimer_init(). Update timr->kclock, so the generic - * functions which use timr->kclock->clock_get() work. + * functions which use timr->kclock->clock_get_timespec() work. * * Note: it_clock stays unmodified, because the next timer_set() might * use ABSTIME, so it needs to switch back. @@ -1032,7 +1032,7 @@ SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, if (!kc) return -EINVAL; - error = kc->clock_get(which_clock, &kernel_tp); + error = kc->clock_get_timespec(which_clock, &kernel_tp); if (!error && put_timespec64(&kernel_tp, tp)) error = -EFAULT; @@ -1114,7 +1114,7 @@ SYSCALL_DEFINE2(clock_gettime32, clockid_t, which_clock, if (!kc) return -EINVAL; - err = kc->clock_get(which_clock, &ts); + err = kc->clock_get_timespec(which_clock, &ts); if (!err && put_old_timespec32(&ts, tp)) err = -EFAULT; @@ -1226,7 +1226,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags, static const struct k_clock clock_realtime = { .clock_getres = posix_get_hrtimer_res, - .clock_get = posix_clock_realtime_get, + .clock_get_timespec = posix_clock_realtime_get, .clock_set = posix_clock_realtime_set, .clock_adj = posix_clock_realtime_adj, .nsleep = common_nsleep, @@ -1243,7 +1243,7 @@ static const struct k_clock clock_realtime = { static const struct k_clock clock_monotonic = { .clock_getres = posix_get_hrtimer_res, - .clock_get = posix_ktime_get_ts, + .clock_get_timespec = posix_ktime_get_ts, .nsleep = common_nsleep, .timer_create = common_timer_create, .timer_set = common_timer_set, @@ -1258,22 +1258,22 @@ static const struct k_clock clock_monotonic = { static const struct k_clock clock_monotonic_raw = { .clock_getres = posix_get_hrtimer_res, - .clock_get = posix_get_monotonic_raw, + .clock_get_timespec = posix_get_monotonic_raw, }; static const struct k_clock clock_realtime_coarse = { .clock_getres = posix_get_coarse_res, - .clock_get = posix_get_realtime_coarse, + .clock_get_timespec = posix_get_realtime_coarse, }; static const struct k_clock clock_monotonic_coarse = { .clock_getres = posix_get_coarse_res, - .clock_get = posix_get_monotonic_coarse, + .clock_get_timespec = posix_get_monotonic_coarse, }; static const struct k_clock clock_tai = { .clock_getres = posix_get_hrtimer_res, - .clock_get = posix_get_tai, + .clock_get_timespec = posix_get_tai, .nsleep = common_nsleep, .timer_create = common_timer_create, .timer_set = common_timer_set, @@ -1288,7 +1288,7 @@ static const struct k_clock clock_tai = { static const struct k_clock clock_boottime = { .clock_getres = posix_get_hrtimer_res, - .clock_get = posix_get_boottime, + .clock_get_timespec = posix_get_boottime, .nsleep = common_nsleep, .timer_create = common_timer_create, .timer_set = common_timer_set, diff --git a/kernel/time/posix-timers.h b/kernel/time/posix-timers.h index de5daa6d975a..b3cc9ee36a6b 100644 --- a/kernel/time/posix-timers.h +++ b/kernel/time/posix-timers.h @@ -6,8 +6,8 @@ struct k_clock { struct timespec64 *tp); int (*clock_set)(const clockid_t which_clock, const struct timespec64 *tp); - int (*clock_get)(const clockid_t which_clock, - struct timespec64 *tp); + int (*clock_get_timespec)(const clockid_t which_clock, + struct timespec64 *tp); int (*clock_adj)(const clockid_t which_clock, struct __kernel_timex *tx); int (*timer_create)(struct k_itimer *timer); int (*nsleep)(const clockid_t which_clock, int flags, -- 2.22.0