From patchwork Mon Jun 18 15:05:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 10471975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7BB86032A for ; Mon, 18 Jun 2018 15:13:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A80622040D for ; Mon, 18 Jun 2018 15:13:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C9BE28813; Mon, 18 Jun 2018 15:13:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 18AE32040D for ; Mon, 18 Jun 2018 15:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ul/YvvVs8fpy4rOraGIORwRtCkoQoYgqSyN2IdyKbO8=; b=txtgh8ZZP6QtTZ898NWGRhM3xN Gk6pXyo0BDyOyW6Cl26URU7EEaimRp/5Ucn5DjkmcNU4tqvCz1CKF12vTYHq+0YIB7NHogx5mq3I2 drrefzau40jjDzYI+pdbsTNbMiopWs4bI3cbskZN8PO3FBS95s0/T53zIzJHtx7ZarQKzGIEnNxul rFEH3SRDUCkxVPQ96G0vgoRPD9OihqyYiL5RprnWIsu0Omze+yOxT2zEXj/nnM81nKlZ2piR+72r5 PxW07U7Hs3h2lXCTzNO1NFnVB+eWxapeGGwn6hB1lRMAlykJPdSCxEeatadc4OxqopmDavWaz2CAl kcaR+hog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvqS-0004RF-Ky; Mon, 18 Jun 2018 15:13:28 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvkl-0000P7-Nu for linux-arm-kernel@lists.infradead.org; Mon, 18 Jun 2018 15:08:30 +0000 Received: by mail-pf0-x244.google.com with SMTP id a12-v6so8331499pfi.3 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=NWZcc8gxhxMySsmQg0GB81Dy20dospI0o1do0qO3uhyYL2WUqIfE6hoJnBiJWnJGgQ p3SEwekIjodNcMqe3AgSr6c+yD5Ohq566rWdIWEASDJ8krSI21/OuJ7AeI3aY1rCA4ge tGQbGkkhkgef3HcyEddj+TNtR1gga+mYoyWM9B7JHrLc/n4qQSUVecx/z1QZgEpKKF7i 6Dy3pV6V7i5rYWvd0Cj6b4LyaxpXvlv0m5PoCUZdKcPbQqxWoj08tuIGiguWog+LH/xg fVkwiyAhw+S/drNNAWT/zuve3VIC5xhNmDL9LVcu1urHwDl3+cC8+uuiYvbBaf09eqs3 +fbg== X-Gm-Message-State: APt69E0Lwbo6bgL3dzkVgt4W1q1/Gj075b99TY0VqrQ4Nl/+UNb7o+mL EUFJgSHWQRKBsOMtTwjDxWAyZw== X-Google-Smtp-Source: ADUXVKKpztKg/Qq5SsJ4vRI9oyD5IkHNF0Aku6gyslsuxt/Z1BShQ0hHHJUpXs7qxFeDHtv1hOOZEQ== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180618_080735_808919_9A012F3F X-CRM114-Status: GOOD ( 18.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Will Deacon , Mark Salyzyn , Ingo Molnar , Russell King , Andy Gross , Laura Abbott , Mark Salyzyn , Kees Cook , Kevin Brodsky , Jinbum Park , John Stultz , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, "Paul E. McKenney" , Ard Biesheuvel , Dmitry Safonov , Jeremy Linton , Andy Lutomirski , James Morse , Andrew Pinski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; +}