From patchwork Tue May 20 22:16:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 30501 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A1CA202FE for ; Tue, 20 May 2014 22:16:56 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf4716643obc.8 for ; Tue, 20 May 2014 15:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=LpAP04aoIxzeWilQMDMHAfKVII7taPLUEGoN6pS/DKU=; b=ILc3Ea2mjbApTbFiNvBXw2A1ElurOYhkIcW4Z84yayn5Gop7E8J2ioiUt1I0vVKYaS 4K/6AhPKfr2wkfCXdgSrH20oYBTqdToxGU7T78bhJ0agflx0zF/Y+6uDqtZVMF1GS5OZ zNip0PE8g5lrKF4RdZQRwO+fjeubA/BTRRpejvRwe/Bg4pd4WS0ID06sg3x5e9OwB51a To3u3qCc4uKBKO9MGPoW0XlNXI0W3WXbyWFfI5NTwkSYSEKsZIX375Y9FEkl+bQNXdyC ku2dCCIJ+la4ytpqaI1Taz4qK9eV02r6J5RNOFcUPE9W+SalvKkxAS9Xf28r/vnReY6I 1Hfg== X-Gm-Message-State: ALoCoQnXPUmRuxDghC/swDExwF05noxBKBh0TOX3zOvRUJCgm10PCdj1rLfo48JysklqgJiptRd8 X-Received: by 10.50.17.65 with SMTP id m1mr2977466igd.1.1400624216192; Tue, 20 May 2014 15:16:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.5 with SMTP id s5ls454065qgd.75.gmail; Tue, 20 May 2014 15:16:56 -0700 (PDT) X-Received: by 10.58.132.228 with SMTP id ox4mr3195081veb.54.1400624216095; Tue, 20 May 2014 15:16:56 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id rw10si1567213vcb.44.2014.05.20.15.16.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 May 2014 15:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so1452725veb.35 for ; Tue, 20 May 2014 15:16:56 -0700 (PDT) X-Received: by 10.58.219.166 with SMTP id pp6mr39479652vec.1.1400624215999; Tue, 20 May 2014 15:16:55 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp64494vcb; Tue, 20 May 2014 15:16:55 -0700 (PDT) X-Received: by 10.68.106.130 with SMTP id gu2mr53691310pbb.59.1400624215524; Tue, 20 May 2014 15:16:55 -0700 (PDT) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by mx.google.com with ESMTPS id ys1si26439992pac.149.2014.05.20.15.16.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 May 2014 15:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.160.44 as permitted sender) client-ip=209.85.160.44; Received: by mail-pb0-f44.google.com with SMTP id rq2so726442pbb.31 for ; Tue, 20 May 2014 15:16:55 -0700 (PDT) X-Received: by 10.66.148.197 with SMTP id tu5mr54079872pab.108.1400624214951; Tue, 20 May 2014 15:16:54 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id gz11sm4815082pbd.1.2014.05.20.15.16.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 May 2014 15:16:54 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , Tony Luck , Fenghua Yu , Thomas Gleixner , Miroslav Lichvar , linux-ia64@vger.kernel.org Subject: [PATCH] [RFC] ia64: Attempt to update of fsyscall gettime to use modern vsyscall_update Date: Tue, 20 May 2014 15:16:42 -0700 Message-Id: <1400624202-3778-1-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Ia64 hasn't yet moved away from the old vsyscall_update to the newer implementation. This is in part due to the vsyscall being implemented in asm (via the ia64 fsyscall feature), which makes me want to run away. The core logic change with the updated vsyscall method is that we preserve the base nanosecond value in shifted nanoseconds, which allows us to avoid truncating and rounding up to the next nanosecond every tick to avoid inconsistencies. Thus the logic moved from nsec = ((cycle_delta * mult)>>shift) + base_nsec; to nsec = ((cycle_delta * mult) + base_snsec) >> shift; To try to get the discussion going, I've taken a swing at migrating the update logic and have naievely tried to change the asm logic, but its quite likely wrong. NOT BUILD TESTED! Feedback and thoughts would be appreciated! Cc: Tony Luck Cc: Fenghua Yu Cc: Thomas Gleixner Cc: Miroslav Lichvar Cc: linux-ia64@vger.kernel.org Signed-off-by: John Stultz --- arch/ia64/Kconfig | 1 - arch/ia64/kernel/fsys.S | 4 ++-- arch/ia64/kernel/fsyscall_gtod_data.h | 6 ++++-- arch/ia64/kernel/time.c | 37 ++++++++++++++++++----------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 12c3afe..35562fb 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -40,7 +40,6 @@ config IA64 select ARCH_TASK_STRUCT_ALLOCATOR select ARCH_THREAD_INFO_ALLOCATOR select ARCH_CLOCKSOURCE_DATA - select GENERIC_TIME_VSYSCALL_OLD select SYSCTL_ARCH_UNALIGN_NO_WARN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index abc6dee..91ae672 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S @@ -265,9 +265,9 @@ EX(.fail_efault, probe.w.fault r31, 3) mf ;; ld4 r10 = [r20] // gtod_lock.sequence - shr.u r2 = r2,r23 // shift by factor - ;; add r8 = r8,r2 // Add xtime.nsecs + ;; + shr.u r8 = r8,r23 // shift by factor cmp4.ne p7,p0 = r28,r10 (p7) br.cond.dpnt.few .time_redo // sequence number changed, redo // End critical section. diff --git a/arch/ia64/kernel/fsyscall_gtod_data.h b/arch/ia64/kernel/fsyscall_gtod_data.h index 146b15b..ff292a9 100644 --- a/arch/ia64/kernel/fsyscall_gtod_data.h +++ b/arch/ia64/kernel/fsyscall_gtod_data.h @@ -7,8 +7,10 @@ struct fsyscall_gtod_data_t { seqcount_t seq; - struct timespec wall_time; - struct timespec monotonic_time; + u64 wall_time_sec; + u64 wall_time_snsec; + u64 monotonic_time_sec; + u64 monotonic_time_snsec; cycle_t clk_mask; u32 clk_mult; u32 clk_shift; diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 71c52bc..6b249c5 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c @@ -440,30 +440,31 @@ void update_vsyscall_tz(void) { } -void update_vsyscall_old(struct timespec *wall, struct timespec *wtm, - struct clocksource *c, u32 mult) +void update_vsyscall(struct timekeeper *tk) { write_seqcount_begin(&fsyscall_gtod_data.seq); - - /* copy fsyscall clock data */ - fsyscall_gtod_data.clk_mask = c->mask; - fsyscall_gtod_data.clk_mult = mult; - fsyscall_gtod_data.clk_shift = c->shift; - fsyscall_gtod_data.clk_fsys_mmio = c->archdata.fsys_mmio; - fsyscall_gtod_data.clk_cycle_last = c->cycle_last; + /* copy fsyscall clock data */ + fsyscall_gtod_data.clk_mask = tk->clock->mask; + fsyscall_gtod_data.clk_mult = tk->mult; + fsyscall_gtod_data.clk_shift = tk->clock->shift; + fsyscall_gtod_data.clk_fsys_mmio = tk->clock->archdata.fsys_mmio; + fsyscall_gtod_data.clk_cycle_last = tk->cycle_last; /* copy kernel time structures */ - fsyscall_gtod_data.wall_time.tv_sec = wall->tv_sec; - fsyscall_gtod_data.wall_time.tv_nsec = wall->tv_nsec; - fsyscall_gtod_data.monotonic_time.tv_sec = wtm->tv_sec - + wall->tv_sec; - fsyscall_gtod_data.monotonic_time.tv_nsec = wtm->tv_nsec - + wall->tv_nsec; + fsyscall_gtod_data.wall_time_sec = tk->xtime_sec; + fsyscall_gtod_data.wall_time_snsec = tk->xtime_nsec; + fsyscall_gtod_data.monotonic_time_sec = tk->wall_to_monotonic->tv_sec + + tk->xtime_sec; + fsyscall_gtod_data.monotonic_time_snsec = + tk->wall_to_monotonic->tv_nsec << tk->clock->shift, + + tk->xtime_nsec; /* normalize */ - while (fsyscall_gtod_data.monotonic_time.tv_nsec >= NSEC_PER_SEC) { - fsyscall_gtod_data.monotonic_time.tv_nsec -= NSEC_PER_SEC; - fsyscall_gtod_data.monotonic_time.tv_sec++; + while (fsyscall_gtod_data.monotonic_time_snsec >= + NSEC_PER_SEC << tk->clock->shift) { + fsyscall_gtod_data.monotonic_time_snsec -= + NSEC_PER_SEC << c->shift; + fsyscall_gtod_data.monotonic_time_sec++; } write_seqcount_end(&fsyscall_gtod_data.seq);