From patchwork Fri Dec 14 17:15:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10731493 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 269EB746 for ; Fri, 14 Dec 2018 17:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C94D2CD9E for ; Fri, 14 Dec 2018 17:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DB5A2D8F8; Fri, 14 Dec 2018 17:16:38 +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 7BE0F2C807 for ; Fri, 14 Dec 2018 17:16:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 324218E01FA; Fri, 14 Dec 2018 12:16:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2FB9A8E01DC; Fri, 14 Dec 2018 12:16:35 -0500 (EST) 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 1C48E8E01FA; Fri, 14 Dec 2018 12:16:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id BBDCC8E01DC for ; Fri, 14 Dec 2018 12:16:34 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id m16so4350485pgd.0 for ; Fri, 14 Dec 2018 09:16:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Nn1Ue314+SswAOf+vuY6es4gTIX1DYSVA06c4QWx+Js=; b=HbE6Ip+aXuA745ajf/4ILRRogjc66AGpdUD7HPexJ526enO84ZFgwEaIg7Mevj5Azn pMHnpuwl4e3s5nj1ShdRKR/rSv+0BwuebrjCgzWRATS+5dyMqUh2CB7QEj4ODlay5fxu M2Db+vG3h/JetFBaRuP5y2xP41z8InUbpu9ZooTK7C5x+jdYLor1Ync9Ib8X6gU5IPPp vUq6Rpe/9VNA8xhF260QSjw+sq4GRzmYNqpZnbq5DCgFVnpfCiz6FDjZ2p9nww4YptWY ikjtbwilPYTkxsGGROvrmzaaTJGsBPi/pFnkCcpalbk/GUBrVqfuXuXlhPnN0bcUHfwM 55zw== X-Gm-Message-State: AA+aEWYprCjlYN7AWRUESghF6uRAbkZFM+7pkQuy5kR0dQREfYrYACSa 9o64Rov/+1SnXO+QD+pfuqETvGRrDc9LsrabTIPvZ10ne14DSWgrUjHVgTOWhYbILwo2oeSN6wJ C0/5bN70uAVc2IxjKXFSOWPwhO5/KZaWoYdRa8DnQhzRLo6bCEf1yh3osR/Lfn3EtL/QK9GH4vh NaJmQ0ZVmRpdIufyWqsjl3Mk5LR9dF/FDiPVNReNwHAzV15hmlT9cSevGLgAAZcS0oo6W3zrLYN ybTFhOD8Al735cQFCOfz3EK03ORIW9Fma0As+DtQuAjj+4HucVqow1GPRc7PwdZUmAtgh413zTE nIL2Z5qxvHqoaZT5KALjgxH0CiFCOhX/vnZDl7A1d3ZWYUcB7f3AuctxeVU1LyIZXkNo7n2vfcR o X-Received: by 2002:a17:902:f091:: with SMTP id go17mr3690654plb.235.1544807794270; Fri, 14 Dec 2018 09:16:34 -0800 (PST) X-Received: by 2002:a17:902:f091:: with SMTP id go17mr3690464plb.235.1544807791812; Fri, 14 Dec 2018 09:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544807791; cv=none; d=google.com; s=arc-20160816; b=JhGgDU3rC+ClGUExorJ9e/TuFslJ8rq1uqxN+IZJNLcLPh1JJ4QVLn5CbAX+Ld87jW yuV5ZTDZzGnM81h3s5vQF3skvlFQnbJLnwd5Tdj+0d0IEkWtjWqCfaxiR7NVHQQ5Io42 9D+HwnQH29wWHyW1PkZCKuzHLZ6l1icmCAVo1r2JQv4azaqD5WzWaMsoZoIuMf/LpR7I 3vjJ9LsdNUVzYZ7i57s2u3R3L4w7AOr7jZSmfWEgFyZvPbaDghqdVF1L5GeCZLCE6ZQE 0yow3kJAUGSzngTYhujt/txo6YREflg05TPsW14uM4nOM99aj1XcXBeNLuZuQrQEnB7N 9Axw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Nn1Ue314+SswAOf+vuY6es4gTIX1DYSVA06c4QWx+Js=; b=nH3FAxfNKKXg9Jf/wu3IzGrSbgnqXQjUQD3TjOsKcVRDcnw11YB7I0/nrS9vPqFRPL VDUWTQbeixNmAx2lV6cbSJxitDZgZpwMRG2Ih8QzDSUKGx+8DtjYZ3gBwhVsdTveSQYJ nPc/DZ2Va/6d3Ef7t711+tVoKIjoo8PNA8M20sYmdpCES88ee3Cm0oOym5GWTB1T2Wbb Hv6DuYAVGGdZPnL+GfPyiaNzANa10EY4F10d4Sv2UNvmtcWxllI7PXKGYRCs1AW9/IhW PYI37MEP6Il2R43JpUjD7qRFHydYWRjxiW3tFoVxB4ef3bVseoGQ9fm9qsVLSgQOj7o2 FtkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tGiGcMHC; spf=pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=surenb@google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p22sor9050510pfi.50.2018.12.14.09.16.31 for (Google Transport Security); Fri, 14 Dec 2018 09:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tGiGcMHC; spf=pass (google.com: domain of surenb@google.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=surenb@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=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-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 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 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: + +