Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2280163imm; Thu, 9 Aug 2018 10:07:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyR9mwt3guGQl/aI0c+upqD0njPRbqS8ufRZ0TzEMAd3dO2ymLooHIeXm2J/immS6HG1ja0 X-Received: by 2002:a63:af14:: with SMTP id w20-v6mr3028382pge.47.1533834462520; Thu, 09 Aug 2018 10:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533834462; cv=none; d=google.com; s=arc-20160816; b=YGGWXU2x8Je/Wrxvx8dw3OtrtlcjwzgyczpAZZDZDZDyUqMaw3ED5xQolYe8SKe4Bh ACzqmkzYmxJ4TtsKJp50hBCSbevR8SZUomH1UgjAMqTipfvmYVpFfofBd5krAHo773ml qUmbOVF4mBMhPhJ/r2idEAOSMk2pISqa7ROeSS3HbWfUvL3ECZJwChk+8gyUbCWBd4qf PojghhH8D7bd2KSG5mpqzFP3lXEEqvyvU/Y1NdDil2CfZFj6nWlCEumjLF7cwLZN/gIr ApgkaeUvSebiBHzrZZuVcMMKb8ByoUA8B9pfP4fEMjJnba0MCsDq2UkmsfvxO8ZFW/Xm R0LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=4Tae2c/tXSAym/+pbX+3Q8E3OMphRRZ2zCvnnMZucU4=; b=IV+65GqR88eFEsNTxLazUeXdtQ4UX/p5rhZvAC42d/aJubaNStAvxa0ptO283uJRMf HgUbUffzmkSNNYITOI5HTOds1I1EQmN63TAALxhGeSyhR1FT8zu5/8ssbnXLBbsUj+0W a4WcLwMHqmZawyD6o50k5jYfV9G+uv8Des0zfTWkTBQLzpk1xprkvDSiN0noWsthsgU5 LRtacWA1vhTdhImvQcZQak7t2QEDc0gcIY/jHHVQTRRGDs5kBzwe/saS8sH3YEuXpm14 v1kkHjNCsU5ao66u7TyLwOIydRKGfIA7zGSsW/mbs9F7Qk/+cCxo9LQvbRAlKdoD9sWu RqnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=epEUY63E; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j67-v6si6533296pgc.186.2018.08.09.10.07.27; Thu, 09 Aug 2018 10:07: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=fail header.i=@gmail.com header.s=20161025 header.b=epEUY63E; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732627AbeHITcY (ORCPT + 99 others); Thu, 9 Aug 2018 15:32:24 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:45373 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730634AbeHITcY (ORCPT ); Thu, 9 Aug 2018 15:32:24 -0400 Received: by mail-oi0-f65.google.com with SMTP id q11-v6so11014635oic.12; Thu, 09 Aug 2018 10:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=4Tae2c/tXSAym/+pbX+3Q8E3OMphRRZ2zCvnnMZucU4=; b=epEUY63EF89m/wsjROg95xof+tabZ7g9kUxIp0LDA+EnNLfM/EYcBCpUK0dBdHxP2g l59VGb2rcALUcCkKCPzckvAr+x2k6+LH6di2/oG5vY/FPYblPD0L+46DNbyv3ynLHVvA TDAN6W3P5dcE5FHSvJW7dcq8lZvcRI77IBjqaYmxAReFsfsDNDXC2+Px/zRABdHa8F4H wBhU0Nm9oFKHkXCh61NhCzHNcMBBmvgzI2c0ACrRNYsH4qWgvTQ19QfuYZJq1ZKQaLMi 3ZlCd9wmYI3K9KgCYxo65yOgKrTZ3MzljkzNZ9LTl2wZPthsKMF8nQCOn9Gwv2rV1Q+O Z84A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=4Tae2c/tXSAym/+pbX+3Q8E3OMphRRZ2zCvnnMZucU4=; b=gRNeP58T7K38XfV9FNi+pw05MtllII8C0xBTfNntTSerZQs3B3ZQfr/hAik8pDY1kE a+M9BlkSloBnIvMndbZu8IQ2nu0mnvH+asm5/43CB1340qFHFGhp2cTwHpQSBkWfdLCz j+HRQDuv0Q8ArUaH0P5JHqwHWYPJJ1HqQjpptxmuyC/xwdhxhTpX6BYVNXTWNiHNG6nv 0bhVHHom63nuM73dG3d+ibYH7rEc/bWuKDI/6AVhBC8mM1ImrR4m9jvioOK8dleJZ59P 06tHrJhnyCTsXQAzkJVPqvq9Z/vCm1WHBt49qHlLmRBw0zEuAzc2Bkt28zsZY+X0LNUg jJWA== X-Gm-Message-State: AOUpUlEkSXiDpdqPEJCklLlezY+cYJaAXhgE2Ktg/HB/OpIvwLrMgebX XB7ILUQvaw21rNn4AxUGUcMYlDWvxejtDCR3TAg= X-Received: by 2002:aca:adc6:: with SMTP id w189-v6mr3034482oie.174.1533834397115; Thu, 09 Aug 2018 10:06:37 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:63d2:0:0:0:0:0 with HTTP; Thu, 9 Aug 2018 10:06:36 -0700 (PDT) In-Reply-To: <20180809170449.GE14362@leoy-ThinkPad-X240s> References: <1533793647-5628-1-git-send-email-leo.yan@linaro.org> <2704016.RYJlhC2yyo@aspire.rjw.lan> <20180809162957.GD14362@leoy-ThinkPad-X240s> <20180809170449.GE14362@leoy-ThinkPad-X240s> From: "Rafael J. Wysocki" Date: Thu, 9 Aug 2018 19:06:36 +0200 X-Google-Sender-Auth: -nXhBeZ29YQZfTG9HfwtidtmIbg Message-ID: Subject: Re: [PATCH] sched: idle: Reenable sched tick for cpuidle request To: Leo Yan Cc: "Rafael J. Wysocki" , Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Daniel Lezcano , Vincent Guittot , Linux Kernel Mailing List , Linux PM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 9, 2018 at 7:04 PM, wrote: > On Thu, Aug 09, 2018 at 06:43:55PM +0200, Rafael J. Wysocki wrote: >> On Thu, Aug 9, 2018 at 6:29 PM, wrote: >> > On Thu, Aug 09, 2018 at 05:42:30PM +0200, Rafael J. Wysocki wrote: >> > >> > [...] >> > >> >> >> This issue can be easily reproduce with the case on Arm Hikey board: use >> >> >> CPU0 to send IPI to CPU7, CPU7 receives the IPI and in the callback >> >> >> function it start a hrtimer with 4ms, so the 4ms timer delta value can >> >> >> let 'menu' governor to choose deepest state in the next entering idle >> >> >> time. From then on, CPU7 restarts hrtimer with 1ms interval for total >> >> >> 10 times, so this can utilize the typical pattern in 'menu' governor to >> >> >> have prediction for 1ms duration, finally idle governor is easily to >> >> >> select a shallow state, on Hikey board it usually is to select CPU off >> >> >> state. From then on, CPU7 stays in this shallow state for long time >> >> >> until there have other interrupts on it. >> >> > >> >> > And which means that the above-mentioned code misses this case. >> >> >> >> And I don't really understand how this happens. :-/ >> >> >> >> If menu sees that the tick has been stopped, it sets >> >> data->predicted_us to the minimum of TICK_USEC and >> >> ktime_to_us(delta_next) and the latency requirements comes from PM QoS >> >> (no interactivity boost). Thus the only case when it will say "do not >> >> stop the tick" is when delta_next is below the tick period length, but >> >> that's OK, because it means that there is a timer pending that much >> >> time away, so it doesn't make sense to select a deeper idle state >> >> then. >> >> >> >> If there is a short-interval timer pending every time we go idle, it >> >> doesn't matter that the tick is stopped really, because the other >> >> timer will wake the CPU up anyway. >> >> >> >> Have I missed anything? >> > >> > Yeah, you miss one case is if there haven't anymore timer event, for this >> > case the ktime_to_us(delta_next) is a quite large value and >> > data->predicted_us will be to set TICK_USEC; if HZ=1000 then TICK_USEC is >> > 1000us, on Hikey board if data->predicted_us is 1000us then it's easily >> > to set shallow state (C1) rather than C2. Unfortunately, this is the >> > last time the CPU can predict idle state before it will stay in idle >> > for long period. >> >> Fair enough, but in that case the governor will want the tick to be >> stopped, because expected_interval is TICK_USEC then, so I'm not sure >> how the patch helps? > > Correct, I might introduce confusion at here and I mentioned in > another email I have one prerequisite patch [1]: "cpuidle: menu: Correct > the criteria for stopping tick", if without this dependency patch, the idle > governor will always stop the tick even it selects one shallow state. > > Sorry when I sent patchs with [1], I didn't send to linux-pm mailing list, > do you want me to send these patches to linux-pm? Please do.