Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2544253rdb; Mon, 12 Feb 2024 08:09:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUx1x8vfPzKBJNeKzw8Q8Bsj67U/yaKtIoMSJ4aDvi/dUXMp7Orpr+ZYV7NxEtKIl07BngEo9cl1fWuQUNvQOjGnJabISzYhJdbzuXCqA== X-Google-Smtp-Source: AGHT+IEmL0/MMty80dC0dlDoBoanxptOjlYnzQ5HsJe/pfjTBve1xcizT60zvPHs1E6QT/GZwER/ X-Received: by 2002:a05:6402:3182:b0:561:9653:339b with SMTP id di2-20020a056402318200b005619653339bmr3029145edb.6.1707754197563; Mon, 12 Feb 2024 08:09:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707754197; cv=pass; d=google.com; s=arc-20160816; b=HGuVgkyyqMueHYarqFcyAJ6BIs/Z3SvdvJ7EGu1MGh93IOZv4to8Q3qzaV1nE6Pf/m 1ROCwi7U/b9mfrIjyyeUDVdWgvdfbJQSy6/t0VOCSJX5ENEfL0TZJOzMJvfKOvQ4f9Vg 7uwnavHHzq41l+qFc0830ZoXPAlktPO3IHxeuO/21TLZlN6XMS+czjVV6e0ckMAKs/tK AvgkPno8/wcJzIN6T05KiMkwQLMQXHVMR3KDysaCLlho1+RQMGAPWopUowP75SrOg4jL w6KQXkkcNg/dfiNXxD1UM6/xM9vPT0AJ+I84m3dbFbuVegWE62d44WJZIoynOfB+h9+6 AL7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=c5e0qLsgbAC04Ea+lUsuUQR8n5Q6fLgOHYw/TRDHBms=; fh=wiAeZor+HQMEGF6wGBM036sEA+a8VbQCXlzx7nDDvxw=; b=hyuqG7SE6fegGBaWurnEXbRPZl8i8YBJd33dL58scOC5p43gH9pMmgrIX32lV7SJ7z OLr8o1jbEZb7qctWotgOomtU9grFhmCj2FKOe7IuhsjPKPa8UmiP5F0CpIkcj4MxXMhs rFwLtD/1t3wqlYyf59n78V5h4bGE3upeqjgr3JBX350T6YisrISP7Eqww0m9JEuk8Bzd 3ulcwNVZzU4Gs5f/0JS3sfpitxmngsGMgFEPXyIKmGP3ORkD1KWFxLOZMesmeb+scmBn wp5Qs1CL1Sk/ZTGcpIBLWcc0SZQR6GcVNHHbHb4AHFAxbB3/kvuFew2+6g/UCHZrf+lJ QdOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-61939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCX4A+uCpf7wwVOV30FsqVUMZwyDI94m5NHAwfoDRwipLX8DdvR1jsQEtMaleepUQXAbbkzwN15TU+fDPSzjfpKVfr+bF+avm/cQ998t9A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s3-20020a50d483000000b005600f538252si2871145edi.227.2024.02.12.08.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-61939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4FFF81F22413 for ; Mon, 12 Feb 2024 16:09:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A95433D0BF; Mon, 12 Feb 2024 16:09:48 +0000 (UTC) Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 330343D0AD; Mon, 12 Feb 2024 16:09:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707754188; cv=none; b=f47BFw/MLXaPCmG21yGiB3DGMVLwnpaa8o2rgn8KRWvi96CYRK3RgXhTZPjopsXWpzHOHbil0WVaSyAfXexK53YD/UyQPFZYScunxTNu4pWgxUtbPtuyGGzr+vW9Gt3DW9xECbTNAHma4ktUuEGsdvj6myHPn49Gs62c04Uhmp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707754188; c=relaxed/simple; bh=WSZs8xa+WI8054UfUvFjQl73JxvCck5P/K79KrcpSM0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=g2CoGYntxu/FT/MfHddMDSaDChZXAh9wb22XzJ0XmZC3w4g+AXm2S4xgXYgDLj3wiDieQUg4c5ljQ2yuwv1w4LAEk/oGA/PbFEQBLQ9h2esV/jGR9BVkaTVVs77CCAzxoXXbPbYxX9H8AGUHDk8e2t/Uu05sDmSDnjUi7GBPicE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.161.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-59a24bf7cadso1131234eaf.0; Mon, 12 Feb 2024 08:09:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707754185; x=1708358985; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c5e0qLsgbAC04Ea+lUsuUQR8n5Q6fLgOHYw/TRDHBms=; b=UdcRlQbDLVoG2q9YvV7/CTVliZR4GO7YSQ3OCPMoBWFnHyqqAz+BHyZEOb72JmA4qJ 4AYgRLwzMVaFrzndlfpYJtAP5wSt9VjGjxwjGtbxvnYZgujb7H+FpWFVowijTUyHi2FL 0kP/ov5OojXp1fEtbsg4aCOP7sq0e7vAVPl1c2Lsi1fvQNpciY/0uEQ5iAS0tipxTFo+ Kf94K623m6xqPya3PI1wlIeOyhvI2sOWQIElTju0k2TNRRTqYxnsei+wm7xClmuXouXK t9UfJQ772zKkQ/+5faSLVdKPPFBHZIfzMerEub/0OHoZYvp7YvSmoxtda3R0JgW3rsg6 xQlQ== X-Forwarded-Encrypted: i=1; AJvYcCX2ruGcvPgRtfZKuaNysmeE/8MPhPa4RzXZz+Kwbx7bqhwXiur2HuTbTUeTCG1cODPsWrW0uMoVLm6KGYMRV7tq+n2NMF8/fhC+fZ10A+e4Pt06Jp3g7BiKD/jR/jlEFTNFwZh1Q88= X-Gm-Message-State: AOJu0Ywytprldsk4YtVqItSGAIkPH4SUvF1G0vOFKFFTGdNRBP2m1Eg5 bWVTPGO0zCV3OEcIn5pJKoYjYgQD7e5TTqhx8AImustcxysLgi9n9pRGs3PFDLs7my0M9qw5ZaV jTqruHP58d2r+Cc1M9x1rgthYVrg= X-Received: by 2002:a05:6820:1f8e:b0:59c:eb7b:c04e with SMTP id eq14-20020a0568201f8e00b0059ceb7bc04emr5091034oob.1.1707754185267; Mon, 12 Feb 2024 08:09:45 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231219031444.91752-1-bo.ye@mediatek.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 12 Feb 2024 17:09:34 +0100 Message-ID: Subject: Re: [PATCH v2] fix overflow in idle exit_latency To: AngeloGioacchino Del Regno , Bo Ye Cc: Daniel Lezcano , Matthias Brugger , yongdong.zhang@mediatek.com, C Cheng , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Dec 19, 2023 at 11:56=E2=80=AFAM AngeloGioacchino Del Regno wrote: > > Il 19/12/23 04:14, Bo Ye ha scritto: > > From: C Cheng > > > > In detail: > > > > In C language, when you perform a multiplication operation, if > > both operands are of int type, the multiplication operation is > > performed on the int type, and then the result is converted to > > the target type. This means that if the product of int type > > multiplication exceeds the range that int type can represent, > > an overflow will occur even if you store the result in a > > variable of int64_t type. > > > > For a multiplication of two int values, it is better to use > > mul_u32_u32() rather than s->exit_latency_ns =3D s->exit_latency * > > NSEC_PER_USEC to avoid potential overflow happenning. > > > > Signed-off-by: C Cheng > > Signed-off-by: Bo Ye > > Reviewed-by: AngeloGioacchino Del Regno Applied as 6.9 material under a different subject (cpuidle: Avoid potential overflow in integer multiplication), thanks!