From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com ([217.140.101.70]:47318 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbeLKNjy (ORCPT ); Tue, 11 Dec 2018 08:39:54 -0500 Subject: Re: [PATCH v2 06/28] kernel: Define gettimeofday vdso common code References: <20181129170530.37789-1-vincenzo.frascino@arm.com> <20181129170530.37789-7-vincenzo.frascino@arm.com> From: Vincenzo Frascino Message-ID: <64ff3b50-ce55-ff69-ac3a-61f221299895@arm.com> Date: Tue, 11 Dec 2018 13:39:50 +0000 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Arnd Bergmann Cc: linux-arch , Linux ARM , Catalin Marinas , Will Deacon , Russell King - ARM Linux , Ralf Baechle , Paul Burton , Daniel Lezcano , Thomas Gleixner , Mark Salyzyn , Peter Collingbourne Message-ID: <20181211133950.XIPkzRq6wd5yE6nQ1CfSgIdk8s-40wSjYyue0WvToHw@z> Hi Arnd, thank you for reviewing my patches. On 29/11/2018 20:42, Arnd Bergmann wrote: > On Thu, Nov 29, 2018 at 6:06 PM Vincenzo Frascino > wrote: > >> +/* >> + * The definitions below are required to overcome the limitations >> + * of time_t on 32 bit architectures, which overflows in 2038. >> + * The new code should use the replacements based on time64_t and >> + * timespec64. >> + * >> + * The abstraction below will be updated once the migration to >> + * time64_t is complete. >> + */ >> +#ifdef CONFIG_GENERIC_VDSO_32 >> +#define __vdso_timespec old_timespec32 >> +#define __vdso_timeval old_timeval32 >> +#else >> +#ifdef ENABLE_COMPAT_VDSO >> +#define __vdso_timespec old_timespec32 >> +#define __vdso_timeval old_timeval32 >> +#else >> +#define __vdso_timespec __kernel_timespec >> +#define __vdso_timeval __kernel_old_timeval >> +#endif /* CONFIG_COMPAT_VDSO */ >> +#endif /* CONFIG_GENERIC_VDSO_32 */ >> > > Have you considered doing this in the reverse way, by including > the common parts from multiple implementations (32 and 64 > bit), instead of compiling the same source file multiple > times with different macros set? I think that would make it > easier to understand. > The common code is never compiled as standalone. It includes arch specific code (for the fallbacks) and it is included in the arch specific vdso library (for both 32 and 64 bit where it makes sense). Hence it is built once or twice. If I understand correctly your question, seems inline with what I am doing. >> + >> +#ifdef CONFIG_HAVE_ARCH_TIMER >> +static __always_inline notrace int __do_realtime_or_tai( >> + const struct vdso_data *vd, >> + struct __vdso_timespec *ts, >> + bool is_tai) >> +{ >> + u32 seq, cs_mono_mult, cs_shift; >> + u64 ns, sec; >> + u64 cycle_last, cs_mono_mask; >> + >> + if (vd->use_syscall) >> + return -1; >> +repeat: > > Maybe instead of the #ifdef, do it like > > if (!IS_ENABLED(CONFIG_HAVE_ARCH_TIMER) || > vd->use_syscall) > return -1; > Ok, thanks. I will change this in v3. >> +static notrace int __cvdso_clock_gettime(clockid_t clock, >> + struct __vdso_timespec *ts) >> +{ >> + const struct vdso_data *vd = __arch_get_vdso_data(); >> + >> + if (!__arch_valid_arg(ts)) >> + return -EFAULT; >> + >> + switch (clock) { >> + case CLOCK_REALTIME: >> + if (do_realtime(vd, ts)) >> + goto fallback; >> + break; >> + case CLOCK_TAI: >> + if (do_tai(vd, ts)) >> + goto fallback; >> + break; >> + case CLOCK_MONOTONIC: >> + if (do_monotonic(vd, ts)) >> + goto fallback; >> + break; >> + case CLOCK_MONOTONIC_RAW: >> + if (do_monotonic_raw(vd, ts)) >> + goto fallback; >> + break; > > Please sync this up with the latest x86 version in > arch/x86/entry/vdso/vclock_gettime.c, that version has > seen a lot of improvements recently, so I'd recommend > using a copy of that file as the base, and then > modifying it as needed to make it work on the other > architectures. > Thomas commented on my patches and from v3 I am going to port the recent improvements to the vdso common code. > Arnd > -- Regards, Vincenzo