Received: by 10.213.65.68 with SMTP id h4csp249146imn; Mon, 26 Mar 2018 20:45:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx48qMCBQKvhxJznUEK0CF8LboPAw/CQB6h52r3LBMz2PEnalgdDsq8aVUh2mULyvuUcfGlwf X-Received: by 2002:a17:902:7084:: with SMTP id z4-v6mr5173499plk.395.1522122304572; Mon, 26 Mar 2018 20:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522122304; cv=none; d=google.com; s=arc-20160816; b=F0AtdrkDuO/OuqEXuorC96hZFmi1Oe7UHm78d1i7rpD7wD3dVpUuomGUrXpBOKe6Wt +rwFQggwNK35jvmmC0ajRbbmuoFXVaxNnb3g1xMx+TYGMXs5xIclnNcVpfX9i/bTdJ+f xxoKO8lKaIRuFEWgfhSt9htHWxUuwA9WI7nfUZl8k7y45KHCT7aSIY49VZNuZQI7ebvM XB44ESWDjg2BAy8rKT6qpARHEhV8nsKqyx4dy4uyWnn4ZRYj32OTHxk9CXWaPTG26BGV 7oMU5VDPNCDb7XhscoNVO9Mi4Dxjdd6Wd9vbtNgDuLOqKmegYazVJzoFpcKdZ/jlNck2 OsmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=aBs75fSUHFug4GRiHgq1xYTqxxduxVAJpRVORGcnb7Q=; b=trGfLmfMZmjFvs6jUSvVVFTxx1Rz1Zl8ZkMGQXWjY8ZSU0EkfWZ1tIIOGFdMBWse7S mj24sz8ZZYDRJCadrVlzsO942va/cHm7ykfrfAT3kaKxtsoNS1yNOwwg26oQfLJL4YaK /PfBOLVNMpK+0DriUsx2ePoDyKuhsWrmj9GlbEJkXdCb418cjrZ0S0sjWA/MTOCB+eaM YhgDDONlNofb//weNJFKB3vXAeBNOmSzemAFGPclTUbeCO9wHa4dJgWOziVt2AKgc9oA FvwGrGjGKi8XPwct/jBqBjJZPfTiVhYhDuzIcqunNDLFgDAkEcN0VY/a9+YMzAsCvwlX D6VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MSPp2++u; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si251827pff.146.2018.03.26.20.44.49; Mon, 26 Mar 2018 20:45:04 -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=@linaro.org header.s=google header.b=MSPp2++u; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbeC0Dnz (ORCPT + 99 others); Mon, 26 Mar 2018 23:43:55 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33454 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751489AbeC0Dnx (ORCPT ); Mon, 26 Mar 2018 23:43:53 -0400 Received: by mail-wr0-f193.google.com with SMTP id z73so20885549wrb.0 for ; Mon, 26 Mar 2018 20:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aBs75fSUHFug4GRiHgq1xYTqxxduxVAJpRVORGcnb7Q=; b=MSPp2++upQCjB8idac59rE+fJ3oASUyyS1xAQw9XXDgqU1sRhvQl0phosClXW2ZkAC UrLk+i7ZloUN50bYQpbm5KdQNph+qiQx9u2NRSc5ig8Y/vzSmL+qCBkA4OKlv74dJpXj XGeSdwOSX9JUHLVJs9dV+ZQiMx0+RqTIxHw0g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aBs75fSUHFug4GRiHgq1xYTqxxduxVAJpRVORGcnb7Q=; b=j5R6G1CNFJLvF3+reWitPRN5dNW2knQ7J8bR1V5Qh0xYxu9ZuiXrx+tChDbiFBqye1 8XW6JV+PDoRFUxwHlC/cNKflRlYnyWA8jhmIHW5HrXZo7SoJUK5sDzTHiczRz3/rXOvC bwvF00Ql4NDvLB5TBpPCROkfs2buG4z9eAiN+mCHqltN1NBer0OcalVAmNNEvrqyS/wk gALacrf53I8BF60Ge3imZ13Dh4pt9Z/kqoAyv5pHt452onejxTgimwyEt0MksjBIbYPC L9NhWZTZOG6CioBNDzgPwLInKa1JsItfXqrvJlBuQYT00SIOxc2lzGGVV8qkRUt+Jm92 pu2g== X-Gm-Message-State: AElRT7EcZ+kT/qrTM2I7yeMMcs6EU8cIalWQ+VrrzxGYPj7axa1/tUwI OcveXwcs9+qQ69ekHOMecB1dGg== X-Received: by 10.223.176.98 with SMTP id g31mr31905110wra.256.1522122232701; Mon, 26 Mar 2018 20:43:52 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li622-172.members.linode.com. [212.71.249.172]) by smtp.gmail.com with ESMTPSA id b38sm537558wrg.81.2018.03.26.20.43.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 20:43:51 -0700 (PDT) Date: Tue, 27 Mar 2018 11:43:44 +0800 From: Leo Yan To: Daniel Lezcano Cc: Viresh Kumar , edubezval@gmail.com, kevin.wangtao@linaro.org, vincent.guittot@linaro.org, amit.kachhap@gmail.com, linux-kernel@vger.kernel.org, javi.merino@kernel.org, rui.zhang@intel.com, daniel.thompson@linaro.org, linux-pm@vger.kernel.org Subject: Re: [PATCH V2 6/7] thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver Message-ID: <20180327034344.GC21693@leoy-ThinkPad-X240s> References: <1519226968-19821-1-git-send-email-daniel.lezcano@linaro.org> <1519226968-19821-7-git-send-email-daniel.lezcano@linaro.org> <20180223073432.GF26947@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 23, 2018 at 12:28:51PM +0100, Daniel Lezcano wrote: > On 23/02/2018 08:34, Viresh Kumar wrote: > > On 21-02-18, 16:29, Daniel Lezcano wrote: > [ ... ] > > >> +static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev) > >> +{ > >> + s64 next_wakeup; > >> + int state = idle_cdev->state; > >> + > >> + /* > >> + * The function must never be called when there is no > >> + * mitigation because: > >> + * - that does not make sense > >> + * - we end up with a division by zero > >> + */ > >> + BUG_ON(!state); > > > > As there is no locking in place, we can surely hit this case. What if > > the state changed to 0 right before this routine was called ? > > > > I would suggest we should just return 0 in that case and get away with > > the BUG_ON(). Here if 'state' equals to 0 and we return 0, then the return value will be same with when 'state' = 100; this lets the return value confused. I think for 'state' = 0, should we return -1 so indicate the hrtimer will not be set for this case? Thanks, Leo Yan