Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6477090ybl; Mon, 23 Dec 2019 06:32:50 -0800 (PST) X-Google-Smtp-Source: APXvYqyRctWwmY2oWijOn/BMHAKLMOPRHlnc2LqqtMyDnWsKm2FL6ZDKhIkDQqgprUA/V2plvOsi X-Received: by 2002:a9d:75da:: with SMTP id c26mr32920958otl.40.1577111570339; Mon, 23 Dec 2019 06:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577111570; cv=none; d=google.com; s=arc-20160816; b=dff0nx2v62PAd1yjsIuM1IuAe9q5gjDz1bP11X79MYa13NjViQSvlpOrLlB3ZE8gvn IbTq54Q8lGdgseEs8ZmAyYHbw4krElZTZQuEzAyPFaradIR3JOPhzPmFbNvBkoB8ntFr NwZpBYgkfhLJE+mxXrzrHLAOBABUzUICaKm/RWtd0kWr1s0HInBX0B2Vf8yaegmCL+qw VxCj/bcw4ZGlC/HUywaWbODGL+heBkuYzD1ctbSZYrSo0rFbbRYagMjrorAgYpo+D0HD 0IGTGO4mVaw4LjzJiHxL0r9LM6VBSyX35JDzjQ/B4rCoUCxFglv7LJZTLHLo2smXt0pJ DaMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=N2ZgUlBGtsvYJmL4aNIvn4kelyr3xUIlcSwbXOh8dAY=; b=Repa7noPE5BJqBl+tRP0yzCEyc2B6LG/Co+el+5CuGMAPcQHsPJ6sqLy+0e8D/mm8I KufIQy1T8F2Qjy3B+wj4E5UlUCB32iMraReDG2fAK7p19cM6aaICenVbUggnmvxD/35c E29jkLbfsI8I9UCQtda0B+kj4KqJqZrM7gY3+bSsQ2t1/khmrHyEkMRvPojf9EWWXw+A LCL7AtuOkVW+6moHJOuojXyAaguicsAGuUlNgKpzcQ23Zwc4CBZ67em/gykj55pyQsFn rbuIixfxIIG9//6i9ImR5KAcKId/X3wBUYibRALw2Zftkv2WhkhwvsRcmIlAly9kL25P 1gUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=HzWceXyE; 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 w2si9882603otq.31.2019.12.23.06.32.38; Mon, 23 Dec 2019 06:32:50 -0800 (PST) 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=@c-s.fr header.s=mail header.b=HzWceXyE; 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 S1727368AbfLWObh (ORCPT + 99 others); Mon, 23 Dec 2019 09:31:37 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:18097 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbfLWObK (ORCPT ); Mon, 23 Dec 2019 09:31:10 -0500 Received: from localhost (mailhub1-ext [192.168.12.233]) by localhost (Postfix) with ESMTP id 47hMGb4QXVz9txjy; Mon, 23 Dec 2019 15:31:03 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=HzWceXyE; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id bkTv1TgFVniR; Mon, 23 Dec 2019 15:31:03 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 47hMGb3Gynz9txjx; Mon, 23 Dec 2019 15:31:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1577111463; bh=N2ZgUlBGtsvYJmL4aNIvn4kelyr3xUIlcSwbXOh8dAY=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=HzWceXyEVD1Emm0wwEOE1bCdfm4qtJn+RLfuJ+8Hl/RwcdV35a4DNiyknWPUyNLZq wVAMMpO7O4TDPh8O30kOtwmkeCpiX9AOkoMz5d8KvvzSAP/UyJu/lPQ2RvdFwZHmwj 97Amm7bJkkQbo4p6/X7Ca0N8qAiBNpv9MLgC0LWY= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 8E2F98B7AB; Mon, 23 Dec 2019 15:31:08 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id LhG5tUkjJ7iO; Mon, 23 Dec 2019 15:31:08 +0100 (CET) Received: from po16098vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 67BCF8B7A1; Mon, 23 Dec 2019 15:31:08 +0100 (CET) Received: by po16098vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 71E13637D4; Mon, 23 Dec 2019 14:31:08 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , arnd@arndb.de, tglx@linutronix.de, vincenzo.frascino@arm.com, luto@kernel.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, x86@kernel.org Date: Mon, 23 Dec 2019 14:31:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org READ_ONCE() forces the read of the 64 bit value of vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough only the lower part is needed. This results in a suboptimal code: 00000af4 <__c_kernel_time>: af4: 2c 03 00 00 cmpwi r3,0 af8: 81 44 00 20 lwz r10,32(r4) afc: 81 64 00 24 lwz r11,36(r4) b00: 41 82 00 08 beq b08 <__c_kernel_time+0x14> b04: 91 63 00 00 stw r11,0(r3) b08: 7d 63 5b 78 mr r3,r11 b0c: 4e 80 00 20 blr By removing the READ_ONCE(), only the lower part is read from memory, and the code is cleaner: 00000af4 <__c_kernel_time>: af4: 7c 69 1b 79 mr. r9,r3 af8: 80 64 00 24 lwz r3,36(r4) afc: 4d 82 00 20 beqlr b00: 90 69 00 00 stw r3,0(r9) b04: 4e 80 00 20 blr Signed-off-by: Christophe Leroy --- lib/vdso/gettimeofday.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 17b4cff6e5f0..5a17a9d2e6cd 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -144,7 +144,7 @@ __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tv static __maybe_unused __kernel_old_time_t __cvdso_time(const struct vdso_data *vd, __kernel_old_time_t *time) { - __kernel_old_time_t t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec); + __kernel_old_time_t t = vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec; if (time) *time = t; -- 2.13.3