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); } }