From patchwork Thu Jan 24 21:15:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10780149 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 2CED691E for ; Thu, 24 Jan 2019 21:15:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BE0E2F805 for ; Thu, 24 Jan 2019 21:15:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FE262F83A; Thu, 24 Jan 2019 21:15:48 +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 D58132F805 for ; Thu, 24 Jan 2019 21:15:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 989778E009C; Thu, 24 Jan 2019 16:15:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8EE2A8E0097; Thu, 24 Jan 2019 16:15:45 -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 740F68E009C; Thu, 24 Jan 2019 16:15:45 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 2FD338E0097 for ; Thu, 24 Jan 2019 16:15:45 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id 82so5671922pfs.20 for ; Thu, 24 Jan 2019 13:15:45 -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=ucF1EwcLVxCtpPOBrQuqUFcO6ME+3ZXcCq84fU7zCQU=; b=nEFxo5qh/0yzk7UgyovvBb8WcX6p+6/Ze1MzJSlvSan/dP+drTgxgfB5RuCqTGrGBl yYUcs3lZe8Fjtjr6OG06eUm7+grru4mw3rNlbRYR0fVFxDiZiuN8pX7zIlpNKDjueKWP j34IoAmux0iwxWCGDpI+lG+OpKUYaGPiiCV+MlxzLeV+g7TTXnhdOwKiV6RrX9IPPgs/ Oaaa6w5e1pkH9oHvu33vQsYG7cSqcHGOiKdZpzu5hvysX/z1A6yHoEKP2NboLWo++V3Q +F/yNVs1ehQ9tU7echejBquiPZ5epyn51dL+Ku3bnIqWJRqdPoScNJz3lJp7ckMDRRuT x+Mw== X-Gm-Message-State: AJcUukec1vfPPtigPtiE1JlA/WUfFW1onv0SoY+bjcQf9JN04ifk3ZSW SQS1Osgg6Mv2ZZ/6y5WvLbZHFfjWGUegzxmn6P4cL3JcfZvd/5BOxSVJUc23gcAe+OLdIgZ/o5b fh+eAt6xrVoyAk7Z6oYr4mfLJJnMwtobkIonUcdGT0CT9un69PtRCOd1wHz16tcq3ci8re6gNig uEs1r/cMsGCbu0RilY4zEhM/i+Qzxn0/6gZic13NatOJXgXCZdTxFbPZ9l2PGod38Mz1vm3Uf8D j5GaIHyEKnO12vtGZUIaPSNAuKqLH5Kp53pDZ4Bw32Dv7i9d62DLMLmuF7FU+bMbANjVhU1pEz9 ha3O/xozLvXkd5vOZDnKkkvkuokUKkVALqKpHC8hdvpdkouB8n6HJaVY+C+pRncpk8n5TqcaZ8K F X-Received: by 2002:a17:902:1008:: with SMTP id b8mr7839416pla.252.1548364544758; Thu, 24 Jan 2019 13:15:44 -0800 (PST) X-Received: by 2002:a17:902:1008:: with SMTP id b8mr7839370pla.252.1548364543985; Thu, 24 Jan 2019 13:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364543; cv=none; d=google.com; s=arc-20160816; b=oh23fQzZe3KuZqns9U/Z+TPHHC/O4jtWwnB/6yI4EGMYsArejDsANeVY972AkpflOx 0LBlORm1M2Sit2Z1YoaD2R/61BDeGCWdLejHTbNn5y5IJLX4hYfwZZ8MT0o43Mrs4JvI 66tcTB8oER1MQ0EIRlFBmmpO3oJ5KiOkFZM1cjmMHRP44lZRyZYh7tq8cGOMn75YE9VW krmOj8J/cBu7zcJeybt1B/1oNBf0w8VDVD17e+s28bBqN+WVjVzlriV4XzKx4Ir9gdRE pjkt1hGoAw7Aa9+yGZwuOOLe9mODsCXVfSY2+Ki2+ADK5QnBKruV5Huy97GolkkpqHce uHYw== 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=ucF1EwcLVxCtpPOBrQuqUFcO6ME+3ZXcCq84fU7zCQU=; b=DTKrtWZxIJA4HKATP7Aua5syXutTqjgr7CxHv7B90MDOxSt04XyLENZfkWLjHwqKKV VwovmHSAtYebnBfol1ZcJHGAjRM2ZOIsTOAntWTgYSlddii0UUK8Q1MWei6aSfxP8K1M cVKgEkeQHmEYPBH/nO5RvUKb629lz0xCJlBNkv1eZv4nxALzrBTu+vsgBfClQNksO8D1 C5q2Z98hW0hnfqne7rGk+raMeaIEbTwkAABosxf3YORQCJSqcWukFgAWMunSSC3P7JEP RJ08N0xcalsNOVSlnFTi+tsgO55BZoDG9fSjfPK3CXDlaogcJu3lXWRJTFqaD9aNaDgf Cowg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gygzfM8D; 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 n6sor35862537pgv.69.2019.01.24.13.15.43 for (Google Transport Security); Thu, 24 Jan 2019 13:15:43 -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=gygzfM8D; 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=ucF1EwcLVxCtpPOBrQuqUFcO6ME+3ZXcCq84fU7zCQU=; b=gygzfM8DMwdV2iIuQLyTUNZoqz3zBV3YtlUapmjclo6FC0Cojxkyvg4NivMng9lbsQ UWdyeeLEfhPEp8uDGJi7V+xJ1r8fLv7cSF3AgCBMzvurwt/n6qyU4ar7Cg9qTtZeIxbU J6YSkeKSSK0UPNMIulk/GIHII8GRmfVYhpB65NdU5mVAAkC5EC5Z9ITK8S75A88PP/rM YCmvpjQontE64hJ0camuKp/QHj5ID+XU4FRhNKvHB2zo3jpM7bZb6q/XuMvwwy6vaDwK BPTQ0nG+MGuEYAZ0eOa1zCAzJnqN3qOecuomYBNuInO5ONQIFkVFx7A78idtIZ3d2iHh EAXA== X-Google-Smtp-Source: ALg8bN7SzOSe/SY78Pfzr1GOzAhXFURTr4LVGcJJzkPSCrKgxlqMkTFLV98NujEgXfWObOrL6iJgLg== X-Received: by 2002:a63:31cc:: with SMTP id x195mr7538081pgx.52.1548364543402; Thu, 24 Jan 2019 13:15:43 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:42 -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 1/5] fs: kernfs: add poll file operation Date: Thu, 24 Jan 2019 13:15:14 -0800 Message-Id: <20190124211518.244221-2-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 From: Johannes Weiner Kernfs has a standardized poll/notification mechanism for waking all pollers on all fds when a filesystem node changes. To allow polling for custom events, add a .poll callback that can override the default. This is in preparation for pollable cgroup pressure files which have per-fd trigger configurations. Signed-off-by: Johannes Weiner Signed-off-by: Suren Baghdasaryan --- fs/kernfs/file.c | 31 ++++++++++++++++++++----------- include/linux/kernfs.h | 6 ++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index f8d5021a652e..ae948aaa4c53 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -832,26 +832,35 @@ void kernfs_drain_open_files(struct kernfs_node *kn) * to see if it supports poll (Neither 'poll' nor 'select' return * an appropriate error code). When in doubt, set a suitable timeout value. */ +__poll_t kernfs_generic_poll(struct kernfs_open_file *of, poll_table *wait) +{ + struct kernfs_node *kn = kernfs_dentry_node(of->file->f_path.dentry); + struct kernfs_open_node *on = kn->attr.open; + + poll_wait(of->file, &on->poll, wait); + + if (of->event != atomic_read(&on->event)) + return DEFAULT_POLLMASK|EPOLLERR|EPOLLPRI; + + return DEFAULT_POLLMASK; +} + static __poll_t kernfs_fop_poll(struct file *filp, poll_table *wait) { struct kernfs_open_file *of = kernfs_of(filp); struct kernfs_node *kn = kernfs_dentry_node(filp->f_path.dentry); - struct kernfs_open_node *on = kn->attr.open; + __poll_t ret; if (!kernfs_get_active(kn)) - goto trigger; + return DEFAULT_POLLMASK|EPOLLERR|EPOLLPRI; - poll_wait(filp, &on->poll, wait); + if (kn->attr.ops->poll) + ret = kn->attr.ops->poll(of, wait); + else + ret = kernfs_generic_poll(of, wait); kernfs_put_active(kn); - - if (of->event != atomic_read(&on->event)) - goto trigger; - - return DEFAULT_POLLMASK; - - trigger: - return DEFAULT_POLLMASK|EPOLLERR|EPOLLPRI; + return ret; } static void kernfs_notify_workfn(struct work_struct *work) diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 5b36b1287a5a..0cac1207bb00 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -25,6 +25,7 @@ struct seq_file; struct vm_area_struct; struct super_block; struct file_system_type; +struct poll_table_struct; struct kernfs_open_node; struct kernfs_iattrs; @@ -261,6 +262,9 @@ struct kernfs_ops { ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes, loff_t off); + __poll_t (*poll)(struct kernfs_open_file *of, + struct poll_table_struct *pt); + int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma); #ifdef CONFIG_DEBUG_LOCK_ALLOC @@ -350,6 +354,8 @@ int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name, int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent, const char *new_name, const void *new_ns); int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr); +__poll_t kernfs_generic_poll(struct kernfs_open_file *of, + struct poll_table_struct *pt); void kernfs_notify(struct kernfs_node *kn); const void *kernfs_super_ns(struct super_block *sb); From patchwork Thu Jan 24 21:15:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10780151 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 372401390 for ; Thu, 24 Jan 2019 21:15:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 265F32F810 for ; Thu, 24 Jan 2019 21:15:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1722F2F876; Thu, 24 Jan 2019 21:15:50 +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 8EC8B2F810 for ; Thu, 24 Jan 2019 21:15:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B93F8E009D; Thu, 24 Jan 2019 16:15:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EE3588E0097; Thu, 24 Jan 2019 16:15:47 -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 CE5EF8E009D; Thu, 24 Jan 2019 16:15:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 8B2328E0097 for ; Thu, 24 Jan 2019 16:15:47 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id l76so5724660pfg.1 for ; Thu, 24 Jan 2019 13:15:47 -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=hQMXtShjYz4LIok46DuN+DSpcNGcRKZs3McroLRrGJw=; b=CFEif2lIKLIa28DL3OGg9/fm9oY/SepTNwuP77/J9EfuR/oT0S2xvtDoh6vF7UWZy+ it4SZOkKLsxhZ4gG8sc1h/vJESF140n0TBuEhChyhYw1j//L2U8X3sDjVXXvmfjOdcAz /iURsRwOz8Ewk51Jftl7GPCnZ7VUmkm6ToAPyJ4Oc0D9OlMharjzkJuvsG6JEHv6lY3g Hg7TmlGXVXWRWKU4sPfn0NNK63DEkgWeVO11X2Qe9XrXAYuKWPyh4UwzWpDDhW3yBZys Anlk8YeVCIhn+58C+qP1EEt5X0xtyhUrW4fOK85yV0QOHXWtCp9r2WK08S84dToSAMoW d/mg== X-Gm-Message-State: AJcUukfa8LLcm4uBGnfyeUbXgm0P6zsqKEqVmqDka8opiq9nrcipgWwO wXRy2wVCK+Ra/aksHkhZO6tQ3WhiJwDTzM1YeI8Fuh+6KtKI1i9wOVDvdidxf/gkx6IqNPHKqbg G4xCnbvqN0CSZUSvqp5YINwt3TI5NIXQfFkmc7gifRtrW7dgzIQhewnx3A9UNWRNVkLn2sKe5RS 4nMwJr1GmjIKErXdSjWnTMHURcuC4qQxK/MVdWLEzz6Fq6sZOtvMK0NqCVigTO3+Kj/KPQDZejl c/wCbMr2BNwJ/PpZ1umq1G+BgH2YF0Oxr65t6BkpfJzI7dhzQ5JhBFC3YoE2UUHeg1M90QMRe6Z 9SFJU3YNt6xuhMWxGl4sWWtzdaBm1GTpVgsTg/a5ZDBPV7KODDa5FebkeNSerHOl8pKxq1yzbm2 M X-Received: by 2002:aa7:8758:: with SMTP id g24mr7991278pfo.250.1548364547213; Thu, 24 Jan 2019 13:15:47 -0800 (PST) X-Received: by 2002:aa7:8758:: with SMTP id g24mr7991234pfo.250.1548364546371; Thu, 24 Jan 2019 13:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364546; cv=none; d=google.com; s=arc-20160816; b=qQjv8gXqQbs7YVLrx4nRzYSeXnFUiaFD/AthoGkBIZFfudCC/GrC2jDrWyxlnO9I6k yIbDM2JV2qffs7EBZQeObvX57lvVtK5xQgPl/3vihjTQLJ9S/2BHQy/mx4+VS+I6s+RV ONQZSu45XJBvNW2T5zGrt77Vj/598h9jGis3Lr5cnOA7MMQBLCJqHXcO/OF9qGy/9nkn P0by0QnQOP6fU0NpuyT68zul+5BtylvbZ2spdig08e1j3YKAddjqT05y6qnFBSpiA5h0 ge54FB5VeKBgeolh3iJlSKDR1SUvJQ+cgAYMMHTbReLr1dE2Pw8sFHRtS2OC4Bc6GgZy QdSw== 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=hQMXtShjYz4LIok46DuN+DSpcNGcRKZs3McroLRrGJw=; b=eH96APQGzQsnxmtrw+aKCcwSDDYg1edlBhnz8UBMnv3/REGRXb0WlpNb3C7MK7j48x fohF2XIxMKnbs1X2AmMG1oyMJHSvukW+0OqkKKPRrKQuEDbOH/MRV4TPYEmbT3+FDi+9 EjisRJ0duQx3ToAAMdaI1yHroKTaN6uNarQ21jDuZpn/LBzpmImpdQ1449JwHABImuCH aQZobJwEvu0sRAHx6vYiDzojoenxnGuloa5iGscMT7QceuLVnH7hGXR0hqZYVsl9o7M9 i1km8VQHmc6jBUSnpV1ppqJcXQG+6STB/KmzQQQLDTsCf00dP/UFzwq4cilgAFh3bfcb /7zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=j20YsKHG; 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 p3sor32892617plo.56.2019.01.24.13.15.46 for (Google Transport Security); Thu, 24 Jan 2019 13:15:46 -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=j20YsKHG; 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=hQMXtShjYz4LIok46DuN+DSpcNGcRKZs3McroLRrGJw=; b=j20YsKHGwaT+e7qtfX+pJMn7EqgnnAg98DHCtEKAcNNAthLRLG8JE/6hRv7KyQ5Iiz g0cQdc6pIJoSNiXlKr5WinqrLgPEyyyT3ueTy2KBOv5V7YP+cZAFTlF+rB9CIxSpQJxG r43vq8LUoKlLqhCQAloIuMQU+cSFgagDdDNtqJu/3gx84lgakSYZqN2brhiwObjRTIf1 X++KVwfttX10Q5Dwj4X55d7C4wtHOvzDch/8RmJjhBu2y0rDPFeIHjbFfjE540Fv/dvd jBcaZipg2xsJp2QnwLiTyYtSLmwgKypskSEK4EcIDc/gjPZnGZm3zMY3OayW//GIfrhe DCuQ== X-Google-Smtp-Source: ALg8bN7nCufI9BYh2GZ0ogHwAUMbkmGJZbvBktdzlwXxc4JpxluUrMJcb20Y/QlbwgK+in4KOP50ww== X-Received: by 2002:a17:902:d697:: with SMTP id v23mr8003217ply.261.1548364545767; Thu, 24 Jan 2019 13:15:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:45 -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 2/5] kernel: cgroup: add poll file operation Date: Thu, 24 Jan 2019 13:15:15 -0800 Message-Id: <20190124211518.244221-3-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 From: Johannes Weiner Cgroup has a standardized poll/notification mechanism for waking all pollers on all fds when a filesystem node changes. To allow polling for custom events, add a .poll callback that can override the default. This is in preparation for pollable cgroup pressure files which have per-fd trigger configurations. Signed-off-by: Johannes Weiner Signed-off-by: Suren Baghdasaryan --- include/linux/cgroup-defs.h | 4 ++++ kernel/cgroup/cgroup.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 8fcbae1b8db0..aad3babef007 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -32,6 +32,7 @@ struct kernfs_node; struct kernfs_ops; struct kernfs_open_file; struct seq_file; +struct poll_table_struct; #define MAX_CGROUP_TYPE_NAMELEN 32 #define MAX_CGROUP_ROOT_NAMELEN 64 @@ -574,6 +575,9 @@ struct cftype { ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t nbytes, loff_t off); + __poll_t (*poll)(struct kernfs_open_file *of, + struct poll_table_struct *pt); + #ifdef CONFIG_DEBUG_LOCK_ALLOC struct lock_class_key lockdep_key; #endif diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index f31bd61c9466..e8cd12c6a553 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3533,6 +3533,16 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, return ret ?: nbytes; } +static __poll_t cgroup_file_poll(struct kernfs_open_file *of, poll_table *pt) +{ + struct cftype *cft = of->kn->priv; + + if (cft->poll) + return cft->poll(of, pt); + + return kernfs_generic_poll(of, pt); +} + static void *cgroup_seqfile_start(struct seq_file *seq, loff_t *ppos) { return seq_cft(seq)->seq_start(seq, ppos); @@ -3571,6 +3581,7 @@ static struct kernfs_ops cgroup_kf_single_ops = { .open = cgroup_file_open, .release = cgroup_file_release, .write = cgroup_file_write, + .poll = cgroup_file_poll, .seq_show = cgroup_seqfile_show, }; @@ -3579,6 +3590,7 @@ static struct kernfs_ops cgroup_kf_ops = { .open = cgroup_file_open, .release = cgroup_file_release, .write = cgroup_file_write, + .poll = cgroup_file_poll, .seq_start = cgroup_seqfile_start, .seq_next = cgroup_seqfile_next, .seq_stop = cgroup_seqfile_stop, From patchwork Thu Jan 24 21:15:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10780153 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 E87BC1390 for ; Thu, 24 Jan 2019 21:15:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80C82F805 for ; Thu, 24 Jan 2019 21:15:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB55F2F83A; Thu, 24 Jan 2019 21:15: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 3E36B2F805 for ; Thu, 24 Jan 2019 21:15:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B43D8E009E; Thu, 24 Jan 2019 16:15:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76C3C8E0097; Thu, 24 Jan 2019 16:15:50 -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 5BAA78E009E; Thu, 24 Jan 2019 16:15:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 141618E0097 for ; Thu, 24 Jan 2019 16:15:50 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id p9so5698920pfj.3 for ; Thu, 24 Jan 2019 13:15:50 -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=Yle1TlNGJaGEEnORF+DKn94y7Tdky3DBMIMdCA8cBkQ=; b=M5uvNn5pK1rzgIeDJxKtxWQWny+mJdtUBZNJPuJKbYhhYYJDEeaviaEkYjFcELASEh cS6nom4pc/KhL88vAboeebqhcPzwRrSoqeL7C6G9kp3PnxeORI2btmkrFf9Dt09a1m+g 5wVUGfKK80F8nzvAUPN2FogYNPTybMEnPYKUGP9PIXi09dgx9lOzCtobRaGTIK3fRQR6 p+b85G9+MjXWoRvCUKvVpVuxMZCbpxHj5Yi4iojTSDz4+oVouyuvvSC4pEk+0hjhl9vP 5syj1iAf1f49HXmGr3kPhBb03N4EtUKsuI1TmuorZxr2hlzOQpYBpzzeu5rzovD8GfUG E3ww== X-Gm-Message-State: AJcUukcKTG05JAk7lOyYNTtRsmZYNtrv04Uc6UAD4GiH7zjZzHL4u0+k 9ZEKVijYEamgKk8WLlcpdO68EcAbUTEQ4YX8ksT47VbKFnJZWgdXVrFFVpULyPR84YmAVdWRzZn iFOXdyE1UCgAQfgy21813fKc+Ax7EuYnkECeAOpswpIJzXWJNIIQ4Zr76olSymgZsp4da8OVicg 8fq1/TH36DpnBKdlst+JUSCnj7ya9xySTil1q0wua9MJuUzQYXMfqq4FEbnj+LV3//OtJ587cO0 ti3Kl5ria+f6n4X22y0dhT1qmacfRry6+59iXAU5X5j37K1Bwxj5NrdnxQ2cSJlo2I0fR9R8Uus vX42O44uGWaKPpc//M+24ypPwyONU0CscpXnuIkRFyiyvyPatP0pX7SeX29+/1qAxrXjQFIBCGH Q X-Received: by 2002:a17:902:be0e:: with SMTP id r14mr7678406pls.124.1548364549727; Thu, 24 Jan 2019 13:15:49 -0800 (PST) X-Received: by 2002:a17:902:be0e:: with SMTP id r14mr7678363pls.124.1548364548811; Thu, 24 Jan 2019 13:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364548; cv=none; d=google.com; s=arc-20160816; b=vgqUWhJstge0OHGFLzMeBnteRgUlrf60EZ09IL4KLfGG8hmv59jajeULzf6/FYRL7X eU9LReC1TIUFIaI5f+A/0qDJZ6z9IJsiyobO825ZPEi4QIondlfvkK9sivMJcYDvVtCk 3kmDoTXJLZqOrF5hd4+GdHZSJY3LSltzM6Whn2K583f8APegaE/N8Mwe1CBP9ItOat/C zj4EV91hRSX8slJbJUUNTrdXFLiU/dRrFi7V/RiFdI2pzPQdAQEjPBHOZ2Q6VxOgVX/8 p1us1PLkejMth/DtR5Kuut2brkyRZr5IOgGUDf4vocleQ8b0TOHQ2P5nIXctC7W7cOa3 /jnQ== 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=Yle1TlNGJaGEEnORF+DKn94y7Tdky3DBMIMdCA8cBkQ=; b=FIIz2oGbqYl1WxdemuMQF+ioTIReflhvOzscyUbIkHfYt60SxQhahz8XQAgAadGOPN 4dvhgEA/E4wlntVLycYpLMBGtdRvv6WXCqSvm8gAIyCsNay1OJMUT3irTWiEW+hhQGR8 ijZjje0rr/OfOViWwIpt9Akk7MpEbLlQT5CvbQU2t03KMUTgvWSwir2e9WwdmK0ZxM/V FF+1ljHbhV7rLZ1++XtAhdOrQxvu1tMhft6npM4/v8EUQ7G5QJ7kAcJ+o2y6DKosNgBf sECOs8hM1YVnKRoql9uNRuLw+ku5bhk/16S0o62+bLiIpC1TnXi1OBRCXr4WXjz/4fZa sd9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=G5aiYxBy; 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 u10sor35044647pgr.25.2019.01.24.13.15.48 for (Google Transport Security); Thu, 24 Jan 2019 13:15:48 -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=G5aiYxBy; 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=Yle1TlNGJaGEEnORF+DKn94y7Tdky3DBMIMdCA8cBkQ=; b=G5aiYxByVc6VsErIA8+F4qk2siELUvTdPPrbChQIOsAm83h4aweDW1EtGssVAsYcqr d0Hbfi1U48XHWNKKSg6xfBhvQrj7g8/hZUrKv+aKhCRjAxjIsEjMdq9EtxxcRfVJu90f BX6molsDxFs4E2ZxSEKUqzNfPjR4gcB67U8DPKVZujIWJXG+/xQti5Q/HhQ39OkRPKta 4qHw9QqImaawmIin18WKnJassSVIia4mg97ND/pwSl+bQs6LEJIkMU8ykdXNaM3OntUy 4wCAEHFwa73hdoSX8Xisl4JJso5mKIZzv+rz5PzXQafcVRCiPugAP22E9Ys7jJVMBrL2 ulKw== X-Google-Smtp-Source: ALg8bN7c9mCecQ7dN9e6nW340zvc5kgy4jrTniqrJWOGIuXa6rjmzTyuutcXsHTaWk10Kf/c9uFy0w== X-Received: by 2002:a63:ed42:: with SMTP id m2mr7480273pgk.147.1548364548221; Thu, 24 Jan 2019 13:15:48 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:47 -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 3/5] psi: introduce state_mask to represent stalled psi states Date: Thu, 24 Jan 2019 13:15:16 -0800 Message-Id: <20190124211518.244221-4-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 The psi monitoring patches will need to determine the same states as record_times(). To avoid calculating them twice, maintain a state mask that can be consulted cheaply. Do this in a separate patch to keep the churn in the main feature patch at a minimum. This adds 4-byte state_mask member into psi_group_cpu struct which results in its first cacheline-aligned part to become 52 bytes long. Add explicit values to enumeration element counters that affect psi_group_cpu struct size. Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- include/linux/psi_types.h | 9 ++++++--- kernel/sched/psi.c | 29 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index 2cf422db5d18..762c6bb16f3c 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -11,7 +11,7 @@ enum psi_task_count { NR_IOWAIT, NR_MEMSTALL, NR_RUNNING, - NR_PSI_TASK_COUNTS, + NR_PSI_TASK_COUNTS = 3, }; /* Task state bitmasks */ @@ -24,7 +24,7 @@ enum psi_res { PSI_IO, PSI_MEM, PSI_CPU, - NR_PSI_RESOURCES, + NR_PSI_RESOURCES = 3, }; /* @@ -41,7 +41,7 @@ enum psi_states { PSI_CPU_SOME, /* Only per-CPU, to weigh the CPU in the global average: */ PSI_NONIDLE, - NR_PSI_STATES, + NR_PSI_STATES = 6, }; struct psi_group_cpu { @@ -53,6 +53,9 @@ struct psi_group_cpu { /* States of the tasks belonging to this group */ unsigned int tasks[NR_PSI_TASK_COUNTS]; + /* Aggregate pressure state derived from the tasks */ + u32 state_mask; + /* Period time sampling buckets for each state of interest (ns) */ u32 times[NR_PSI_STATES]; diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index fe24de3fbc93..2262d920295f 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -212,17 +212,17 @@ static bool test_state(unsigned int *tasks, enum psi_states state) static void get_recent_times(struct psi_group *group, int cpu, u32 *times) { struct psi_group_cpu *groupc = per_cpu_ptr(group->pcpu, cpu); - unsigned int tasks[NR_PSI_TASK_COUNTS]; u64 now, state_start; + enum psi_states s; unsigned int seq; - int s; + u32 state_mask; /* Snapshot a coherent view of the CPU state */ do { seq = read_seqcount_begin(&groupc->seq); now = cpu_clock(cpu); memcpy(times, groupc->times, sizeof(groupc->times)); - memcpy(tasks, groupc->tasks, sizeof(groupc->tasks)); + state_mask = groupc->state_mask; state_start = groupc->state_start; } while (read_seqcount_retry(&groupc->seq, seq)); @@ -238,7 +238,7 @@ static void get_recent_times(struct psi_group *group, int cpu, u32 *times) * (u32) and our reported pressure close to what's * actually happening. */ - if (test_state(tasks, s)) + if (state_mask & (1 << s)) times[s] += now - state_start; delta = times[s] - groupc->times_prev[s]; @@ -406,15 +406,15 @@ static void record_times(struct psi_group_cpu *groupc, int cpu, delta = now - groupc->state_start; groupc->state_start = now; - if (test_state(groupc->tasks, PSI_IO_SOME)) { + if (groupc->state_mask & (1 << PSI_IO_SOME)) { groupc->times[PSI_IO_SOME] += delta; - if (test_state(groupc->tasks, PSI_IO_FULL)) + if (groupc->state_mask & (1 << PSI_IO_FULL)) groupc->times[PSI_IO_FULL] += delta; } - if (test_state(groupc->tasks, PSI_MEM_SOME)) { + if (groupc->state_mask & (1 << PSI_MEM_SOME)) { groupc->times[PSI_MEM_SOME] += delta; - if (test_state(groupc->tasks, PSI_MEM_FULL)) + if (groupc->state_mask & (1 << PSI_MEM_FULL)) groupc->times[PSI_MEM_FULL] += delta; else if (memstall_tick) { u32 sample; @@ -435,10 +435,10 @@ static void record_times(struct psi_group_cpu *groupc, int cpu, } } - if (test_state(groupc->tasks, PSI_CPU_SOME)) + if (groupc->state_mask & (1 << PSI_CPU_SOME)) groupc->times[PSI_CPU_SOME] += delta; - if (test_state(groupc->tasks, PSI_NONIDLE)) + if (groupc->state_mask & (1 << PSI_NONIDLE)) groupc->times[PSI_NONIDLE] += delta; } @@ -447,6 +447,8 @@ static void psi_group_change(struct psi_group *group, int cpu, { struct psi_group_cpu *groupc; unsigned int t, m; + enum psi_states s; + u32 state_mask = 0; groupc = per_cpu_ptr(group->pcpu, cpu); @@ -479,6 +481,13 @@ static void psi_group_change(struct psi_group *group, int cpu, if (set & (1 << t)) groupc->tasks[t]++; + /* Calculate state mask representing active states */ + for (s = 0; s < NR_PSI_STATES; s++) { + if (test_state(groupc->tasks, s)) + state_mask |= (1 << s); + } + groupc->state_mask = state_mask; + write_seqcount_end(&groupc->seq); if (!delayed_work_pending(&group->clock_work)) From patchwork Thu Jan 24 21:15:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10780155 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 978EE91E for ; Thu, 24 Jan 2019 21:15:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 861932F810 for ; Thu, 24 Jan 2019 21:15:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A3772F876; Thu, 24 Jan 2019 21:15:55 +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 E30362F810 for ; Thu, 24 Jan 2019 21:15:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24A98E009F; Thu, 24 Jan 2019 16:15:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9B2D28E0097; Thu, 24 Jan 2019 16:15:52 -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 7669E8E009F; Thu, 24 Jan 2019 16:15:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 2DF778E0097 for ; Thu, 24 Jan 2019 16:15:52 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id b17so5668879pfc.11 for ; Thu, 24 Jan 2019 13:15:52 -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=FaB5hpMUbkzrw9imUPc3mrdBFq091uUG7T5XaC1Sbdc=; b=Yx8RmYhR2OBDNpgonf5bcc9gwWr9TMEFLA+N6GtgUdEnOSsXsUsu/L0T4Klryu48DE t0oPLl09gfr+ICOlPa5wIbda69+ZC/tPkR+xIviaZaNZP4h1/RGYIXm0oaNJEnY/qbrG KMZkiCsgYlGOUTyS+NSGP+4zylwMVONUeq8ruxNUuTvQhQhcBrsPQVYyoe9NwK9yIC5M ILinSP7wuhB2hqdCO0RRQGWff6wgino940jO9mHzR/EFh786FlgDR5zmS93hQD6NRv9B LAyQGpSQ+HovQKHig+0zxapu10KnoAj1aRPxg+ByZb+K5HFmHo1HEz8MhMfBZlFW7qM6 Ms5g== X-Gm-Message-State: AJcUukdS/j+PYtcWWviCzJY73XsF1aDv3Ppp9mOdlQGGP41Qc88bvb7e wKQ7E2Ij0ijJuYtEO2kbxT9GpSb7sMKPG5yC++HdUzq0ZbFfQyDyByOtGG8Prm/glvdwAuC42E+ lE3kPnlEVnJwRxhZ41qMwzE3f5HqqLDH5SJQ6LDKH7PqXLfh1cLnp4IcfBDJxJswX3AAFak5zsa a53qL31XntQAYj2wmsztrplDFEXL8qSs2WNpJM0OFOdZtGdl5bWyUp3PTo9Vtev3+RCS3GdvW2n kd2eto13HgBaa8VJU9CVA57TuFjR5Iz2RYmwcUlUuCwnAxxAggtuPVmuJ2bVxw3gs6q2X7N20kb qtLQXkjeAk8kIdhwI6k9gj0wtH1Bya1TvXD65GXZ7RzJurEAwjm7LLv9bx7C/CLbITRUDbd6nF/ / X-Received: by 2002:a65:4683:: with SMTP id h3mr7157200pgr.225.1548364551781; Thu, 24 Jan 2019 13:15:51 -0800 (PST) X-Received: by 2002:a65:4683:: with SMTP id h3mr7157176pgr.225.1548364551055; Thu, 24 Jan 2019 13:15:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548364551; cv=none; d=google.com; s=arc-20160816; b=y6CvxDgqwK/JBRxKoJ37uWbzZkMF3BMXNcmycFvGafHu+kn3h+LtMWj1SlFRzIfRDD ZaufyhicV8wQ0mYLLjq2HHYzSQp0JxUFyX0OCeTmHsJITaYH4xvOp1zgY6/8rLHa8Du0 7VLFhoCYDy86TBR+seoY1q+72BJr6OLizx9HmO2rOa5f67rcqH2ginJvvjJRw8ooxPO6 3vblatyNvut28UfyBfw8l5cyCKj8S7oajWS/Xf3syaZD7bO7U7sMjdwP50nGlGOM1l8M veHhSNlL3opguD2DYp/T2nDaWeoxusuyQ2zzi1V7m3mWTauFE+cdWhjvvt6nG9q3pwlN jl1Q== 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=FaB5hpMUbkzrw9imUPc3mrdBFq091uUG7T5XaC1Sbdc=; b=O+QfesGZeMfTNWcPDDE9jlh2/EsCEfHbp4Pd/Qo41EbuY+RC0Xml7RFaOHl4QVSPwh 5uSCzzf9Jqw1jal0rb6C/NCGpuCYq/NPqV9oL6d9SgdG5Dy4Z7VbE/06Noetdb5f3ryk BhxvVwsBVOV79MvCCLMsMT4P8Sap3p1SQ+Mk1GP0HAuMA3ZB6tGdiluKoOMpezTiqSto DkgiM2iEAGXjpM8wWGhg39p2SuTAPxMbJfJUwU2cM9zIXDs4Akd/fKEkP5fJYa3rAo2J ZEEnb7RS4hcwcd1pUIVwMCVQzKrCklDmy/2TY40FQ7UJ6snwVYwjW/cmhYQO+uhzgq4E DvVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d8DyLoRK; 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 az5sor31957935plb.11.2019.01.24.13.15.50 for (Google Transport Security); Thu, 24 Jan 2019 13:15:51 -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=d8DyLoRK; 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=FaB5hpMUbkzrw9imUPc3mrdBFq091uUG7T5XaC1Sbdc=; b=d8DyLoRK+ddHRiwPLKr4NnRhwUxe9KcJbasDwaBbAy08lwXJ2Dh3UpBvKD5gJhr1XD ygCYLowX1NgycoSyCV0KpdJc45ecKTSXqJfcWE5/daHnt2JEDTJYd3P71a2APZJi6gsE wCkCCxyQKfSz4OON3OoRJfMRnDMMH3ELo7NTxAL46p+Z/hNOIK73oT/U83YroGojCS0c bb4NcpNde6m5cW2n1LDqgbnUoUADyEbmlsEduYccLSa/Df/QPALxgXtvWSA/7TF8ATG7 W6E0CrAv2zgQJ8S/utkFZ05JP/1BU0q/KVg7q0ekkSeXacE+QZeD/J9YFPgUCjAE+G05 sUOw== X-Google-Smtp-Source: ALg8bN5ubkNevpGRpp/f5Y4ShhZRlBmfee1EWHPVxx4kMKUcbRjoIt6YzEkuktkm1W/PHnkThYik+g== X-Received: by 2002:a17:902:a50a:: with SMTP id s10mr7770481plq.278.1548364550496; Thu, 24 Jan 2019 13:15:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 13:15:49 -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 4/5] psi: rename psi fields in preparation for psi trigger addition Date: Thu, 24 Jan 2019 13:15:17 -0800 Message-Id: <20190124211518.244221-5-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 Renaming psi_group structure member fields used for calculating psi totals and averages for clear distinction between them and trigger-related fields that will be added next. Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- include/linux/psi_types.h | 15 ++++++++------- kernel/sched/psi.c | 26 ++++++++++++++------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index 762c6bb16f3c..47757668bdcb 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -69,20 +69,21 @@ struct psi_group_cpu { }; struct psi_group { - /* Protects data updated during an aggregation */ - struct mutex stat_lock; + /* Protects data used by the aggregator */ + struct mutex update_lock; /* Per-cpu task state & time tracking */ struct psi_group_cpu __percpu *pcpu; - /* Periodic aggregation state */ - u64 total_prev[NR_PSI_STATES - 1]; - u64 last_update; - u64 next_update; struct delayed_work clock_work; - /* Total stall times and sampled pressure averages */ + /* Total stall times observed */ u64 total[NR_PSI_STATES - 1]; + + /* Running pressure averages */ + u64 avg_total[NR_PSI_STATES - 1]; + u64 avg_last_update; + u64 avg_next_update; unsigned long avg[NR_PSI_STATES - 1][3]; }; diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 2262d920295f..c366503ba135 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -172,9 +172,9 @@ static void group_init(struct psi_group *group) for_each_possible_cpu(cpu) seqcount_init(&per_cpu_ptr(group->pcpu, cpu)->seq); - group->next_update = sched_clock() + psi_period; + group->avg_next_update = sched_clock() + psi_period; INIT_DELAYED_WORK(&group->clock_work, psi_update_work); - mutex_init(&group->stat_lock); + mutex_init(&group->update_lock); } void __init psi_init(void) @@ -277,7 +277,7 @@ static bool update_stats(struct psi_group *group) int cpu; int s; - mutex_lock(&group->stat_lock); + mutex_lock(&group->update_lock); /* * Collect the per-cpu time buckets and average them into a @@ -318,7 +318,7 @@ static bool update_stats(struct psi_group *group) /* avgX= */ now = sched_clock(); - expires = group->next_update; + expires = group->avg_next_update; if (now < expires) goto out; if (now - expires > psi_period) @@ -331,14 +331,14 @@ static bool update_stats(struct psi_group *group) * But the deltas we sample out of the per-cpu buckets above * are based on the actual time elapsing between clock ticks. */ - group->next_update = expires + ((1 + missed_periods) * psi_period); - period = now - (group->last_update + (missed_periods * psi_period)); - group->last_update = now; + group->avg_next_update = expires + ((1 + missed_periods) * psi_period); + period = now - (group->avg_last_update + (missed_periods * psi_period)); + group->avg_last_update = now; for (s = 0; s < NR_PSI_STATES - 1; s++) { u32 sample; - sample = group->total[s] - group->total_prev[s]; + sample = group->total[s] - group->avg_total[s]; /* * Due to the lockless sampling of the time buckets, * recorded time deltas can slip into the next period, @@ -358,11 +358,11 @@ static bool update_stats(struct psi_group *group) */ if (sample > period) sample = period; - group->total_prev[s] += sample; + group->avg_total[s] += sample; calc_avgs(group->avg[s], missed_periods, sample, period); } out: - mutex_unlock(&group->stat_lock); + mutex_unlock(&group->update_lock); return nonidle_total; } @@ -390,8 +390,10 @@ static void psi_update_work(struct work_struct *work) u64 now; now = sched_clock(); - if (group->next_update > now) - delay = nsecs_to_jiffies(group->next_update - now) + 1; + if (group->avg_next_update > now) { + delay = nsecs_to_jiffies( + group->avg_next_update - now) + 1; + } schedule_delayed_work(dwork, delay); } } 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: + +