From patchwork Thu Jan 10 22:07:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10756997 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 D69F517D2 for ; Thu, 10 Jan 2019 22:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0E0929EF5 for ; Thu, 10 Jan 2019 22:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B41ED29EFD; Thu, 10 Jan 2019 22:08:25 +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 8BA1029EF5 for ; Thu, 10 Jan 2019 22:08:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 174FE8E0006; Thu, 10 Jan 2019 17:08:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 124EC8E0001; Thu, 10 Jan 2019 17:08:22 -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 F08DA8E0006; Thu, 10 Jan 2019 17:08:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 9A5868E0001 for ; Thu, 10 Jan 2019 17:08:21 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id v2so7007904plg.6 for ; Thu, 10 Jan 2019 14:08:21 -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:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=eFHjwjpppG2Kj1npy1Ew9VcpInW52tTVzzoa0XOz9mZNdZ61kfAlaIOce2piEq59jY E04+G+zKkK6i+AnoR08Cr+29TupxleEdTOi+lCugpyj6BR98ygvxsPZmp6LNrvNftS2U jkj5Ab1NfxBVW/hxDtNKo6MO9xE7PRoxs+h0OCqEx3xBtrHlfo6E0yzU+1TxQpQDGpe7 c4SdX1y6Z0ihsvWvPT/q4Vs/iLyTcajTOXIDK+3Ao8AQXjG767NOPLcD2TMMzf7Xw4qQ ptYuoUXUCEDcXjFGKFA7RgzSb8bSsNABe4VvGotyhfzSarhmlUDLxypm44NdMnOi3q22 sRXQ== X-Gm-Message-State: AJcUukdVBUtXFmlKIMn0tdB5pqiyphD5vanClSi+1OHykpxSu/udD/V+ cqbYhvDoDfeXbbYo1UluQMhvUln+cSQqekmh44JZQpKNwHf92gOfUsEAKOwvSzf/2LDgoB+Q0oQ SIUfletqJgWLX/eqvRx5VcceX3eVtcZlDTfugRWsR44rSphJyqDOFyWjXHBBPdobdkHDzRaconT 1wyH85WTLn+S+vT4A9JRZXbB+IrhKlDMOOTr01ADuLcDqPQqj8aYB2H9OyRFvlRsyx/1CoY/RXw EpdDJVo1kTiv4RYLUqq9Lv2TTIU6qaSKQ506RIrE2YJQOgUGTQcruP19UkWkCA6FOfzCxGm24/P 6dBpkqEdkWgw23v+hC2zcdKRDHEs960Yc2yllZ4ngB3QbSyCywQMzd/BhUcqK7rltEckt2ozcjg 5 X-Received: by 2002:a63:fe0a:: with SMTP id p10mr8742607pgh.265.1547158101173; Thu, 10 Jan 2019 14:08:21 -0800 (PST) X-Received: by 2002:a63:fe0a:: with SMTP id p10mr8742479pgh.265.1547158098718; Thu, 10 Jan 2019 14:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547158098; cv=none; d=google.com; s=arc-20160816; b=mqjixAPvIXYtsjib9kjYyVcgSehkbmL0H6t7nKZVpMRtLa3SOJ229D4eyPYu6LRzLZ r3BBMFschxjHHn48KDYaMdFQ/FsK8IBLeoaylVBayYiHt3Ut7F8LxJsf2HGr048+LmpX /9qUK2KnaFG0dFQQGUmo09E7nnCRHjwqu8l8f3/Lz5WWSDCoNukd0X7UzXYPIqQ1WcbS G/USsPPCI1B1HaehKMRtzTeDNWJm/3+vD9c1Ke38yh+27sXHaNiq/TFX1vwHYA73O+kT p6iZp17j0TNAgNpf9Bx5I5Fg6srdLtsJ7us2ff+cCzfdS7XFFhuteGWe/knQdQq9nl3A aVzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=hjwwWjdChFDGimAsPbojmfRMYlbxGXktYSHsL9LCjMxCpxtn1K13dDhwLVEk6QiazT ue9A+Ht69tpbjHfgkRETV1+YYta+of+GVfU9B0tgoVG6+bEVXsOiUYhWyrKuTlz8nEYU 7H0k7uXfGa99US+BeWWK4vHWC/IGyQhvjj/ZL0L4OGFZ6gzYUvEzwUXOU8t0htjfWZ/y KYSCwi1S5zphbYGOYq3l5a2CVn+Au+kGYhODPSW+QNy7+hVHoFtXbszeH7KZFDqY9J8k 67D3b3SSGKbWNP64JtykzWwOmUHAotoL3fCGCj4vk6jkkPyqIeO19ReHZbxr9pUoZHMe 2aBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wASq212f; spf=pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id gn15sor490300plb.64.2019.01.10.14.08.18 for (Google Transport Security); Thu, 10 Jan 2019 14:08:18 -0800 (PST) Received-SPF: pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wASq212f; spf=pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=surenb@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=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=wASq212fPJAbSw+wDVzjj4TGxnkBFur8nfdkTP9iLdfs8nl+TPnRkKbu/aoj6sFgtC /t+g1WSA4iZeeNksTjZLTdhVA4w5sFCD03hsISvSFSzO6eTR3/6LKmKAzcLe+uKgXaRg PleSXlF5ESDh4+oHMs/qfZYkPgMVx19FkANmmcmzAyriz/1a9o1443VgvtPcMFpBMwUM GWBVi0J8y9Xl/3V9CSo51itmCCpTl2mrK93bHLAAlGNjw4dy1ZVFXMoXXUwlTmH0+mHN 3HTZrAJiYe49cOueM+mPs3jmD4gJDUhkdcy2AyVMnllbqvUq2XhsnSA+yPDhmqaQcCNY XP2w== X-Google-Smtp-Source: ALg8bN5ga+MMqMuzoOfiJZ44lkbun/HNzvHb8pDsCVfwfOYipzi2bieVhP/zvaJ0UNyREBa+7i1urA== X-Received: by 2002:a17:902:4401:: with SMTP id k1mr12148610pld.307.1547158097575; Thu, 10 Jan 2019 14:08:17 -0800 (PST) Received: from surenb0.mtv.corp.google.com ([2620:0:1000:1612:3320:4357:47df:276b]) by smtp.googlemail.com with ESMTPSA id p7sm152958019pfj.72.2019.01.10.14.08.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 14:08:16 -0800 (PST) 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 Subject: [PATCH v2 5/5] psi: introduce psi monitor Date: Thu, 10 Jan 2019 14:07:18 -0800 Message-Id: <20190110220718.261134-6-surenb@google.com> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog In-Reply-To: <20190110220718.261134-1-surenb@google.com> References: <20190110220718.261134-1-surenb@google.com> MIME-Version: 1.0 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 | 104 ++++++ include/linux/psi.h | 10 + include/linux/psi_types.h | 59 ++++ kernel/cgroup/cgroup.c | 107 +++++- kernel/sched/psi.c | 554 +++++++++++++++++++++++++++++-- 5 files changed, 802 insertions(+), 32 deletions(-) diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..6b21c72aa87c 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,107 @@ 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: + +