Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp4009734ybd; Tue, 25 Jun 2019 12:21:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxvND9scpJqO/iw+KagwRGj6UHIHdbVABT+om7K6ITY1nmZ+8xCFOWif3bSzFu22zZwLGZ X-Received: by 2002:a17:90a:1904:: with SMTP id 4mr515557pjg.116.1561490511938; Tue, 25 Jun 2019 12:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561490511; cv=none; d=google.com; s=arc-20160816; b=jfaZl4hg3vfyXcdx483QlAgaTP9S0vLWjPQDwy0qQhpFjimsskjiTPgfQDbgSAEbXl IR5j7lEqaJGsq6Pt8cyspv4S/CYtTgbYrUhKYc2BMfnKF+lWU9xSfn08MY4Golup6CGT lQCg/g50VdNAPf4+AeLQx12hgHPfCvPGEK2UJedi/fA8dkvX6sCsbUu/WD+xLSsdpy3C UfuAgb8uoXtavSllV76v1+7Fc8rG0sKOBFgRIpMEg0LD52RSDLamxCo1lUVnSFwNqEC9 F+MIBUIDyYiGx73Zxjw47UqrY6KkIALJ45TIswX9OIZAPvjQlJbtqkF+P0u7hpr6CyvG YF9A== 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; bh=ahp9YydgmpWj8+Wxf0t9fOnjTUc4F9+PO/hYGZ45KnA=; b=PlXjE5CqN+NYY1jgfLrVY9Tt3+ldwtFyasKkFWec+7CG+Tw6CsOYEvXa1DjV54+CIW H/LtWSpN2SAZF1INAOdqO7tcXmD0BaKl+twh0hQW098L2UiPNNJdPUDDVAzTsB0RNv+K ubK4WU6ykbAvVA7S/XgB0i1noYLgd9Nzvdlzi9gtw1PR3AlGn0b9ET8H1Tqk8BdBd6A9 HJbvZfR8vWcCwj8dbbuUkKVQvYelR9tiky/P2gOFguq5ZbFmiRvyeeHN4US8L3WcvfIE fuzxSR/FSnH1IEeRvnGH8tWlLS8xyUraajjnXLVT/+ynDQBbhod+UHlLZoivknmmLabk MNqw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n65si39199pjc.54.2019.06.25.12.21.35; Tue, 25 Jun 2019 12:21:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbfFYQSf (ORCPT + 99 others); Tue, 25 Jun 2019 12:18:35 -0400 Received: from foss.arm.com ([217.140.110.172]:44760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbfFYQSf (ORCPT ); Tue, 25 Jun 2019 12:18:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 916D1360; Tue, 25 Jun 2019 09:18:34 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F12313F718; Tue, 25 Jun 2019 09:18:31 -0700 (PDT) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, arnd@arndb.de, linux@armlinux.org.uk, ralf@linux-mips.org, paul.burton@mips.com, daniel.lezcano@linaro.org, tglx@linutronix.de, salyzyn@android.com, pcc@google.com, shuah@kernel.org, 0x7f454c46@gmail.com, linux@rasmusvillemoes.dk, huw@codeweavers.com, sthotton@marvell.com, andre.przywara@arm.com Subject: [PATCH 1/3] lib/vdso: Delay mask application in do_hres() Date: Tue, 25 Jun 2019 17:18:02 +0100 Message-Id: <20190625161804.38713-1-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624133607.GI29497@fuggles.cambridge.arm.com> References: <20190624133607.GI29497@fuggles.cambridge.arm.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 do_hres() in the vDSO generic library masks the hw counter value immediately after reading it. Postpone the mask application after checking if the syscall fallback is enabled, in order to be able to detect a possible fallback for the architectures that have masks smaller than ULLONG_MAX. Signed-off-by: Vincenzo Frascino --- lib/vdso/gettimeofday.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index ef28cc5d7bff..ee1221ba1d32 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -35,12 +35,12 @@ static int do_hres(const struct vdso_data *vd, clockid_t clk, do { seq = vdso_read_begin(vd); - cycles = __arch_get_hw_counter(vd->clock_mode) & - vd->mask; + cycles = __arch_get_hw_counter(vd->clock_mode); ns = vdso_ts->nsec; last = vd->cycle_last; if (unlikely((s64)cycles < 0)) return clock_gettime_fallback(clk, ts); + cycles &= vd->mask; if (cycles > last) ns += (cycles - last) * vd->mult; ns >>= vd->shift; -- 2.22.0