Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1168884imm; Fri, 1 Jun 2018 17:17:31 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ2THuKSOgpuBdguAED3qL3UjNx8EyheGmZ6KhbXaIkWc1AKj2L5vKvU/3fi31tHlXHEt/a X-Received: by 2002:a17:902:780a:: with SMTP id p10-v6mr13104226pll.281.1527898651817; Fri, 01 Jun 2018 17:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527898651; cv=none; d=google.com; s=arc-20160816; b=jWt3anpopXiQ/Oo+Yqfo4dNGpC02htM4FtiZBCbA72ZosO9YIczSwPuVkXhFoZBHFh QVHaW3HjJo6xyw7IrsU+2FmPw4fZjGCcG53cfowzWWHfVfmUBX5EE7SgfyNOz6O0Vn6I SRcfRnNVTbRfCYF3FD4WUFq7fxloVD3roWb72OWmDtvi9Sjq4fgbAUvh4nThDkIt9AjF a7YeKZDIG7FXGZtbEjktqcuN4MxJ2dHm/jBaQ4huVshWDXqlCupEDjM/8jOEG0uXVsaB rXdNGivPpTN4zjHJB6hLVEH/hZBv58sqZmLo2iQY2KPcc+iAkJmxR7364OPUo5p4fWfm qSCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Y5UTwVc51O6aO/2xnbnHgw7mexsvbfYqrS3TGGjNx3g=; b=zyTNMy20Ds1EMCa4rm5HIQmNlS/2qU0Njp+fRslzI8eVcQ/0sTPPAYEr7xxk/WYc7n sJgJ5LYZVWDoytu+SK2871BqTXl0Nkd03tXA8YEmw93pKiSPQAGHXiwg83Clmb+Iqw28 AlUU7KZ0PQhenhVA+X+zd64Nsra0H3BlH6LEA9IZoASIJhEaxWq/QlmoLYftPY6oLhvJ pGMIrCsUhQaqWbIDrIeV51Upcv//JsVZRSqQmLkC8DQ5cykO2FcCNgopJUJiRVHY7UCS h7c9V0fJKu7q3hJ2c4gTAXMvJvchImx0O2emJY9Wp1zncpLBoBMUBNdvPlX+cRJfjq1d Yzng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KQj1JIN6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si40595073plv.16.2018.06.01.17.17.15; Fri, 01 Jun 2018 17:17:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KQj1JIN6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750999AbeFBAQt (ORCPT + 99 others); Fri, 1 Jun 2018 20:16:49 -0400 Received: from mail-ua0-f193.google.com ([209.85.217.193]:38144 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbeFBAQr (ORCPT ); Fri, 1 Jun 2018 20:16:47 -0400 Received: by mail-ua0-f193.google.com with SMTP id y8-v6so18496320ual.5; Fri, 01 Jun 2018 17:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Y5UTwVc51O6aO/2xnbnHgw7mexsvbfYqrS3TGGjNx3g=; b=KQj1JIN65hcMmIOBnaHffTJliUjNlv916az3fzdm7WyVchUdIQCZ5O7FoZBrQIgCTq X9RlaQ3De7Q6myrJYU3rA7LjrVC4KNNeI1Zudw9NvDFyEIsFkfja4exb1dE/U78NpPUJ CFVB3QE7trD59ASt765D4mI/+aGZP8RA+TTt/Ih/iornf6y3mwpLiSf90gSP+zJZllla jcj6aZZcWqWMULlhEZey7GeCIulrlMHVJjNJQpwfPKYY7qQwAWH6cQjnR0JmRW4mJ8To mjMvcOZVZ2/SG8/etB9nbTMo7on0Nx0btNQt+UU1E3gvjzTc3Zczdf99r5SW2CpUatNx Dypw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Y5UTwVc51O6aO/2xnbnHgw7mexsvbfYqrS3TGGjNx3g=; b=Xf7V6lGqgTi7wdSS9lv4CbuwmGQCYExYKwEQjxffeEnV4h8kdN2DVPIQr+7GAEiCVn sL7aIqthr517tYh9kZrvGjvAl9PTXTs2O8KfooZfbckAkil+o43fKgqOFBAtiWvMx8NC zsDxLQymkRga3tjxwUg389omxKaG9NX+nCJE2oqz5BwSgdJeFFrmHULGLRdHxOwz7q5D 15VpZb+AlyHCnaEQHBjLkOwXh502fjgcoQD7RvowxRv1WZnXhS9IIwAhL2DJMj/se7ET ImmTO9RX+bQqqzL5J0jYLW15p1GMngj93rByUywSpcB55MSKf8PyWrhXXK08QB3T6lgQ PWzQ== X-Gm-Message-State: ALKqPweNWXArCw5RYHxmCslk2SVOm+ATo/u87gvEQsBgco2jHMGUFoYe 2qmOBcJWR3SMn7qCa1MJSC6qURo+g0KcP/bKs8Y= X-Received: by 2002:ab0:124:: with SMTP id 33-v6mr8487567uak.13.1527898606604; Fri, 01 Jun 2018 17:16:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:549e:0:0:0:0:0 with HTTP; Fri, 1 Jun 2018 17:16:45 -0700 (PDT) In-Reply-To: <20180601045433.GA17425@in.ibm.com> References: <1527768909-32637-1-git-send-email-ego@linux.vnet.ibm.com> <20180601045433.GA17425@in.ibm.com> From: Balbir Singh Date: Sat, 2 Jun 2018 10:16:45 +1000 Message-ID: Subject: Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic. To: Gautham R Shenoy Cc: "Rafael J. Wysocki" , Daniel Lezcano , Michael Ellerman , Stewart Smith , Michael Neuling , Vaidyanathan Srinivasan , Shilpasri G Bhat , Akshay Adiga , Nicholas Piggin , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , "linux-kernel@vger.kernel.org" , linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 1, 2018 at 2:54 PM, Gautham R Shenoy wrote: > Hi Balbir, > > Thanks for reviewing the patch! > > On Fri, Jun 01, 2018 at 12:51:05AM +1000, Balbir Singh wrote: >> On Thu, May 31, 2018 at 10:15 PM, Gautham R. Shenoy > > [..snip..] >> > >> > +static u64 get_snooze_timeout(struct cpuidle_device *dev, >> > + struct cpuidle_driver *drv, >> > + int index) >> > +{ >> > + int i; >> > + >> > + if (unlikely(!snooze_timeout_en)) >> > + return default_snooze_timeout; >> > + >> > + for (i = index + 1; i < drv->state_count; i++) { >> > + struct cpuidle_state *s = &drv->states[i]; >> > + struct cpuidle_state_usage *su = &dev->states_usage[i]; >> > + >> > + if (s->disabled || su->disable) >> > + continue; >> > + >> > + return s->target_residency * tb_ticks_per_usec; >> >> Can we ensure this is not prone to overflow? > > s->target_residency is an "unsigned int" so can take a maximum value > of UINT_MAX. tb_ticks_per_usec is an "unsigned long" with a value in > the range of 100-1000. The return value is a u64. The product of > s->target_residency and tb_ticks_per_usec should be contained in u64. > Fair enough, looks reasonable to me Balbir Singh.