Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2731491rda; Wed, 25 Oct 2023 10:36:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJH7YOu5VU9vmN8e3FXOCCX/ETUbiztPP6lBGrUOl60I9t0ZF5SQBU7dethQxyvpGjGP+i X-Received: by 2002:a25:41d2:0:b0:d9c:fdc7:632c with SMTP id o201-20020a2541d2000000b00d9cfdc7632cmr464153yba.21.1698255410151; Wed, 25 Oct 2023 10:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698255410; cv=none; d=google.com; s=arc-20160816; b=fiJvdmWI8cXLbG5/URKbahbJNsr09EqkowanJP92r+MOxrtJEwBzdSgI67r2hAcJ9a fBpgohtr23IGC6JjkkpgUIwHWnRsl0nVA/kt8HO1HqiJ/MoC7NQMbDyZBkm2p9bLkhpZ 2P6KtZJ19wwGP19CdYYXaLXMq/180vJVZxPSyc8ujMmz6Pan9DaLtUPXfsqoi1u+GbsG ARVkFqfenI8pCb3XYw54bEJMvoMcTxJmGVDPP0v2rQJPXpWBT8GlycPJKXfMnjK9m4B4 UKE7ICuo6vHg6wuQ0+Gk/O+kDbCKYFk0z9xULLJ4Sqk/01omRPtTzO/YO9RZMFBJH7Ol XwGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=W0BHbdjzZciWEuvjKTzCVN+BNSOJ0GOttRxUoRO+m+Y=; fh=tthDhrZiUYXsLyLJwE1H/1H/YLrF/bvh6CrHrmmYy74=; b=pFbEf513SaY2yUJE24tRqIuRTjKD+Celj+eXOaV5Pxb2qK4p+FVxVN4reZsjt++p3c AjxLyJzExVOctoXRnyf8upy3iz4RUGFb2ePjZHbNwvR7fIXRU7PA0DSwLNMrXYY+JThY +oWp5Sl2mHqIZbbFUYy4nvKXfZsO7KWwUuAnMS05WXqU9UmUYpQhFsJnI2ZPJK8PfczV mgiz4/7BvI9ibMtgUPwQ+jQ7PSZIifUBhxSJ8sQ3tSECypbPYd8mVBZPE+EOszR4qNz7 Gfga0w/x7DT/Mf8eztRR1kHZ72HsYjsHk/Ct8yzZbzd2ryKgXLrDNEni6SS6DEDwQ2mf B6gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Js86oV2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id j206-20020a2555d7000000b00da048bcd186si4505032ybb.549.2023.10.25.10.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 10:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Js86oV2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B6A5C81C8736; Wed, 25 Oct 2023 10:36:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232992AbjJYRgS (ORCPT + 99 others); Wed, 25 Oct 2023 13:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjJYRgM (ORCPT ); Wed, 25 Oct 2023 13:36:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C24F1182; Wed, 25 Oct 2023 10:36:10 -0700 (PDT) Received: from mercury (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 70F1E6607349; Wed, 25 Oct 2023 18:36:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1698255369; bh=R1j0yF7ON9HljamXpo4RStWWAUzHA+3I02cIzDZbN+E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Js86oV2d5JuhzHjZBL0v0OkFlQkw+AifCEvxM/t9mTYki5BalgXOkp5gmI8wV83Xd 8iWv5m+l4CNyIRFgNK8Nsb5i06jR/fuClZUAwKicSAnGcWEede9YyhanVMfva7PGOS lhU4lLIzi2tGr2CrX7qmUqI0XeMxPNN85z6BOF+GzV4S956EqmhkR1tWVWKZTsLabz gbFyGDN2swhB+M9lmdy5v7bQBrfaj8+MZrLBCWpOmPq3+24UAB8u97orvp0ZHfZaqg hYbxzEX8O995BF6niTasSFM2cSZxtlOI0NfH6X07aCrtz5sV6jgrr3ogLl8yubPtOB zWonJwi33UgSg== Received: by mercury (Postfix, from userid 1000) id 873DD106057B; Wed, 25 Oct 2023 19:36:06 +0200 (CEST) Date: Wed, 25 Oct 2023 19:36:06 +0200 From: Sebastian Reichel To: Linus Torvalds Cc: Andy Shevchenko , Michael Turquette , Stephen Boyd , David Laight , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Niklas Schnelle , kernel@collabora.com Subject: Re: [PATCH v4 1/3] math.h: add DIV_ROUND_UP_NO_OVERFLOW Message-ID: <20231025173606.i2e74tfpbo6as5u4@mercury.elektranox.org> References: <20231024161931.78567-1-sebastian.reichel@collabora.com> <20231024161931.78567-2-sebastian.reichel@collabora.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3xdyay7hajk67vjt" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 10:36:27 -0700 (PDT) --3xdyay7hajk67vjt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Tue, Oct 24, 2023 at 12:53:03PM -1000, Linus Torvalds wrote: > On Tue, 24 Oct 2023 at 09:32, Linus Torvalds > wrote: > > > > I would really prefer to just make our regular DIV_ROUND_UP() DTRT. Bu= t: > > > > - people do use it with complex first arguments (ie function calls > > etc) that we don't want to evaluate twice > > > > - we can't make it an inline function, because the types aren't fixed > > > > - we can't even use a statement expression and __auto_type, because > > these things are used in type definitions etc and need to be constant > > expressions >=20 > Ok. I have a potential beginning of a solution. >=20 > It is unbelievably disgustingly complicated. But it might approach > being correct. >=20 > And by that "it might approach being correct" I obviously mean "this > is untested, but builds at least some kernel code". >=20 > I'm almost certain it will fail on more complex cases, because I > already found a lot of questionable stuff that was simply hidden by > the old macro just silently doing the C arithmetic type conversions, > and this thing does type handling manually. >=20 > I'm hoping that somebody will go "Linus, you're just being > *completely* silly, it's much easier to do XYZ". I think your new __div_round_up_ull() should also be used by DIV_ROUND_UP_ULL, which is defined in linux/math.h. -- Sebastian --3xdyay7hajk67vjt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAmU5UgYACgkQ2O7X88g7 +pr6lxAAney3xsyWL9nxuzXlOqg2Bt+J+bDxMLJpjmNnsXbt3UjeyNOkBd1GBaaF 4rkeE1wVapAmWMdt+zoNmX+1A/r0gF6So80qAf622+Ae2L+78h36M1cnb4KPoBoD ffNmWVaf7lJeuNfwbYfOs/ymXx2b0abs7Pf8IbrKl04ER+oCzWlaeaxzsMocyvw2 0CKoYw/jyWDnFhREC0qOJTb8oiUQHfSAa5mo61jBzjMErtdizF0rBG389W6GGgXA N8pMZg502VAAOqxQRke3XS5Zk8IEHBj/aKrGRUvKDd5IbqwYWJT74p3/TionUs06 Z/TEr3X8NW4TElNRyxCqgudNXWqs7KYDB4tj7cDWHktPysw65Ow60M8BHExSKWc0 hfSbbdnN88DRhP8KP6m//dArD7cN+EVmLUmfNNzJ8GKxVdOGWvLbOUDCWq2+/Vzg lsnv9CkWGjkCwzz8fzATkMfB0SW9SeCtAz1/9QGfWsV5M7rVWalkUyd1DCKSmtgG G3V0+tTVJunazyhKBxzY1Y40HZB7BCfABuHTNwnWsu7yNQi52o1+GpkbSf9ieRD+ NmW4jgxqJzp8wzxpGhlHm1/R59vLSaTXWHP7UvaUQD/Jp4adik45m++iykv0XkTW ErDfEJPQWkxVjybb6RIKdl9I1qQfbBVgOUzgOa1tb298xc8Ngys= =jhkV -----END PGP SIGNATURE----- --3xdyay7hajk67vjt--