Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp215663imm; Wed, 22 Aug 2018 02:56:27 -0700 (PDT) X-Google-Smtp-Source: AA+uWPydkWzZghrUDj0era1RNj/ieBEEJ/LMpSzCO6pYA2jWUrTXhKlZ8ug7LVcWOsPBIYyGJ6hJ X-Received: by 2002:a65:4849:: with SMTP id i9-v6mr50372252pgs.350.1534931787100; Wed, 22 Aug 2018 02:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534931787; cv=none; d=google.com; s=arc-20160816; b=sGPNwObv2AwN0k7UZ7ZS63w9/OwP0yMAdtIZqtNhzhZGwKC6mUR4H2KGQaDLpD3xa/ xMynMz+u7UzUub4MNPAmHlV/Dh+ZlcMD+1jpYzr8PaNbmDTeBth3mEeoxXoLRxHXjTwc MXOup4lYsi4ew2ySBt+UJT+0zRZ0KVGlzJN9aS2FK46OB0okLEe00ZgjglcVsmSHYFZF AIIN0RAnn9bpVphiDul9D3rt36KlkRxi+urBN8AX0HYqPwsRLbWD3QNXW8W0TolTzhzh l9plDAx0TDXUxGSY1QtCzCD/4MbvPNG4N0gRy5CPPvInzd2+0wWthPC93UruYWd4dc3r 5L7w== 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=YbdDDn0LmMntOvsDynUtkB+mSIAFRIE4RGQzJvC3h5Q=; b=oMlBusroKFkJPNxVwgOFdLK9mLLvGKwpOD5zcxbUogCciOkugsRQkZbZi0n+PmTZQJ DZ1WA1JPYlnSzoaUtT/hoEGtNvzeZd1bcxl2BVn+2qnFQzj4fmHpyjJPy39k6+CVJc4i q7Crb5+3dzll2pxS3Udp0BWWZ33r1m5M2Ce8rM98ks9MbCTMzzuhrBUjnZqWJnsv66HY 8COV4uVITVM09HFUfveRZrdBQ+Lf+5MYjBJ5jXJQu24lbOo53Vi8cdQdBkW9tDWfiKSs a6uLVgY3AqDh9ZSqp3bmfzDDj+wK6QF9z8dXs63iERpJSCpKG8+J+XYFhfL31QaqgsS1 QvJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jSiz0SUq; 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 31-v6si1241290pli.238.2018.08.22.02.56.11; Wed, 22 Aug 2018 02:56:27 -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=jSiz0SUq; 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 S1728594AbeHVMef (ORCPT + 99 others); Wed, 22 Aug 2018 08:34:35 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54436 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728208AbeHVMee (ORCPT ); Wed, 22 Aug 2018 08:34:34 -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=YbdDDn0LmMntOvsDynUtkB+mSIAFRIE4RGQzJvC3h5Q=; b=jSiz0SUqgjqtYAL67S8Lqar0i p0b7Y7CW10WpXS0NNVGlBubKM8EeCLv1Jaaou8dQCVTcElzguUN/Qs0+SlAHfcnF/mIHfVGmqsyLT s93/sZxhQwWIwqwVs7MNBaOsFZm5hyd6ROK5gaL2lOBo982Ww+U0YqRMmdSV9UarpPQfzV6XNWn6m 0Nqq20kfiGNXzjtfK3hvjtA3dUXVqMMne8QJ4AijNqnL2KzK8YneUDZ8Yi9wiC2eZE6cOJYRs+rgo SMdhHO15+3XIi073bSguMNAihmCZ709twxhLzv26WYHo5bMKi3vPi+YOwbljVTFkyYzXRxRTHssL2 Q7dTgWu/g==; 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 1fsP9l-0003D6-Ss; Wed, 22 Aug 2018 09:10:26 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 25FD42025D75D; Wed, 22 Aug 2018 11:10:24 +0200 (CEST) Date: Wed, 22 Aug 2018 11:10:24 +0200 From: Peter Zijlstra To: Johannes Weiner Cc: Ingo Molnar , Andrew Morton , Linus Torvalds , Tejun Heo , Suren Baghdasaryan , Daniel Drake , Vinayak Menon , Christopher Lameter , Mike Galbraith , Shakeel Butt , Peter Enderborg , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 8/9] psi: pressure stall information for CPU, memory, and IO Message-ID: <20180822091024.GU24124@hirez.programming.kicks-ass.net> References: <20180801151958.32590-1-hannes@cmpxchg.org> <20180801151958.32590-9-hannes@cmpxchg.org> <20180803172139.GE2494@hirez.programming.kicks-ass.net> <20180821201115.GB24538@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180821201115.GB24538@cmpxchg.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 21, 2018 at 04:11:15PM -0400, Johannes Weiner wrote: > On Fri, Aug 03, 2018 at 07:21:39PM +0200, Peter Zijlstra wrote: > > On Wed, Aug 01, 2018 at 11:19:57AM -0400, Johannes Weiner wrote: > > > + time = READ_ONCE(groupc->times[s]); > > > + /* > > > + * In addition to already concluded states, we > > > + * also incorporate currently active states on > > > + * the CPU, since states may last for many > > > + * sampling periods. > > > + * > > > + * This way we keep our delta sampling buckets > > > + * small (u32) and our reported pressure close > > > + * to what's actually happening. > > > + */ > > > + if (test_state(groupc->tasks, cpu, s)) { > > > + /* > > > + * We can race with a state change and > > > + * need to make sure the state_start > > > + * update is ordered against the > > > + * updates to the live state and the > > > + * time buckets (groupc->times). > > > + * > > > + * 1. If we observe task state that > > > + * needs to be recorded, make sure we > > > + * see state_start from when that > > > + * state went into effect or we'll > > > + * count time from the previous state. > > > + * > > > + * 2. If the time delta has already > > > + * been added to the bucket, make sure > > > + * we don't see it in state_start or > > > + * we'll count it twice. > > > + * > > > + * If the time delta is out of > > > + * state_start but not in the time > > > + * bucket yet, we'll miss it entirely > > > + * and handle it in the next period. > > > + */ > > > + smp_rmb(); > > > + time += cpu_clock(cpu) - groupc->state_start; > > > + } > > > > As is, groupc->state_start needs a READ_ONCE() above and a WRITE_ONCE() > > below. But like stated earlier, doing an update in scheduler_tick() is > > probably easier. > > I've wrapped these in READ_ONCE/WRITE_ONCE. I just realized, these are u64, so READ_ONCE/WRITE_ONCE will not work correct on 32bit.