Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4477969ybi; Sat, 6 Jul 2019 06:03:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPEN0Wzfl9qj+YtE9Xrv+SBTWJnogcbzJ+8ckeP7YSv2EYOYk6YDiZb/WkR82vjYZYmJJh X-Received: by 2002:a17:902:9f81:: with SMTP id g1mr11160347plq.17.1562418203004; Sat, 06 Jul 2019 06:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562418202; cv=none; d=google.com; s=arc-20160816; b=emRrGSj35oj530E+GN4UmxHQYu16sMuf0b0Fc+bD/xqfxnNC7FAxumYzk2ZbitCE+I cGGC+kDRo/1e4ydty7Rxf7QBtVoZm8+VxT0Ui/loDgG10XM7/VBgi9fBVptWfh1GQhug WAN0dIupQQ3/+Z6ZRhZgFCfVgbk2estxsm7NSgfFsFgwdNLngxTYCKMtpnTcdxh3WwVm zuarHk6xk3M7SdiNcI7u4SitvuM8LUzErb/kTU8MqQWmR5rc6rYXPZNVFgMHu8gamf3N JVHSzEbqHi2C6iRI5aYVQ/V0bukU/RsRLfiexrktpe0GzhPIXrf2d2xEtbDojyq0Ud5a sHLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=52BprqlVDWbCsQ1NEtnXaXZ+0CoB00f6xjSj2np3pDk=; b=0ZqxwYguQxEpEJ2Alenrx1TCLC9UMswvCPONRZMDGSULkdhk7pZp2d0Yi7SCQ73lDy iwg2p4PHCyNd/rPLhOKM4bi+DtShFkIW3QuZ8ivohox0ca6eI7UC5xb6btTQHGsDp3vo 2yB950Xoiaw2KG11vGFEXhJCpUKsWhPSZi9/jefcmutDmeorzD+F8UvMH/aHV5+ZL2Bv rbPz6fO62gu/W3Ej1JFn9PmkAwwxAodZVpw0JujEUKTlxhod6T6ggQtQjpa9Yy5+cUsl WlBHiuEta4jTxU4yG3i6E6HKXQ/U/Ebmtt3CrORIFbK6864SQGRV2/DxVbzeiF+Zl1yZ kCZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OOZym21L; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl14si11339063plb.341.2019.07.06.06.02.53; Sat, 06 Jul 2019 06:03:22 -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=@gmail.com header.s=20161025 header.b=OOZym21L; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbfGFNCP (ORCPT + 99 others); Sat, 6 Jul 2019 09:02:15 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37045 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbfGFNCP (ORCPT ); Sat, 6 Jul 2019 09:02:15 -0400 Received: by mail-lj1-f193.google.com with SMTP id z28so2758601ljn.4; Sat, 06 Jul 2019 06:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=52BprqlVDWbCsQ1NEtnXaXZ+0CoB00f6xjSj2np3pDk=; b=OOZym21LfegewVwvfPzS4p2BWszlZBxyEaf5OrjoKdJMoOMFaoeRhWC7SGcjkW553B Nj7Dht7dpVbXidrhR8WF9Ld1OlssB/qscLYtPa68BG7PjLJmTl5HuCBhtSa6+7SZQAea wCn3a6zkuvX2GF/Es9/2rC2t4hn8Pp+gB8r08ASOZKx6Tbc5AfIOuY/jBPh5UUamE+sP 0W9yOemJgQFAr2rhSnPWeg3bI3ULx2l5tG66cSAsLrq8fPCpjoL1yoq/VQSZssz4fIJh iL4G2abfIWZpG7nu1b70RFbAv8tAI1sk5sgmPop8JjL1ZOoj5KvdKDa3Z/gaDVil/B3H T5zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=52BprqlVDWbCsQ1NEtnXaXZ+0CoB00f6xjSj2np3pDk=; b=sKH1CrRxKPhiro9n9tm2wAvUKtIUAI3smN3qgOIwmzzr6mQ7r/93pKZWAAdzZ2kVUK 1dCgPtI3ViNf+vD1VX03Ct/FKBuJqqigtUM6olYFGcKTlcAXVq5YpZFjwH9R4wJbcTCk Rhhw7eMLjV1e+tQio1jzXWF/Jv2ytSo2+L/F3CQ185wJ3ceSbQhirkG4BkqRWwvoU4mq MAHxKb8+mCXgP4+sCp3XSFr4fAMNeIeIpyhDJ8DiqbrWfbKYVaKikrlp5BjM5cknyo2b MwH2d2TfpRhV1fbLNqtnU/UXeLXX5BNWMiGwqT/GziIEA4qzRvqr4ehsP6pMul5KffGu nWtg== X-Gm-Message-State: APjAAAVZxri0IoNdHBXjeuiG+fH7yaCJOvIaz9N7JbNWX74FIGM+AS3f 0k6dhIuqI9h9IsIk/MDJN2U= X-Received: by 2002:a2e:894a:: with SMTP id b10mr4249623ljk.99.1562418133466; Sat, 06 Jul 2019 06:02:13 -0700 (PDT) Received: from [84.217.169.237] (c-74afd954.51034-0-757473696b74.bbcust.telenor.se. [84.217.169.237]) by smtp.gmail.com with ESMTPSA id b27sm450300ljb.11.2019.07.06.06.02.12 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jul 2019 06:02:12 -0700 (PDT) Subject: Re: The tick is active on idle adaptive-tick CPUs when /dev/cpu_dma_latency is used To: "Rafael J. Wysocki" Cc: Linux PM , Linux Kernel Mailing List , Peter Zijlstra , Frederic Weisbecker References: <79b247b3-e056-610e-9a07-e685dfdaa6c9@gmail.com> <7332404.L1nL2KBT3s@kreacher> From: Thomas Lindroth Message-ID: <6ef6b96e-1772-6e80-60cf-eb57af618e99@gmail.com> Date: Sat, 6 Jul 2019 15:02:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <7332404.L1nL2KBT3s@kreacher> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/6/19 1:06 PM, Rafael J. Wysocki wrote: > The patch is below, but note that it adds the tick stopping overhead to the idle loop > for CPUs that are not adaptive-tick and when PM QoS latency constraints are used > which is not desirable in general. > > Please test it, but as I said above, the real solution appears to be to treat adaptive-tick > CPUs in a special way in the idle loop. > > --- > drivers/cpuidle/governors/menu.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > Index: linux-pm/drivers/cpuidle/governors/menu.c > =================================================================== > --- linux-pm.orig/drivers/cpuidle/governors/menu.c > +++ linux-pm/drivers/cpuidle/governors/menu.c > @@ -302,9 +302,10 @@ static int menu_select(struct cpuidle_dr > !drv->states[0].disabled && !dev->states_usage[0].disable)) { > /* > * In this case state[0] will be used no matter what, so return > - * it right away and keep the tick running. > + * it right away and keep the tick running if state[0] is a > + * polling one. > */ > - *stop_tick = false; > + *stop_tick = !!(drv->states[0].flags & CPUIDLE_FLAG_POLLING); > return 0; > } > > @@ -395,16 +396,9 @@ static int menu_select(struct cpuidle_dr > > return idx; > } > - if (s->exit_latency > latency_req) { > - /* > - * If we break out of the loop for latency reasons, use > - * the target residency of the selected state as the > - * expected idle duration so that the tick is retained > - * as long as that target residency is low enough. > - */ > - predicted_us = drv->states[idx].target_residency; > + if (s->exit_latency > latency_req) > break; > - } > + > idx = i; > } I tested the patch and it appears to work. Idle CPUs now have ticks disabled even when /dev/cpu_dma_latency is used. I also want to thank you for your work on the idle loop redesign. Overall it works much better than before. I used to have a problem where idle CPUs would end up doing C0 polling for a long time resulting in a big performance drop on the HT sibling. When benchmarking I always had to offline siblings to get consistent results. That problem was fixed in the redesign.