Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2920002imm; Fri, 20 Jul 2018 07:12:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdCPgtNsxvi4mPOP55Kf4k8tLO8FPAN94M3+XDaEhaDQyFwBaSvEX7u3OtAvOvuQgiFZ7Cm X-Received: by 2002:aa7:86d7:: with SMTP id h23-v6mr2392261pfo.132.1532095945304; Fri, 20 Jul 2018 07:12:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532095945; cv=none; d=google.com; s=arc-20160816; b=Pa8XbtBj/yIpsPYoCL6OQkVlW1VJkJbmB2YaUC5RDYmsDNLNZO4psFVAh72a0vmMvC XDxuHwt1z9+yvD9eNRpMzMI/GfPFGEdzLt5dENAiFKghHkqRG3B4ImDh0QBmid88fGER rUqu8OSUZLVJX2oZOBFoNQGhl0nIivqUfcQl0jRrJW+DIKGTTZdnTq0fiHN5eiQiRNtA ZH+MVcyF88aftQCPKtRJckuwIF5iKzycuM5pIj479RF9Agz7xcTaDqG9vpZjbV+W4BF0 UTb4a9upy6c1OCzMzNR9dsxLuxJgt6UoxKXW6hWCtTvBbnZX7774Alp741e/tTOnaRcI Kgpw== 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=1eKckAY6Q8yGz2v8taoR+58hqhVZAG5hgWuBNXgBA8U=; b=GPxsyaQHod9vt2kcJwVsvVhkHpLD/rdInhjNnFnWkfyXbtFL4ng2nGspntbXVxJUxE lk6CBZNw9bqPEVLQ1u6if2fpoRrV6MJXUzCH6XErRgQFUebmR5bWgu8y0yeGsTJB8H3Z s60w35h2EQ9p+ActqR9JLZh2evc2FW+IbozVOu93B4Jk1lPNubfi9IPeKTdh6c8NWwLw Yycl6ypFVsc1P4RfKyemd8Q3jERsFNCjMOOnvSAKkLXOlJwunaRGkc2wf0TRhMr3oldQ vtriX5y8lrwJE5dQ6rJCBZnnb+Hf+cgWbMpSLlSHhZqCIBJvUornj6gZmehrngfw0aC3 14JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=akk6uf5j; 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 p3-v6si1748049pld.408.2018.07.20.07.12.10; Fri, 20 Jul 2018 07:12:25 -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=akk6uf5j; 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 S1731986AbeGTO7g (ORCPT + 99 others); Fri, 20 Jul 2018 10:59:36 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:37276 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731203AbeGTO7g (ORCPT ); Fri, 20 Jul 2018 10:59:36 -0400 Received: by mail-qt0-f193.google.com with SMTP id n6-v6so5809359qtl.4 for ; Fri, 20 Jul 2018 07:11:08 -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=1eKckAY6Q8yGz2v8taoR+58hqhVZAG5hgWuBNXgBA8U=; b=akk6uf5jnv3Zy1VFcpTFGgNmaYsJXuDrFH5QUCroLeAF902e3LhFgsUOau+Rbmb69q pOsOnvJfUd61S6IgFhCdCenoMS2fG87oXUatq/Y/QVZ8cDIbJ/vM+qmZmmKnRXCkCfPJ goofJZTR1N1BD9ct9W7dcOxXr2Jw75gMl6EEGqseQIYZKSaJu7lUJLCSGbcZqSSL45eJ jUI0UgMryTmnFRX+6E4ZrC0OWt4mhwe6oHaF21QuAmnUds1FnsmJ3gJDCSBurlox4m98 zPRTBFzWh9dc0Cg0cfWx6B1UOFSf9Htl6afr6qx/At7erTcDqGGgB1l+O+R6lBNVeZAr a1qw== 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=1eKckAY6Q8yGz2v8taoR+58hqhVZAG5hgWuBNXgBA8U=; b=B79pjCWQhop3Y4pzAQGvJ7UXU2dTYxDUC1Pse9m3qTlxQZmJDuU8iK+LqPYFKcvI0R q/j3eUhcSTJ6ie51yQnLmpmmDEdlJRlaFQfOxGTgrDGwTUARuwIWKWRkz2I9Ee6NV9KN ynOmLQsgCmc5WEae/AJBJ27OjdpNJe2T6RWdHH1ODuK/QUo8rf6kHcuMUcOaX3TJMiIx A0qWv7XfsTw+lZ9mxoh8tzO7B89NvNQCtqtYILbyZ45fmQXri53zeSDL4usE8CpjOyl5 ucFMFdOfs1yKDQbuPoCm9oJySxEjipXPnRBU2mUk00j9BongCXPF5qve2V5A3kEUE1pE RAvA== X-Gm-Message-State: AOUpUlEu3VVTMqvjh8B6SgxPoIQT3G5Im1f/2NebSk8u+ljNZot7IeNn 8aORh1UnTTZENfSzq1ksmrSWeGYOmeI= X-Received: by 2002:aed:3803:: with SMTP id j3-v6mr2065466qte.353.1532095867530; Fri, 20 Jul 2018 07:11:07 -0700 (PDT) Received: from localhost (216.49.36.201.res-cmts.bus.ptd.net. [216.49.36.201]) by smtp.gmail.com with ESMTPSA id v129-v6sm1195039qkd.86.2018.07.20.07.11.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Jul 2018 07:11:06 -0700 (PDT) Date: Fri, 20 Jul 2018 10:13:54 -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: <20180720141354.GA1729@cmpxchg.org> References: <20180712172942.10094-1-hannes@cmpxchg.org> <20180712172942.10094-9-hannes@cmpxchg.org> <20180717150142.GG2494@hirez.programming.kicks-ass.net> <20180718220623.GE2838@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180718220623.GE2838@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 Wed, Jul 18, 2018 at 06:06:23PM -0400, Johannes Weiner wrote: > 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. Thinking more about it, this really doesn't buy anything. Whether a CPU comes online or goes offline during the loop is no different than that happening right before grabbing the cpus_read_lock(). If we see a sample from a CPU, we incorporate it, if not we don't. So it's not so much avoidance as it's lack of reason for synchronizing against hotplugging in any fashion. The comment is wrong. This noise it points to is there with and without the lock, and the only way to avoid it would be to do either for_each_possible_cpu() in that loop or having a hotplug callback that would flush the offlining CPU bucket into a holding place for missed dead cpu samples that the aggregation loop checks every time. Neither of these seem remotely worth the cost. I'll fix the comment instead.