Message ID | 20231206123717.524009-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4073468vqy; Wed, 6 Dec 2023 04:37:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEymHjJWeIqzJ5DD+xBxWA2IsCHrh+ENsmIX2gQMqXYkOMDAWzHB4Qsm/kXkmrZu+MC9ppE X-Received: by 2002:a92:c5c7:0:b0:35d:8735:2aa6 with SMTP id s7-20020a92c5c7000000b0035d87352aa6mr947822ilt.54.1701866251685; Wed, 06 Dec 2023 04:37:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701866251; cv=none; d=google.com; s=arc-20160816; b=V5vYZOMHLQQOvvUYi8dzMZU0EBiEPNFnRmMsF6j/VVQbbVsPWQi6EoT9oVnOZkmUE5 13nS4QVMO7NIhwQweUPVVlqJ3FuXJf3xtqpkPGgtHVBuKwpNlQIJk1Dwt0Sq5ReSLSOm NwIIiPEKOfhIUsEXN2iqRhw3ppst59vW1KPslgkG9uL2waqz2JEyxXCBaiw+IyglRtpP muK7PUWGiyDBF3XB/t0p5QMKvtwSHD2HdhGClZx4t/8x3A9YSj1wJUATtvIdc0Czs+ZX kh1Y+nX4Cbi7eVEmj598vkS8t/CVU8A0B2mlkjYHNqiLnBjCxfOhBmsptFtIuf7AkyX0 Cnmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vUWzo2mwEay9Yo3CJVR1tizyLprTJoRzT2o1RccfPhI=; fh=zJrK3BEvIbNibf9qiAWXud+d9fWCUY4mb+heoComI5s=; b=W3VB7Yvur7Uxgbx27ancLAPTR9lfBW/Dwi2bVecgqlgu1crFNPvmtXn0V+iDL9L3fE lhOrduy5J463bdUcD+aKTvsb8YhvvxCJLTMBGfdRfy5jN8Yis+6ettVVl5Zh5oLBp0mm YL8+z+NbpLE/C1f+MhVJbP8SKbYSY0JM7d0ggyiya4r5M5zioHEIfOQ+kSJXqlAysPUz bXNjiEm3sYv1MlXRvxGOXVqEmyP5eaVRu8Z5wiHBvFzx70AJMJ1isffVQzzg3PL3TVBd 3uuKOE/9z87hHxksOuDUUWjgyJLxLdjBBiDI8t8cg5INCrwjsQ2ntR3HtZZcCGGa6OLw 40XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RcwhKY5d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id a13-20020a65604d000000b005c216b7d4easi11704131pgp.473.2023.12.06.04.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 04:37:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RcwhKY5d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1B267826E584; Wed, 6 Dec 2023 04:37:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378319AbjLFMhS (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Wed, 6 Dec 2023 07:37:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377925AbjLFMhR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 6 Dec 2023 07:37:17 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07547D1 for <linux-kernel@vger.kernel.org>; Wed, 6 Dec 2023 04:37:24 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D26C433C9; Wed, 6 Dec 2023 12:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701866243; bh=rpE8tUM2R/1vhSlb7IqgfgIczGVZAD4AZUaewUYEnhI=; h=From:To:Cc:Subject:Date:From; b=RcwhKY5dkx9Ra+6ZK+fh2xWlEwOwFl2Uw0B/m5v5ovvziWI3hRlO9ai6VnyxAbMvD czgNL9W6WnTLezAjG9C7ktlYhjZ0/Ys3rIq1JVuCXEMozsspQiGWGP+Zt7lm7UZ6HD 5stWmarfaqI1ioZHFJ/tfzfiQ6xm6Kdj8oT2wP088PshaGGDfeIp/aUSmPqUnomUTl XGIWpnhbLg4QoHCyyFEju904l8+NQHc0fnTom+IW+jXMUC++rq+YnUJ+PtuHQssq5l IlMwmyO993Kzr7qSwhLocupRq+e3c4wDXWG6yb2mMUBzrvJDIm9KoV2yw80+hqR3RS ARURZ/fpvvO5g== From: Arnd Bergmann <arnd@kernel.org> To: Bjorn Andersson <andersson@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, Andy Gross <agross@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Stephen Boyd <swboyd@chromium.org>, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] soc: qcom: stats: fix 64-bit division Date: Wed, 6 Dec 2023 13:37:06 +0100 Message-Id: <20231206123717.524009-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 06 Dec 2023 04:37:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784536106397640045 X-GMAIL-MSGID: 1784536106397640045 |
Series |
[1/2] soc: qcom: stats: fix 64-bit division
|
|
Commit Message
Arnd Bergmann
Dec. 6, 2023, 12:37 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Unguarded 64-bit division is not allowed on 32-bit kernels because this is very slow. The result of trying anyway is a link failure: arm-linux-gnueabi-ld: drivers/soc/qcom/qcom_stats.o: in function `qcom_ddr_stats_show': qcom_stats.c:(.text+0x334): undefined reference to `__aeabi_uldivmod' As this function is only used for debugging and not performance critical, rewrite it to use div_u64() instead. ARCH_TIMER_FREQ is a multiple of MSEC_PER_SEC anyway, so there is no loss in precisison. Fixes: e84e61bdb97c ("soc: qcom: stats: Add DDR sleep stats") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/soc/qcom/qcom_stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hallo Arnd, On Wed, Dec 06, 2023 at 01:37:06PM +0100, Arnd Bergmann wrote: > Unguarded 64-bit division is not allowed on 32-bit kernels because this > is very slow. The result of trying anyway is a link failure: > > arm-linux-gnueabi-ld: drivers/soc/qcom/qcom_stats.o: in function `qcom_ddr_stats_show': > qcom_stats.c:(.text+0x334): undefined reference to `__aeabi_uldivmod' > > As this function is only used for debugging and not performance critical, > rewrite it to use div_u64() instead. ARCH_TIMER_FREQ is a multiple of > MSEC_PER_SEC anyway, so there is no loss in precisison. Maybe add this information in a comment? We have #define ARCH_TIMER_FREQ 19200000 so it's a multiple of MSEC_PER_SEC (= 1000) indeed. Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Best regards Uwe
On Wed, Dec 06, 2023 at 01:37:06PM +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Unguarded 64-bit division is not allowed on 32-bit kernels because this > is very slow. The result of trying anyway is a link failure: > > arm-linux-gnueabi-ld: drivers/soc/qcom/qcom_stats.o: in function `qcom_ddr_stats_show': > qcom_stats.c:(.text+0x334): undefined reference to `__aeabi_uldivmod' > > As this function is only used for debugging and not performance critical, > rewrite it to use div_u64() instead. ARCH_TIMER_FREQ is a multiple of > MSEC_PER_SEC anyway, so there is no loss in precisison. > > Fixes: e84e61bdb97c ("soc: qcom: stats: Add DDR sleep stats") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> I had [1] lined up already, but hadn't pushed the branch out out... Like your version better, so dropping mine. [1] https://lore.kernel.org/all/20231205-qcom_stats-aeabi_uldivmod-fix-v1-1-f94ecec5e894@quicinc.com/ Thanks, Bjorn > --- > drivers/soc/qcom/qcom_stats.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c > index 4763d62a8cb0..5ec8a754b22b 100644 > --- a/drivers/soc/qcom/qcom_stats.c > +++ b/drivers/soc/qcom/qcom_stats.c > @@ -221,7 +221,7 @@ static int qcom_ddr_stats_show(struct seq_file *s, void *unused) > > for (i = 0; i < ddr.entry_count; i++) { > /* Convert the period to ms */ > - entry[i].dur = mult_frac(MSEC_PER_SEC, entry[i].dur, ARCH_TIMER_FREQ); > + entry[i].dur = div_u64(entry[i].dur, ARCH_TIMER_FREQ / MSEC_PER_SEC); > } > > for (i = 0; i < ddr.entry_count; i++) > -- > 2.39.2 >
On Wed, 06 Dec 2023 13:37:06 +0100, Arnd Bergmann wrote: > Unguarded 64-bit division is not allowed on 32-bit kernels because this > is very slow. The result of trying anyway is a link failure: > > arm-linux-gnueabi-ld: drivers/soc/qcom/qcom_stats.o: in function `qcom_ddr_stats_show': > qcom_stats.c:(.text+0x334): undefined reference to `__aeabi_uldivmod' > > As this function is only used for debugging and not performance critical, > rewrite it to use div_u64() instead. ARCH_TIMER_FREQ is a multiple of > MSEC_PER_SEC anyway, so there is no loss in precisison. > > [...] Applied, thanks! [1/2] soc: qcom: stats: fix 64-bit division commit: 73380e2573c34a45e01786750a4a2efafc2248bd Best regards,
diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c index 4763d62a8cb0..5ec8a754b22b 100644 --- a/drivers/soc/qcom/qcom_stats.c +++ b/drivers/soc/qcom/qcom_stats.c @@ -221,7 +221,7 @@ static int qcom_ddr_stats_show(struct seq_file *s, void *unused) for (i = 0; i < ddr.entry_count; i++) { /* Convert the period to ms */ - entry[i].dur = mult_frac(MSEC_PER_SEC, entry[i].dur, ARCH_TIMER_FREQ); + entry[i].dur = div_u64(entry[i].dur, ARCH_TIMER_FREQ / MSEC_PER_SEC); } for (i = 0; i < ddr.entry_count; i++)