From patchwork Fri Mar 8 18:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10845331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1819E14E1 for ; Fri, 8 Mar 2019 18:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000A52FDE4 for ; Fri, 8 Mar 2019 18:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E78AD2FE20; Fri, 8 Mar 2019 18:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9AC12FDE4 for ; Fri, 8 Mar 2019 18:43:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B878E8E000A; Fri, 8 Mar 2019 13:43:46 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B38A88E0002; Fri, 8 Mar 2019 13:43:46 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00D68E000A; Fri, 8 Mar 2019 13:43:46 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) by kanga.kvack.org (Postfix) with ESMTP id 68BA18E0002 for ; Fri, 8 Mar 2019 13:43:46 -0500 (EST) Received: by mail-vk1-f200.google.com with SMTP id b123so9823817vka.21 for ; Fri, 08 Mar 2019 10:43:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=0ZL/3pZ59izFS2kEKhcW03BhmVQQsRxh317XsxqmI88=; b=O6rTA9RTmxK4LuYKSX3NcmvVjrh/rqTepMdFbGC01nv4+C/IoqJ3m0WZ/dY5buN2nx 2zeiucMPZiwafep8qqiUUWN2R93a7sE/0kqw/CI9lfEp+2BJM9puPJcO+VouGZtg0Myh 36rlOdEvHCU+mGaYvlwKqwWZn8suOMAYCCGpfVOTHLPgHMf9SUZPt2c5DZinF5ZYvbCb rVqnt/Xbh8Rkq+K5bSlu3KkihysrPRAlkdHUw+dwDalGrr71WFOiQ/wJskyiFS/XYzZK ZNS6iMD1Em5kXG6Yh8lAivGGxBD1JEgxcxi1U6GCI4bsey1QlI/vuQNFa1Esq4rbMm/5 Pojg== X-Gm-Message-State: APjAAAVPNVYKbp/tzTofeghHA6zNiC60AeajlqrVAl2g2BWvjzzyv5fz hclUnfeZhpSqeHX/4M2ifCcX1cqrvimqg8zYOwIemWcX/nNMx9WK0x568iQLG0REIpR0DtaR5tI eh5JdlXLultQn0I+tNzez0pGbShAyWWlNyUz9lplysgv7Ia6eD0rN26MCf/2BmD+P5pkqcjVY0M 2n6kUv3K6qUwUhTAnKfc5IY+gRHQS9lueflXu5oktUHCDQebwbqU9SBQMqN7cxog2+taN82iIb4 oy0ud1ZPu0r9vF6/dPmI7T4jMrYYsHLZ2yuiAUaJzi13qjMw/hTyaS1I2ce4TU7v7Ks1+j3T68I 0tSBpa0ORkjBjnGkATyzCG6E56znU7VjPUa5gRg7o4/Y4zUbwhqfWKvcsYYbd8mkU2op9PaJw/3 y X-Received: by 2002:a67:fd13:: with SMTP id f19mr10029909vsr.58.1552070626039; Fri, 08 Mar 2019 10:43:46 -0800 (PST) X-Received: by 2002:a67:fd13:: with SMTP id f19mr10029827vsr.58.1552070623662; Fri, 08 Mar 2019 10:43:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552070623; cv=none; d=google.com; s=arc-20160816; b=AJCz/YgO6mbOK7jgwaNYtjdaFjB6VdG+6DZVg2Q2SIP1NoTMIhVmmd3aqNcXtvU9HH Qwz6W99nka2xErFlrSEO+CTfaM1Inmq8wH+sVLVgDupiZ+fleqj7zx4cahFG/X/hNVvP 1EXjwCZRxMeAWwnkMPt908tDbMVTlrYgga90z427ZyB1ycqewv3adc0vEHB5qxoOYYDi NCe3B+no9dS8pHr9cFYHKkhg6ycV9oMBUGRI286VD8ms0Ar6RgN5RxT/fYhQRWgg4VYx 4vpLh3hE89v8D1BGRZHLawngH3DobXqfJ3cLuHQtytk8P6Cp/Inh3I6zoZz5VcCcwiai Ri3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=0ZL/3pZ59izFS2kEKhcW03BhmVQQsRxh317XsxqmI88=; b=Lqak96muL2Z6L3w3j44BSv9gRU4VUgw75MKbbqhV6p+VjPZivX9Amv7GtIdVWIhdYJ k78VEYUkUvkrhVRgmeGgSLPUQhHl6hGxLyRFX/ZTzg1gYj/z7uab9fVGEDj/WfDJAhNd dVj3KIQZ2FWf1MKCxue6RQyfEEUcztuTVsk1CqVxTUVeyKr0PDDXfJ9Ck++7qQjYmzJ3 A/6FB8T/TWYfqH4cDNFupoop4cho7y3AkJ6La313JMC2KqHAQe9Jdjzz5/4s369jQwOW QsAKMhzD7tNWamwqBS+dkJn/EEA/s0YIn5fCLA1r0zlevmQTirHtgEAdxlpuEho9beY8 fhUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GhJzk1A0; spf=pass (google.com: domain of 337ecxaykceqy0xkthmuumrk.iusrot03-ssq1giq.uxm@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=337eCXAYKCEQy0xkthmuumrk.iusrot03-ssq1giq.uxm@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id y25sor5481226vsn.20.2019.03.08.10.43.43 for (Google Transport Security); Fri, 08 Mar 2019 10:43:43 -0800 (PST) Received-SPF: pass (google.com: domain of 337ecxaykceqy0xkthmuumrk.iusrot03-ssq1giq.uxm@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GhJzk1A0; spf=pass (google.com: domain of 337ecxaykceqy0xkthmuumrk.iusrot03-ssq1giq.uxm@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=337eCXAYKCEQy0xkthmuumrk.iusrot03-ssq1giq.uxm@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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-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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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: + +