Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp934444imm; Wed, 6 Jun 2018 08:03:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKjMmTriYqF3NCPcHspdBOOMm5mJH7EJ7XzL3wLknPZj+4oGMcr2i8+7oojWbcxv0L5dGJU X-Received: by 2002:a17:902:a703:: with SMTP id w3-v6mr3680956plq.111.1528297414974; Wed, 06 Jun 2018 08:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528297414; cv=none; d=google.com; s=arc-20160816; b=a1yTXJ6zQTKQEcb+oJXFyJd+HcWPJ8gkT6qcWEYpLw+GqOUhOdYdVAZUVN1zTBof1X M0fF17V6CgC9Wo7yHnRrl2e8ykZ6zrXQVRzisDGlHjypk/SmWJ/q7a3ijIW+Qgrdyk4K ijgvgd6YnCKkYPARXyv8t9Bje4rtWbEPtwm/gay9baXENZUeAHTyGWI/puuToDby7KHG g//rzoryf480mfmjH4ByIbz2dBswl3kV2FJ0lg/Bt/+3LifUzJK1ZItQt5lcDdzsMl6q ogok2UNLhYsdBa2n/xSpbx4WtW4EbwA0eF25uAC7fFDNF+b8lfFuqRZi2P0kt3pn/2+J gz2Q== 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=tw737N+h9UIi9EpgjXkYpEVDtQ2179tUiHRPYTdvjd0=; b=PDMmRJezqNrmKLBtaSZ+c4VPGgWO9DfesAXHok3qwBVu/48CNippCFinDvN6Vneohh O8QdgHoFrLhg8On6vdALT7TkPrSo+kpjGhMLty7Dr82PQ52UHeehD3v5Cof/TKYkQZx5 YrFe8mXZ/5F0LhCMDA9WWo7QJ4PYIhlDTmJGb3TiEHdkFo+MVFwoL/O9Of9A1vtdn0+G lEHXSonMggUl6CJD/7ZbM9rqNd94AQal9XFbosOnGX/zidSY3PuUw13d8CU95qHvgQeq psMO7i6knuwgPcht2yjiKbHJkzVf9SK4Eg1vi3LwOSKt0e2VvLNRwE1dFVuYl7ImDdSa kSew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fyZ9Ya0F; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j5-v6si2426839pfb.244.2018.06.06.08.03.17; Wed, 06 Jun 2018 08:03:34 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fyZ9Ya0F; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752303AbeFFPCM (ORCPT + 99 others); Wed, 6 Jun 2018 11:02:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49286 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbeFFPCL (ORCPT ); Wed, 6 Jun 2018 11:02:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tw737N+h9UIi9EpgjXkYpEVDtQ2179tUiHRPYTdvjd0=; b=fyZ9Ya0F1QaAmah+XnG3MD/E6 MzgqESVTEZueNuzH9nORAm50QJEaPnIPGoHUd3/SP4SaW22j1DiHwHtq7QHJ89OXJuWdXMBZXxnVC pe14un78O2jXVN00BWhyUeAekr4gwuicDH77XOjuPIpxrZEhfx6hw5NA4gSyRdWPcrcKbBVVvEywJ 4ihFOgW2vldvFcKhc2FYhlYzImZvdLtjP2WtsbyNqn9NlJBFwtGSrHbMswNb4DK19hEfl9wz/W2YA 0Z1aNnU5sUAD667gWAGDX/hAb8qM5es//0NFWlveDFcV0RVA1Jqcfy6SJotCPSqcpcGCTlZrNBT2d STLE27NOg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQZws-0000TB-2l; Wed, 06 Jun 2018 15:02:06 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A530A201EA7AB; Wed, 6 Jun 2018 17:02:03 +0200 (CEST) Date: Wed, 6 Jun 2018 17:02:03 +0200 From: Peter Zijlstra To: Daniel Lezcano Cc: rjw@rjwysocki.net, linux-kernel@vger.kernel.org, Viresh Kumar , Eduardo Valentin , Javi Merino , Leo Yan , Kevin Wangtao , Vincent Guittot , Rui Zhang , Daniel Thompson , "open list:POWER MANAGEMENT CORE" Subject: Re: [PATCH V5] powercap/drivers/idle_injection: Add an idle injection framework Message-ID: <20180606150203.GE12180@hirez.programming.kicks-ass.net> References: <1528190208-22915-1-git-send-email-daniel.lezcano@linaro.org> <20180606122357.GN12258@hirez.programming.kicks-ass.net> <22f5cf0b-049e-7938-55f6-4b4b154f8389@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22f5cf0b-049e-7938-55f6-4b4b154f8389@linaro.org> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 06, 2018 at 03:42:08PM +0200, Daniel Lezcano wrote: > On 06/06/2018 14:23, Peter Zijlstra wrote: > > On Tue, Jun 05, 2018 at 11:16:40AM +0200, Daniel Lezcano wrote: > >> + atomic_t idle_duration_ms; > >> + atomic_t run_duration_ms; > > > >> + idle_duration_ms = atomic_read(&ii_dev->idle_duration_ms); > > > >> + run_duration_ms = atomic_read(&ii_dev->run_duration_ms); > > > >> + atomic_set(&ii_dev->run_duration_ms, run_duration_ms); > >> + atomic_set(&ii_dev->idle_duration_ms, idle_duration_ms); > > > >> + *run_duration_ms = atomic_read(&ii_dev->run_duration_ms); > >> + *idle_duration_ms = atomic_read(&ii_dev->idle_duration_ms); > > > >> + if (!atomic_read(&ii_dev->idle_duration_ms)) > > > >> + if (!atomic_read(&ii_dev->run_duration_ms)) > > > > What is the point of atomic_t here ?! > > idle_duration and run_duration can be changed from different places at > the same time. The atomic is here to ensure the read/write are consistent. > > Do you think it is pointless ? Yes, atomic_read() / atomic_set() are no more atomic than READ_ONCE() / WRITE_ONCE().