From patchwork Fri Dec 14 17:15:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10731491 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 88AFC6C5 for ; Fri, 14 Dec 2018 17:16:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7FF52C807 for ; Fri, 14 Dec 2018 17:16:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB8E12D8F5; Fri, 14 Dec 2018 17:16:30 +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 45D632C807 for ; Fri, 14 Dec 2018 17:16:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EDB48E01F9; Fri, 14 Dec 2018 12:16:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 19C8C8E01DC; Fri, 14 Dec 2018 12:16:29 -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 0B37C8E01F9; Fri, 14 Dec 2018 12:16:29 -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 BF0ED8E01DC for ; Fri, 14 Dec 2018 12:16:28 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id f69so4882333pff.5 for ; Fri, 14 Dec 2018 09:16:28 -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=1K/9jxBUhr3ZKbGV/xGf2bm9+2dhfv3m9ZmKXLf2XLM=; b=jL7yZNW/PMH0Me8oznMUni9Gi8FiqE7N0DGCUCY6kERhpMEZvUJlOkPjIDtHy7FfX5 p3cpvAGJXJzsxn8B94cDdCyEUs5OYKUbwAuYCUY8whBCXbtJ+EVYIfE8MRkT9+nJ2dVB wvOjJmHmL70tM0yR7ixyq5lhQq7HzZ0YlRIN93vymWW1UYXBy7p2JfXA8v0FUZp/Yoxh OgWiK3kvHDiFWNbWSs2ObjJpBdTelUnPOZfyJ2s1/Zp9t5h3wYqXi91d+L+U7SWk/ZuS 6lWLOcM2JVhZGPPD5ZQCvvxc2B6qNzJP+gd2xf/Ic6wlreDCQgD+MZnrw8GndjVI6uu2 igMg== X-Gm-Message-State: AA+aEWZ3NN6dspKSA0md0V5mdMvrp+Q8UJAHZumBSsuVV0meqMgQNezq rirIfDCiKF5m2lpFVWlBQHS7U8ZCr20ps9lPGZcm5RgK9imsAP2g9Wc0Osy+REVqY5LCo9TlrXg z6EaDgIN+v52DXPImwbkD1Bi0fRIHr/T5eknU/SWu2Hn3sUImA8Yf/YtptSegFucdrznoibZgnh xZid1mAFVsGZe1/gmaXrhXR7Gj5KmWUfZ5lWDI5opFck7OKhGMpi3tjKgMeghjpGWBdXR6RSVcD umF4d66FbIuL/mA/gUHTCG3h90Mw2RWCGUQdLAiHYcaF2kUrqJ7lI4XIqmANUFYX8QOoYQBig4H /u8QWpwN/Rwu8TfDRnsevQs1PZ3+zA6DKBFsWcJUP8bhSzFWIOh34EXHn9QKlJ3BVoD+sj1qymM B X-Received: by 2002:a17:902:22f:: with SMTP id 44mr3571297plc.137.1544807788434; Fri, 14 Dec 2018 09:16:28 -0800 (PST) X-Received: by 2002:a17:902:22f:: with SMTP id 44mr3571244plc.137.1544807787754; Fri, 14 Dec 2018 09:16:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544807787; cv=none; d=google.com; s=arc-20160816; b=i8DE3SLF7AgBi9xlGPUZRSQal30lBluvjAw+LnCWVvGxiDy8E+8WNPQKGqA0OtlUgI N0AWFQF5x3hg941ehtAYO7h75B3d/dlg0MjAOG3CzG0fGTALmf8Cy5wCzDXpQQXjZ7i9 2NbAdhnztJjg2dhYHDw84DQruuD4/mwBFHOrAq7/Lc+f1Oq2QchyiUpw91s8u9A1JG17 zPaMYqK9OZZ/P0Y2cS+ttXewgAyXNv7LdV2HY0RIPl9BxD5+YVN8VY9MRh5aNHS5h56V FdIMzR84IbyM8fqfgjz1/GCkCKIPS4q0iQe0QAAZNoA0fj+GAT8oWdmJPPrJqRWazb1g uQTw== 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=1K/9jxBUhr3ZKbGV/xGf2bm9+2dhfv3m9ZmKXLf2XLM=; b=mqBgGSPQWq5YRnyTxr/V5irRzuAiECNNAIJ9vVPVSJPCTqZyrPvuJp4alNll8RGcJ2 fJgJpXpfSlwZtWSs/AI0zRgOVsbnzxivRwh2a3SAvjr6zarL9UugOHP0Xk6xRf3EMafx X2MPyJvgL2VJhimo2zjoVbzIfImAELUIfDDVOdkeqoR9yx0KYOO28Zlzsngh9uVq7wKa 2BDvc7HqLHLpM2i5cAQjUlYBw+9TLSM+4BRwhesDCvork92qlk9zuRYu1jfdK6sUDtHc ITK82192I1v8ci1flAnUz9KoAevJ/WgjYQAyhNmYXGKtZWFF9JtbzuH/u8JnvagAdrJj MISw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fdbSosqk; 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 a33sor3694174pla.29.2018.12.14.09.16.27 for (Google Transport Security); Fri, 14 Dec 2018 09:16:27 -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=fdbSosqk; 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=1K/9jxBUhr3ZKbGV/xGf2bm9+2dhfv3m9ZmKXLf2XLM=; b=fdbSosqkmOy+GOJSWJ6aOnhR9OK/6rV7BapjvJttxkHBRPlyq0NYeMod4uZFvdSdmT YuqAwToioC5aXk49M7de1ONOHk9gEsqA7b40kGqvGCau9bMzwLC+BfUXeXcvoRoXY/6z hgN9QIykNobCdulmez5DFg6uIyyRfq7Fv1vwvgOPGumapbEOiO4sslYg8YcjTvKfeWK+ Q14G6m3ZKlkUIUwWpyj24NjsPl7ZP6FsYoj8aqWhtBb9nh7IrV5WHsNgYb40G4jcArqC 8EpvQKL679AjqTo4JLW8cTKtzZMHTArygO9acydjH0zI5ExKr4x7CG85JKpbMTXGdASU 5w/w== X-Google-Smtp-Source: AFSGD/UAxdLH6HoIs+mnW869kAVAqSMJdTBnZfNTiYAZJdKFhswZe4dHVAjkbuZrTEVtGTcbSwoN2Q== X-Received: by 2002:a17:902:4c85:: with SMTP id b5mr3446926ple.226.1544807787259; Fri, 14 Dec 2018 09:16:27 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Dec 2018 09:16:24 -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 5/6] psi: rename psi fields in preparation for psi trigger addition Date: Fri, 14 Dec 2018 09:15:07 -0800 Message-Id: <20181214171508.7791-6-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 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 --- 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 2c6e9b67b7eb..11b32b3395a2 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 153c0624976b..694edefdd333 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) @@ -268,7 +268,7 @@ static void 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 @@ -309,7 +309,7 @@ static void update_stats(struct psi_group *group) /* avgX= */ now = sched_clock(); - expires = group->next_update; + expires = group->avg_next_update; if (now < expires) goto out; @@ -320,14 +320,14 @@ static void 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 + psi_period; - period = now - group->last_update; - group->last_update = now; + group->avg_next_update = expires + psi_period; + period = now - group->avg_last_update; + 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, @@ -347,11 +347,11 @@ static void 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], sample, period); } out: - mutex_unlock(&group->stat_lock); + mutex_unlock(&group->update_lock); } static void psi_update_work(struct work_struct *work) @@ -375,8 +375,10 @@ static void psi_update_work(struct work_struct *work) update_stats(group); 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); }