Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3868961ybf; Tue, 3 Mar 2020 14:37:42 -0800 (PST) X-Google-Smtp-Source: ADFU+vsVnZPDAuMVNkAHPxzrO/Tm9fK1DsjjWY8s7+8MVyXafCBEyEwmBVRa3zcityP64ImfMWMC X-Received: by 2002:a05:6830:1684:: with SMTP id k4mr100339otr.75.1583275062586; Tue, 03 Mar 2020 14:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583275062; cv=none; d=google.com; s=arc-20160816; b=aEpxp9HyADhZQIaeI9IJpOPOghEizo+0JOaVsIjzz8BeBGBk2Y72OI/BSaa4Ky8Ag3 p3H7SMv/bxSkrgUsUUgAWPlNRFmsIocmOdU0LaJMBa//0HeNViZwhwPXEBC8JsKQy/KN 5dkMCyxJ/2ulY3bihIbtXjNyDFdTkeoXFJiTnu3ye1jk09IS+08+NtFL4LzfQ01dQWwf 9BbiTAza0IJsH9xaHBG268GcuNVUctvEDHMIK1YdAzjL8y7znbh3+o30mRj5GnWTkXES J7wmVns9GoeUTLIs3a2wW7sWNpAORzCVJf5WE3bJ24kIiVQUAI1QD+qMaEbU9zr3UW12 3x1A== 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 :in-reply-to:references:mime-version; bh=1gv3fyBKvtyX+tFFlzrOXFcsjJxt1T00icp5fgfMvZ8=; b=oV3+K8Ilcky75VoBPBz9eaxQLbLkRIIx32sz3vClzbHTLltAtnkhvTQ+LSWH7590Iu QcMO3t1gzdotgDbajSS7FPz1/BVFJ+UcNuNNX2SG7aOWfIVaHmWxrRRdLStAQ+5TfcA5 gwPVjF2HZRfLBPqcSmHUnUbkHpTyI4Khsrlr6vP1OG3ADR61eWrEKGzsEIgTnEY9vIig fVl7jsdIM+xBekymjn/LeqASIPhwnYOWQeKLyjzeeBOcPxRgl+AmiQojU+Lnx0xDC9KH booZNU+zOzhJ+W4mwp7uCITc2i4OngN/9bzFu+s5MpEL567g2QXaG5M4rOsSXEth6V1f hNNQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 25si78622oiz.230.2020.03.03.14.37.29; Tue, 03 Mar 2020 14:37:42 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbgCCWhU (ORCPT + 99 others); Tue, 3 Mar 2020 17:37:20 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:34616 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbgCCWhU (ORCPT ); Tue, 3 Mar 2020 17:37:20 -0500 Received: by mail-oi1-f194.google.com with SMTP id g6so83863oiy.1; Tue, 03 Mar 2020 14:37:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1gv3fyBKvtyX+tFFlzrOXFcsjJxt1T00icp5fgfMvZ8=; b=oOfaQWgFCYaEFjIHZApWe2OSwRILLszc+u9Dbj6U1UC16VQ0ilatiPVZBOKkYwGzaB ROKNtAyhxhaNKbvhlPHqvGREysbnPpJVCcT39cTUufzI19TbcPP28iWz5TxyWMm8d9zM kJqV9bb5fANx5pTtrDeMYBY29ojjI998GsfOJWW47StCm7gEqnk45Y4zG5xQWYy5dLE0 9ebX/9ccYKOxHNb5SvpGKLq64ZwMwHJ5gf3rZyg0OqjAiOhr39p4l5lLCdxMcjc9nkSI kv0dgJjG5jRlZyCtPWgXo1w7vqVxUG9JCcg/h6dAXIzjDUjMGa3vw/ZsxJy/rG7p7JKa JgEw== X-Gm-Message-State: ANhLgQ0IQBhDGvLooqHspKZbsb314fA/rRD4EXj+q9C6pqvVbj0vL4W4 spgaIDqsCHWwf/3u83oZzzwZ2hkvEI7aLTgxYIA= X-Received: by 2002:aca:bfc2:: with SMTP id p185mr566616oif.57.1583275038372; Tue, 03 Mar 2020 14:37:18 -0800 (PST) MIME-Version: 1.0 References: <20200226015813.987-1-cai@lca.pw> In-Reply-To: <20200226015813.987-1-cai@lca.pw> From: "Rafael J. Wysocki" Date: Tue, 3 Mar 2020 23:37:07 +0100 Message-ID: Subject: Re: [PATCH -next v2] power/qos: annotate data races in pm_qos_*_value To: Qian Cai Cc: "Rafael J. Wysocki" , Marco Elver , Linux PM , Linux Kernel Mailing List 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 Wed, Feb 26, 2020 at 2:58 AM Qian Cai wrote: > > The target_value field in struct pm_qos_constraints is used for lockless > access to the effective constraint value of a given QoS list, so the > readers of it cannot expect it to always reflect the most recent > effective constraint value. However, they can and do expect it to be > equal to a valid effective constraint value computed at a certain time > in the past (event though it may not be the most recent one), so add > READ|WRITE_ONCE() annotations around the target_value accesses to > prevent the compiler from possibly causing that expectation to be unmet > by generating code in an exceptionally convoluted way. > > Signed-off-by: Qian Cai > --- > > v2: borrow the commit log from Rafael. > > kernel/power/qos.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/power/qos.c b/kernel/power/qos.c > index 32927682bcc4..db0bed2cae26 100644 > --- a/kernel/power/qos.c > +++ b/kernel/power/qos.c > @@ -52,7 +52,7 @@ static DEFINE_SPINLOCK(pm_qos_lock); > */ > s32 pm_qos_read_value(struct pm_qos_constraints *c) > { > - return c->target_value; > + return READ_ONCE(c->target_value); > } > > static int pm_qos_get_value(struct pm_qos_constraints *c) > @@ -75,7 +75,7 @@ static int pm_qos_get_value(struct pm_qos_constraints *c) > > static void pm_qos_set_value(struct pm_qos_constraints *c, s32 value) > { > - c->target_value = value; > + WRITE_ONCE(c->target_value, value); > } > > /** > -- Applied as 5.7 material, thanks!