Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1912863imm; Thu, 9 Aug 2018 04:18:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwvp/sLEDc39NrVRNHDMk9Gqj+c4vapnij/e11yNV29zjKwyyiNzTNpEmXtDWP3c8CQ2PRg X-Received: by 2002:a62:8d16:: with SMTP id z22-v6mr1938507pfd.181.1533813522600; Thu, 09 Aug 2018 04:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533813522; cv=none; d=google.com; s=arc-20160816; b=JKvjH+o8CKQNedA5acE3UXRxNSbJ5fQXWbxbdZI3Tnqkjv26XSqJ30B6AB3O3G9/19 Gfw8HfpPvS8Kk0fuNoAnrvX5DZb+7FQScdAL9dtovMoTiuBoAb6VJO9/CRngn9Bc9VeU H7Hg22pk6ULeKnr2H/0HFSFC1HJcChHJA086y8Rw+XfGi7GOncJFSZm+ZV0vg5vq8M1T 1hgG2SsIy6frmmLK5JcUD0lw+xIxqMEMcK85/t2vR7A6TIsAl/k9CwPqrXGokOvRV9Gn 688ELuNBd/M58ECttBmyEVg/cYbaHy3JaiIFYePC0CAf5gJElOAHF05ALWXNzfciv1Uk DHpg== 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=h0BxJRg0ZU8+Hj+go9HJ+g3lK1ARBqBXM4Ub8q7BRfo=; b=P/aWz3dHaVXz8UVPJZSBk11DJwH0IKZgqUyF2yak2MYcwlfceHBFau/G/hCs0znGxF fdo1v6zUB6SF3vTnwawShdtUsFLQN405Fk9m4xQuDLgD9Nu2sCWWxQAkF7alkAzMp8C/ +YK009UCyKw4VEaNVnUrVD53e2ONZj0yHKt8K5cYCxPf3i7BZZ8if2flreI05f3fFUce jWr8Z2Anc06ChZw1gKLoTNOf0VPdAiKKaehwufJ88R2r8Vf7TVs65sxir9TY+qzh/daj xH/wBWaJVpqltwd83wUPqZnZQzQuW09aJh70yTH0OPiEvxtHbwcap85XcjUmOwuhcITT PKww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I57JDLcB; 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 i5-v6si6174463pgc.351.2018.08.09.04.18.27; Thu, 09 Aug 2018 04:18:42 -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=I57JDLcB; 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 S1730878AbeHINmD (ORCPT + 99 others); Thu, 9 Aug 2018 09:42:03 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37131 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730673AbeHINmD (ORCPT ); Thu, 9 Aug 2018 09:42:03 -0400 Received: by mail-wr1-f66.google.com with SMTP id u12-v6so4811878wrr.4 for ; Thu, 09 Aug 2018 04:17:38 -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=h0BxJRg0ZU8+Hj+go9HJ+g3lK1ARBqBXM4Ub8q7BRfo=; b=I57JDLcBP2b0TxYK3xgoCb8wVppJlNR5AJAJPkRzTYud172NcxOc4D1y6R7POY//9w mIHgSzscngTlyj3BtMcHKdCZs6tS51SHDf/ZiciXJj931QU/rfVx08iWHIhdwq4dJlbb HQxDf9vggIRfoQtHlkxe1xlmEvKMGAJIb6ZQQ= 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=h0BxJRg0ZU8+Hj+go9HJ+g3lK1ARBqBXM4Ub8q7BRfo=; b=tvuO6i/wAJiKriXL8RZFV8PH2ApWix3k+SPVe4Huczs2cUd5yH1HrF09pnFSQ9dB6o y2iphbEQ89NM2iJL1CjxiXFuHzUQr3cyL9li2oiPYwvL+8F9ZNTd9oAb/BWBTZXuIyTB +cNC5xkHKl8hX8RMjSqJforJD1vFmPhcBqpK0SJVXI2uLdkny/k0iqn7AF6hO0ImOGuk ofbFNalwBI6h2WV/9/GKdp0m9PgNHnF2ruQ+g1gqTI9AP8Y0gPaOk/tiQ7Es48ykbEAA 27U/cAwN6ZQCw3ICehEs2SM/0B9YkTA6ivsOHxL0t1DZYK7dp2yshaS2mngvjfZmjfHi 2G8g== X-Gm-Message-State: AOUpUlF/4d1Nq/ThB95t8AmuU7+CrFK9FCnW/L/lX9fiYTViJE8pfns2 r2za5K6YPRs6Q4QslTHyHjlwng== X-Received: by 2002:adf:b2a7:: with SMTP id g36-v6mr1151139wrd.218.1533813458318; Thu, 09 Aug 2018 04:17:38 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([45.76.138.171]) by smtp.gmail.com with ESMTPSA id 68-v6sm9111356wmk.45.2018.08.09.04.17.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 04:17:37 -0700 (PDT) Date: Thu, 9 Aug 2018 19:17:26 +0800 From: leo.yan@linaro.org To: Peter Zijlstra Cc: Ingo Molnar , "Rafael J. Wysocki" , Daniel Lezcano , Vincent Guittot , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched: idle: Reenable sched tick for cpuidle request Message-ID: <20180809111726.GC14362@leoy-ThinkPad-X240s> References: <1533793647-5628-1-git-send-email-leo.yan@linaro.org> <20180809104549.GS2494@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180809104549.GS2494@hirez.programming.kicks-ass.net> 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 Thu, Aug 09, 2018 at 12:45:49PM +0200, Peter Zijlstra wrote: > On Thu, Aug 09, 2018 at 01:47:27PM +0800, Leo Yan wrote: > > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > > index 1a3e9bd..802286e 100644 > > --- a/kernel/sched/idle.c > > +++ b/kernel/sched/idle.c > > @@ -190,10 +190,18 @@ static void cpuidle_idle_call(void) > > */ > > next_state = cpuidle_select(drv, dev, &stop_tick); > > > > - if (stop_tick) > > + if (stop_tick) { > > tick_nohz_idle_stop_tick(); > > - else > > + } else { > > + /* > > + * The cpuidle framework says to not stop tick but > > + * the tick has been stopped yet, so restart it. > > + */ > > + if (tick_nohz_tick_stopped()) > > + tick_nohz_idle_restart_tick(); > > + > > I suspect you want an 'else' here. restart_tick already calls > timer_clear_idle(). No, from the testing I found must call retain_tick, otherwise the kernel compliants the warning from tick_nohz_idle_exit() when exit from idle state: WARN_ON_ONCE(ts->timer_expires_base); > > tick_nohz_idle_retain_tick(); > > + } > > > > However, I would rather we stuff all this into retain_tick. Ah, yes; I tested below change and it also have same improvement for idle state with my preivous change; please review if it's okay? diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index da9455a..fd2bfad 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -962,6 +962,10 @@ void tick_nohz_idle_stop_tick(void) void tick_nohz_idle_retain_tick(void) { + /* Restart the tikc if it has been stopped yet. */ + if (tick_nohz_tick_stopped()) + tick_nohz_idle_restart_tick(); + tick_nohz_retain_tick(this_cpu_ptr(&tick_cpu_sched)); /* * Undo the effect of get_next_timer_interrupt() called from Thanks, Leo Yan