From patchwork Thu Jan 10 22:07: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: 10756995 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 9216891E for ; Thu, 10 Jan 2019 22:08:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F77529EF5 for ; Thu, 10 Jan 2019 22:08:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7318D29EFD; Thu, 10 Jan 2019 22:08:18 +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 E6E5429EF5 for ; Thu, 10 Jan 2019 22:08:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA9D68E0005; Thu, 10 Jan 2019 17:08:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D59458E0001; Thu, 10 Jan 2019 17:08:16 -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 C485C8E0005; Thu, 10 Jan 2019 17:08:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 85D538E0001 for ; Thu, 10 Jan 2019 17:08:16 -0500 (EST) Received: by mail-pl1-f199.google.com with SMTP id v2so7007739plg.6 for ; Thu, 10 Jan 2019 14:08:16 -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=gvi1iRKLPW3qMsLI6kumJKUVDFg5NUDF94Fa5S4jUjU=; b=OO6zygfNa4GbTPUdOwSFOdSsbYti5HZyzg9jaPd6GlLCAXywkX8c/iszALxLlf1G3q 4OO02dynZhVDsbegcpvAB8NjhWiOGmSfaJ742p6mW343igCVm/8QarkXjrjKD4PfsIvw Q6M+0Jqrw25eblJuk7uaWqaHr+79/JtmhI5UeHoPRbVOA9e+N50KooB3OR1g4VONbko+ YkkW8AI2L9we36cKbDOMIAXu/2JiDQGebZB18ZmCd95GVe6LzzR0oRY7VGJ4wIsuJR5e zSGasmpGfyLxjgQ6DlCvYoEe+09dCuThEGeyr+GBwpvmTlp04o/vYCdlMXIo5vyb5KEp R3uw== X-Gm-Message-State: AJcUukdCm2zwovfscTAzSHBG1wpP91X4Ia220n13ggHInPFMLO4FF+Bq t3DsRVtzZKDdHP219A4VH0WgmryvPAq8L/kNFGwPlQrEpL/gNndMJ4KN9eQkHscoFpVvhKf1fXm GACqRbaRY75cW7oh52LHD8MIHF5tSHAwwdhfO9ol/5N1Za0RUduMjpAB46b3HOQU58/k1vD8w55 Ggx4joj0CtD16BHu2dYPOvrFiTm89MKTOjj//fAUYZeiv75tyQWSWNl3Dxq/Sefc1iKMSvXUQic mZaf+PgjKpK4odJzd+B9rqzKs5e2LY3p6St/+1qrY/BvNGbKFG70wmt5wJ9/5tBrBocmjJpG4e3 jlx54mgT8UIjvc9Ut8bvM4lMBIY1ob3Xqg0Gx4lRG3ZxWEuxQgbX13tzKHHCeJMP3vjtqwZWype j X-Received: by 2002:a17:902:4624:: with SMTP id o33mr11810098pld.289.1547158096206; Thu, 10 Jan 2019 14:08:16 -0800 (PST) X-Received: by 2002:a17:902:4624:: with SMTP id o33mr11810063pld.289.1547158095487; Thu, 10 Jan 2019 14:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547158095; cv=none; d=google.com; s=arc-20160816; b=PIKmsyDASK9FfjAlgKmwlZ2pFjnz+B2oy4olwDdh0n4WUToVrllDMcVxIb++wLd/2J +DCoW4bWqqwfY5jn8kH4RaW9puHyt/kx3z61pVJy3VAVSdnHD4IrQB1ng8oEP+RMGs6E NY9jYADTM/5oLDTo+lOCFmtQfKOKPFqeXqaHO9vFmL9vwJ529A5ud803piLSSkhttvDm R8I45oQc6N21O8S5h/xkbOnXgYwEoOpCIXGeq16PVIPcgx/S9+ID9gBozdeEpoSCprAY 3E9h2m5BDLRJxbvqT5ftSCDy+oL18GKL5rAIVkoPQrL9KG4r8nmCu1AFHGLzyXJTSp9J 0zlQ== 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=gvi1iRKLPW3qMsLI6kumJKUVDFg5NUDF94Fa5S4jUjU=; b=fEgSFYfaiEFwU2zjhbjTgqNIoiC9pC/dYAj3kiVkQkDPeUDoevq36RbwYe0oGH8cks I7TszqlnxeM1LhrBkdCqENPBvXa3x7rm0H8DB0NihWGnQvkv2TU4taFM+D+T/Xlw8i5k bFJLHYAWq5KDu09jeknLwEOS2o/6o/ezYC5fsO4/47oOmSc1r1l1sy+AQAaB/aK478uB Y/dM53+KkqIisu20I2RcXjfb0fHapIIRmQEC7BRYhAPKW5nCqN7waiMTq/ono5yd2Dic Ghljvmp0JoSh5zefNVlfc39v0hgIi3Ml4NFSgVYy0IVyL5nlQf5HvWSnKYtGaW3PNXw2 cSag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OdfmzDI9; 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 a83sor569195pfj.39.2019.01.10.14.08.15 for (Google Transport Security); Thu, 10 Jan 2019 14:08:15 -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=OdfmzDI9; 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=gvi1iRKLPW3qMsLI6kumJKUVDFg5NUDF94Fa5S4jUjU=; b=OdfmzDI9CcL+2VXf5ocSTDNyRd9IHxsxjkC2PxQORGPsj0X7psQuS3Umk7pGcF+y1N 2erlFLdCgBeLM6sKPD7UtLOkmNwDY3Q8+bYqlRpPzxYaWaUO9Ku8vgf0RYaWAZcgeQDp +OycaSHT78G3F5f1FH0QvE8CIaRHZ77mkmp4zAhGBT3h+OnHhOI95bD1lAbzndzCJcN8 kAYejfjaXIKLAAr8fN6d+3sQPM/sqCNbQm4TKt/fmoxpEaDlXqQnfBs/W76fh5Si1HRb 2Ywu2dMPM2Aw/LeKx3cXLOODPCznDtA+9g6oDheS4QVxUuvqwreMha9jFWiYakAAlmvd BQvA== X-Google-Smtp-Source: ALg8bN6gohws80ogM6bKIwE/KhY+FsflDzhULCDncx+SgcmmVujJEzOQajCDWV/20rlAO9DnbJk3/Q== X-Received: by 2002:a62:3943:: with SMTP id g64mr12126011pfa.114.1547158094933; Thu, 10 Jan 2019 14:08:14 -0800 (PST) Received: from surenb0.mtv.corp.google.com ([2620:0:1000:1612:3320:4357:47df:276b]) by smtp.googlemail.com with ESMTPSA id p7sm152958019pfj.72.2019.01.10.14.08.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 14:08:14 -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 v2 4/5] psi: rename psi fields in preparation for psi trigger addition Date: Thu, 10 Jan 2019 14:07:17 -0800 Message-Id: <20190110220718.261134-5-surenb@google.com> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog In-Reply-To: <20190110220718.261134-1-surenb@google.com> References: <20190110220718.261134-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 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); } }