Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754540AbdDDP3V (ORCPT ); Tue, 4 Apr 2017 11:29:21 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:55034 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753094AbdDDP3D (ORCPT ); Tue, 4 Apr 2017 11:29:03 -0400 X-IronPort-AV: E=Sophos;i="5.36,275,1486396800"; d="scan'208";a="8521435" From: Bart Van Assche To: "paolo.valente@linaro.org" CC: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "fchecconi@gmail.com" , "linus.walleij@linaro.org" , "axboe@kernel.dk" , "avanzini.arianna@gmail.com" , "broonie@kernel.org" , "tj@kernel.org" , "ulf.hansson@linaro.org" Subject: Re: [PATCH V2 04/16] block, bfq: modify the peak-rate estimator Thread-Topic: [PATCH V2 04/16] block, bfq: modify the peak-rate estimator Thread-Index: AQHSqjPmqK7Jhq4010+VKTKsNo1cqaG1C+IAgABQEQA= Date: Tue, 4 Apr 2017 15:28:59 +0000 Message-ID: <1491319738.2513.2.camel@sandisk.com> References: <20170331124743.3530-1-paolo.valente@linaro.org> <20170331124743.3530-5-paolo.valente@linaro.org> <1490974279.2587.5.camel@sandisk.com> <867BBC1E-080B-4A4B-88CE-BD103610BA6C@linaro.org> In-Reply-To: <867BBC1E-080B-4A4B-88CE-BD103610BA6C@linaro.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=sandisk.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [63.163.107.100] x-microsoft-exchange-diagnostics: 1;BY1PR0401MB1529;7:htaDzwu8UC1kbkY1hyDuWAoBCP3OZhG8GPmsdO/vMcbNOCAEvokRcbyVbjZTtXxWcAFWIrY+smtpyVWzBskWoR0cFPma23BH7t6UIlf3JDYIumaU7jefoTygV5fNIu4uBa1QA7/tNcsxwm6+awZ4lzo0zX87H16JomIt0Lm+lEYCOicumyUe0CEgv6kzwTi7eKxKlUx0Vd1XyoV7fIEGraJT4kafkupvMAkUcnGLq72lDbLYc8GKeEIyJQneHDMB8uBOyT+iymi0qzOVtTX0mW5/fbIdQ6a3h1xeuGZBxPn1O0JgbBn38Zwluasykzunc7xjj3mslDszfXFR7gpuMg==;20:onIXujZn+vb1vVshSHxz4ELYev5tqj1A9LNMlluiiTeiMLK2N6ShglqTc4p9FN2kbP8zCBrN5KD4X2w2fslN5up0OcRWxCNbUxBsshkoqaFGhP4QYcQZHM40yhBwcUR6TYknzMFHcBeowP2VGrz7Cwmp4luVhu8ICUvIZlh2oTs= x-ms-office365-filtering-correlation-id: df6847c6-c680-44d5-17bb-08d47b6f5144 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:BY1PR0401MB1529; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(42932892334569); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:BY1PR0401MB1529;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0401MB1529; x-forefront-prvs: 0267E514F9 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39840400002)(39860400002)(39450400003)(39850400002)(39400400002)(39410400002)(24454002)(377424004)(189998001)(81166006)(7736002)(2501003)(53936002)(305945005)(5640700003)(6512007)(6116002)(33646002)(6486002)(54906002)(6436002)(4326008)(99286003)(102836003)(66066001)(8676002)(8936002)(3846002)(93886004)(77096006)(25786009)(6246003)(6506006)(54356999)(2900100001)(39060400002)(110136004)(38730400002)(36756003)(86362001)(3660700001)(229853002)(2906002)(5660300001)(7416002)(50986999)(3280700002)(6916009)(122556002)(2351001)(2950100002)(103116003)(76176999);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0401MB1529;H:BY1PR0401MB1532.namprd04.prod.outlook.com;FPR:;SPF:None;MLV:ovrnspm;PTR:InfoNoRecords;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Apr 2017 15:28:59.9354 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0401MB1529 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v34FTWjX003697 Content-Length: 1335 Lines: 28 On Tue, 2017-04-04 at 12:42 +0200, Paolo Valente wrote: > > Il giorno 31 mar 2017, alle ore 17:31, Bart Van Assche ha scritto: > > > > On Fri, 2017-03-31 at 14:47 +0200, Paolo Valente wrote: > > > + delta_ktime = ktime_get(); > > > + delta_ktime = ktime_sub(delta_ktime, bfqd->last_budget_start); > > > + delta_usecs = ktime_to_us(delta_ktime); > > > > This patch changes the type of the variable in which the result of ktime_to_us() > > is stored from u64 into u32 and next compares that result with LONG_MAX. Since > > ktime_to_us() returns a signed 64-bit number, are you sure you want to store that > > result in a 32-bit variable? If ktime_to_us() would e.g. return 0xffffffff00000100 > > or 0x100000100 then the assignment will truncate these numbers to 0x100. > > The instruction above the assignment you highlight stores in > delta_ktime the difference between 'now' and the last budget start. > The latter may have happened at most about 100 ms before 'now'. So > there should be no overflow issue. Hello Paolo, Please double check the following code: if (delta_usecs < 1000 || delta_usecs >= LONG_MAX) Since delta_usecs is a 32-bit variable and LONG_MAX a 64-bit constant on 64-bit systems I'm not sure that code will do what it is intended to do. Thanks, Bart.