From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79900C4360F for ; Fri, 8 Mar 2019 18:43:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D38D2085A for ; Fri, 8 Mar 2019 18:43:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GhJzk1A0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728755AbfCHSnr (ORCPT ); Fri, 8 Mar 2019 13:43:47 -0500 Received: from mail-ua1-f73.google.com ([209.85.222.73]:37276 "EHLO mail-ua1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728724AbfCHSnp (ORCPT ); Fri, 8 Mar 2019 13:43:45 -0500 Received: by mail-ua1-f73.google.com with SMTP id 49so2615347ual.4 for ; Fri, 08 Mar 2019 10:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0ZL/3pZ59izFS2kEKhcW03BhmVQQsRxh317XsxqmI88=; b=GhJzk1A0ryZH53AjlI90bDUlCqp6CIMeYszP9fYPPKvXoULkUBmCOBROAHZSDxDCoa cj0bNUzUacf0RxUKpZX4QnukkYJIST8aFdpJFQjxNHCdCM8aUfllEWLUHpDDHvqTcYqX uqvScywnfV1Dla0bYiYKRBU2L7onNhf6Rwl2YhK2XyBJMi2VtkZ9ehPN6YSnaLM4kTlH su1eOvmUbsRUq64F/g7lBUgTjZfynF2ZkyGjjLQGcz/bcWtZHto+5bb7ey8urxlVmSOl 3GVtu79i+Jb8WXh97eWrzXVSU2uyhnpzWu96foB+vbf/unkkBLfFnLWpwUPVa4yMOkRF hbSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0ZL/3pZ59izFS2kEKhcW03BhmVQQsRxh317XsxqmI88=; b=N1DnLJioYhe3t+zrfGp8ppKBq0/ss1Tx2nUyE9YAT6WdvNnYBAY8luTMY+F9baJEAX ELnM+50+RLzapEzBOUL/23veFXinoYlQKW3pu2WqWpktUSVZwWcaXLbrp2goiJAG1ibf +d6xedkZL4JtgOqh0Y347iRvgyTRwAWK4MTdozLsvYRUENKNMoR/2l33rlZ8RWXmfbgZ +2NWS+EQFNp31ssK/aRNThYHI4gXhOc+xMEwKe6nQe6IrIVrn087hfUEtd1CILJyrfLY Mr5HQlbfTeW4MoC5xPieNsqEHZbtMWbHuyl39+5iDTfpk1ZOj6YuSr7Kna/VWa6zjINJ sCVg== X-Gm-Message-State: APjAAAWAsnErx+mNLoSLmYO+WnkEUbttiZBbNz5oz+p0BZKpvaJ6ihk4 HlZCz/fHpqEvS3rHB1n6aqqcNIz3Tmk= X-Google-Smtp-Source: APXvYqzQJx8wd9uhB05DpOyRslnOwWJkrlQA8DQpjapGCOCNfcTch9IrLubZTjX/zzgZNGmNsJNzc8Mxuzg= X-Received: by 2002:a67:efc1:: with SMTP id s1mr13017815vsp.1.1552070623342; Fri, 08 Mar 2019 10:43:43 -0800 (PST) Date: Fri, 8 Mar 2019 10:43:11 -0800 In-Reply-To: <20190308184311.144521-1-surenb@google.com> Message-Id: <20190308184311.144521-8-surenb@google.com> Mime-Version: 1.0 References: <20190308184311.144521-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog Subject: [PATCH v5 7/7] psi: introduce psi monitor From: Suren Baghdasaryan To: gregkh@linuxfoundation.org Cc: tj@kernel.org, lizefan@huawei.com, hannes@cmpxchg.org, axboe@kernel.dk, dennis@kernel.org, dennisszhou@gmail.com, mingo@redhat.com, peterz@infradead.org, akpm@linux-foundation.org, corbet@lwn.net, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Suren Baghdasaryan 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 Psi monitor aims to provide a low-latency short-term pressure detection mechanism configurable by users. It allows users to monitor psi metrics growth and trigger events whenever a metric raises above user-defined threshold within user-defined time window. Time window and threshold are both expressed in usecs. Multiple psi resources with different thresholds and window sizes can be monitored concurrently. Psi monitors activate when system enters stall state for the monitored psi metric and deactivate upon exit from the stall state. While system is in the stall state psi signal growth is monitored at a rate of 10 times per tracking window. Min window size is 500ms, therefore the min monitoring interval is 50ms. Max window size is 10s with monitoring interval of 1s. When activated psi monitor stays active for at least the duration of one tracking window to avoid repeated activations/deactivations when psi signal is bouncing. Notifications to the users are rate-limited to one per tracking window. Signed-off-by: Suren Baghdasaryan Signed-off-by: Johannes Weiner --- Documentation/accounting/psi.txt | 107 +++++++ include/linux/psi.h | 8 + include/linux/psi_types.h | 82 ++++- kernel/cgroup/cgroup.c | 71 ++++- kernel/sched/psi.c | 494 ++++++++++++++++++++++++++++++- 5 files changed, 742 insertions(+), 20 deletions(-) diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..4fb40fe94828 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,110 @@ tracked and exported as well, to allow detection of latency spikes which wouldn't necessarily make a dent in the time averages, or to average trends over custom time frames. +Monitoring for pressure thresholds +================================== + +Users can register triggers and use poll() to be woken up when resource +pressure exceeds certain thresholds. + +A trigger describes the maximum cumulative stall time over a specific +time window, e.g. 100ms of total stall time within any 500ms window to +generate a wakeup event. + +To register a trigger user has to open psi interface file under +/proc/pressure/ representing the resource to be monitored and write the +desired threshold and time window. The open file descriptor should be +used to wait for trigger events using select(), poll() or epoll(). +The following format is used: + +