From patchwork Wed Jul 17 06:19:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 2828465 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 064E89F9CA for ; Wed, 17 Jul 2013 06:21:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20E7720114 for ; Wed, 17 Jul 2013 06:21:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68E482010C for ; Wed, 17 Jul 2013 06:20:59 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzL5y-0005ML-32; Wed, 17 Jul 2013 06:20:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzL5q-0000mY-Pa; Wed, 17 Jul 2013 06:20:06 +0000 Received: from guitar.tcltek.co.il ([192.115.133.116] helo=sivan.tkos.co.il) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzL5m-0000lM-8M for linux-arm-kernel@lists.infradead.org; Wed, 17 Jul 2013 06:20:04 +0000 Received: from tarshish (unknown [10.0.8.6]) by sivan.tkos.co.il (Postfix) with ESMTPA id 1EAD4B4F7B; Wed, 17 Jul 2013 09:19:27 +0300 (IDT) Date: Wed, 17 Jul 2013 09:19:25 +0300 From: Baruch Siach To: Max Filippov Subject: Re: sched_clock always 0 and no process time accounting with 3.11-rc1 Message-ID: <20130717061925.GC6950@tarshish> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130717_022002_490747_A1A8F19B X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) Cc: Chris Zankel , linux-arm-kernel@lists.infradead.org, linux-xtensa@linux-xtensa.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Max, On Mon, Jul 15, 2013 at 06:18:33PM +0400, Max Filippov wrote: > with 3.11-rc1 printk timestamps are always zero (which means that > sched_clock is always 0) and process time accounting always shows > 0 for system/user time. I see it regardless of HZ_PERIODIC/NO_HZ_IDLE > and HIGH_RES_TIMERS settings. Am I missing any necessary config > options? Can you see the same issue? The following patch fixes the issue for me: Apparently the expression '(1 << 32)' evaluates to 1 on xtensa cross gcc, and x86_84 native gcc. According to my limited understanding, the C compiler is allowed to do so. This caused sched_clock_32() to return constant 0. I wonder how it didn't bite the ARM people who are using this code from quite some time (added LAKL to CC). If this patch proves correct I'll send a formal patch to the timekeeping maintainers. baruch diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index a326f27..0b479a6 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c @@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate) BUG_ON(bits > 32); WARN_ON(!irqs_disabled()); read_sched_clock = read; - sched_clock_mask = (1 << bits) - 1; + sched_clock_mask = (1ULL << bits) - 1; cd.rate = rate; /* calculate the mult/shift to convert counter ticks to ns. */