Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3645295imm; Wed, 5 Sep 2018 03:44:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaN5YoHfExYzS11zT9hGgYwU++w47LsB6N4nF8nVKKPS0JAZ47SVwgKYCbfA4fo+FJTWZ9a X-Received: by 2002:a62:6d02:: with SMTP id i2-v6mr40275521pfc.218.1536144284784; Wed, 05 Sep 2018 03:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536144284; cv=none; d=google.com; s=arc-20160816; b=PV54SMfXPBkaYTHFAM5B5glkwMP0fKeBg99R98GMcSLGJ8DI75hUBG3B4+sRmDRlLa aTo3osdmqgke+BEeiPm15uaRlCCaCw4mhE5nLiWk1YiVO9u92gN9ghO5iI11iusbZYsG ryiFp19zHCLyo2/CvUAVu6DNXLFfqP+cKLTzOk0Vospx+6PilvPHghUh/nHtSAqhypAw TYDtd8NH/lBLJWOYtXw3/ufIXVeTX7nlk73eZFgQ8ff8JDAJgLLQ2PVoITkGEw6mZet4 bCLif91QwtCIWf82swE4daPAyGpRW5njBn+5kWe9Gu+vc6Cid0scPEBoxozLgYt3TTay m4Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=jtC2NjxMNjANDl8nrprf1ELQKogXDsC3Oafi19hIMFw=; b=LkHgMpYlYaVEQy9jUD5d+UqhN4PAuckCKYEyNTJQ7fnKqsmO3hoIWesDgqrJhaKXR5 HtkbgOcq/YbiC4bQbM/ljejJpn07E489hk+pYyMmxjcrXDGcOpEh7sepFy5FPyXvUWox jmL3ZxpQ5gyGQKVQS92dsssB+9SyZmWYaTo2LoZu+8BQe/1CouzvdiE9PW2y4L0J+qQe xQrwfrBkm5t+otJXrgMfTgV6JZtzh4EYFt9LPhMGyigClkldkEutPte55UaatZsx7RdP 1R+ae1Zx7ByCIVs3z8qA8GxsA7ldr1dhnWvorYEhrjkzfYyS2747jfpP4AGDoeE6kCXB uhFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si1769897pln.142.2018.09.05.03.44.29; Wed, 05 Sep 2018 03:44:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727706AbeIEPMW (ORCPT + 99 others); Wed, 5 Sep 2018 11:12:22 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:59184 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727234AbeIEPMW (ORCPT ); Wed, 5 Sep 2018 11:12:22 -0400 Received: from p4fea45ac.dip0.t-ipconnect.de ([79.234.69.172] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fxVGg-0000rr-G8; Wed, 05 Sep 2018 12:42:38 +0200 Date: Wed, 5 Sep 2018 12:42:38 +0200 (CEST) From: Thomas Gleixner To: "Chuan Hua, Lei" cc: Pavel Tatashin , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v15 19/26] x86/tsc: calibrate tsc only once In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 5 Sep 2018, Chuan Hua, Lei wrote: > > static unsigned long __init get_loops_per_jiffy(void) > > { > > unsigned long lpj = tsc_khz * KHZ; > > > > do_div(lpj, HZ); > > return lpj; > > } > Just tried this with 4.19-rc2 on x86(32bit). lpj return as zero which is not > expected > After disassembling the code, > 0xc1239a9e <+199>: imul $0x3e8,0xc12296e4,%edx > 0xc1239aa8 <+209>: xor %ecx,%ecx > 0xc1239aaa <+211>: test %edx,%edx > 0xc1239aac <+213>: mov %eax,%ebx > 0xc1239aae <+215>: je 0xc1239abd > 0xc1239ab0 <+217>: mov $0x64,%ecx > 0xc1239ab5 <+222>: mov %edx,%eax > 0xc1239ab7 <+224>: xor %edx,%edx > 0xc1239ab9 <+226>: div %ecx > 0xc1239abb <+228>: mov %eax,%ecx > 0xc1239abd <+230>: mov %ebx,%eax > 0xc1239abf <+232>: mov $0x64,%ebx > 0xc1239ac4 <+237>: div %ebx > 0xc1239ac6 <+239>: mov %ecx,%edx > imul will load the result into %edx, %edx supposed to be high 32 bit which is > not zero, > It should be zero in this case. both lpj and tsc_khz should be u64 to work > properly. Good catch! Care to send a patch? Thanks, tglx