Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp23497img; Tue, 19 Mar 2019 16:57:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwz901CbYDiW/TKHPwoWA7ygDOW0FkeMD9BQEki6AuveW5gcMiVQHP+B4P3+mnKcp+oQm2M X-Received: by 2002:a17:902:b413:: with SMTP id x19mr4885130plr.256.1553039876183; Tue, 19 Mar 2019 16:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039876; cv=none; d=google.com; s=arc-20160816; b=Kl1x+HLuci8ZUXKZUzX/UWoXiqcCfjnurPD9GZ/Rnz4uJPWzhppFIAJhamWlXxZs1V o7lQkDS6g9AzBSB+50ADroNukZ7FWX0ymqmssnXBvefmky6qBPVON5HF1yDC6c7jkP6R aE6fKtIUyDqm3RtXWZVvvJ4jzySFo4KXJeiBIfmNHxtGBLEJavpTzmaV9U4Cqx9eeiE9 /xVnRMjugDkYtq7hCigxq0PKPhieLX1j4m1t3cmx6u2PZ9FuASltWx/PfZPTdDhqefE4 m8rGCE/GEu1ooxpikPs3jJcuiw7nBy01BsWfT+nEYf0a/9QHJaVxqn01KcBkPrSus1y0 jArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=0gBo1Np5wzQkTBZtZpwqDveIWgNN7msVVjmQ2Ho+Bjg/69GgB11eHU2Taf2CXomgKY /5LnjKwARgSlnzt3Eqnf9t0DvxTu6N7MwsYoQcFMqa5mfXjsdhJn/Pt6KUJrCDRrZJXY w3DYdLZCxSqfgpFXvhtZ49/OBi/PrflUCCcuOp+uQDNJibuAbbo8AK8o7nubxcxpVy0q UKIrqrg9lQvvivQW0BvNSNLeMeWH0qpVDEbQsuiT87ZIhRKsVODvwUo8OJ/lu+Pubbnz sK4WbumzntsJH/3v5qU2TdBMCBJuSva1ycFjrzaN9BhJnthSQ3PT972bQK6WiTfhOA3F ClkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tDTLBAGv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si391620pla.128.2019.03.19.16.57.41; Tue, 19 Mar 2019 16:57:56 -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=@google.com header.s=20161025 header.b=tDTLBAGv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727603AbfCSX4v (ORCPT + 99 others); Tue, 19 Mar 2019 19:56:51 -0400 Received: from mail-it1-f202.google.com ([209.85.166.202]:38630 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbfCSX4q (ORCPT ); Tue, 19 Mar 2019 19:56:46 -0400 Received: by mail-it1-f202.google.com with SMTP id r136so595920ith.3 for ; Tue, 19 Mar 2019 16:56:46 -0700 (PDT) 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=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=tDTLBAGvjP1aWgYAToI0jrG0Ojb4KLFuFfahjHLMvszYkeiDWwjY8SDWm8y8Y6WwEs bBCOKw2P63Q8prUZUD8b3ryydHwgB97IFkWB7kzy0bZoIBMU+NvZSonG+RJ2DUKznRWn z3umqoYZGp6l8nguV4DH/oDPrhh1yVkqukzZYMR+pU4Lx4uYvNrSKP1Q4uygTaAfk0mJ wYHGTXwAcx9775B0pBTXyPbYgC2IXzIHF4Wiua/7EQBM+74psKEm1ZwRZYfJca+EUvUk INuX2eRdG1lW7MPgHg/NuMNtdgrYvjehTAQH2Uwp/DjwxIl1uiP95K1uhpcM9XPynU/t TXrg== 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=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=sumdzIkIhWVC4iJO7Cos7qSazbLq0I/+J3gWgyZmEUGONtCbePwpPFbDF/IOVY6jpp UTnapw8xES6/jnSnYovr661YfrEu53vI0FZr87EPZ+YoO2kpeAXUP4/QhgqPgaryN7ao MvYV8S8y9EX/BwR5LQyjojVfjSG7gwB9QxeNjZ6X9867KRWuapx3eJiY/sdAav5u6iuO v/IIbVPYXhGeKoQN8shpfpE7zw5D5c7lQ5K8WLMdg6239Jwt1paO8XT2ASjb8XZyBBs6 z95TezeARn/G2OK0nkXfyB9SrUiDkdf1ECiT1V/okxluNTSq8ZLgZNnoBN4bz65vnVzn /+Uw== X-Gm-Message-State: APjAAAUq9tHRzfzaxCDtKP9COLpgC7WPJO7fDtUbc4TTf9WQWHA6hn6E L/xUQogh4L4Iaoz63f+SvtQWJcHcM/8= X-Received: by 2002:a24:7d8a:: with SMTP id b132mr3009072itc.20.1553039805672; Tue, 19 Mar 2019 16:56:45 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:19 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-8-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 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: + +