Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2334562imu; Fri, 14 Dec 2018 09:19:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeEZ5myl2XFAgb6UyJeNFVwuK7eTiQ/TYGKN3MboXZHBxCx7uIE4TDwkpRYCRJpWkuBYVj X-Received: by 2002:a62:c3:: with SMTP id 186mr3603130pfa.24.1544807989068; Fri, 14 Dec 2018 09:19:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544807989; cv=none; d=google.com; s=arc-20160816; b=EO18Ctl1zWtRFU4SImS/s6UavxatLia68KZikGy/ZqHXCFjvT0CmQ3lutsCKxI40YR mIqfQYHVtMiOfdZFCTgvmTyP1jOqh1bYexiw14796jyImLBApoJWI/qWsYGg9U98sBPJ FVVzt1Xbb+LEz5Hgn30NfN05gjbJwpwq+RIqTKQOdZ4i05LC1h3QpBNeH2j7HxluFy1A dEJ3iPh/Xi7fzRwPQrNZhuA9fHn9lRCOEuP4aQ9vLWCIx/9sSI/WZ6aSwlXFKbvVUaeM pVq86mVzWrEgIFi2SLg3QVztjQVS/bCZtZen+iYSKH8mUnOKLuwetUizCpnS4pWILDpF 6+eA== 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=Nn1Ue314+SswAOf+vuY6es4gTIX1DYSVA06c4QWx+Js=; b=Kkbv+f7/gkZUKKdCLIuHSrPkwT+mkPr4z5HxCGzqLjMrZctk2+Qs/YBl2IZ91uXxnk 1fcONfru+/SQ6l3ogLAV9E4BzYuR2MOqUpHVmJa4/wD38cVO68vnLAlkLdTeUuH2U31/ XoVg/Lt9hir/Sil1S23krkj/5ZNMRRZVDOmIm2T9jhpBllQSzas9ySugFZcnqwIQU0nF QxaqEhPR7BgWeEvHzkRC9zUyqFU1yGJHYg84vJ9lYMJoIgNo+Q/AAC7+j0nOc76n/R2W 01B4CF+3rUNgShh149ZoU2ws7ASlj4b04Ti+oRBORovExK4npFDuCLolTVAzce4qKfuq ZGeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tGiGcMHC; 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 o195si4640849pfg.106.2018.12.14.09.19.34; Fri, 14 Dec 2018 09:19:49 -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=tGiGcMHC; 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 S1730465AbeLNRQe (ORCPT + 99 others); Fri, 14 Dec 2018 12:16:34 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42871 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729854AbeLNRQd (ORCPT ); Fri, 14 Dec 2018 12:16:33 -0500 Received: by mail-pg1-f194.google.com with SMTP id d72so2969772pga.9 for ; Fri, 14 Dec 2018 09:16:31 -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=Nn1Ue314+SswAOf+vuY6es4gTIX1DYSVA06c4QWx+Js=; b=tGiGcMHCsDgHZsibAW6sAWf/+Rm39sMWc9MZsmiT0YP2QTv8F/vKO78Zq7xBDlFVkT qfwF8qJOn6J2Sazm9+qrPDsyRQWqPGYC4Az/EXSlixdSVPLx8qE785Djmu9+6N5fLsEr c2T2kCphP5DbvzPMjiIXmrYYliVwROp0ATUNGJHohc2KxoetApyu+FngwQ70bpoxnoHE ncSrXfAGWuSdskRjyJsCwvYJTL3D9Ma3j/s3KciEpNjgWYBEyQ7F+YLhCkGIg2VzOGu2 8sWwAV+bshSPo43Zv0ncsTZ/Prg1V2IbyE5IRSAOgemRx/0V6rscKkgFNgqIP4THUr+y eEpg== 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=Nn1Ue314+SswAOf+vuY6es4gTIX1DYSVA06c4QWx+Js=; b=cNlR4DahKbhs6LipNM1Ih+lVJhQbljWDTmBxx0XMKgo6H3FIUsawNIqS9sQIHgc152 O41HLmmMI6KaXQ1vU3dek7wbJxn9qSTJO3AhslfBU0FBlqVp5v5UYC2sSe6JRgzsTQjv 5PnUkJoMliy19y5OSy/ZYEQ9GoWGL4Vb1l+cd1YS6FtWvWCFV+/LpYVA/fgSrJAqXn1O I+0hy6SzMgNmOWWFn5A8sm9mWzskH4NLCTjyveJ51fNXu1K8d3Ucmbl9aMc0K0jdwTW0 7RGByauJVu/Vvr36A5n/i7P+EcVE14f3GnumAYxyB10o5BSf54j4RGkODI1yxg3dflGU 3EMg== X-Gm-Message-State: AA+aEWbRZy7+3mIrRHZMoxsTgMjjImcVP88IBuloA+nrRmgGtcJi4gwd A2kQvFC2IaZJzpfVD5tF9FD0FQ== X-Received: by 2002:a62:1c96:: with SMTP id c144mr3555511pfc.129.1544807790658; Fri, 14 Dec 2018 09:16:30 -0800 (PST) Received: from surenb0.mtv.corp.google.com ([2620:0:1000:1612:3320:4357:47df:276b]) by smtp.googlemail.com with ESMTPSA id g185sm7605761pfc.174.2018.12.14.09.16.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 09:16:29 -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 6/6] psi: introduce psi monitor Date: Fri, 14 Dec 2018 09:15:08 -0800 Message-Id: <20181214171508.7791-7-surenb@google.com> X-Mailer: git-send-email 2.20.0.405.gbc1bbc6f85-goog In-Reply-To: <20181214171508.7791-1-surenb@google.com> References: <20181214171508.7791-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 is expressed in usecs and threshold can be expressed in usecs or percentages of the tracking window. 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 --- Documentation/accounting/psi.txt | 105 +++++++ include/linux/psi.h | 10 + include/linux/psi_types.h | 72 +++++ kernel/cgroup/cgroup.c | 107 ++++++- kernel/sched/psi.c | 510 +++++++++++++++++++++++++++++-- 5 files changed, 774 insertions(+), 30 deletions(-) diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..b006cc84ad44 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,108 @@ 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: + +