From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754746Ab1JaNHE (ORCPT ); Mon, 31 Oct 2011 09:07:04 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:34097 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751776Ab1JaNHB (ORCPT ); Mon, 31 Oct 2011 09:07:01 -0400 Message-ID: <1320066197.2266.11.camel@js-netbook> Subject: Re: [MIPS]clocks_calc_mult_shift() may gen a too big mult value From: John Stultz To: Chen Jie Cc: Yong Zhang , linux-mips@linux-mips.org, LKML , tglx@linutronix.de, yanhua , =?UTF-8?Q?=E9=A1=B9=E5=AE=87?= , zhangfx , =?UTF-8?Q?=E5=AD=99=E6=B5=B7=E5=8B=87?= Date: Mon, 31 Oct 2011 09:03:17 -0400 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.0- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 x-cbid: 11103113-1780-0000-0000-00000095EDE7 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2011-10-31 at 18:48 +0800, Chen Jie wrote: > Hi, > > 2011/10/31 Yong Zhang : > > On Mon, Oct 31, 2011 at 5:00 PM, Chen Jie wrote: > >> Hi all, > >> > >> On MIPS, with maxsec=4, clocks_calc_mult_shift() may generate a very > >> big mult, which may easily cause timekeeper.mult overflow within > >> timekeeping jobs. > > > > Hmmm, why not use clocksource_register_hz()/clocksource_register_khz() > > instead? it's more convenient. > > Thanks for the suggestion. And sorry for I didn't notice the upstream > code has already hooked to clocksource_register_hz() in csrc-r4k.c > (We're using r4000 clock source) > > I'm afraid this still doesn't fix my case. Through > clocksource_register_hz()->__clocksource_register_scale()->__clocksource_updatefreq_scale, > I got a calculated maxsec = (0xffffffff - (0xffffffff>>5))/250000500 = > 16 # assume mips_hpt_frequency=250000500 > > With this maxsec, I got a mult of 0xffffde72, still too big. Hrmm. Yong Zang is right to suggest clocksource_register_hz(), as the intention of that code is to try to avoid these sorts of issues. What is the corresponding shift value you're getting for the value above? Could you annotate clocks_calc_mult_shift() a little bit to see where things might be going wrong? thanks -john