From patchwork Tue Mar 19 23:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10860597 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 B2E831515 for ; Tue, 19 Mar 2019 23:56:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5882994B for ; Tue, 19 Mar 2019 23:56:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80BFB2994E; Tue, 19 Mar 2019 23:56:52 +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 7FE812994B for ; Tue, 19 Mar 2019 23:56:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D84436B000E; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D0D616B0010; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) 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 B899D6B0266; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by kanga.kvack.org (Postfix) with ESMTP id 8E00C6B000E for ; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) Received: by mail-io1-f72.google.com with SMTP id r21so395534iod.12 for ; Tue, 19 Mar 2019 16:56:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=frwiutCdP4rIs7VzndCw++HxcxANOWIj7MX63sPxLHXva7BJegHFk5E8k0JDBMfd8k YfhsbA11AjAFk88MBzxNucffm9oR7nhGY64XelN0klXImZgpi3gn1YJl64ppFNEa15Ft PwNo6zYGbcIwbz19c5lMETv6eESaQ6u+O4JfX0aav4ePtpDH4qfQkZYh1n2qBiY41A0m 4tdgYyWDpjcRAtYyGlhtg2CHAFEqncWEz+4S4PJGm1tRgFprF78z47eiNaSXqNH3TX60 Tt1TfUqZSi79VzoLqSQU5+2rCzKUFUu8xWmiciVfClkR496RM1Zgu8k9hctzbyGt4+f7 BYrg== X-Gm-Message-State: APjAAAV+bspQegUf5KJKgcJPKf6g0LW5QpKJzWzVDulZvE7M6rNbmoLN Qf0aslhIBCb1614F4MiVjU6sdGCF5F3wLdd2M75xN35c/ovuv4m5v492iGttkDzEemAWKqzNe0C zxQka9DDqQQxZ9Peqck51NIt5U5wzelDAkb5TTfIm3a/zJ5vg798Hdgj8S6iJ2msPVw== X-Received: by 2002:a5d:93d9:: with SMTP id j25mr3522017ioo.305.1553039808218; Tue, 19 Mar 2019 16:56:48 -0700 (PDT) X-Received: by 2002:a5d:93d9:: with SMTP id j25mr3521943ioo.305.1553039805942; Tue, 19 Mar 2019 16:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039805; cv=none; d=google.com; s=arc-20160816; b=gU2WDh6/44ojjesOApS0R+q5hRWUFCnVJu7yeJ2kCw5u6XxLV+dmKcWW6A+o/vcXc+ DyFeCHhH8IyBnNiKzSdJz6VWUKaB6/5CB9goSrE3bO7h5KxOUW92wSZq+yGWwjcBmP3n djiILftpS3cGRN9HjilnkQAGDa0rnkjNEq/JX0QdTVCSnGC3PTvz7pNmf8hTcVZW6W8a FF8Pi4V4pT0Ec3JBrLL7L+9jPCMxfeT913+T4IZ4wDxq6FhGE6qiNloYZJ/IS+4+TqeP tcesvB03fPWkYL8DIbZcjOOup/QI7+4zT5yik5HGWObsnbXvxVBMX6ZgLWmfbk4qlht1 VRpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=G/8yf8ZH6IhtnJY5Nr+21G/lg9StD5xPeQYUEqsSwjYsQTkPXEYM7rsQWy8nA8zcE/ IJlyXlkVly6mbKqb5T12J9MUWRrsAVjYrjZadoaiHYM5zCdll6wi0e62MRRZQVKeu089 LzZmFADUSBdKx9OISTHuJhcuJxsZpWZnFR0hKaix26aLqmcG87s6RA+ToLMXCHLO6zQD e2ffe8qpd9XrONq/lWDu7dyxMFt4AW7ESi0trQkoOVifctYvWkAYaGHrMyqD4UBz0RR/ uwKClPICRgkuQ07wV0DV8k53fw7aA5NrnC/6DiQIvJbk0SiZq5N2+YT7+tGo9Vboz4Wv WZ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tDTLBAGv; spf=pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3vYGRXAYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id q67sor568684ita.3.2019.03.19.16.56.45 for (Google Transport Security); Tue, 19 Mar 2019 16:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tDTLBAGv; spf=pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3vYGRXAYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=tDTLBAGvjP1aWgYAToI0jrG0Ojb4KLFuFfahjHLMvszYkeiDWwjY8SDWm8y8Y6WwEs bBCOKw2P63Q8prUZUD8b3ryydHwgB97IFkWB7kzy0bZoIBMU+NvZSonG+RJ2DUKznRWn z3umqoYZGp6l8nguV4DH/oDPrhh1yVkqukzZYMR+pU4Lx4uYvNrSKP1Q4uygTaAfk0mJ wYHGTXwAcx9775B0pBTXyPbYgC2IXzIHF4Wiua/7EQBM+74psKEm1ZwRZYfJca+EUvUk INuX2eRdG1lW7MPgHg/NuMNtdgrYvjehTAQH2Uwp/DjwxIl1uiP95K1uhpcM9XPynU/t TXrg== X-Google-Smtp-Source: APXvYqyeblFB8b2GIjj6UvR07OrEL8oGXI1Wd4F+PP4czPiRT2vkBl2eKgsnemwdtOo2inYGl/8y5CuGRR0= X-Received: by 2002:a24:7d8a:: with SMTP id b132mr3009072itc.20.1553039805672; Tue, 19 Mar 2019 16:56:45 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:19 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-8-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 7/7] psi: introduce psi monitor 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 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 | 107 +++++++ include/linux/psi.h | 8 + include/linux/psi_types.h | 82 ++++- kernel/cgroup/cgroup.c | 71 ++++- kernel/sched/psi.c | 494 ++++++++++++++++++++++++++++++- 5 files changed, 742 insertions(+), 20 deletions(-) diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..4fb40fe94828 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,110 @@ 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: + +