Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4257864ybi; Sat, 6 Jul 2019 01:20:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnbo+9FT85KTdJxoZ7J/ZByKxZ7irvnR990hbGLbogkmITRBZeExCysGY0u6bxg341B9t0 X-Received: by 2002:a17:902:204:: with SMTP id 4mr10107577plc.178.1562401204587; Sat, 06 Jul 2019 01:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562401204; cv=none; d=google.com; s=arc-20160816; b=PQQTcfHDdEfYgwFDLYm150N2HDpuKtqpaWCqszjw06ZSDEoiyVL9erowA1Mi9sZYd9 kjlurHcPDtizwUf0YKSxCHgZYHETyV/+RSMCCXNrfmySAf5a1L2Q+UgwhFVoI6Ihp1+w BbfV+MMh6SwJucdFrLy6fLMASYNIWNss5900ThCN8NciCZGNCN05MHNUzsRMxhL46nB7 s/uVr2YJzwvXEVYMds0HzCBrQkPl6jaB5zLlJtp/k+o9h1hsmu23vZSbxRPfT/Om2/8E +hDdPYbcv7sIHnTBY9YuIQ4XqZu0zB///1p9yvXyfA6OJtA8xOQKis8Mk47L5EoKyv+e Rkww== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=fAxTzm9AYcXrSM+BQH4+n0hfqDYqW0RFjdDHnGHjtYk=; b=QduvenAs8b8IQN/W6fvCvIM5yNFdKAa0XPwe0qXslMHQtgGBG+k4ktfyI55G9fFusa bmO+0xSSXdVEQd9EaOd5YYRoyNYa1rSSjTfr448HQbnKKVmS7w2kSBQaFegPdrptbMhG 8xUgZ5tficldWQP+rV5H1tQaHLox0trX1cKUhcAzdG48+bn9H7BHh+m/EuJkwfgldFq5 6hDk3CB12hKZpwgnRoZj7nhi8scECzPpJJ3woCDdj78Txd4DOQsBM7aYPktqo0CVvJ6H TrIe88i33gNJmD34psvrQw/YKk784FdEs2Awh36rWfXBbFZuiPd6z3hQQdX23xmqL12e UxSA== ARC-Authentication-Results: i=1; mx.google.com; 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 z4si10361974plk.364.2019.07.06.01.19.48; Sat, 06 Jul 2019 01:20:04 -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; 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 S1726164AbfGFIR1 convert rfc822-to-8bit (ORCPT + 99 others); Sat, 6 Jul 2019 04:17:27 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:40286 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfGFIR1 (ORCPT ); Sat, 6 Jul 2019 04:17:27 -0400 Received: by mail-ot1-f65.google.com with SMTP id e8so11214106otl.7; Sat, 06 Jul 2019 01:17:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=BmjS73XlAr/xExYyGQ/UHQ+KTYtukJa8bAxRUnVmDcg=; b=hr4kZONchUsldLXs4gsKEpLO43E+E2ZQ5ZWfVEKAhnA00j8JjAANZ3Lmhqp3Pbv3ZO 6MP/XY91biXb+/DIAgXGKNRNI7vrOj+R7LbcvSakusBroLzoPGGpxWW6cG/e+Ey24PH9 yQk2o+MMy2JVS64jDAerbmjYs9xYJjMTDk8j7N/Ak5aDHNmEQ7iOV+uRUui8fLNKuOd1 c6npUbiDurafKwM6bmE7HwX9Xa56ZNVfgkY/bZsR4JHmSWSr4WGFkrOW7EC01gOoheIY VH/6i/sHIQYTVTgUnrB46WxgB3pJKqqVBoaKw3j/y6TUDZcnng5Ubl3ZGshFz46owNqs geeQ== X-Gm-Message-State: APjAAAUH0M+pq1IF15jFbTqXH5lSYlPX7ISR8TyL2PScTXZlsxLwNRpg PvVcZlplZBzEB+4meTaZ0JUsQ6E2NlVhJatAwg0= X-Received: by 2002:a9d:6a4b:: with SMTP id h11mr4036175otn.266.1562401046081; Sat, 06 Jul 2019 01:17:26 -0700 (PDT) MIME-Version: 1.0 References: <79b247b3-e056-610e-9a07-e685dfdaa6c9@gmail.com> In-Reply-To: <79b247b3-e056-610e-9a07-e685dfdaa6c9@gmail.com> From: "Rafael J. Wysocki" Date: Sat, 6 Jul 2019 10:17:15 +0200 Message-ID: Subject: Re: The tick is active on idle adaptive-tick CPUs when /dev/cpu_dma_latency is used To: Thomas Lindroth Cc: Linux PM , Linux Kernel Mailing List , Peter Zijlstra , Frederic Weisbecker Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 5, 2019 at 7:22 PM Thomas Lindroth wrote: > > On recent kernels the tick remains active on idle adaptive-tick CPUs when a small value is written to /dev/cpu_dma_latency to restrict the highest C-state. Before the idle loop redesign in 4.17 idle CPUs had the tick disabled even when C-state were restricted. Is this change intentional or a regression? It was intentional, but this kind of is a gray area. At least for the menu governor you may argue that the decision on whether or not to stop the tick should be based on the predicted idle duration. > I use an x86_64 system built with CONFIG_NO_HZ_FULL that I recently upgraded to the 4.19 series from the 4.14 series. I noticed that adaptive-tick CPUs (nohz_full=1-7) still fire timer interrupts about 1000 times/s (CONFIG_HZ_1000=y) even when they are mostly idle. Some debugging showed that this only happens when a program is writing to /dev/cpu_dma_latency to restrict C-states. The old 4.14 kernel only have around 10 timer interrupts per second on idle adaptive-tick CPU even when C-states are restricted that way. > > I would expect an adaptive-tick CPU to turn off the tick when it has 0 or 1 processes to run and enable the tick for >2 processes. Kernels after 4.17 instead have the tick on when 0 or >2 processes are running and the tick off in the 1 process case. Since the tick is off when a single process is running that workload isn't directly harmed by the change but if the CPU use hyperthreading the constant wakeups on an idle HT sibling will reduce performance on the other sibling. > > They way I look for timer interrupts is by comparing the LOC line in /proc/interrupts or using the hrtimer_expire_entry tracepoint when function=tick_sched_timer. Both methods seem to give the same results. > > I can reproduce the problem using an i7-4790K CPU with /sys/devices/system/cpu/cpuidle/current_driver:intel_idle. I can also reproduce the problem on an old core2duo laptop with current_driver:acpi_idle but I can't reproduce the problem in a virtual machine where current_driver:none. I also can't reproduce the problem if C-states are restricted using the intel_idle.max_cstate=1 kernel argument instead of /dev/cpu_dma_latency. > > The commit that introduced the change is 554c8aa8ec "sched: idle: Select idle state before stopping the tick" in v4.17 and the problem exists at least up to kernel 5.1 using the menu cpuidle governor. Restoring the previous behavior in this case should be relatively straightforward. I'll send you a patch to do that later.