Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3354478imu; Sun, 11 Nov 2018 13:04:48 -0800 (PST) X-Google-Smtp-Source: AJdET5eaJB60T/nt/IWhGHK/4ann4Ayh70DFn5rYBAsbK8mo0lTrUZIDjzt58O4jK2EIqxnEvg9N X-Received: by 2002:a63:5026:: with SMTP id e38mr15230669pgb.123.1541970288853; Sun, 11 Nov 2018 13:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541970288; cv=none; d=google.com; s=arc-20160816; b=WX84vkabkXqBTpzR3prc9Jpy8g6w8z4HC1LPTcj/6QF3Z0K9fvK17YtD2bWllpvloZ OpieAg1lz1KXjDFFWBOjlNCgO36awAS3bz10Y9U7E5yUFVll94w6mukHRW6WNIdMLBxl S3Fs59H3ETy1giBe+gRCmFrezSYbCoD9dyX4nPlmoCFiMN9k6L/+RMMKdnayJBwzPNaF 5vqRfDIEhRA5USwU+E88eDBAemvIRncPsCeDJ02Ayq8IKn0nbdQhcUBEiyaDpryTpj4y yAdShcek2nFYMr1EC7hvjfKDu0Id2qqJJg+Ilcpuxu7YTL6GnEK/uN585GjvPjeBTkZM S5VQ== 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; bh=VtZLvi1i5i3/o6eED3xQ7YUlWUIzrxTzRo49NWMIPl0=; b=L43vBcWSHiHBLNP+TApfgTg38Qru7AJ80HppX9tBnTLZb4X5prT4xtdB/gNzh4fG1t RKvE/NRcunxoSqHRndBXjVFXg5HQeauNByQKuiaO+tUx3zbqnWobpWaWDsUskn5k9q50 iDwE/JJfkNCM6Yo35X4adx7UvfIblQtOFko8y4Hv1wNrTI5Xa6SrgnLFtDd8JmG+CjN6 puoZgvmVfOIUVtZr6Y0oTENn2Vltks/2sp96Jzk01vzBr/ueBJpmdmo/AJ+FrymRhYym nq2JRp1y0rKVHeQ46RtMXNcndS1b54BuPOsjrJRxoSdgVBjik3/MiBNvCukWfFibKi2S RzMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=BF+0meAT; 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 o27si14701392pgl.53.2018.11.11.13.04.32; Sun, 11 Nov 2018 13:04:48 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=BF+0meAT; 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 S1729730AbeKLGxv (ORCPT + 99 others); Mon, 12 Nov 2018 01:53:51 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45126 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbeKLGxv (ORCPT ); Mon, 12 Nov 2018 01:53:51 -0500 Received: by mail-pl1-f195.google.com with SMTP id r3-v6so2548501pls.12 for ; Sun, 11 Nov 2018 13:04:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VtZLvi1i5i3/o6eED3xQ7YUlWUIzrxTzRo49NWMIPl0=; b=BF+0meATvt4cio6Aad5ANop2mxZRAkQUBR9fjhIADx4dZyihP9J5ZpGXTAAc2WaKNf R6vbOPjsliYxRk/xolYzL4w7TkJ42m/1Tz7BNaWDDc2WveUnprkrFsDW0PzpKRDi4/pr jVvq74oGWr7r552+NN7cRZQVuDx/1dL6MmU34= 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=VtZLvi1i5i3/o6eED3xQ7YUlWUIzrxTzRo49NWMIPl0=; b=mwyzCexlMuDsT2cP/ArvmXBxZOkwxQE78xnS+MMMQJvoPJ4T0v4ar3zbcHd9A7c3ke RFoXCmN1O7CGVi/hDs9lCWyqkDLoLnpNG58ZWo0ICmSyn+b5fUql2miTNAlwSdQBpKfN 5a0EYPty4KotY8QjpteD9iMQ2gkVcslgzMAyy/qtaSA90krqR8gpeA9nhOzk75eRVkhz R0LxRA2hjv60JjN6Cc5/vtTC9CEgKEpbuoCMy673jAe3L2+8Kii2iphLCQofPHI9zNRw Nj2xZnLgrhmsu0ZFvFBv91uUrIcxdgzScQ9rhgpbYEbiYF4SV86dniWE42j+AmmYA92n FZIA== X-Gm-Message-State: AGRZ1gIN+qdlQaPG7eNy5g4Y6rygB26fMyHIM+UNTKPaaVR0Md0Edfj4 NmDc59LhUjJWLDlOCFt01X6OjQ== X-Received: by 2002:a17:902:110a:: with SMTP id d10-v6mr17531664pla.85.1541970250658; Sun, 11 Nov 2018 13:04:10 -0800 (PST) Received: from localhost ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id a16-v6sm323526pfh.107.2018.11.11.13.04.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Nov 2018 13:04:09 -0800 (PST) Date: Sun, 11 Nov 2018 13:04:08 -0800 From: Joel Fernandes To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com Subject: Re: dyntick-idle CPU and node's qsmask Message-ID: <20181111210408.GA85122@google.com> References: <20181110214659.GA96924@google.com> <20181110230436.GL4170@linux.ibm.com> <20181111030925.GA182908@google.com> <20181111042210.GN4170@linux.ibm.com> <20181111180916.GA25327@google.com> <20181111183618.GY4170@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181111183618.GY4170@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 11, 2018 at 10:36:18AM -0800, Paul E. McKenney wrote: [..] > > > > > CPU will with high probability report its own quiescent state before three > > > > > jiffies pass, in which case the cache misses on the rcu_data structures > > > > > would be wasted motion. > > > > > > > > If all the CPUs are busy and reporting their QS themselves, then I think the > > > > qsmask is likely 0 so then rcu_implicit_dynticks_qs (called from > > > > force_qs_rnp) wouldn't be called and so there would no cache misses on > > > > rcu_data right? > > > > > > Yes, but assuming that all CPUs report their quiescent states before > > > the first call to rcu_gp_fqs(). One exception is when some CPU is > > > looping in the kernel for many milliseconds without passing through a > > > quiescent state. This is because for recent kernels, cond_resched() > > > is not a quiescent state until the grace period is something like 100 > > > milliseconds old. (For older kernels, cond_resched() was never an RCU > > > quiescent state unless it actually scheduled.) > > > > > > Why wait 100 milliseconds? Because otherwise the increase in > > > cond_resched() overhead shows up all too well, causing 0day test robot > > > to complain bitterly. Besides, I would expect that in the common case, > > > CPUs would be executing usermode code. > > > > Makes sense. I was also wondering about this other thing you mentioned about > > waiting for 3 jiffies before reporting the idle CPU's quiescent state. Does > > that mean that even if a single CPU is dyntick-idle for a long period of > > time, then the minimum grace period duration would be atleast 3 jiffies? In > > our mobile embedded devices, jiffies is set to 3.33ms (HZ=300) to keep power > > consumption low. Not that I'm saying its an issue or anything (since IIUC if > > someone wants shorter grace periods, they should just use expedited GPs), but > > it sounds like it would be shorter GP if we just set the qsmask early on some > > how and we can manage the overhead of doing so. > > First, there is some autotuning of the delay based on HZ: > > #define RCU_JIFFIES_TILL_FORCE_QS (1 + (HZ > 250) + (HZ > 500)) > > So at HZ=300, you should be seeing a two-jiffy delay rather than the > usual HZ=1000 three-jiffy delay. Of course, this means that the delay > is 6.67ms rather than the usual 3ms, but the theory is that lower HZ > rates often mean slower instruction execution and thus a desire for > lower RCU overhead. There is further autotuning based on number of > CPUs, but this does not kick in until you have 256 CPUs on your system, > and I bet that smartphones aren't there yet. Nevertheless, check out > RCU_JIFFIES_FQS_DIV for more info on this. Got it. I agree with that heuristic. > But you can always override this autotuning using the following kernel > boot paramters: > > rcutree.jiffies_till_first_fqs > rcutree.jiffies_till_next_fqs > > You can even set the first one to zero if you want the effect of pre-scanning > for idle CPUs. ;-) > > The second must be set to one or greater. > > Both are capped at one second (HZ). Got it. Thanks a lot for the explanations. > > > > Anyway it was just an idea that popped up when I was going through traces :) > > > > Thanks for the discussion and happy to discuss further or try out anything. > > > > > > Either way, I do appreciate your going through this. People have found > > > RCU bugs this way, one of which involved RCU uselessly calling a particular > > > function twice in quick succession. ;-) > > > > Thanks. It is my pleasure and happy to help :) I'll keep digging into it. > > Looking forward to further questions and patches. ;-) Will do! thanks, - Joel