From patchwork Thu Jan 24 21:15:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10780157 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 5FE3E91E for ; Thu, 24 Jan 2019 21:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B35E2F805 for ; Thu, 24 Jan 2019 21:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E9042F83A; Thu, 24 Jan 2019 21:16:01 +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 346642F805 for ; Thu, 24 Jan 2019 21:15:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 987F68E00A0; Thu, 24 Jan 2019 16:15:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9117C8E0097; Thu, 24 Jan 2019 16:15:57 -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 78C668E00A0; Thu, 24 Jan 2019 16:15:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 1E17D8E0097 for ; Thu, 24 Jan 2019 16:15:57 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id a10so4740114plp.14 for ; Thu, 24 Jan 2019 13:15:57 -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=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=gj1YEOR7cYwo9DO0Mgacw7eXRmL+U9fAbZHj0jZ6Pd74MybXwyMoJqUVNrS1iHaB+K udhimiPaFys9Pe72gn50ZiRaQfhFUNoVGNluK63LPnwHebdway7lHljsh/FIvwFB+8J/ rszItE0TRQTXQAMQAv35CKPSEU5AGsYzy4gxPtPLfNNB79ZC0gvjvkKQfaySgElBUZYi C6kHhOvq1/aKhY4DSEByPAd0S46dDoOKUN9cHP4Mrcp//PjzYJ4DDDHbivF/QQ3K4YJl ot5jgdnspsMHmI+WsETPOAJLgtXrPeI5QJ6S7SR+HWulvLBTJrA/79FATrHzJ7TPXd24 wUYg== X-Gm-Message-State: AJcUukdItXWjeCXmc14vNTJx1tljPVwLDbRhabvOnoR00doUngPgFgz0 hrlzPFO9em0oCN+bzUDetyNmvWpOy+gErezVOQ9nWkTHlYf5uEIL2rsjWbXvo0qKJIsxGUFEvo+ RtUa+MuJ9EoptnN6PxS93fWowaAq/CIBoxx3TDicqOjRgz2ThDbSrEoLrfu2lxMo9GtclomMGov JBHfmX8WbP5yVeu8s4Bw4fg/kDLJkcpeytrEFiR6pZdVEwz4QluPcRNaA6u3qWqpf454gvFMOAI 7M0E9HH1/M4IspI89HJRANvBvUSWuLJOu5X9Mj/JrY5F8sD2aIoHe1jMz+6DnDFS7LaNDFAX/fo tKzUpVlMgHTf1aL2ta72rRk+buCg55B6gpURGC6mcjArOJwG5SS6ymB7xaRrb3y7H9rekmD/lhp I X-Received: by 2002:aa7:8802:: with SMTP id c2mr8102816pfo.20.1548364556554; Thu, 24 Jan 2019 13:15:56 -0800 (PST) X-Received: by 2002:aa7:8802:: with SMTP id c2mr8102686pfo.20.1548364554173; Thu, 24 Jan 2019 13:15:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364554; cv=none; d=google.com; s=arc-20160816; b=pVk8FQzaH6o+UGgMpgz8DKGYahQXLLZKqLiATxtYiENuL0hM7B1XKkjBb2kuZdl4+s 0hfV9kTbIbHMvUJk3m6WzoAByAu23PoBocEo3oF76t2ficsKoJPAUqQb1LTipc210WoX zkagw8NokRBcO6USiYrPYeP1DCwin394OBEw+1FgeNGnx+VNYK6qzbhm3BJWTOqxG7Pb FA+OZhyzCSzKDcf9t9BJ7A7vfazwct7SIXyeeldhVeLB16FxJ01DIKE+rqK2lxstB2Z5 howHv1a1KUWk9aTWePECFW4ih26peWVSH8M+lTTZ+aTxRC9O/2KRTUUy5YR/ID9i/lDf Tf4Q== 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=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=MSyt7up8U4OT3mKWk/ZpL5TUL1H8rv7JWYR6kctRPAZY8xt3XTHB1gCV1CVVZ/W/b/ fFOLW+UjViRoP49AmpBhSRmTM/fnICAiMFZloQknk21qRi7bdngOd95gcZk7rbB1lUlU CJ5jOXe030khrg0YCgf/v5S8L4eDTftnFfpCQNzaA6gOdKTMMkTTeruP/U1nNXS5/vBJ XXWZDvsQstbZrLuXUKUaG/tXkKkUr1leernQY6MFy+CCiuLYL0q435xHe9Al+TmmsQPM Dr9UXmqlPvVip6je70I1OmtJXKcWnsc1u7z3PDT1ejPfw4EcFfSX9i+jh0v8R85k8hys hCrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=D82j1sHK; 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 s16sor33452701pfi.69.2019.01.24.13.15.54 for (Google Transport Security); Thu, 24 Jan 2019 13:15:54 -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=D82j1sHK; 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=jfPDsizXFvuEx4Zf2R7rWTHRSgVVFK955p3ms6TglQo=; b=D82j1sHKK3TRkYNHfcY/bZZuek1N9eLTp/LtInXcIH74XxdkU/9dIRvu5dF5YR46X1 G7dGafKoXB9lDZ95hhNpeoJYOC/PMAvCr/u6od/jKyFzSTgVQ9KREUCpJgyKn6mkdOdN C1HpOpFEK3H9wTfZ3MY6u7Q7aJ7UDnSIemLa9F/+Sazr/jvqdmMOBBb17OG0DykBPqkQ hsKrHb8LHYP4Lfa1jhBgWY44v8tzWhfu87nYJWzisxkAc/Ugflu0KeszaX6I1NRPH7LD 10h5p3RjA7sXAlFAbbAmOCviMd0C/Acd0Z0Jsue2OhngekXL/RKhYP3AU1F3nLYlWGo2 kqig== X-Google-Smtp-Source: ALg8bN68x9T0eJokG1BPGt0R+4pOEjGNnsNqCOTW3GuWSp2tGAwkcmDKIni0+LaYE36dkvV+NfNAng== X-Received: by 2002:a62:1f53:: with SMTP id f80mr8135910pff.92.1548364553045; Thu, 24 Jan 2019 13:15:53 -0800 (PST) Received: from surenb0.mtv.corp.google.com ([2620:0:1000:1612:3320:4357:47df:276b]) by smtp.googlemail.com with ESMTPSA id j197sm29626418pgc.76.2019.01.24.13.15.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:52 -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 v3 5/5] psi: introduce psi monitor Date: Thu, 24 Jan 2019 13:15:18 -0800 Message-Id: <20190124211518.244221-6-surenb@google.com> X-Mailer: git-send-email 2.20.1.321.g9e740568ce-goog In-Reply-To: <20190124211518.244221-1-surenb@google.com> References: <20190124211518.244221-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 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 | 562 +++++++++++++++++++++++++++++-- 5 files changed, 808 insertions(+), 34 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: + +