Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1263306lqm; Thu, 2 May 2024 09:26:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQVJqMB01gevH2ozPzCAD0iGgROX1I3Fh/qM2vjMeMrr9cmeELJkF1ZMTE7u+vBMsAhGizcSnpbU8vmxFmjg0tkgVyS6DcoDPlSdOzDA== X-Google-Smtp-Source: AGHT+IGOsdZaUaP+Bn+vmMHr5iSc2SU0B+fZPVmEVf74KlaZ+Rsrq/hxiTqnqN6spRk/agqQV5Yj X-Received: by 2002:ac8:7d01:0:b0:436:f25c:f14d with SMTP id g1-20020ac87d01000000b00436f25cf14dmr4740qtb.19.1714667209164; Thu, 02 May 2024 09:26:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714667209; cv=pass; d=google.com; s=arc-20160816; b=A1fTVzqwTOdsomVCadowVCbyoh0UVLwiFixltAlD9PwONC0svs96pYVZGjyoA32gLf OxPcZ6/16RpwioloZPI992xY63Ae9y+Lgmn4sO0Wj986Lumjt2DiKQ5vbEWo3//fHTnK B+mff8b08HUFSI+6OwvFFyfVYl+CCL0ixZetmT0BPoxUzR+YeKQgbqkBn0H/SruIzOPk Xl7A/EQkeOGNwYHHpwYH5/hof4h2XtCU93oqbvfy9VHvuAeiMNJqBZvRAOm4RLuuvDQ6 M9gRE7bwKzFrJsrpKD1ONXwXj4hZqW2by7Abk+oSNxV80xq4WE/VxjhTG5CtBseDudYK IEzg== 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=VTC6mBaQe5y0ApTlm47373RneLNkwmr7O8uQJqRRkWM=; fh=XnZQxeUDUHvoZjEwTPeTxt27b8DgFIDofv+dz6qshKI=; b=K1+m29oZdJbmbAPxx+Ti4m7B8v+jCoV3C3XluE1gGOPshAcBlzqNuJPh5weMD3TdSD l8sj6bsG4i1f0LI4MIxIPSaTigdxFjHwTINAQaQ/aR6YZXfgL5UUQcE7L1K//13llbXN OtTXw/uzmP2ZX8pKCN+hbe3CZol0yCR7YssCmPFImWL3Yjiqlt28h0FmNJbY3zF1oAkX ym1a/AOfVeDLpY3FzYmw/59TCyLGwuS0WOq0Qe0ozWsI3pRHvDE4xnAiQZ0UcJPLKCIC YEFnNtEVGHMxkPsEolwwkDf2P6Q5N5NoQqs5GucxFdS/DLUIqJq+2bW1kvh7R8Ejddvt U4Tw==; 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-166721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166721-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v12-20020ac8578c000000b0043a904e3a55si1333067qta.85.2024.05.02.09.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 09:26:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-166721-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166721-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 B5B201C22810 for ; Thu, 2 May 2024 16:26:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E52215E5DB; Thu, 2 May 2024 16:26:43 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.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 4E6861553BB for ; Thu, 2 May 2024 16:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.86.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714667202; cv=none; b=LquU/ZivsyF0WBRBetTU1xLQkDLTNX5fHeShfRCfMyjc/vc+xZAXNf+OB05P8y1ieOf8C2AfX38dk1Zksz3ElCvc+MIITY1gXlmGZGqV0jy4b0njv3RMoA6XC8UaFnX0oar+qtK41Z02pZNBLZadZeh/iLocYDElsCcARpFs8DU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714667202; c=relaxed/simple; bh=U3YldxXJcGf7WG0ecgFb0yY6/sPYuvXH992nRZL34Aw=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=oPlz9sfr/fb7Orlw0H9WPKqHkWZSzh2W1mfyYoGVGoOmCQYtBibpn12x2OupPfuO6pDZhx5dJ9Ad5tykFTFFN/i/NgXHYljhHjoALfEC0/HFnWMK/1z6/ilFB9O8PWxpTTzIW6aRk8ORlFT6XTiBW2Jmh+H1zQEhkOcVMyEPXD0= 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.86.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-319-8JfQbD0yNe2epfzRFaAXmw-1; Thu, 02 May 2024 17:26:28 +0100 X-MC-Unique: 8JfQbD0yNe2epfzRFaAXmw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 2 May 2024 17:25:58 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 2 May 2024 17:25:58 +0100 From: David Laight To: 'Jules Irenge' , "mark.rutland@arm.com" CC: "alexander.shishkin@linux.intel.com" , "jolsa@kernel.org" , "irogers@google.com" , "adrian.hunter@intel.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "linux-perf-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] perf/x86/amd/power: Use div64_u64 onstead of do_div() Thread-Topic: [PATCH] perf/x86/amd/power: Use div64_u64 onstead of do_div() Thread-Index: AQHamYq9w5OrjuroEEyWIm0jPSXs6bGEJ7/A Date: Thu, 2 May 2024 16:25:58 +0000 Message-ID: <41180245c6e94a06b789cd44b8aebd62@AcuMS.aculab.com> References: In-Reply-To: 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: Jules Irenge > Sent: 28 April 2024 17:40 >=20 > do_div() truncates a u64 divisor to 32 bit. > This can lead to non-zero being truncated to zero for division. >=20 > Fix coccinelle warning > WARNING: do_div() does a 64-by-32 division, please consider using div64_u= 64 instead >=20 > Signed-off-by: Jules Irenge > --- > arch/x86/events/amd/power.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/arch/x86/events/amd/power.c b/arch/x86/events/amd/power.c > index 37d5b380516e..ff003c1a645b 100644 > --- a/arch/x86/events/amd/power.c > +++ b/arch/x86/events/amd/power.c > @@ -64,7 +64,7 @@ static void event_update(struct perf_event *event) > =09delta *=3D cpu_pwr_sample_ratio * 1000; > =09tdelta =3D new_ptsc - prev_ptsc; >=20 > -=09do_div(delta, tdelta); > +=09div64_u64(delta, tdelta); Nak - you've not tested it. =09David > =09local64_add(delta, &event->count); > } >=20 > -- > 2.43.2 >=20 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)