Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2464728imu; Thu, 24 Jan 2019 13:17:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN70NCHCiKL+Qe9y76KTZYnwSi9K+9TPhFKvmwgGgJFQbC3YPv2iBSuGXpGo2eGmpid8RlAf X-Received: by 2002:a63:1560:: with SMTP id 32mr7277916pgv.383.1548364621425; Thu, 24 Jan 2019 13:17:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364621; cv=none; d=google.com; s=arc-20160816; b=MNtpv54hP5Ui0TghFUb76y37r2UXJxCXf/YpJCq/NLtyEoB2n4BePx8WMrY11+XRkv Ptr87ctAodJy+OXsGo3vI2hAjxDr9OAPmpQqZ6lvS3GXmQtM+CKGvbLB6MPpxUkFULpt cjmRYWTo++YsLeq6bejw0HNcvDU2a/S1NkCWeBfjAG0lbNyWRk/odrumgjhtgZYr8O1a oEFynZr9t0wedSWhE63w/7YNljYyDRaubIT1DM/eHzu6/fkkk3DZTWRFolrYBGhUI3pi ZM8zKzxHgu0rb+hYMAEFmD4Uiu/tP0Nihi7PKGnzI2f+/flc+iaoXIxAIG9Twm449iVt z2yw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=EaFJC5VITa9d3QxZ5DS9X1xZUCZS/tLruDe5qLaHs6/D/pOBvZGRmn3oWVvU7F8Kbs 9JyKpzawfkA/g1UsISKTUCPe5Mj8bvBTfuQDdgnWsiZFI9XPU2MLjTjN83HCCANTPt7q pbMErLNVul64i7moJOuXe9iYzBX1Z8EVZP1bon7KaVvvPsSaG08W+oJFQKb8Qfc4B27U ADAQuIS5gvkWOXZ2danWmolKb6CrS6MIO9ZSm9mEfZAZ9tasSXQyBjoh/PTqDjHcXQLc SkmbgN3zHn8HTmeCu4S1FLebtzDelqL6gkDsJY/MaQqI/nqwvYfxQoWJE3oOQ/7V6nvK ZD+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D82j1sHK; 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 v25si256799pfg.135.2019.01.24.13.16.45; Thu, 24 Jan 2019 13:17:01 -0800 (PST) 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=D82j1sHK; 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 S1728180AbfAXVQG (ORCPT + 99 others); Thu, 24 Jan 2019 16:16:06 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34283 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728063AbfAXVPz (ORCPT ); Thu, 24 Jan 2019 16:15:55 -0500 Received: by mail-pf1-f193.google.com with SMTP id h3so3649572pfg.1 for ; Thu, 24 Jan 2019 13:15:54 -0800 (PST) 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=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=D82j1sHKK3TRkYNHfcY/bZZuek1N9eLTp/LtInXcIH74XxdkU/9dIRvu5dF5YR46X1 G7dGafKoXB9lDZ95hhNpeoJYOC/PMAvCr/u6od/jKyFzSTgVQ9KREUCpJgyKn6mkdOdN C1HpOpFEK3H9wTfZ3MY6u7Q7aJ7UDnSIemLa9F/+Sazr/jvqdmMOBBb17OG0DykBPqkQ hsKrHb8LHYP4Lfa1jhBgWY44v8tzWhfu87nYJWzisxkAc/Ugflu0KeszaX6I1NRPH7LD 10h5p3RjA7sXAlFAbbAmOCviMd0C/Acd0Z0Jsue2OhngekXL/RKhYP3AU1F3nLYlWGo2 kqig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=KhC8f7WOUU1pIOCgAOuJ85khyyWgFH3+RnR02NOR548/IiUrSQlJsJcAWqLWJEsCG8 F8pgBt1FKazVUr0qfPqjTk6/XJflZW/b19pcCYdz2FP/THs9XSPXmtUOFLEfCHzZGPse CX+hVCCIDFyPXwa3rUCM1b6orKbWA+GfCsW2zOtPDJwgAEkP/j5JM3x4Gle0std3dRSv NxbuoDMkAEjwPDOOIV+PN1ypW+sssW2M0YbMaKU5t2HaGfrwv2VMbKYbD/WkbRZ+UycG QSWurcn+t3JAvmYRsAbEpth3OOFKifHjUAUURNXwOMujTrJE+qcyB4S75TcegekgWBKd dOyA== X-Gm-Message-State: AJcUukd5a6CIWA4kdDlyisga9LXl6WjGWrmcFe4Y8kpRHORDmHQuNtQV PoMgEAHX2/vQyjJFepQUFYdvUw== X-Received: by 2002:a62:1f53:: with SMTP id f80mr8135910pff.92.1548364553045; Thu, 24 Jan 2019 13:15:53 -0800 (PST) Received: from surenb0.mtv.corp.google.com ([2620:0:1000:1612:3320:4357:47df:276b]) by smtp.googlemail.com with ESMTPSA id j197sm29626418pgc.76.2019.01.24.13.15.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:52 -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 v3 5/5] psi: introduce psi monitor Date: Thu, 24 Jan 2019 13:15:18 -0800 Message-Id: <20190124211518.244221-6-surenb@google.com> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog In-Reply-To: <20190124211518.244221-1-surenb@google.com> References: <20190124211518.244221-1-surenb@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 | 104 ++++++ include/linux/psi.h | 10 + include/linux/psi_types.h | 59 ++++ kernel/cgroup/cgroup.c | 107 +++++- kernel/sched/psi.c | 562 +++++++++++++++++++++++++++++-- 5 files changed, 808 insertions(+), 34 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: + +