From patchwork Thu Aug 14 18:31: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: 35412 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9586B203C5 for ; Thu, 14 Aug 2014 18:32:01 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id v10sf10228155pde.2 for ; Thu, 14 Aug 2014 11:32:00 -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=/aE5cpmKO+rmqaxMK9/359q63wXrP4XPULFnB1MW9NM=; b=EwfF80V3rjuuzzk7NHJ4jwcJqpSLCHR3xYiI34I5g3S7HrzbZoveybaCPwaY9/ED5V AP3P8zs11tJjJnDvlcYSUlbn/nQWo8GyQKUVEqS4baVOLjdUDYuZdpKF6G8uVkG5PGr+ Z6kY5M6ahM5RrcTTTl6Lixs3AgFlTmiYdDoGIGeQx4weh9aobswCPTd5PDkrgZ/A9Uh/ 5cpgXDrYrUE2iRPjdGrqaAtIPwsgn3yiRlynU5mDKndGKR+v7cHbCSyitrtNalE1SlqZ XNuVsV2+6frK9YCtf2MMnMUP0gVb9De2+hqy8ztFZeIIR5cD/4KShaykkno1oOWeUViK SM4w== X-Gm-Message-State: ALoCoQnCHhddUdbYB+M1pEk8KyzlcxSik5xr0vPjTAIpUYsInN4fWMjih8LIONZUKFgxKgdDM3gu X-Received: by 10.70.34.195 with SMTP id b3mr6639353pdj.7.1408041120915; Thu, 14 Aug 2014 11:32:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.48 with SMTP id m45ls1108030qgd.18.gmail; Thu, 14 Aug 2014 11:32:00 -0700 (PDT) X-Received: by 10.140.19.201 with SMTP id 67mr18914663qgh.28.1408041120642; Thu, 14 Aug 2014 11:32:00 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id f94si8434666qgd.22.2014.08.14.11.32.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Aug 2014 11:32:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so1862394vcb.40 for ; Thu, 14 Aug 2014 11:32:00 -0700 (PDT) X-Received: by 10.52.73.202 with SMTP id n10mr2401775vdv.86.1408041120383; Thu, 14 Aug 2014 11:32:00 -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.221.37.5 with SMTP id tc5csp55770vcb; Thu, 14 Aug 2014 11:31:59 -0700 (PDT) X-Received: by 10.66.237.206 with SMTP id ve14mr5981244pac.40.1408041119436; Thu, 14 Aug 2014 11:31:59 -0700 (PDT) Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by mx.google.com with ESMTPS id ko1si5018998pdb.20.2014.08.14.11.31.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 14 Aug 2014 11:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.49 as permitted sender) client-ip=209.85.220.49; Received: by mail-pa0-f49.google.com with SMTP id hz1so2064022pad.8 for ; Thu, 14 Aug 2014 11:31:59 -0700 (PDT) X-Received: by 10.66.90.162 with SMTP id bx2mr5997386pab.51.1408041118983; Thu, 14 Aug 2014 11:31:58 -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 ou2sm3874076pdb.17.2014.08.14.11.31.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Aug 2014 11:31:56 -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: Thu, 14 Aug 2014 11:31:42 -0700 Message-Id: <1408041102-15524-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.220.181 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: , Sent this out awhile back, and only heard crickets. Figured it was time to update and resend it. 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! (Well, actually I did get it to build, but I'm no more confident that the code is right here). 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 | 2 +- arch/ia64/kernel/asm-offsets.c | 12 ++++++++---- arch/ia64/kernel/fsys.S | 8 ++++---- arch/ia64/kernel/fsyscall_gtod_data.h | 6 ++++-- arch/ia64/kernel/time.c | 37 ++++++++++++++++++----------------- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 64aefb7..d60ebfb 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -43,7 +43,7 @@ config IA64 select ARCH_TASK_STRUCT_ALLOCATOR select ARCH_THREAD_INFO_ALLOCATOR select ARCH_CLOCKSOURCE_DATA - select GENERIC_TIME_VSYSCALL_OLD + select GENERIC_TIME_VSYSCALL select SYSCTL_ARCH_UNALIGN_NO_WARN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA diff --git a/arch/ia64/kernel/asm-offsets.c b/arch/ia64/kernel/asm-offsets.c index 60ef83e..a02bc6d 100644 --- a/arch/ia64/kernel/asm-offsets.c +++ b/arch/ia64/kernel/asm-offsets.c @@ -268,10 +268,14 @@ void foo(void) /* used by fsys_gettimeofday in arch/ia64/kernel/fsys.S */ DEFINE(IA64_GTOD_SEQ_OFFSET, offsetof (struct fsyscall_gtod_data_t, seq)); - DEFINE(IA64_GTOD_WALL_TIME_OFFSET, - offsetof (struct fsyscall_gtod_data_t, wall_time)); - DEFINE(IA64_GTOD_MONO_TIME_OFFSET, - offsetof (struct fsyscall_gtod_data_t, monotonic_time)); + DEFINE(IA64_GTOD_WALL_TIME_SEC_OFFSET, + offsetof (struct fsyscall_gtod_data_t, wall_time_sec)); + DEFINE(IA64_GTOD_WALL_TIME_SNSEC_OFFSET, + offsetof (struct fsyscall_gtod_data_t, wall_time_snsec)); + DEFINE(IA64_GTOD_MONO_TIME_SEC_OFFSET, + offsetof (struct fsyscall_gtod_data_t, monotonic_time_sec)); + DEFINE(IA64_GTOD_MONO_TIME_SNSEC_OFFSET, + offsetof (struct fsyscall_gtod_data_t, monotonic_time_snsec)); DEFINE(IA64_CLKSRC_MASK_OFFSET, offsetof (struct fsyscall_gtod_data_t, clk_mask)); DEFINE(IA64_CLKSRC_MULT_OFFSET, diff --git a/arch/ia64/kernel/fsys.S b/arch/ia64/kernel/fsys.S index abc6dee..acda4c5 100644 --- a/arch/ia64/kernel/fsys.S +++ b/arch/ia64/kernel/fsys.S @@ -197,13 +197,13 @@ ENTRY(fsys_gettimeofday) ;; ld4 r2 = [r2] // process work pending flags movl r29 = itc_jitter_data // itc_jitter - add r22 = IA64_GTOD_WALL_TIME_OFFSET,r20 // wall_time + add r22 = IA64_GTOD_WALL_TIME_SEC_OFFSET,r20 // wall_time add r21 = IA64_CLKSRC_MMIO_OFFSET,r20 mov pr = r30,0xc000 // Set predicates according to function ;; and r2 = TIF_ALLWORK_MASK,r2 add r19 = IA64_ITC_LASTCYCLE_OFFSET,r29 -(p15) add r22 = IA64_GTOD_MONO_TIME_OFFSET,r20 // monotonic_time +(p15) add r22 = IA64_GTOD_MONO_TIME_SEC_OFFSET,r20 // monotonic_time ;; add r26 = IA64_CLKSRC_CYCLE_LAST_OFFSET,r20 // clksrc_cycle_last cmp.ne p6, p0 = 0, r2 // Fallback if work is scheduled @@ -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 9a0104a..59c3f4a 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c @@ -425,30 +425,31 @@ void update_vsyscall_tz(void) { } -void update_vsyscall_old(struct timespec *wall, struct timespec *wtm, - struct clocksource *c, u32 mult, cycle_t cycle_last) +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 = cycle_last; + /* copy fsyscall clock data */ + fsyscall_gtod_data.clk_mask = tk->tkr.clock->mask; + fsyscall_gtod_data.clk_mult = tk->tkr.mult; + fsyscall_gtod_data.clk_shift = tk->tkr.clock->shift; + fsyscall_gtod_data.clk_fsys_mmio = tk->tkr.clock->archdata.fsys_mmio; + fsyscall_gtod_data.clk_cycle_last = tk->tkr.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->tkr.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->tkr.shift) + + tk->tkr.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->tkr.shift) { + fsyscall_gtod_data.monotonic_time_snsec -= + NSEC_PER_SEC << tk->tkr.shift; + fsyscall_gtod_data.monotonic_time_sec++; } write_seqcount_end(&fsyscall_gtod_data.seq);