Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1657671lql; Wed, 13 Mar 2024 04:53:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWb60NzVaNrIREG68KD6nycjR5CZUeSIFctbU2zUUBGugDFTN3b+67IMIglQW/8Et7IRCOZxHHpkUBSYTCHpK617XDR68Hv9R/tnNVXow== X-Google-Smtp-Source: AGHT+IEeLuvC3i3p3K895FUy3Q5Hsz6pWkM0+/sqOLnYR8ZaDojOAssGq6DNndzN/oyyCloArFKT X-Received: by 2002:a05:6e02:1c89:b0:365:1459:e1ed with SMTP id w9-20020a056e021c8900b003651459e1edmr3109260ill.4.1710330824459; Wed, 13 Mar 2024 04:53:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710330823; cv=pass; d=google.com; s=arc-20160816; b=CMH+6PjR94rPJlbWhlH63g4pWIuvvT2fb/WQX2PiQo3PMGS7Ch3yyCOOaAJkvHjjKM OQkoOxhg9lFkcrUTq19+RzLkmzoeSeGoq3fQf0+X6iwBgCIQFCrd3mhaSs/pf2+vvcWB Dbw7gEkO2g3O8hsq9Rf3+MwYNTTwGC5UgIlqGFWdHMsY7iizV2IsrWLj/hNMlVaRDy2n aSjLr1qcKmh/iQZB99B9wwT3RZI4tABtaYSU+jr3DVizcxDZZDL3stIXqHUEryqOPVxW mu1dzwv8nBEgbQjTE0Jeq11GgyAbIhbGXAZ/v63SCJ5iLsq5CqjCIdTrbx5VtlQHx3Pk wtnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:subject:cc:to:from:date:references :in-reply-to:message-id:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:user-agent:feedback-id:dkim-signature :dkim-signature; bh=gn0b2WKvEfTg/FZ9LXq190CVS7p5sTA5MQLvPVDkM3s=; fh=80HcwgO7wG8Saxc9A3/YXLP+GwvAvxVtlqYXUTdwEj8=; b=bU72NpQkYB+6TthC8qmtZ4uPDTQ+0ixgq162wOoBawZzhcSIfMoAYh1EiHP69k5Whg myPa5cRLKRqbLAE1GBguadriFtn0VaWwWGaONX5tRcliZeKRexywuaQFA27P2HSg3mSs cfDIZLfaVBvyXKHXi3GXj44rCYsK2qMhIbpfaKtYTxLKpZ/mrraQ93VyDLXMAI/NuzMv v5FdVOXUbU/mH0S/W6IoBcOmAHbCfEH9Kv9DcUOQrGjlybkMf3iXe/1k0FrLdIvWwizw Ajn3t/nNLwueKoILzOZTFKzHodx/xVlzLJStz5no3XCxwluStVadh7Yp/lAVj5gB+oLS 75cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=ZYnQM7p8; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=eZUqb3sU; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-101449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m131-20020a633f89000000b005d8e3a18786si8652041pga.508.2024.03.13.04.53.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 04:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-101449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=ZYnQM7p8; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=eZUqb3sU; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-101449-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-101449-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A9F5AB22DA2 for ; Wed, 13 Mar 2024 11:53:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75A9B3F9E1; Wed, 13 Mar 2024 11:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="ZYnQM7p8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eZUqb3sU" Received: from fout1-smtp.messagingengine.com (fout1-smtp.messagingengine.com [103.168.172.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9AB03EA72 for ; Wed, 13 Mar 2024 11:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710330813; cv=none; b=Vl9UoxCwYbo+xFHuWlDfWWqV7g0tjQgkRScA5b1JttaOsjWjEwaeIVPzR6P0DYgIFlHXO8JScWi9/PFnzpuAFkTuPEq/rtOofITZeQLrkei5Bi0dHEheJARdPU3i/xqfcWU2FoBHuDiCC5lmB3h7V66hfOfuT3f0B01+tbCW2Hc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710330813; c=relaxed/simple; bh=6Y76AgpBre4SyVMFQz8Gz8vJ7A93p7tmbyD0hs1nla8=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=rAGM9s3KTOlJPpwFp6ZXHywvtUBDvR7xBe+k6nwvcoqPACL557kjwMzZglDN0eGe3TEQ4jDfC0Tt2zf5ZwyIcq/RkFJ9BJXvfmmgkh8Zbxqhlh3wrS8HqTf7sOs8Sl57wy6RGLGlY/nx+Eo7nGDkLQih1KpPDITVRIN/t7RX2no= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=ZYnQM7p8; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=eZUqb3sU; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id D6D621380134; Wed, 13 Mar 2024 07:53:29 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Wed, 13 Mar 2024 07:53:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1710330809; x=1710417209; bh=gn0b2WKvEfTg/FZ9LXq190CVS7p5sTA5MQLvPVDkM3s=; b= ZYnQM7p8x/dP3H+5hWC13tUah5T99wlcWE8gOwezOGhcibshahMJ5psB/nXpI11J kjwEu3VUBPQfU5TCmCNMNFZGOcQ0xO3MDxzIK/2kd5Bo6v1BnO4AT5IqU3GO5iby M27nshnCWSa7JyT6usf/0VIXG+DYDnrknzaYcyFg1oUXziIClTElvL71abMRpRDK H7gvKtv4XpEedSnH0rBSy55tQUq/eQcmP+JqQV1ZiljN0N9r0IAlecQHVscQRSyt GkCv31l1hX8AW6X4vgbIW5husbH5zCyFiTeXJQlDP0DNPveoTMD0rf1qwP+K/7k1 5VhecXmy3tGx5ZOVquwoNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710330809; x= 1710417209; bh=gn0b2WKvEfTg/FZ9LXq190CVS7p5sTA5MQLvPVDkM3s=; b=e ZUqb3sUkme8YY7sunqMcd7kgqEWfeQZ4GfUpMMuwqPWi3qZC7uCjmrk3AUvXF5I6 sCzYembUcddX4rNT4jppC5CJa9geTUpG2MUT8Tt3jzLwTHlr9cl8wTfDl+BLYfS6 7IAxclCPexIrBG2BVnePeiPOFON5U34KRQEvpF6iAGRdrF1nimJbq1gKm8jgYWbJ QapwtZ3LBd7JWtkrq7TQmYlb21d6CDah3Uf3FgZ8DyMW6jb/fhLiAXkUHkF77uWS U1xrPo7H6Qu/ds46blGaA+7yIFSIWUzr5CzwupSlXBNEthYy//0L0cBEo25Iaf9a wGDf9Xeuuux7gvDqb72VA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjeehgdefvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepgeefjeehvdelvdffieejieejiedvvdfhleeivdelveehjeelteegudektdfg jeevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 46CCEB6008D; Wed, 13 Mar 2024 07:53:29 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-251-g8332da0bf6-fm-20240305.001-g8332da0b Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: In-Reply-To: <4f945f4a-ac29-3ef7-9e15-123962f2a0e9@huawei.com> References: <20240313084707.3292300-1-arnd@kernel.org> <4f945f4a-ac29-3ef7-9e15-123962f2a0e9@huawei.com> Date: Wed, 13 Mar 2024 12:53:08 +0100 From: "Arnd Bergmann" To: "Zhihao Cheng" , "Arnd Bergmann" , "Richard Weinberger" , "Miquel Raynal" , "Vignesh Raghavendra" , "Daniel Golle" Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: ubi: avoid expensive do_div() on 32-bit machines Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Mar 13, 2024, at 12:29, Zhihao Cheng wrote: > =E5=9C=A8 2024/3/13 16:46, Arnd Bergmann =E5=86=99=E9=81=93: >> From: Arnd Bergmann >>=20 >> The use of do_div() in ubi_nvmem_reg_read() makes calling it on >> 32-bit machines rather expensive. Since the 'from' variable is >> known to be a 32-bit quantity, it is clearly never needed and >> can be optimized into a regular division operation. >>=20 > Do you meet a performance problem on a 32-bit machine? There are too=20 > many places invoking do_div, why do you optimize this one? > Have you tested the influence on a x86_64 platform after this patch=20 > applied? Looks like that do_div is more efficient in x86. This one was just introduced. The call site looks like a fast path and it caused a build regression that Daniel addressed with an suboptimal commit b8a77b9a5f9c ("mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems"). The way it usually goes is that someone adds an open-coded 64-bit division that causes a link failure, which prompts the original developer to either rewrite the code to avoid the long division if possible, or add do_div() after showing that it is now performance critical, e.g. only called at probe time. Arnd