Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp184346lqc; Thu, 29 Feb 2024 14:13:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoxpJ6oCpcm0Nikj85j3YVGsudVNmY7jaJUIVe0+9AI7yAD0PeEWipTHkOCTqTPqpj4f1VTZACyH4KPy1j0PLejKILd3HV6pRm1tSNbg== X-Google-Smtp-Source: AGHT+IGaicNjI017BNXDJsraaDdz2rO0B6OpLSbSVfgk9G5Vbga5LUvdrWDe39ylcrflVhr/yLvN X-Received: by 2002:a25:e305:0:b0:dc6:cc35:35e9 with SMTP id z5-20020a25e305000000b00dc6cc3535e9mr3343598ybd.35.1709244822987; Thu, 29 Feb 2024 14:13:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709244822; cv=pass; d=google.com; s=arc-20160816; b=rl8ZrbgYroruMXKRX7HmzHGlkIhjGNxZ65TdzsmI8If0ZzhTvXoos8i2Yj1bxYPrag rv4nnV4mEUoK/j9VmYONSi0/hkI+JZeK6mTP7fQN05STD3f7zBxKi28n0nzbYLmiTQ7R gtle18+BzGiFcpTy7wZX0+H1UnC7i13NsElzMUEWWVN4NLpKNMPyyKm1uynI2LUAD0mG nJUrYjMyRBYyoPuo2s/ZEqrYLuImMVq4uJ63a4rx1WHBj8v5SIx5EPHkRq5WKawIg9+n XVVQhcWgroOifAe/MP19Br6Nk1jBVpUYfYh+NxZrSlhZuyb4sg6JxHdALw8ujPWQcI5V 3cOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=lZDiyJsUmZId/Z3fYLT2IIVuOrOC5HBxpjKM+fv3XMw=; fh=2CHp5PTJys7ohLbR9pMrmFH1RE/qaA0PfHFSwmHWdbw=; b=aeJicznrspBk3reA4OPpoRSW+KkaOTk0RrbLJCds59+gsKFWFNBvk0ZjBeQKH9ZlTG cJ6iAw+UZeZUo79v2dWuufOAsmPZtzjKcYd2QVkNINMa8WH4cJ0Zec1LGvaBTHYOa2rf rj7/5kB/rZPAtGGE7nNqwPWsB8ikeLAoLZd5yQa2JVlnxMMjVbxioaoeaa8LrrXyUcqk 2k7goToTCYSQApqeAupGnaOkVAU5AfWetm0QlCvdwDAyg5vcPHhyqqRBcLNzzu2ezSpS vFFOhTJIyLX1DEkA9dt/YGx2o64VnE2DsCwz5ZmQL88XAxNIeM8UoHypTKoFxRukZ3eE ER7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-87625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c13-20020ac8518d000000b0042ec4255ecesi901188qtn.431.2024.02.29.14.13.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 14:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-87625-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87625-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B10281C22E91 for ; Thu, 29 Feb 2024 22:13:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4FF174BE8; Thu, 29 Feb 2024 22:13:36 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (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 A7DEA6D522 for ; Thu, 29 Feb 2024 22:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709244816; cv=none; b=D33YYcb5u3vfLwoDWqyVu7hbKXGLq4PxWCyltpxFq46aSCHvEV7NzZT/q6aj3gODwXULo3YgXWo8ldmPC7c8aJCCJVOLrxtVYbv53IokqQH4kn3mrj+WQUJRdjUJANO1kH872xux8RqeJAtf2qh+x2sz1H/OULYLSqLx9I2tnWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709244816; c=relaxed/simple; bh=lZDiyJsUmZId/Z3fYLT2IIVuOrOC5HBxpjKM+fv3XMw=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=YGiU69SlljFbSDeAZdqqOCXGRuAWo9Xesy1d1seRLhfqRc+JS774r58n2oy5xN5MAtbwbXYVzLp4GhdRzJZtLKd1yqG6/85gffbMUaQTfgF+JC1fzPPR9zUOG6ZdUdN6jTMMEPGG5nxLkdU2XnrGfu6PDab2ROvMzXTIeXOM2PU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-152-bS3OTQjvO0uFxpOp8UZoqA-1; Thu, 29 Feb 2024 22:13:28 +0000 X-MC-Unique: bS3OTQjvO0uFxpOp8UZoqA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 29 Feb 2024 22:13:26 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 29 Feb 2024 22:13:26 +0000 From: David Laight To: 'Thorsten Blum' , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" CC: "H. Peter Anvin" , "Peter Zijlstra (Intel)" , Wei Liu , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] x86/apic: Use div64_ul() instead of do_div() Thread-Topic: [PATCH] x86/apic: Use div64_ul() instead of do_div() Thread-Index: AQHaaXLYiXydWB8fRkmBfBNz3Gms8bEh48og Date: Thu, 29 Feb 2024 22:13:26 +0000 Message-ID: <7e46123775e64898bd7c467328125ee0@AcuMS.aculab.com> References: <20240227114333.1718-2-thorsten.blum@toblux.com> In-Reply-To: <20240227114333.1718-2-thorsten.blum@toblux.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Thorsten Blum > Sent: 27 February 2024 11:44 >=20 > Fixes Coccinelle/coccicheck warnings reported by do_div.cocci. >=20 > Change deltapm to unsigned long and replace do_div() with div64_ul() > which doesn't implicitly cast the divisor and doesn't unnecessarily > calculate the remainder. Eh? they are entirely different beasts. do_div() does a 64 by 32 divide that gives a 32bit quotient. div64_ul() does a much more expensive 64 by 64 divide that can generate a 64bit quotient. The remainder is pretty much free in both cases. If a cpu has a divide instruction it will almost certainly put the result in one register and the quotient in another. 64 by 64 divides are horribly expensive on 32bit - they typically have to be done in software even if the cpu has a divide instruction which will (typically) do a 64 by 32 divide. Even on Intel 64 bit x86 the 128 by 64 divide (needed to get the 64 bit quotient) takes twice as long as the 64 by 32 one. Even when the values are small. The entire reason that the 'libc' divide function isn't in the kernel is because it is slow and you really don't want to be doing it unless the VALUES not the types require it. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)