From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on archive.lwn.net X-Spam-Level: X-Spam-Status: No, score=-13.5 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,T_MIXED_ES,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by archive.lwn.net (Postfix) with ESMTP id 4BD717DD32 for ; Fri, 14 Dec 2018 17:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730050AbeLNRQd (ORCPT ); Fri, 14 Dec 2018 12:16:33 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38050 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729798AbeLNRQd (ORCPT ); Fri, 14 Dec 2018 12:16:33 -0500 Received: by mail-pg1-f196.google.com with SMTP id g189so2977772pgc.5 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=tahcy1FdYIcaWaxzvFa70oWi6tLyH5uRceN/1hcVnZWEowSEq2chyIjS3+H37qtGpu pNbYBWV6244BoytHKvU42zJmPyhyTdhvL+aq+FGDFvAQwjPbBeUjhBnvZEy8BgVTKsGE 78FOAVNNt5yUcx/q+GJyJW9XxlW5aoSRxQyo80jYBmoCJHvBq9murEELlQ2F7rRlZ77o jOZ+OiiQeBdTW5mwyo73ix78DQmeuKDUQA0bFEXQ0mPwKe1yxHi7DKhC05XskiR0Dnx+ MKBfUHyPhDFJ+FoSDqlpPlQl0HfIhg1Ji3G/BCrVlQOR6pin5aEqes+fGPe/5apWA5nU Fh3Q== X-Gm-Message-State: AA+aEWZcS7J72WNjPWnRL3V6UaVy6UFzE3fQ7pQ/Cf7EEjO49y8xTxpa IOCdW454a3BI2vXGQmWk1fo8Gg== X-Google-Smtp-Source: AFSGD/ViMDG0O+AhMhqckGp7fTYuzr0B6jw0GK8VDwFnvYjAbS86oGJY733jEqTJCnD6+K5jz/mo8w== 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-doc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-doc@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: + +