Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp833463ybi; Fri, 14 Jun 2019 04:12:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAz8LMfc97LXeH6H9YSin52Jtqnkm/LFOrLf4f2TiJ/iEz+2DaIszAF4zsri9QGQ3RkaOz X-Received: by 2002:a17:902:44a4:: with SMTP id l33mr13090785pld.174.1560510776419; Fri, 14 Jun 2019 04:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560510776; cv=none; d=google.com; s=arc-20160816; b=iwbYytiZmXyrhKx0qAlNriDtRSqeFgIEIeBgJw8DC+7Wsa1lUx2rxaGaM5mydLKgOv diLR8q6EjGr44hAmo+1IyMx+i7uPshNZOeRLKvfxPY0eE4HPvTaXaRSHmaof0iyphUpr yHXWHsHzcj+IDFUXr6nS5gVynuRA2QWxZptWZFOGEGJNFwIdH55pvsJvbAeSQxckBFlL JtbwkUZsJSKWXhUSyTJDwvKCjEi9ax7u8eaqNQRJvTF7wbJVrewhRdTpOOEzejfLeMvi zcLaBkRJBYZPyX5VfnIwPB3HXyQwtCehQNX+Q+dodVwZjoX2ynvKGAuJjvKHIFJeYMtK UJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=+6/OKKQYYvD1XZbhb3KLDVSslX5aiQTh8jW7hFEOLAg=; b=HQjuOS6Fvy3vhEjbfLMh3CSU1MCsC+RX6QLv7+hPDgtEP+uYo6rptgU9Y++RlSUORe u9HaOtxWKP5sy66GyPubKFOvfXCvODoIFXRjfAV+O2Pp3aY8gDOhIQNMtWBTNLhW65ox qenBhybXKgtFCqqxAcQKFzr+zs3+teVTT3QB1lq+4ZK0ArvxF+ik0NO2VKOsxnDqPOa3 Ez+xe/MRUIKGbmjySwZ1xjmIasS4G5JtYQOvtG5aQF9hVQR2wYk32vaUkgjaIA2njXMd TdYrO3h9TXi5IdlTjcdR1BDIEsNjZwlK3EaAgtpTuGfvCsqkRljmJ2Ks3xn8NtdRfVPD oReQ== 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 b24si1946060pls.184.2019.06.14.04.12.39; Fri, 14 Jun 2019 04:12:56 -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 S1727471AbfFNLLI (ORCPT + 99 others); Fri, 14 Jun 2019 07:11:08 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:37511 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbfFNLLH (ORCPT ); Fri, 14 Jun 2019 07:11:07 -0400 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hbk6l-0000IX-6H; Fri, 14 Jun 2019 13:10:59 +0200 Date: Fri, 14 Jun 2019 13:10:58 +0200 (CEST) From: Thomas Gleixner To: Vincenzo Frascino cc: 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, Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Mark Salyzyn , Peter Collingbourne , Shuah Khan , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Huw Davies Subject: Re: [PATCH v6 03/19] kernel: Unify update_vsyscall implementation In-Reply-To: <20190530141531.43462-4-vincenzo.frascino@arm.com> Message-ID: References: <20190530141531.43462-1-vincenzo.frascino@arm.com> <20190530141531.43462-4-vincenzo.frascino@arm.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 May 2019, Vincenzo Frascino wrote: > + > + if (__arch_use_vsyscall(vdata)) { > + vdata[CS_HRES_COARSE].cycle_last = > + tk->tkr_mono.cycle_last; > + vdata[CS_HRES_COARSE].mask = > + tk->tkr_mono.mask; > + vdata[CS_HRES_COARSE].mult = > + tk->tkr_mono.mult; These line breaks make it really hard to read. Can you fold in the patch below please? Thanks, tglx 8<----------- --- a/kernel/vdso/vsyscall.c +++ b/kernel/vdso/vsyscall.c @@ -11,6 +11,66 @@ #include #include +static inline void udpate_vdata(struct vdso_data *vdata, struct timekeeper *tk) +{ + struct vdso_timestamp *vdso_ts; + u64 nsec; + + vdata[CS_HRES_COARSE].cycle_last = tk->tkr_mono.cycle_last; + vdata[CS_HRES_COARSE].mask = tk->tkr_mono.mask; + vdata[CS_HRES_COARSE].mult = tk->tkr_mono.mult; + vdata[CS_HRES_COARSE].shift = tk->tkr_mono.shift; + vdata[CS_RAW].cycle_last = tk->tkr_raw.cycle_last; + vdata[CS_RAW].mask = tk->tkr_raw.mask; + vdata[CS_RAW].mult = tk->tkr_raw.mult; + vdata[CS_RAW].shift = tk->tkr_raw.shift; + + /* CLOCK_REALTIME */ + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME]; + vdso_ts->sec = tk->xtime_sec; + vdso_ts->nsec = tk->tkr_mono.xtime_nsec; + + /* CLOCK_MONOTONIC */ + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC]; + vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; + + nsec = tk->tkr_mono.xtime_nsec; + nsec += ((u64)tk->wall_to_monotonic.tv_nsec << tk->tkr_mono.shift); + while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { + nsec -= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); + vdso_ts->sec++; + } + vdso_ts->nsec = nsec; + + /* CLOCK_MONOTONIC_RAW */ + vdso_ts = &vdata[CS_RAW].basetime[CLOCK_MONOTONIC_RAW]; + vdso_ts->sec = tk->raw_sec; + vdso_ts->nsec = tk->tkr_raw.xtime_nsec; + + /* CLOCK_BOOTTIME */ + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME]; + vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; + nsec = tk->tkr_mono.xtime_nsec; + nsec += ((u64)(tk->wall_to_monotonic.tv_nsec + + ktime_to_ns(tk->offs_boot)) << tk->tkr_mono.shift); + while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { + nsec -= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); + vdso_ts->sec++; + } + vdso_ts->nsec = nsec; + + /* CLOCK_TAI */ + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_TAI]; + vdso_ts->sec = tk->xtime_sec + (s64)tk->tai_offset; + vdso_ts->nsec = tk->tkr_mono.xtime_nsec; + + /* + * Read without the seqlock held by clock_getres(). + * Note: No need to have a second copy. + */ + WRITE_ONCE(vdata[CS_HRES_COARSE].hrtimer_res, hrtimer_resolution); +} + void update_vsyscall(struct timekeeper *tk) { struct vdso_data *vdata = __arch_get_k_vdso_data(); @@ -32,92 +92,23 @@ void update_vsyscall(struct timekeeper * vdata[CS_RAW].clock_mode = __arch_get_clock_mode(tk); /* CLOCK_REALTIME_COARSE */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE]; - vdso_ts->sec = tk->xtime_sec; - vdso_ts->nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE]; + vdso_ts->sec = tk->xtime_sec; + vdso_ts->nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; + /* CLOCK_MONOTONIC_COARSE */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC_COARSE]; - vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; - nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; - nsec = nsec + tk->wall_to_monotonic.tv_nsec; + vdso_ts = &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC_COARSE]; + vdso_ts->sec = tk->xtime_sec + tk->wall_to_monotonic.tv_sec; + nsec = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; + nsec = nsec + tk->wall_to_monotonic.tv_nsec; while (nsec >= NSEC_PER_SEC) { nsec = nsec - NSEC_PER_SEC; vdso_ts->sec++; } - vdso_ts->nsec = nsec; + vdso_ts->nsec = nsec; - if (__arch_use_vsyscall(vdata)) { - vdata[CS_HRES_COARSE].cycle_last = - tk->tkr_mono.cycle_last; - vdata[CS_HRES_COARSE].mask = - tk->tkr_mono.mask; - vdata[CS_HRES_COARSE].mult = - tk->tkr_mono.mult; - vdata[CS_HRES_COARSE].shift = - tk->tkr_mono.shift; - vdata[CS_RAW].cycle_last = - tk->tkr_raw.cycle_last; - vdata[CS_RAW].mask = - tk->tkr_raw.mask; - vdata[CS_RAW].mult = - tk->tkr_raw.mult; - vdata[CS_RAW].shift = - tk->tkr_raw.shift; - /* CLOCK_REALTIME */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_REALTIME]; - vdso_ts->sec = tk->xtime_sec; - vdso_ts->nsec = tk->tkr_mono.xtime_nsec; - /* CLOCK_MONOTONIC */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_MONOTONIC]; - vdso_ts->sec = tk->xtime_sec + - tk->wall_to_monotonic.tv_sec; - nsec = tk->tkr_mono.xtime_nsec; - nsec = nsec + - ((u64)tk->wall_to_monotonic.tv_nsec << - tk->tkr_mono.shift); - while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { - nsec = nsec - - (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); - vdso_ts->sec++; - } - vdso_ts->nsec = nsec; - /* CLOCK_MONOTONIC_RAW */ - vdso_ts = - &vdata[CS_RAW].basetime[CLOCK_MONOTONIC_RAW]; - vdso_ts->sec = tk->raw_sec; - vdso_ts->nsec = tk->tkr_raw.xtime_nsec; - /* CLOCK_BOOTTIME */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_BOOTTIME]; - vdso_ts->sec = tk->xtime_sec + - tk->wall_to_monotonic.tv_sec; - nsec = tk->tkr_mono.xtime_nsec; - nsec = nsec + - ((u64)(tk->wall_to_monotonic.tv_nsec + - ktime_to_ns(tk->offs_boot)) << - tk->tkr_mono.shift); - while (nsec >= (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift)) { - nsec = nsec - - (((u64)NSEC_PER_SEC) << tk->tkr_mono.shift); - vdso_ts->sec++; - } - vdso_ts->nsec = nsec; - /* CLOCK_TAI */ - vdso_ts = - &vdata[CS_HRES_COARSE].basetime[CLOCK_TAI]; - vdso_ts->sec = tk->xtime_sec + (s64)tk->tai_offset; - vdso_ts->nsec = tk->tkr_mono.xtime_nsec; - - /* - * Read without the seqlock held by clock_getres(). - * Note: No need to have a second copy. - */ - WRITE_ONCE(vdata[CS_HRES_COARSE].hrtimer_res, hrtimer_resolution); - } + if (__arch_use_vsyscall(vdata)) + update_vdata(vdata, tk); __arch_update_vsyscall(vdata, tk);