Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4036029imm; Mon, 18 Jun 2018 08:08:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIh1QYkNg/yAfwMc8G3Uis7eCQETelLXFmz4FHhtnMc7bctaJ835XAyDXjrGzzcAw6r0mJc X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr11281407pge.67.1529334526171; Mon, 18 Jun 2018 08:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529334526; cv=none; d=google.com; s=arc-20160816; b=fcOYZDcnvPYSKyZIVOIaVirEvEp2lj180scxb8HrOSg5UezOb0uu/YjZHZQy06zyqK aJc1cBvyXvWuy2w6tQzrdUQyljHneh6n5+s4uE57JPK0YZ6VAoSwuLai1bS6mjMKxgzH B6sEHkBM5ctylj7dL7InElcrQ2csEMn6rUVZZYyADxF1Ps46HqR6/EtcjiFqBDLllGbv RGkQkzMIOEC6XmNucRtvcdajCDeWD/N+5WVC9OQLTpD5//DULJBbRG8Ygp5HhqJlYQSK tbgDsldDVU4tW1DZJK8/ckZDp+3UfgBKIAUkXAb8J9V3R35fd5dlyvQlcCDGBtcUlR9s zp6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=B6Z2Yxp10H9ZUhz2OCbIS04Vyjh/4MN4jba+2LuzTic=; b=LlV/D1X/Z+v2y6SJGq9feLcMnVI0vaaxTPGBHO8CYNzKJBhlILaQvC5rBkX4ZN/JrB L+M9r61FXFAAx7EPDCQjydj/+0EgjRKMpNq+PZO669o/qEj/+xRlfraGC5SobNQD+5IT UNZyWHZtiLbaWEK8aalgMTDMCLVNKbOIB9S95Dg2Hwlg77X8SyzU9Mhr2iN5gsQCSnx7 +QTUYbA6fo9QwmeMcVlSRSAUjelovQQnMPz7SMjxyLm4mOydb+c/pO3Tn3J6HneHd5dm WEtHicz1VNC52Tgi8/ZTGaxv+xOss71/clv63vCshB7KqKzLYrYSqtRnh3BDAeNnidcy 0i0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=aripGAga; 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=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21-v6si11884220pgn.279.2018.06.18.08.08.32; Mon, 18 Jun 2018 08:08:46 -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=@android.com header.s=20161025 header.b=aripGAga; 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=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965498AbeFRPHb (ORCPT + 99 others); Mon, 18 Jun 2018 11:07:31 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:45869 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964906AbeFRPHZ (ORCPT ); Mon, 18 Jun 2018 11:07:25 -0400 Received: by mail-pf0-f194.google.com with SMTP id a22-v6so8316279pfo.12 for ; Mon, 18 Jun 2018 08:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B6Z2Yxp10H9ZUhz2OCbIS04Vyjh/4MN4jba+2LuzTic=; b=aripGAgagar7hqzH98wR/kmvzN8nmgmUw7cLY5GLA8xzgi/YdqOy1YyB6AELAp2Kr/ HZJ9wrbW8b9Y5uymLDrPsYR5Sg2C4HMwSa3ZlBeS4NMV+4Ug8FwzAy+i3qE64uKt/FpU WngxhyovqlHfbjdG/U7K/rEBsUq8TbeZ8o0nCqRPZ2KAcXj0otw6ShcisNdyAlwi5hpc mJ6HxsmycgMyBGSqZRp5OJ7kmrW8AhxQgvpcHz/pIpJatU055U/e9BGK8eA1kGvdsY7S BwbateZAB50LTI1B8x4Wl7CGGEAt6JqLAZYIPsmURRyyVO3mkuA7vVLFBeuo8wflmX5v h6Sw== 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; bh=B6Z2Yxp10H9ZUhz2OCbIS04Vyjh/4MN4jba+2LuzTic=; b=dwSnVWecicOpSJ09dJvkxR3fb6wyav3CFrzB9AXAri1+Z+QobFkPM50wqPDq1qx/py SHhGD8+jD/SrAQtq8vDM/iJ0Kz42tXo5G+bx0bvLiV6Nzz5ktNqEVhPa6eWhw+pUqLIW 8VjPM0ILXjidmQhJ5q6Wt7F2VM0FzrhTIsHg+KixzHo8hc91NkLLCAdrCgbqR3+PUiIP RuswCxBQGXTEGrpx3EOr8eTBFReNi1sMDKQfwf6bwE5/u9tso/sX/XvH/8TuOXgWDfmj mXwNmI76UsN6k1SQv1VNBHwsVi1XWTGaJBHdfHyBHBhdEXv5THZ5a2icpRxodugr+eBv LAiw== X-Gm-Message-State: APt69E2sy3g9MRfv0+7gWKGV4ZYECSJ5h/6sDM8YbwpG3ttZJauVeZXp Bf2Z28GG17ahjfyRY0LhtAeO8UtfYRA= X-Received: by 2002:a63:7b0e:: with SMTP id w14-v6mr11159950pgc.165.1529334444882; Mon, 18 Jun 2018 08:07:24 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1611:6077:8eec:bc7e:d0f4]) by smtp.gmail.com with ESMTPSA id i7-v6sm54830660pfa.34.2018.06.18.08.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:07:24 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: Mark Salyzyn , James Morse , Russell King , Catalin Marinas , Will Deacon , Andy Lutomirski , Dmitry Safonov , John Stultz , Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , Andy Gross , Kevin Brodsky , Andrew Pinski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Jeremy Linton , Mark Salyzyn , Jinbum Park , Ingo Molnar , "Paul E. McKenney" Subject: RESEND [PATCH v5 06/12] arm: vdso: add support for clock_getres Date: Mon, 18 Jun 2018 08:05:52 -0700 Message-Id: <20180618150613.10322-7-salyzyn@android.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618150613.10322-1-salyzyn@android.com> References: <20180618150613.10322-1-salyzyn@android.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Take an effort to recode the arm64 vdso code from assembler to C previously submitted by Andrew Pinski , rework it for use in both arm and arm64, overlapping any optimizations for each architecture. But instead of landing it in arm64, land the result into lib/vdso and unify both implementations to simplify future maintenance. Add clock_getres vdso support to match up with existing support in the arm64's vdso. Signed-off-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Kevin Brodsky Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Jeremy Linton v2: - split first CL into 7 of 7 pieces v4: - update commit message to reflect overall reasoning. - replace typeof() with long for nsec - replace clock_id with clock to match usage elsewhere. v5: - add linux/hrtimer.h to compiler.h to supply for LOW_RES_NSEC and MONOTONIC_RES_NSEC. --- arch/arm/kernel/vdso.c | 1 + arch/arm/vdso/compiler.h | 1 + arch/arm/vdso/vdso.lds.S | 1 + arch/arm/vdso/vgettimeofday.c | 23 +++++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index 9c13a32fa5f0..c299967df63c 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -191,6 +191,7 @@ static void __init patch_vdso(void *ehdr) if (!cntvct_ok) { vdso_nullpatch_one(&einfo, "__vdso_gettimeofday"); vdso_nullpatch_one(&einfo, "__vdso_clock_gettime"); + vdso_nullpatch_one(&einfo, "__vdso_clock_getres"); } } diff --git a/arch/arm/vdso/compiler.h b/arch/arm/vdso/compiler.h index 3edddb705a1b..c7751019246a 100644 --- a/arch/arm/vdso/compiler.h +++ b/arch/arm/vdso/compiler.h @@ -27,6 +27,7 @@ #include /* for cpu_relax() */ #include #include +#include /* for LOW_RES_NSEC and MONOTONIC_RES_NSEC */ #include /* for NSEC_PER_SEC */ #ifndef CONFIG_AEABI diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 89ca89f12d23..1d81e8c3acf6 100644 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -82,6 +82,7 @@ VERSION global: __vdso_clock_gettime; __vdso_gettimeofday; + __vdso_clock_getres; local: *; }; } diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index a2c4db83edc4..a354586f8a65 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -32,6 +32,7 @@ DEFINE_FALLBACK(gettimeofday, struct timeval *, tv, struct timezone *, tz) DEFINE_FALLBACK(clock_gettime, clockid_t, clock, struct timespec *, ts) +DEFINE_FALLBACK(clock_getres, clockid_t, clock, struct timespec *, ts) static notrace u32 vdso_read_begin(const struct vdso_data *vd) { @@ -301,3 +302,25 @@ notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) return 0; } + +int __vdso_clock_getres(clockid_t clock, struct timespec *res) +{ + long nsec; + + if (clock == CLOCK_REALTIME || + clock == CLOCK_MONOTONIC || + clock == CLOCK_MONOTONIC_RAW) + nsec = MONOTONIC_RES_NSEC; + else if (clock == CLOCK_REALTIME_COARSE || + clock == CLOCK_MONOTONIC_COARSE) + nsec = LOW_RES_NSEC; + else + return clock_getres_fallback(clock, res); + + if (likely(res != NULL)) { + res->tv_sec = 0; + res->tv_nsec = nsec; + } + + return 0; +} -- 2.18.0.rc1.244.gcf134e6275-goog