Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2430176imu; Thu, 10 Jan 2019 14:13:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN5oJOR1NQOuwaG4/9uf5lyYR2ZLoajpt8JhmbB38OUpddjoLxcgQQpaEW420/0thNW3pDxD X-Received: by 2002:a17:902:8d8e:: with SMTP id v14mr11989294plo.133.1547158388189; Thu, 10 Jan 2019 14:13:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547158388; cv=none; d=google.com; s=arc-20160816; b=iwTfAa8rJ764Fr023HVnQ4wqDjg1yBUlSKCfeZZcaXvkJ8mVqbRfB+7Q+8VjZ2rw8U dVT4FpG+1pOc3p0uHhrkuql2s6Nqp1Kfe7o9XOAhfezcQdJKPSsp3mL/GawA7rjmvfGk oGN7z9mnzZo5HJ4pwlor6Pjsc7u5Jw06DaHkf3kEvsT2tW4b22an7awj0ibfjDQit/Ge Yuhu5LT9bMq21Yg0xEaKRntM0dVGvSBB0ChQg44JRHc14YTdQZ1p91e3JUiU8J2AbtZV NkicppLHFQn34FjGlppabPCmtcxuhx62GZSj6tjSPAghwL3seWG1DeisoV9o7xyrxXUB cw1Q== 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=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=VGBgMiB9Il3kstEYQukTtxZgSsJ8zXTRX5CLh/HtSoGEjVPidSc3sM+OTfSPmd8u5I Q304Fck42TwIbzk2DI8mIkwWRwG/Q1b/4nbCf+6c+VUXwwzUbTOA43EdeMRLeMYVCaPI +cAfkvVUGTnU+6v/PSHuNCRP5exAdtphrJUk1z9UVHl15nQvazF+pOplQQmKUKgDbaoh 36EMYjFyO4pVVAvBWI6D41QU4e28QwafpMKUxIcD5123lPKJdQt/M+0f2q/zoM6xB13U AQoqRvqX4aw5DTAZWsXcQeFja1Z7HiTj997/wg78hbWlkCPdLYioEzM1ev/NpPz/MkI0 HMUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wASq212f; 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 i96si1397035plb.188.2019.01.10.14.12.53; Thu, 10 Jan 2019 14:13:08 -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=wASq212f; 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 S1729140AbfAJWIX (ORCPT + 99 others); Thu, 10 Jan 2019 17:08:23 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41748 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729066AbfAJWIT (ORCPT ); Thu, 10 Jan 2019 17:08:19 -0500 Received: by mail-pl1-f194.google.com with SMTP id u6so5773814plm.8 for ; Thu, 10 Jan 2019 14:08:18 -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=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=wASq212fPJAbSw+wDVzjj4TGxnkBFur8nfdkTP9iLdfs8nl+TPnRkKbu/aoj6sFgtC /t+g1WSA4iZeeNksTjZLTdhVA4w5sFCD03hsISvSFSzO6eTR3/6LKmKAzcLe+uKgXaRg PleSXlF5ESDh4+oHMs/qfZYkPgMVx19FkANmmcmzAyriz/1a9o1443VgvtPcMFpBMwUM GWBVi0J8y9Xl/3V9CSo51itmCCpTl2mrK93bHLAAlGNjw4dy1ZVFXMoXXUwlTmH0+mHN 3HTZrAJiYe49cOueM+mPs3jmD4gJDUhkdcy2AyVMnllbqvUq2XhsnSA+yPDhmqaQcCNY XP2w== 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=Bksm8QgIpk0mhgRhfImjkl115x47YhafN1AI+7vsErU=; b=CTriedlUp1QKyVwF2SxJ7nYHrMc+2v8w9hHjJEp0DtwMSuPj7c4aoijayaV5+oGN+y 0+zj3lIPumwVqoxoY99cuSuhPgo8tpNfR12KFQ6Hyk0B50rpIX03XbOUUKQ0ecjy6m9K hW3biDIgKfRsK3SYOYnx9xe0rPFuJTpWkupoRK0n1J/6kvcuh0dTHpjaNfk0tU32rJBO k3/ErtonfZkauP1Q4dwcV2gHhm/lbtWIWnwYANHq2RHPUJFnoxBFSmW1Ps57jXmJLG2R u39Nh2wRMfcp4//ZByJrQ+rAN5/zPrezEjp3LlAX1gQSnr11hLv8L11JFX35va+ie4rG OZkg== X-Gm-Message-State: AJcUukcqj4ZmLh2oE78D1DDrAOYk0CFP7RYVxnr3uLiHZhW1VtqK6ldM IWHajwsiUD7JNP1YwNDGovQ6JQ== 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 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 | 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: + +