Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1017951imm; Wed, 18 Jul 2018 15:04:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcikzqBsDtF0CpowtLfelw8hmPJr1ySi6YjOGZzclYiHjxrgiP0FWM61Ls32ixf5Z/V/Sv5 X-Received: by 2002:a65:62ce:: with SMTP id m14-v6mr7356444pgv.407.1531951467668; Wed, 18 Jul 2018 15:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531951467; cv=none; d=google.com; s=arc-20160816; b=gZmm1FINCEhfyzn08Usr9ObuFCFPvL6eZvVAyi1jlQVk78qPzTqZFbI4BMO0+S7ucY JH5vwAxqsvalZpS2iZfeiTPEPhefzSBIM3MhPPAJT9mAKEbinTxEZJZK+NBpEJtymk9t mTCiqeqtXUt3ElYp8G7GJkkK/wN/zVz7JDfimIyMd+NKFTY+ueZ3KZjx0HUsQwOKpaza lOlhFLgrM8Fi6J1UHyXcqiOVFWwyx4KneRWqhALjjzPYZxPqxAn4XNfYrHeuxDjtgHO/ 9ZsMX9dngu0WNmH7cxZxg3lxQL5bsmK630Oh/Fjy+cHWRzZLP/7o4ztIaA1Z0ZsKpoiO 9rlQ== 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=wu822VWfbxTbIiJttkXqPEdGO8iaFFkoHKb0MR6LUhQ=; b=TWnJ4c+Yy7Y/pnrepjeIorz93GO+dVT0W0wrlwRSyXuStIEv8a+NwKY+FztE1b8I2i s13SYFfa/aLZ26lBu1rvOObORZVm5yzFh+oRgcW11lXuXVEepJi5kMn3YFMuR9qD0zZo /FMjrIjioKaBrxsZKFumLNqvwTi1JsrMl7Elbp5W9rGUnrrAuEuKVJ5m20uigA8+C3Hh zxL/IpLVvsOhtGkQ9Pc3+nczWOBz/McgnQQ5cpo92BWiX/MWzMcD9C05XoR8xIpVkgnD 6xfMf86YdsvcXCIJ407QnHSVK2KxBxRYn66HjADx3zFsTPf0PFhYUthKC7Lbhu5rl1HR l4NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=GJhavJ1C; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4-v6si4413619pgc.284.2018.07.18.15.04.13; Wed, 18 Jul 2018 15:04: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=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=GJhavJ1C; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729250AbeGRWnd (ORCPT + 99 others); Wed, 18 Jul 2018 18:43:33 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:40304 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727635AbeGRWnd (ORCPT ); Wed, 18 Jul 2018 18:43:33 -0400 Received: by mail-yw0-f194.google.com with SMTP id p129-v6so2318958ywg.7 for ; Wed, 18 Jul 2018 15:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wu822VWfbxTbIiJttkXqPEdGO8iaFFkoHKb0MR6LUhQ=; b=GJhavJ1CI0+lP0q3vonS3J1NpNHq1O0CDD50W8RtXWgK4ObbI+Qy65zeAny1IoopKz v2ufUHT03j4UlOJ0suI5T9mNRHmb9JggsFTdW3mwvtvmfBcYAY4j/eDflE6K1HkNnlcU uaIwZZ6AqIekkTX8a3jmHWli+PO64rvro6ZmvO6MhmKMvvuRInQuHEfV1cbZHUuvCcqX mgaSYVygsyr+VTBMJBBYg+SsxPDPb/Zv3xU41Q/fCuPtjgjtJdEStOQ+uhHE5jJcZ2p5 DSS/VyrFd32GjrxEGrRJ2LHiAbNkKwU1fQVsiaBPjc98XodWakZjcIal0EzvPnwwooaS oo9A== 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=wu822VWfbxTbIiJttkXqPEdGO8iaFFkoHKb0MR6LUhQ=; b=LyTW16Ng5gAahV61mzNR6n3tB7zM4BS8wZyYbp+FBebbre6wbxw85R8pzAYS7FM5K4 GwsOTpptzqWyMM8Z3nuMF/UfoZ4XK5zHHccxbMwwNMZ71Dq1pMQ03wMLiyuCeeIKi8w9 DrJIaAVGtSnD79yxgjYwoSI6+CDsnKPeJYyCsOao+dbmnWCrxmaA98H/vdWpdG+2pqNz EOOPTqerm28wh99SFuFVOvmJmNnFdQBGtlu31mXzLKIvfYxhyTnwC1PTicmI8lgCjp0h AjNVTOVg5g9N4c/nrqfb9Bf7LDCn9gYFEoVMatIqYdfWIfKIPPYdlKxU5htco8/zM89p ki8g== X-Gm-Message-State: AOUpUlEFIWz/ksQ0jVpqTO0sPauaAOtPzG7Xjef6CMEVrpYwFriL4tx0 pVsqH3oocXHF1Sc/0r5wPUQclw== X-Received: by 2002:a81:7742:: with SMTP id s63-v6mr4178720ywc.197.1531951417909; Wed, 18 Jul 2018 15:03:37 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::2:7eca]) by smtp.gmail.com with ESMTPSA id o81-v6sm2120860ywb.76.2018.07.18.15.03.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Jul 2018 15:03:36 -0700 (PDT) Date: Wed, 18 Jul 2018 18:06:23 -0400 From: Johannes Weiner To: Peter Zijlstra Cc: Ingo Molnar , Andrew Morton , Linus Torvalds , Tejun Heo , Suren Baghdasaryan , Vinayak Menon , Christopher Lameter , Mike Galbraith , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH 08/10] psi: pressure stall information for CPU, memory, and IO Message-ID: <20180718220623.GE2838@cmpxchg.org> References: <20180712172942.10094-1-hannes@cmpxchg.org> <20180712172942.10094-9-hannes@cmpxchg.org> <20180717150142.GG2494@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180717150142.GG2494@hirez.programming.kicks-ass.net> 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, Jul 17, 2018 at 05:01:42PM +0200, Peter Zijlstra wrote: > On Thu, Jul 12, 2018 at 01:29:40PM -0400, Johannes Weiner wrote: > > +static bool psi_update_stats(struct psi_group *group) > > +{ > > + u64 some[NR_PSI_RESOURCES] = { 0, }; > > + u64 full[NR_PSI_RESOURCES] = { 0, }; > > + unsigned long nonidle_total = 0; > > + unsigned long missed_periods; > > + unsigned long expires; > > + int cpu; > > + int r; > > + > > + mutex_lock(&group->stat_lock); > > + > > + /* > > + * Collect the per-cpu time buckets and average them into a > > + * single time sample that is normalized to wallclock time. > > + * > > + * For averaging, each CPU is weighted by its non-idle time in > > + * the sampling period. This eliminates artifacts from uneven > > + * loading, or even entirely idle CPUs. > > + * > > + * We could pin the online CPUs here, but the noise introduced > > + * by missing up to one sample period from CPUs that are going > > + * away shouldn't matter in practice - just like the noise of > > + * previously offlined CPUs returning with a non-zero sample. > > But why!? cpuu_read_lock() is neither expensive nor complicated. So why > try and avoid it? Hm, I don't feel strongly about it either way. I'll add it. > > + /* total= */ > > + for (r = 0; r < NR_PSI_RESOURCES; r++) { > > + do_div(some[r], max(nonidle_total, 1UL)); > > + do_div(full[r], max(nonidle_total, 1UL)); > > + > > + group->some[r] += some[r]; > > + group->full[r] += full[r]; > > group->some[r] = div64_ul(some[r], max(nonidle_total, 1UL)); > group->full[r] = div64_ul(full[r], max(nonidle_total, 1UL)); > > Is easier to read imo. Sounds good to me, I'll change that.