Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp415080rdh; Tue, 19 Dec 2023 02:56:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLGUjl4WmkZF9dImer7x+WaG6gt2Fb9G05IlfDxI6uS0e9BGfU4yVs7jAV3dr5YvV7KxC7 X-Received: by 2002:a17:907:36e:b0:a23:6079:67fa with SMTP id rs14-20020a170907036e00b00a23607967famr1234350ejb.112.1702983411189; Tue, 19 Dec 2023 02:56:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702983411; cv=none; d=google.com; s=arc-20160816; b=F+hObZOcGl6Xq5mMvxV/vYo/Dr2oO/qYtPn/RPo/k2KzKAia92P04DMvyjH6/ds0HU drbDGWk5BDwsy0+1SPX1pggG3kFPWN6Yg6LVx0Nzx9wG/aLmbQvy7kFe6NqIQuYIpUyC 1Ym56LgNA/h1K2PtWg8gajewvpw+ybfpqdcQ+9oxyt5mrtnTnHwQkxM+09RMpdEPpsMe eSgyqE4H+cwfcDQRYIMR5km3Mx0rmyngdoZxfkdD9Ix4d79T3EmdAII5og+Mk9xmBYAT RDBCJh/vecNxW3+98c+JNUWiNbCtchvKR1p81+ztWLSBgoVQWCkiubghCG9EP7o7uqVK 9LuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=G82hudDSGLw6AtSQ1T4Z7nqRvn920200QYy8PFech4Q=; fh=pSYlI7q1pZlYpjhfkJ5rHGsC7/2w9G9a1N2vFwNixmU=; b=V+jSMA/T4eqx+CvPvuBiPho4sYXrQyif6E+HL0jZGO9mqumHqZ1+DSwFpO1vkcQn8l LKb+rDXIw83uGkmTlMubNKEzDR7PxI1Q0Ww8+gz7Y8MFLCMvgOLBIlUGEckApm/2/jw3 ZeND7DoqwKlv9Li/PSfcZHLQS0KDmltOoRJibSbKkC6lV/sP7CC8lzlrfP16n7bGHpSn GJPljsiLYcpBntXTNnFi7gHKq2MQ0dTXfiNpmQUTabbtju5D1Oi/KoRSh0/hU1BZ7mSy dWOLM3AQ0EivFsVfnqc0UXbVjWWcTox+mgRCqIAroHn7Wfx7vKaJctgOBvyacTv3/EsU MJhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SnZH+wvt; spf=pass (google.com: domain of linux-kernel+bounces-5039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f9-20020a170906494900b00a234cad6e11si1956329ejt.515.2023.12.19.02.56.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 02:56:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5039-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; dkim=pass header.i=@collabora.com header.s=mail header.b=SnZH+wvt; spf=pass (google.com: domain of linux-kernel+bounces-5039-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5039-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 am.mirrors.kernel.org (Postfix) with ESMTPS id E99421F25D38 for ; Tue, 19 Dec 2023 10:56:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59CC514F79; Tue, 19 Dec 2023 10:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="SnZH+wvt" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 37D8515AD3; Tue, 19 Dec 2023 10:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1702983398; bh=E6SsGnEMQ5sQgGiV6jGfWzSqHuxNI3tqz6LYjcZqyto=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=SnZH+wvtXP/GDQpXtBpr6B06nuYwgID2MgVv83MO2PFYFvCRdaDS4P+bE87L8txKt RoyiRqFbVhDQPx5AkWDyVDaTP1C/+6RjX6EM8EATNNe/kEk/VVzo460gYKNNl3uf+h Z+zANvIvh14t56VGrNHm9Ib7EAx1ZPIorZaMWb4ZDWKFz4c4CAbkw5J9WUknEK7P+K B7AfteaDmOitMNkbE0JdgIUwsTMehGLyt20I3ShIFFkacKwyca1lcelLd92qpahoe6 BvIoFdwvydjowZo1gVXSsF/SnaV7woUSYfhCiNu0Wd7p0T5UMFN8MTrKtHdWHQOxx0 3A16LWwIN13Hg== Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id E8E3337814A3; Tue, 19 Dec 2023 10:56:37 +0000 (UTC) Message-ID: Date: Tue, 19 Dec 2023 11:56:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] fix overflow in idle exit_latency Content-Language: en-US To: Bo Ye , "Rafael J. Wysocki" , Daniel Lezcano , Matthias Brugger Cc: 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 References: <20231219031444.91752-1-bo.ye@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20231219031444.91752-1-bo.ye@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 = 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