Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3023599imm; Fri, 10 Aug 2018 02:22:14 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyGL2RrN4hYnRVnkjw/RSmV5VpYPml/2nKeaSKoatbvM/R/UBcuyFAla1L8aEr+B4SRby6+ X-Received: by 2002:a65:4384:: with SMTP id m4-v6mr5674879pgp.265.1533892934274; Fri, 10 Aug 2018 02:22:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533892934; cv=none; d=google.com; s=arc-20160816; b=O9RSCf7EkvkidalSDzI+KrQJXPW0yYDf1iy1zGy074Rjs+RDPDYWgJn/K4N+Vz3Ta6 1QW5N82ke6Mw/FijcESDkzlF+PeIhksYLYXzKzN5v+efxDWkAwnSeOTnMuai58x0uyYO N/suT+6GvreNPThyBE7kinty5iyVBVEgTmbANOEjfoI+Nqaw2oH8qcVp2TTUwQETz0XA Nhz3VzuHctLUW4j7X1nb2LOmbW8OACo66ZOjl+mJT202SV42X4xSWF3QeUgrP6E7t3+S JKVDXoqLRw+6SwVQgt8ASqTRbGggesDi64RaM/DBChL2bdFm2oHQXOQ1oxwh9SVvSUVq mwlA== 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=t8gXVZ5/MV7r48hJFU6RmmGuGoeboxqn6oRjSnS3SgU=; b=B4r/6k0884m3/M3OYMTRqKKaLHDkIgAqdkuvRc/gUV7zrbBgJoUqT2LoDb4l5AucCk mQDyV9We/l6k+jBaseZi0Nlj1JHtqrfRCO7exaL6yrGYacE346401m+Y9rKLNcZNST6/ ZJej4li5cKpkPEZ3src6WRHLA11v7GhEUt80cLXYHurrdMb6dWMDKYdACgt3GFwZT21p bjQHmBD513pKh+eQAAQr++OleczAaibYR7r56xke61k7NeUY4ZOdoULEpd2lbW/WhUHC SpDLXug2USTnHIKpyTYNX+5vkuOdmgZ9IfssSQmCHoYGHeLpyfdcPokqxuExRXMAgJp6 yKvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GqH/WRAS"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x63-v6si10295698pfb.299.2018.08.10.02.21.59; Fri, 10 Aug 2018 02:22:14 -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=@linaro.org header.s=google header.b="GqH/WRAS"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728007AbeHJLSO (ORCPT + 99 others); Fri, 10 Aug 2018 07:18:14 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:32975 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726997AbeHJLSN (ORCPT ); Fri, 10 Aug 2018 07:18:13 -0400 Received: by mail-wr1-f67.google.com with SMTP id g6-v6so7609282wrp.0 for ; Fri, 10 Aug 2018 01:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=t8gXVZ5/MV7r48hJFU6RmmGuGoeboxqn6oRjSnS3SgU=; b=GqH/WRASX9piKa83/i5c4EcnwW+WEZqGgavqZU+2e61ZFMUwUnpdBbc0pyQiy0qNDm C2WIcV2muhv6zBBodB/OAj55HHj/dMZv8/dariFQQsT28PPDOAifvjAH6nJgSFSmibh7 TdyLMIukOWkY6itv7IFIbZxoduep2c/b88L38= 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=t8gXVZ5/MV7r48hJFU6RmmGuGoeboxqn6oRjSnS3SgU=; b=gZjFw+sZVHnEbt2A+kqwJyPN3ubLgUHrEWG5kvRWHSqj90nUAwy4W/GJC7KQGCAlOd TXWm5+WFXj5MX40sNESvfpqnV8XBPz/1O0Ke6n8d6mST3zLbnUKJo2zR1lAaLq6/bVON +KsuWbZDHkvogszKgeVEC1sfNQoHmkd5KHR7FsC/Sx2HGl8zeDaPXCLsC4IePIizkvSs 4n3pZQeFZQC4bztBjRsaPM8IBkAP9+Bos4xeMKw23+1Xew+yCmI/B303R5v7HUHl7oUI kUgvhGSMapGgMBBJp2JLQb5HOrjH9htMG1/UCWkz64q2Q/tdMM6kKdCYvtZaPhIBVF3O ngkQ== X-Gm-Message-State: AOUpUlFO6CkpCgABxTzbWRt6lvHrjm7xJU7FyWldUG2+EnQzNYXwkuUw hQiC/Qefr7BVQ6wvBeA1x0JNug== X-Received: by 2002:adf:f60a:: with SMTP id t10-v6mr3319051wrp.170.1533890956366; Fri, 10 Aug 2018 01:49:16 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([45.76.138.171]) by smtp.gmail.com with ESMTPSA id o14-v6sm1743524wmd.35.2018.08.10.01.49.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Aug 2018 01:49:15 -0700 (PDT) Date: Fri, 10 Aug 2018 16:49:06 +0800 From: leo.yan@linaro.org To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , "Peter Zijlstra (Intel)" , Daniel Lezcano , Vincent Guittot , Linux Kernel Mailing List , Linux PM Subject: Re: [RESEND PATCH v1 1/2] cpuidle: menu: Correct the criteria for stopping tick Message-ID: <20180810084906.GD11817@leoy-ThinkPad-X240s> References: <1533835203-5789-1-git-send-email-leo.yan@linaro.org> <1533835203-5789-2-git-send-email-leo.yan@linaro.org> <20180810071321.GC11817@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10+31 (9cdd884) (2018-06-19) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 10, 2018 at 09:22:10AM +0200, Rafael J. Wysocki wrote: > On Fri, Aug 10, 2018 at 9:13 AM, wrote: > > On Thu, Aug 09, 2018 at 10:47:17PM +0200, Rafael J. Wysocki wrote: > >> On Thu, Aug 9, 2018 at 7:20 PM, Leo Yan wrote: > > [cut] > > >> And that will cause the tick to be stopped unnecessarily in certain > >> situations, so why is this better? > > > > Let's see below two cases, the first one case we configure > > TICK_USEC=1000 (1ms) and the second case we configure TICK_USEC=4000 > > (4ms). > > > > Let's assume we do the testing one the same platform and have two runs, > > in the Case 1 we configure HZ=1000 so TICK_USEC=1ms, expected_interval > > is 3ms and deepest idle state target residency is 2ms, finally the idle > > governor will choose the deepest state and skip to calibrate to shallow > > state caused by 'expected_interval' > TICK_USEC; > > > > In the Case 2 we configure HZ=250 so TICK_USE=4ms, expected_interval > > (3ms) and deepest idle state target residency (2ms) are same with the > > Case 1; but because expected_interval < TICK_USEC so the idle governor > > will do calibration to select a shallower state. If we image on one > > platform, the deepest idle state's target residency is smaller value, > > then it has bigger gap with TICK_USEC, the deepest idle state is harder > > to be selected due 'expected_interval' can be easily hit the range > > [Deepest target residency..TICK_USEC). > > > > This patch has no any change for Case 1 and it wants to optimize for > > Case 2 so Case 2 has chance to stay in deepest idle state. I > > understand from the performance pespective, we need to avoid to stop > > tick for shallow states; on the other hand we cannot prevent CPU run > > into deepest idle state just only we want to keep the tick running, > > especially the expected interval is longer than the deepest state > > target residency. > > > > Case 1: > > Deepest idle state's target residency=2ms > > | > > V > > |--------------------------------------------------------> time (ms) > > ^ ^ > > | | > > TICK_USEC=1ms expected_interval=3ms > > > > > > Case 2: > > Deepest idle state's target residency = 2ms > > | > > V > > |--------------------------------------------------------> time (ms) > > ^ ^ > > | | > > expected_interval = 3ms TICK_USEC = 4ms > > > > > > > >> > unsigned int delta_next_us = ktime_to_us(delta_next); > >> > > >> > *stop_tick = false; > >> > -- > > Well, I don't quite agree with the approach here, then. > > As I said in the previous reply, IMO restarting the stopped tick > before leaving the loop in do_idle() is pointless overhead. It is not > necessary to do that to avoid leaving CPUs in shallow idle states for > too long (I'll send an alternative patch to fix this issue shortly). > > While you may think that pointless overhead is not a problem, I don't > quite agree with that. I disagree this patch will introduce any extra overhead. Firstly, the idle loop doesn't support restarting tick even this patch tells idle loop to restart the tick; secondly this patch is mainly to resolve issue for the CPU cannot stay in deepest state in Case 2, as a side effect it also can tell idle loop to restart the tick for case 3 in below, actually IMHO this makes sense to tell the idle loop to enable the tick but idle loop can ignore this info. Furthermore, we have another thread for the patch to always stop tick after the the tick has been stopped in the idle loop. So this patch is still valid. Case 3: Deepest idle state's target residency = 2ms | V |--------------------------------------------------------> time (ms) ^ ` | \ TICK_USEC=1ms expected_interval = 1.5ms