From patchwork Tue Mar 19 23:56:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10860585 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 884F11515 for ; Tue, 19 Mar 2019 23:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C882994B for ; Tue, 19 Mar 2019 23:56:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C87B2994E; Tue, 19 Mar 2019 23:56:34 +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 814F82994B for ; Tue, 19 Mar 2019 23:56:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82DE96B0006; Tue, 19 Mar 2019 19:56:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B1DE6B0007; Tue, 19 Mar 2019 19:56:31 -0400 (EDT) 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 67DCE6B0008; Tue, 19 Mar 2019 19:56:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by kanga.kvack.org (Postfix) with ESMTP id 3F2F96B0006 for ; Tue, 19 Mar 2019 19:56:31 -0400 (EDT) Received: by mail-io1-f69.google.com with SMTP id k5so401947ioh.13 for ; Tue, 19 Mar 2019 16:56:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=BhrmowS2eMjbffJ9OB92bQfOOAToNjJ94P17cQjPdo8=; b=czxUHut575MMexrNKiIeeh4GmekW+TCcs+0lYsvy6rHCRx/qSjlzcjprund7iz82y7 7jaTtfbfXTsXPhgv0mKKRxnvuKeftkrSPXHjmlZ3RHtrombdVVcmnOTwSv3/7vyGvi0w WD1HATaEZYLEutiORYo5I1pnRcrxi16ZYaSXmdjrG36ynhAiE+SUB+eZRtImXL2VTg+b vgdfY/4clhFp0U7UfMk1nqWiIItbRi+Ieq0nCOkmaOBFfZregqqWdrFljc0DYq8mvGtI 6tezs1aZT9iXKi/2OYM7/UvAFIv3mxIxaMB9JRvXLKRufHjZAXBa+3ni3QZ0LHBVGY4G T9tg== X-Gm-Message-State: APjAAAX1dXIxL24YmCeyMGLgry2rEPD4CUyo8zzHUPu3CVPeuu3/tdu6 U4AuuaNGGb608t6GeDgyDcmBI5a7pJczcRtOcgV6Pr5ppxqOMtich5XSOlY2G4DtroXOVoHVMMe BMa8Nlr3GWZr1cVGxISEVnJwYwFFMa9hnr1kU/izSj9VgXcZmugZX7T8k4WEOYHLR2g== X-Received: by 2002:a02:94a1:: with SMTP id x30mr3159488jah.82.1553039790933; Tue, 19 Mar 2019 16:56:30 -0700 (PDT) X-Received: by 2002:a02:94a1:: with SMTP id x30mr3159468jah.82.1553039789979; Tue, 19 Mar 2019 16:56:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039789; cv=none; d=google.com; s=arc-20160816; b=KFp/ntYGp+PAHSJW4gh4pJchtxSUSsn6aieb4XyxMC2PhPyC+yufZNES1f3d1+J1jl Xeu5OKBGanNf1J0/j5SfH8vIbWk6usEw1DDx90U79YoLhj5GejU8lNqRG7caqzR4XURm YQVmEPzfGUXqC3qvMYUdabnjdY9RMwqItga7SPa+u/TGy7Lh8f/swB14EhhakkxiOQtk XzSRiNk5BhSt1aaVXRdIsTiFoOZJH7S0WAQht214TBQuJ3WWQI/lLSf6fCow0j6X+0C9 Y/+zxwCQOZTdRURtm1ZpuPFZud8t7uhCp6EIy61SNI3SpDwVq78EzKWW1xvHSvndpi6+ p1kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=BhrmowS2eMjbffJ9OB92bQfOOAToNjJ94P17cQjPdo8=; b=JZxX/nZUkhFl6IOrRw/GAbTK7RLAPn7DD5vnZsOl0tvC8bJw8WSPzbZw0bGCzZi82w aSNzHOBqnbovO4IS3SJb2lkxzB8+fs+i94iYvdFTTuNPPWBG9mG6GqmUqd6qPMoqj3s6 DywWCfyyZTCqQ6OvmP/D2RsB0kCF1r1sBm1RKXliIcIfWkrSmoxZmoCUFKEg4Ib4s6ce Lm0hOL+ePOXKqa4jaohx+KilFTbtUg1Bn39M4AAevffLZA5pM8wllIDKoUR+CivyL1rP lwftgN3Tbmt85yvh9IJNTl6ebt7d9fmi+KcxUQ8OBS3dHT54Mz5RMWgU2oOSRwn/oKN+ QDnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s39qkpCi; spf=pass (google.com: domain of 3rygrxaykcoauwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3rYGRXAYKCOAUWTGPDIQQING.EQONKPWZ-OOMXCEM.QTI@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id w194sor590197ita.22.2019.03.19.16.56.29 for (Google Transport Security); Tue, 19 Mar 2019 16:56:29 -0700 (PDT) Received-SPF: pass (google.com: domain of 3rygrxaykcoauwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=s39qkpCi; spf=pass (google.com: domain of 3rygrxaykcoauwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3rYGRXAYKCOAUWTGPDIQQING.EQONKPWZ-OOMXCEM.QTI@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=BhrmowS2eMjbffJ9OB92bQfOOAToNjJ94P17cQjPdo8=; b=s39qkpCiLoow4b9/kgH0brUOsB6xmuRjJsD/eb1HqzNYh9jtmiyICnlIREYYOCKL88 kXqqEiT1p592C2CJ41x570vo4IJQ+qIpXP1mS4NZTtgimX1bxdcuhLtuhXWjoT7rB8Dn cCHD7VVysNVpuZas/uyx34+spsa3iuS9UElEGU+wOJpvGuxLM1+50lBJdu72gwMh/7wj CCzhl3Pdf2CzqMNOj5pObXsCmj1nUNiS+EioFVGTxI0M1+2nuPhekgCPfSV6zecvX9yc rPXVPjJj0/fg2QH1UnaNfhmCPCuO7XIQEvbgcqFXz50DTetnIuZxNs6cQ/pmXD0+ZpAY nC8Q== X-Google-Smtp-Source: APXvYqwLqcno9l8VDu4DML9YRADDsLxnjwNMeFZHijkxLWCWDs6v5BpwRuxZ0pdSzUMSpS6IEHp6v20vj2U= X-Received: by 2002:a24:6545:: with SMTP id u66mr3145504itb.36.1553039789710; Tue, 19 Mar 2019 16:56:29 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:13 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-2-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 1/7] psi: introduce state_mask to represent stalled psi states 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 , Stephen Rothwell 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 becoming 52 bytes long. Add explicit values to enumeration element counters that affect psi_group_cpu struct size. Link: http://lkml.kernel.org/r/20190124211518.244221-4-surenb@google.com Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner Cc: Dennis Zhou Cc: Ingo Molnar Cc: Jens Axboe Cc: Li Zefan Cc: Peter Zijlstra Cc: Tejun Heo Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell --- 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 0e97ca9306ef..22c1505ad290 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -213,17 +213,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)); @@ -239,7 +239,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]; @@ -407,15 +407,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; @@ -436,10 +436,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; } @@ -448,6 +448,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); @@ -480,6 +482,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); } From patchwork Tue Mar 19 23:56: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: 10860587 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 9195D15AC for ; Tue, 19 Mar 2019 23:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789FC2994B for ; Tue, 19 Mar 2019 23:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC8F2994E; Tue, 19 Mar 2019 23:56:36 +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 0D6502994B for ; Tue, 19 Mar 2019 23:56:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEC236B0007; Tue, 19 Mar 2019 19:56:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A9A2A6B0008; Tue, 19 Mar 2019 19:56:33 -0400 (EDT) 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 9888A6B000A; Tue, 19 Mar 2019 19:56:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 718576B0007 for ; Tue, 19 Mar 2019 19:56:33 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id c25so620382qtj.13 for ; Tue, 19 Mar 2019 16:56:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=Hcsw4jWN1hMUQas5fk8qH4/pHraV7uLJWBMnp4emY1w=; b=PdkvHkLM2Uizgr5/P81RYkG6YWnevxFm4mu0qn+Fyw/LXPLt0slrtfgNdVQ/8jWCvO B6QiB0XsCZd7PIMFmcPHZzrPijMIV8N+TR+HYcXOnSK5QGI2pXib58PI4r+rrTIM1Zhm 7jhM8ako5sg6IOYLRikHiOeEvxoOn+1pMuwSdmRF7FgtzsMkkWKtJyRCDzGGfxxX3GRX kzDhcDjIDcEc+cJjXmoQZz6bA2TbN+vo7oHt69KWBDsNcHoGCSoxu/d1UKjJrxT/z0C9 eI1wws3yr40zzQgkk28VZWJsAJOfoYarYiLl+FiJpE8sox70B4nWS1MsiGCRxitRWIea CIsg== X-Gm-Message-State: APjAAAVlG+PGGy96YfQNIHxXAE9F0pAV2W8Vj0o2ncBAKOEtXHdu28KG iFf1QkDhVJ/cqZUz6bvLy4ZsRBZ8jzMHv9FmkwefjqixzSrIVFyeq9VLUuIHsmXqT3dCdhSVEfN 07k40SooDY0uS4zKQEMfUB0nTdPe/K2VEf4pnpvuL25xRjztl0YbFo3xD/EVa8cjUcw== X-Received: by 2002:ac8:1187:: with SMTP id d7mr2745214qtj.241.1553039793220; Tue, 19 Mar 2019 16:56:33 -0700 (PDT) X-Received: by 2002:ac8:1187:: with SMTP id d7mr2745199qtj.241.1553039792600; Tue, 19 Mar 2019 16:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039792; cv=none; d=google.com; s=arc-20160816; b=evt+j/Yp4+A+Rm3KZjwjjkYFXhrG1QscrKmnOirEEMj8nO2bLK/cBvC+0GZpBEWf5e SgT8SS0hKWLGJ37mqV3V0/NRtx7OLdvvwSNbsPlz5VVwJd6azqtpbfDccybNYQ1pk+Xq NYjBjtSOdbmMeTSYdC9WSQVgGl5GwVWM86HTMU7GUlF4XKJDU+c6/d3QRKC5oqY33zE0 JMXOHLO5LSdplmafonGHCMZuRz/yJP1PSPELzEX9m0LyhZdBjY1QmaO+G2/vLUVwMeWj +Tqnq7BKbJ3Iio2ptyRgVadYcJIP8asYeQiaicELlvJIk3Ku86786+sph4CkN+53uMS/ GfIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=Hcsw4jWN1hMUQas5fk8qH4/pHraV7uLJWBMnp4emY1w=; b=q1X3BI9O39L4TrcFk/KBWOnDNpnp4rxVkO++SUoUlQtLhF13iy1xoDOWy4rLbskp9N 5LMH23afvdizEMiQL0wPI3DH8n00ufQ1w6fpF5h7Q8OTVCHD3V2yyfCUm2sl0UfKZh8c faoOQAusnFtDTYeb4QK4Jv4n0TDKoGgU6b5fgyQstUR8b1gff873HaS7Mdgv0TOs/oR7 CM5KVEMvVePdlM+VLNIqKmGNg1nd5iGKGHk0fUq7mpjuexzaJnZnhiEvTMPLTlCNUeZ0 o7fg6ltjoi7QpJd+JlSYKiAGirleRwCpkiceXFFu4+REdSTZXLp6+XMfVvoIAzjZfC6S J6Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kkRScrd3; spf=pass (google.com: domain of 3sigrxaykcomxzwjsglttlqj.htrqnszc-rrpafhp.twl@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3sIGRXAYKCOMXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id o55sor790241qto.65.2019.03.19.16.56.32 for (Google Transport Security); Tue, 19 Mar 2019 16:56:32 -0700 (PDT) Received-SPF: pass (google.com: domain of 3sigrxaykcomxzwjsglttlqj.htrqnszc-rrpafhp.twl@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kkRScrd3; spf=pass (google.com: domain of 3sigrxaykcomxzwjsglttlqj.htrqnszc-rrpafhp.twl@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3sIGRXAYKCOMXZWJSGLTTLQJ.HTRQNSZc-RRPaFHP.TWL@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Hcsw4jWN1hMUQas5fk8qH4/pHraV7uLJWBMnp4emY1w=; b=kkRScrd31+enlreI5z0oUEdvclr3JCffoxWlBxgdfvsiHG+l1qdm7rpPzTM74AffEB LfPQCYRFRkk5MVQ3Sswlo00GL73nAMZLv5CUblp9iwglJ0iHORdkEQbjcmg+RAyhtDSK O9SwD0WRSCDe+dqmFFjegvme5136ckLAkDUHKL6mVSMZP0sNbLYuvx8Ezdf706E/KfDY 9fBeMjXuR3YFS9h86rSzKNERDrjqmseba0FXjHr885Gzr4DFfIZy5quXrHuTBM0lthvA 9RXHgsNWSfaXr1nwN76MY2akaLAzeMLaPr9LrKq+sgEJNGwUCyr6TQwEqhNFsTdPpUau OdXQ== X-Google-Smtp-Source: APXvYqwR1TAk3oGEqI2JtJ8ECEcet2nolarI6UbO1myJOnWcfePT76GDZJa39xicW9tBqtTiou2qy4qktOo= X-Received: by 2002:ac8:2e7a:: with SMTP id s55mr13937762qta.34.1553039792366; Tue, 19 Mar 2019 16:56:32 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:14 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-3-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 2/7] psi: make psi_enable static 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 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_enable is not used outside of psi.c, make it static. Suggested-by: Andrew Morton Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- kernel/sched/psi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 22c1505ad290..281702de9772 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -140,9 +140,9 @@ static int psi_bug __read_mostly; DEFINE_STATIC_KEY_FALSE(psi_disabled); #ifdef CONFIG_PSI_DEFAULT_DISABLED -bool psi_enable; +static bool psi_enable; #else -bool psi_enable = true; +static bool psi_enable = true; #endif static int __init setup_psi(char *str) { From patchwork Tue Mar 19 23:56: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: 10860589 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 7A89115AC for ; Tue, 19 Mar 2019 23:56:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 603A92994B for ; Tue, 19 Mar 2019 23:56:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53E082994E; Tue, 19 Mar 2019 23:56:39 +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 B25462994B for ; Tue, 19 Mar 2019 23:56:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08E436B0008; Tue, 19 Mar 2019 19:56:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 013676B000A; Tue, 19 Mar 2019 19:56:36 -0400 (EDT) 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 D81AB6B000C; Tue, 19 Mar 2019 19:56:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id A06026B0008 for ; Tue, 19 Mar 2019 19:56:36 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id i23so595258pfa.0 for ; Tue, 19 Mar 2019 16:56:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=OBXkes655anl10ghu56F3PCl5wd5CeGj94L2IaEvAok=; b=lsNmAHPbXjHVCT4CSKV01gQyRg0xm6sZ+WoRZP9plRS+3JS4SjGnBmcafAXzFVcmrR zfVexytvvDQDJmacSg68CUgAQG2zbW5ValTlZxns2Pj8n7VFNXX6UZjSkaO2S6h2Wh1T 4zggDyxnqqytLBjMd/wGz2Jq5+Htv8rcNRVtmQawC27AYf4lQLmz+QggSlhmxxQmc46Y BBTu0mKC0Ver+PjoJAi+dYnJSNQGsQtr98S7a1NOnhoEYqs8MN8eSkLZNnUCXePyCPDV kkPoaJ9AjLnMa4WYUddSTF6vhvmRiO86d3XoJhojUbqvcQenJ4r1PlZfTr7jo+d2kzTq Q0jA== X-Gm-Message-State: APjAAAUXUraXmknzb2/AkWNfr80wakMOkK6cqrZeZ1P1jRccpKuvb6SR 4Gic/p4ldMDQwR6v3h0bo8HafTBYmYdx5cz9Ysr507YxEM+Yykk8J7CnxFV8rGbo7a2J6iIQKAa YxWuHQmnP6XIWZVnHuv1ny3GZEh5hc5YE2ZwbcXhn9rqqTpFP3+MiobkAoj8OHiHtCQ== X-Received: by 2002:a65:62d6:: with SMTP id m22mr4880985pgv.443.1553039796099; Tue, 19 Mar 2019 16:56:36 -0700 (PDT) X-Received: by 2002:a65:62d6:: with SMTP id m22mr4880935pgv.443.1553039795003; Tue, 19 Mar 2019 16:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039794; cv=none; d=google.com; s=arc-20160816; b=RN/r2eKTRLptkGt8r8fsY5D/xSidTgQwEVVPiwTU+GMnTdUPpDhfn1zCVuWwo7l0Pl jiKIn20rFQix/zt6tRmevm+rLuxZpAtW3wgDisUI47oWClgV/R9CNUvYx+Bpr8Au02ed DzTSMFW8f9wbnxxVo3bJee4effhIDhrQKYx7Z7s5vFPN0sOT1e5q9uL6MMwzpOdKL/dx HlOSEpidAX9bUNQ8lD6QJeQzPFJ2HOuR5XYWx0cfHIdjlWaf9JBQflQG6mrKDBk7RVC5 K89cMPGXkE7c9vIJnPzOd426JMG0xQ059HzimN35BRWtDnUzjTCnMmdp2G2p+RFn+PVC OhyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=OBXkes655anl10ghu56F3PCl5wd5CeGj94L2IaEvAok=; b=pk069JAHTyg1tRJwrsywa5KmLBrUs187gDNrBuMmVmha5fUYCrniOT++zH+TjQH/gZ G16t407NHJa0324gwOWU4qnLOk4XfU9W2fYQ95R6jgiMRbIw3zn7K+5vcRyagcDacP2+ peiK4+gmwKCF8d1q3R4y7oxFFO0bQlSSX8E5vFTIaaEE3lfrOD05EWe0e04AZ8Np9hBP Pabt5PKTh5xDPli9Bf377zKro0y+KPAgxu3x766kBjCMc6n3PqeVDzHut71jfiq7KXbG ZYJHUvotdE4bxG5sGHwoOaM+Fsep6RNKNGfjd3mXA9CfT5cMCrRfhimh1wA8L3BiErHT kcDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ViufV3H9; spf=pass (google.com: domain of 3sogrxaykcouzbyluinvvnsl.jvtspube-ttrchjr.vyn@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3soGRXAYKCOUZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id w8sor300136pgs.25.2019.03.19.16.56.34 for (Google Transport Security); Tue, 19 Mar 2019 16:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of 3sogrxaykcouzbyluinvvnsl.jvtspube-ttrchjr.vyn@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ViufV3H9; spf=pass (google.com: domain of 3sogrxaykcouzbyluinvvnsl.jvtspube-ttrchjr.vyn@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3soGRXAYKCOUZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=OBXkes655anl10ghu56F3PCl5wd5CeGj94L2IaEvAok=; b=ViufV3H9RpAeDfEYRca09ZHiuCDEEE7bKNCDMcMtKBrJC14eRqNfcqNHHYQOq+na9V 6H7JdNNGddCsCaecqnHRDT4qvYX1DB8C6plteEXU+zIk9R8baXzQOsoHfLMW7UYoIrJa xnxyu8o4Ns4Hw4KIqkgi04u/ojN0sGrpDJ53t1VKOu9ympyYotAVuoZWBitaFUIMdMav Nyhu/nbgRgdMV1SO9zoqliqG4Z3hvkfNYsgnd1suNAvHG589L2XGHM6fZx/n65Up7Ijh Cxbjtaq3cvyaQyocIsPIbFFUuY28iDEH1CwonE07NSVXVpttNoqUiLr31kJH9b2CyWhZ 7Azw== X-Google-Smtp-Source: APXvYqyuwpOXbhD+fWfIrgCA7neQKWQsukpEJktLS0Mziza+SL39C80NgdVKpxLsF1KcKTsjtymvde1TM/8= X-Received: by 2002:a65:6495:: with SMTP id e21mr8268337pgv.58.1553039794697; Tue, 19 Mar 2019 16:56:34 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:15 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-4-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 3/7] psi: rename psi fields in preparation for psi trigger addition 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 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 | 14 ++++++------- kernel/sched/psi.c | 41 ++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index 762c6bb16f3c..4d1c1f67be18 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -69,17 +69,17 @@ 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 avgs_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; + /* Running pressure averages */ + u64 avg_total[NR_PSI_STATES - 1]; + u64 avg_last_update; + u64 avg_next_update; + struct delayed_work avgs_work; /* Total stall times and sampled pressure averages */ u64 total[NR_PSI_STATES - 1]; diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 281702de9772..4fb4d9913bc8 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -165,7 +165,7 @@ static struct psi_group psi_system = { .pcpu = &system_group_pcpu, }; -static void psi_update_work(struct work_struct *work); +static void psi_avgs_work(struct work_struct *work); static void group_init(struct psi_group *group) { @@ -173,9 +173,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; - INIT_DELAYED_WORK(&group->clock_work, psi_update_work); - mutex_init(&group->stat_lock); + group->avg_next_update = sched_clock() + psi_period; + INIT_DELAYED_WORK(&group->avgs_work, psi_avgs_work); + mutex_init(&group->avgs_lock); } void __init psi_init(void) @@ -278,7 +278,7 @@ static bool update_stats(struct psi_group *group) int cpu; int s; - mutex_lock(&group->stat_lock); + mutex_lock(&group->avgs_lock); /* * Collect the per-cpu time buckets and average them into a @@ -319,7 +319,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) @@ -332,14 +332,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, @@ -359,22 +359,22 @@ 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->avgs_lock); return nonidle_total; } -static void psi_update_work(struct work_struct *work) +static void psi_avgs_work(struct work_struct *work) { struct delayed_work *dwork; struct psi_group *group; bool nonidle; dwork = to_delayed_work(work); - group = container_of(dwork, struct psi_group, clock_work); + group = container_of(dwork, struct psi_group, avgs_work); /* * If there is task activity, periodically fold the per-cpu @@ -391,8 +391,9 @@ 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); } } @@ -546,13 +547,13 @@ void psi_task_change(struct task_struct *task, int clear, int set) */ if (unlikely((clear & TSK_RUNNING) && (task->flags & PF_WQ_WORKER) && - wq_worker_last_func(task) == psi_update_work)) + wq_worker_last_func(task) == psi_avgs_work)) wake_clock = false; while ((group = iterate_groups(task, &iter))) { psi_group_change(group, cpu, clear, set); - if (wake_clock && !delayed_work_pending(&group->clock_work)) - schedule_delayed_work(&group->clock_work, PSI_FREQ); + if (wake_clock && !delayed_work_pending(&group->avgs_work)) + schedule_delayed_work(&group->avgs_work, PSI_FREQ); } } @@ -649,7 +650,7 @@ void psi_cgroup_free(struct cgroup *cgroup) if (static_branch_likely(&psi_disabled)) return; - cancel_delayed_work_sync(&cgroup->psi.clock_work); + cancel_delayed_work_sync(&cgroup->psi.avgs_work); free_percpu(cgroup->psi.pcpu); } From patchwork Tue Mar 19 23:56: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: 10860591 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 D71B21515 for ; Tue, 19 Mar 2019 23:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCFD52994B for ; Tue, 19 Mar 2019 23:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B121A2994E; Tue, 19 Mar 2019 23:56:41 +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 2A7BE2994B for ; Tue, 19 Mar 2019 23:56:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FE9D6B000A; Tue, 19 Mar 2019 19:56:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0B0E96B000C; Tue, 19 Mar 2019 19:56:39 -0400 (EDT) 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 EBE736B000D; Tue, 19 Mar 2019 19:56:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id B54516B000A for ; Tue, 19 Mar 2019 19:56:38 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id i21so653531ywe.15 for ; Tue, 19 Mar 2019 16:56:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=dn6PEiCR+dScVGu5EewnvuQCwpS0GucFANxBNtI0jyg=; b=faJJ7Y0Qm8q4Ztw1LgniVeBCPkziMYHM2ZbZma1FhPgx1KKeEHVwvoBeYABPZLyKXt yHsXY3GamoJAwPHFyHxmg7wAxBbYhJUtbVJdRETWzC3s4F7Qyvc+2YyNGTDtp0GTmoXo Ja6TLVHgVytA93T4ff8kBdwnhPGGlbhQgVGe5pIr4Lx6q5kU42dDoYxZqn1mLfBeo3vc K9psVRUOIah81rAYfrNvg2M8zCh6qhM/QQ+giPWR40dM+1kaj3SkEpgf3D0ggGQImjyo +0YkUathPbmGvybESsA0N0qh2f72cKlHa9ZAHtK530lCll1cwtlbu9xF0KchLbBZO5RC f7ag== X-Gm-Message-State: APjAAAUdIeBXqtli3frGNZkwYo86gNvBfo+X7cysdo9zORi1mbsugigy vi8P397nmvtBO6nOMSj8FF2IwMKEYr1tTnktsoXA+oaatN9DMbRBhsVrOCWtrX+ioaFfmaRyo59 5Ul4qOAIeunSYXRaFs/4AEyLI4JehX2JkIw/BnzN/y7x+r7tZzee3BbBLUqKV9IS/3g== X-Received: by 2002:a5b:70f:: with SMTP id g15mr4298312ybq.382.1553039798417; Tue, 19 Mar 2019 16:56:38 -0700 (PDT) X-Received: by 2002:a5b:70f:: with SMTP id g15mr4298290ybq.382.1553039797596; Tue, 19 Mar 2019 16:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039797; cv=none; d=google.com; s=arc-20160816; b=bXDJZwS8frApcJ9mIKnaosjflmD2YPPzC83ZFXhmYNa/biI8XO/pVNvQfQcQar8db1 zVCDa6fVBdg6AVS6T6qwJGh8g/bk5aUqP6ov2uZi77mI6OhrIOml4wp4B0nV3um2Mb8p Y2uKozy2+6eBVI34lIPUIoiEWXxtpJckwgFX2f6GuFaTdNS4nHI1N6OxuZQBEmG3CsJC R0rngupHlOWp4lXE3g+d/n0BtFI61jaIojCSweNFG8m6hdMZd66o5D3fqtrTlC3znFD4 cPIKVoIoRGlctBqEZKHp7/dRzSCEG0ceACwcjApkz2fQG5Sb/RAkCl57iY8Fyj+BilkX qocA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=dn6PEiCR+dScVGu5EewnvuQCwpS0GucFANxBNtI0jyg=; b=dATSj3/EfnqEhi4owONDFk7yYoRXWyLb2DonmSGjKFAojZl+dUrXnkt/6NCmJvXQSS RJxk0+2JU+f50IdDhLRXfzrfIxq0pBFsNyTSoRvEl9iPH3ULrPtK5X9XCBkYpKbomYhX cjipkoZ9AzA0VBR5ItCvINa0ZSB+sH376O0dh6csJT1eXMmvv99k2AX7NuggNOYB+bdT RO+72vYpIavSUOmD2TBOKaoI6M6FotaEZG+wRG1CU8fhV7HImMim7Dy+wKw3Mok6OQdR UWtepChJu9kLP88dUtCrYNciDo1xLP6ZIWJWwzxQsQYfqLUIAN1GceLlRZE8eZUzN6qE llPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Z6b442+6; spf=pass (google.com: domain of 3tygrxaykcogceboxlqyyqvo.mywvsxeh-wwufkmu.ybq@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3tYGRXAYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id c83sor118540ybb.66.2019.03.19.16.56.37 for (Google Transport Security); Tue, 19 Mar 2019 16:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of 3tygrxaykcogceboxlqyyqvo.mywvsxeh-wwufkmu.ybq@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Z6b442+6; spf=pass (google.com: domain of 3tygrxaykcogceboxlqyyqvo.mywvsxeh-wwufkmu.ybq@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3tYGRXAYKCOgcebOXLQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=dn6PEiCR+dScVGu5EewnvuQCwpS0GucFANxBNtI0jyg=; b=Z6b442+6DNI/wL3Sl+GmBfCDemyRgLchS2XX8vUdUBCLvLTr6SRAXAFrKle3CWKt83 v/Lyw5vroFag4ZNItRCs1E2AW0rTWPfFeUTPo1GonT4xq3BSGy7UAoDlpLr8wfzd4dEk cAQsQM3nDSIJoKigdyekrTeWCnEDlgdImc40cSqjYKkcrN0irpacS5iuUwz+nNKTfCj6 gN9agbjk3JafwYtdbZcJrSQ9KVE5u5RPfTsRdqFUk6odVENAIbN2URKCX146f8h3tIki tQqvJcideceDh5tkn6j7mXS/7dCIydNbwoCEy1XZmg00rksFqoQLHtmFE2PGru24T2ue Q36A== X-Google-Smtp-Source: APXvYqzqRXV9Su0O8ijkHzVc98Uu6jekXyU8mHEz8z0Z4ekoSX8Xd/HdmZXF1XnScGWT74vxfZWql8OgG4g= X-Received: by 2002:a25:ae96:: with SMTP id b22mr1664495ybj.94.1553039797316; Tue, 19 Mar 2019 16:56:37 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:16 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-5-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 4/7] psi: split update_stats into parts 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 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 Split update_stats into collect_percpu_times and update_averages for collect_percpu_times to be reused later inside psi monitor. Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- kernel/sched/psi.c | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 4fb4d9913bc8..ace5ed97b186 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -269,17 +269,13 @@ static void calc_avgs(unsigned long avg[3], int missed_periods, avg[2] = calc_load(avg[2], EXP_300s, pct); } -static bool update_stats(struct psi_group *group) +static bool collect_percpu_times(struct psi_group *group) { u64 deltas[NR_PSI_STATES - 1] = { 0, }; - unsigned long missed_periods = 0; unsigned long nonidle_total = 0; - u64 now, expires, period; int cpu; int s; - mutex_lock(&group->avgs_lock); - /* * Collect the per-cpu time buckets and average them into a * single time sample that is normalized to wallclock time. @@ -317,11 +313,18 @@ static bool update_stats(struct psi_group *group) for (s = 0; s < NR_PSI_STATES - 1; s++) group->total[s] += div_u64(deltas[s], max(nonidle_total, 1UL)); + return nonidle_total; +} + +static u64 update_averages(struct psi_group *group, u64 now) +{ + unsigned long missed_periods = 0; + u64 expires, period; + u64 avg_next_update; + int s; + /* avgX= */ - now = sched_clock(); expires = group->avg_next_update; - if (now < expires) - goto out; if (now - expires >= psi_period) missed_periods = div_u64(now - expires, psi_period); @@ -332,7 +335,7 @@ 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->avg_next_update = expires + ((1 + missed_periods) * psi_period); + avg_next_update = expires + ((1 + missed_periods) * psi_period); period = now - (group->avg_last_update + (missed_periods * psi_period)); group->avg_last_update = now; @@ -362,9 +365,8 @@ static bool update_stats(struct psi_group *group) group->avg_total[s] += sample; calc_avgs(group->avg[s], missed_periods, sample, period); } -out: - mutex_unlock(&group->avgs_lock); - return nonidle_total; + + return avg_next_update; } static void psi_avgs_work(struct work_struct *work) @@ -372,10 +374,16 @@ static void psi_avgs_work(struct work_struct *work) struct delayed_work *dwork; struct psi_group *group; bool nonidle; + u64 now; dwork = to_delayed_work(work); group = container_of(dwork, struct psi_group, avgs_work); + mutex_lock(&group->avgs_lock); + + now = sched_clock(); + + nonidle = collect_percpu_times(group); /* * If there is task activity, periodically fold the per-cpu * times and feed samples into the running averages. If things @@ -383,19 +391,15 @@ static void psi_avgs_work(struct work_struct *work) * Once restarted, we'll catch up the running averages in one * go - see calc_avgs() and missed_periods. */ - - nonidle = update_stats(group); + if (now >= group->avg_next_update) + group->avg_next_update = update_averages(group, now); if (nonidle) { - unsigned long delay = 0; - u64 now; - - now = sched_clock(); - if (group->avg_next_update > now) - delay = nsecs_to_jiffies( - group->avg_next_update - now) + 1; - schedule_delayed_work(dwork, delay); + schedule_delayed_work(dwork, nsecs_to_jiffies( + group->avg_next_update - now) + 1); } + + mutex_unlock(&group->avgs_lock); } static void record_times(struct psi_group_cpu *groupc, int cpu, @@ -707,11 +711,18 @@ void cgroup_move_task(struct task_struct *task, struct css_set *to) int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) { int full; + u64 now; if (static_branch_likely(&psi_disabled)) return -EOPNOTSUPP; - update_stats(group); + /* Update averages before reporting them */ + mutex_lock(&group->avgs_lock); + now = sched_clock(); + collect_percpu_times(group); + if (now >= group->avg_next_update) + group->avg_next_update = update_averages(group, now); + mutex_unlock(&group->avgs_lock); for (full = 0; full < 2 - (res == PSI_CPU); full++) { unsigned long avg[3]; From patchwork Tue Mar 19 23:56: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: 10860593 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 CFF2717E9 for ; Tue, 19 Mar 2019 23:56:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4EC82994B for ; Tue, 19 Mar 2019 23:56:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8C262994C; Tue, 19 Mar 2019 23:56:45 +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 2CBD82994E for ; Tue, 19 Mar 2019 23:56:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 088776B000C; Tue, 19 Mar 2019 19:56:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 038136B000D; Tue, 19 Mar 2019 19:56:43 -0400 (EDT) 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 E42726B000E; Tue, 19 Mar 2019 19:56:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id C5C9B6B000C for ; Tue, 19 Mar 2019 19:56:43 -0400 (EDT) Received: by mail-qk1-f197.google.com with SMTP id 23so19215596qkl.16 for ; Tue, 19 Mar 2019 16:56:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=/1f+k74gk1272nyZAYvhUzZCD+eEvuFJDJVbOJgy+wk=; b=iTqCTR7aV+hUM4woDLn0KOK43ZKLmQF7A3dL21wF5s1MBiiC4Sfl9bH3S8ouNYJcS9 LoWMxmMKtupMd3QQ9qrtdvmrwIE39hopLJrlT7uZrmBRhEu9meuFAGdk96JI+fBAGbH/ IqJ2yNZ/kC3b8KJfI2obU3yrZVGE7BxTyUM0mkoEO3OYzgu+w1+KznO8Rum+xpe6ctKg 4JIS4ZGouJmOvyCHEQ/5TMwcrOfiWuxESBZv4cvVGv0r/Ml3vwiBw69/K0L8WKP2kWFb idateBei4mTZrAqPE0PAcmTK99oJtE8tnAA1Qrrc7scVFU4W1W+J3CKHJfSG9tG2YKtO 39ow== X-Gm-Message-State: APjAAAW6LTup5Pz3GyKK9My2AYbYy3oVAKCTvCvq9SeR3fIPZ9/RjZXi p7LqtM6FraWpD2GrPeKuuMiC6Untx/kvd96HQ6ofsOrH3GFRJaYOJZsmKQQhJZh+ljzATbG3Yjr k8cwFGkTTGfvuzar3zR+ehIInC7bc6YlktD2nWBetA7+ZMPFj3QjvHmQiuKbI3wQOeg== X-Received: by 2002:ae9:f00b:: with SMTP id l11mr4167593qkg.84.1553039803535; Tue, 19 Mar 2019 16:56:43 -0700 (PDT) X-Received: by 2002:ae9:f00b:: with SMTP id l11mr4167466qkg.84.1553039800410; Tue, 19 Mar 2019 16:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039800; cv=none; d=google.com; s=arc-20160816; b=qhKnVwgzMoO2x1tueHE4Qlc0/DgeNc9aV67Ic9H61YlpinY7Xrc5fgN9j9/WG9+eRU S72JCAfYSC3Fh0uIFlPsmx+Hwr9YnZFzF9yspem7oziW6cKl3AgjpLmQloNbR0MVDvm2 dDs+Vx418P742CzFqxdaSxemV5colH1PjOnAlB3202qjREOywzAkAZg1oGY9rFzbTuvg ITriYsyPYhe5c+1T3qG9NT04Gz+msxiE2nSOvneof7wBP7ICzSp/23vmSuVhTuMvopsT Uknxt2WIuUQ372I9cB3gwfjUJtjtZQ0vXlyGKWSxhCU4Gz7MIC49XQAuC46aLWCC9j6t B+rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=/1f+k74gk1272nyZAYvhUzZCD+eEvuFJDJVbOJgy+wk=; b=LgaDSB5aGf5QQQqmvIonrY/fiGk4ssYnsosx1RYcdjhxFRA19eUh4lvPhKs5yERabZ Lma24cqDAcs3z5L6M/zHN4krtIIaHRd2Mop8Or3s5LK+KOPcStvFCoiVpv+iOZG+KHnv mOulNejnXoyBtjN6Np4qrfw7ggur3LwDA7CNmnR61jYwnRrjpy3bKgRsrJMSEEj83oQo VQ26dGXYC1+kfD4P5UHpVLGZ+4lIccYVQnq/CXXVjM7e15EYIQpefHxxTP1fuA1k+ZJW TKM4tuxf8A34b2mNXBZ/u2ZeOZPrB2ZEnBgs5h/dGv3olUZjHXIjP2P4ywalOqme6Htf tRmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q8ffQgdK; spf=pass (google.com: domain of 3uigrxaykcosfheraotbbtyr.pbzyvahk-zzxinpx.bet@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3uIGRXAYKCOsfheRaOTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id q11sor850611qtq.28.2019.03.19.16.56.40 for (Google Transport Security); Tue, 19 Mar 2019 16:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of 3uigrxaykcosfheraotbbtyr.pbzyvahk-zzxinpx.bet@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Q8ffQgdK; spf=pass (google.com: domain of 3uigrxaykcosfheraotbbtyr.pbzyvahk-zzxinpx.bet@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3uIGRXAYKCOsfheRaOTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/1f+k74gk1272nyZAYvhUzZCD+eEvuFJDJVbOJgy+wk=; b=Q8ffQgdK/wkTC+TdacBpBr7s7ZA+ibEdwudd2fRpPvrcaC/Z4LqJTNqtLCyv8fay3Q chiHW354Gbcen71ue0RFArhXaTYhUvFlgw847q/e4JvbmuxVF1URZSS4uI5/2AOq95Tg EUZGBIm5ffQd2Ig8HQTcV4Ga4AwlViHgtFeDDiCPhfHDPO06IXDNPK9KlA6EzFdtzCZw XIpSvnBo/nnTQIl706MCfwLeDFb6UkMXt7TLQ9AlMLikpSRMRfuJ/IfBREdiXgcI3pzN Tqwh1wtk3Mfv6veI944tZm831+Y/Nmg0Yiy3lc4aslJlMD8H+RAAp6Z3buACiQNjY+Pi ZHIg== X-Google-Smtp-Source: APXvYqw+3rmGmXN+0NOE9KYUNNYevZu09CHWRK5dGTsF91CDis8OUSyXsZ9D4hzjIdVioTkn+fpmgfJUK48= X-Received: by 2002:ac8:1410:: with SMTP id k16mr13547779qtj.58.1553039800238; Tue, 19 Mar 2019 16:56:40 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:17 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-6-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 5/7] psi: track changed states 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 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 Introduce changed_states parameter into collect_percpu_times to track the states changed since the last update. Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- kernel/sched/psi.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index ace5ed97b186..1b99eeffaa25 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -210,7 +210,8 @@ static bool test_state(unsigned int *tasks, enum psi_states state) } } -static void get_recent_times(struct psi_group *group, int cpu, u32 *times) +static void get_recent_times(struct psi_group *group, int cpu, u32 *times, + u32 *pchanged_states) { struct psi_group_cpu *groupc = per_cpu_ptr(group->pcpu, cpu); u64 now, state_start; @@ -218,6 +219,8 @@ static void get_recent_times(struct psi_group *group, int cpu, u32 *times) unsigned int seq; u32 state_mask; + *pchanged_states = 0; + /* Snapshot a coherent view of the CPU state */ do { seq = read_seqcount_begin(&groupc->seq); @@ -246,6 +249,8 @@ static void get_recent_times(struct psi_group *group, int cpu, u32 *times) groupc->times_prev[s] = times[s]; times[s] = delta; + if (delta) + *pchanged_states |= (1 << s); } } @@ -269,10 +274,11 @@ static void calc_avgs(unsigned long avg[3], int missed_periods, avg[2] = calc_load(avg[2], EXP_300s, pct); } -static bool collect_percpu_times(struct psi_group *group) +static void collect_percpu_times(struct psi_group *group, u32 *pchanged_states) { u64 deltas[NR_PSI_STATES - 1] = { 0, }; unsigned long nonidle_total = 0; + u32 changed_states = 0; int cpu; int s; @@ -287,8 +293,11 @@ static bool collect_percpu_times(struct psi_group *group) for_each_possible_cpu(cpu) { u32 times[NR_PSI_STATES]; u32 nonidle; + u32 cpu_changed_states; - get_recent_times(group, cpu, times); + get_recent_times(group, cpu, times, + &cpu_changed_states); + changed_states |= cpu_changed_states; nonidle = nsecs_to_jiffies(times[PSI_NONIDLE]); nonidle_total += nonidle; @@ -313,7 +322,8 @@ static bool collect_percpu_times(struct psi_group *group) for (s = 0; s < NR_PSI_STATES - 1; s++) group->total[s] += div_u64(deltas[s], max(nonidle_total, 1UL)); - return nonidle_total; + if (pchanged_states) + *pchanged_states = changed_states; } static u64 update_averages(struct psi_group *group, u64 now) @@ -373,6 +383,7 @@ static void psi_avgs_work(struct work_struct *work) { struct delayed_work *dwork; struct psi_group *group; + u32 changed_states; bool nonidle; u64 now; @@ -383,7 +394,8 @@ static void psi_avgs_work(struct work_struct *work) now = sched_clock(); - nonidle = collect_percpu_times(group); + collect_percpu_times(group, &changed_states); + nonidle = changed_states & (1 << PSI_NONIDLE); /* * If there is task activity, periodically fold the per-cpu * times and feed samples into the running averages. If things @@ -719,7 +731,7 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) /* Update averages before reporting them */ mutex_lock(&group->avgs_lock); now = sched_clock(); - collect_percpu_times(group); + collect_percpu_times(group, NULL); if (now >= group->avg_next_update) group->avg_next_update = update_averages(group, now); mutex_unlock(&group->avgs_lock); From patchwork Tue Mar 19 23:56: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: 10860595 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 3527D1515 for ; Tue, 19 Mar 2019 23:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1835E2994B for ; Tue, 19 Mar 2019 23:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C1272994E; Tue, 19 Mar 2019 23:56: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 890CE2994B for ; Tue, 19 Mar 2019 23:56:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98D936B000D; Tue, 19 Mar 2019 19:56:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8794C6B000E; Tue, 19 Mar 2019 19:56:44 -0400 (EDT) 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 716366B0010; Tue, 19 Mar 2019 19:56:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 515246B000D for ; Tue, 19 Mar 2019 19:56:44 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id d49so627840qtk.8 for ; Tue, 19 Mar 2019 16:56:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=CF4+E5UIa39xAKg6YCWVn7zIouVA3+WI4DKW8uAVCQw=; b=Dr+J79VURYgcYBh336H9Rs8puoLuVPi/+FjLTK7ILJsCT1A2xICZbY8Gmbcmva3N41 MrUhLbkHNwmnXSfuhKLUMUCGdQqVRssW0qW5MPnkbHCaJP3CH4wEnGyc+kHC1F4u8WMM yGLGUNgryW99WRGLazZ9u63lu0n1FEPPJ4hoUi2hfwsZWJ+r1IakPxNyO9da/EAppg3K pxkKoZpZu6sk+PfB6tif5XaZmVB3lrqfdCvrk+ZMpFdZ6l4Lz2HTVU/MuGqStDIx1mX0 qeEK2Fx93o0rhajcLGiwB9zUyRlgrdlmsgVnrv77E9diNBnh0XzoQ5iV3znLqCOOvlnB bOJA== X-Gm-Message-State: APjAAAXcbyZOHG/ZuO1kZ6BW8Oz60umIcuXlhdTLskqonLjjYoFDz/cq Qst+C7AET38HUdHmmMsxmir6mGGmuK5n4Ch/QAIQh5sLj3RCExwylQxMfQccHV6d5QRF5OjQq4p 2ljoAaDpDWkWvgBqjCld3IzoD7j8gNS0oh93/RfFom2a7CTE6B43/br1yFqJuSCtDFQ== X-Received: by 2002:ac8:67d6:: with SMTP id r22mr4351425qtp.183.1553039804067; Tue, 19 Mar 2019 16:56:44 -0700 (PDT) X-Received: by 2002:ac8:67d6:: with SMTP id r22mr4351388qtp.183.1553039803287; Tue, 19 Mar 2019 16:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039803; cv=none; d=google.com; s=arc-20160816; b=KsnemkV1IWfHA2Oxb8d0NWK5IXFSEbOHwFxzwRu5IMq/28HaQLjdxCwHu1hUpMIAyU q+P10eV9GbTsm62/DjjkHvCurddyNRA3W+UfXZDd7Dh5i5oQ/j965C2KNQXBvY8fjH3T BtXZMMt4tESZrVansfGGdDuV5GnObYmI/7Xptnty6mStcOL9XVKUtSGytf/+OUhip4Tl 3pm9D4sNPt5AqItfD/VHbm/rZJXNnJ1OX8qKAA4WtKVQ0vhpDgLJCkTRg6Z93xOD74iL 4y/oNG4dnquU6z5BMkN1+nyVNwMoEtb7FY5V7FQLjKadZj4kx5v3ZieB23giSIHQIc5n sRzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=CF4+E5UIa39xAKg6YCWVn7zIouVA3+WI4DKW8uAVCQw=; b=lXKNZ6WNepgGCgzPNmzgIxJTcDOjRIzomY3DybS94mwDGcMrmIt3/dLRjTFZaNcnDE pBv9+/3JPNp714aQbma4Q/38m+DuuASEg5Va1zeNLllr4k76f28yKxfcDQZZn4AR62rF iAnusnzK/E+iVn9gwW7F9zcCcFiGUcp98b0koHgERgX78OWQ/mmxJ0N5DKtKiBQ2iMqj wq+NHBHjRd1D9KjbuJjB+yJXnHZXHHePv9GOehuhyfrlhEc6tu8R4MGic28GHO2h15sB 8rhCZhPcRoLC3Da+XKaU/rLMKJwXXJ+lUbq/wGegusvXo81NzThFpyPWs1sTTPXSjnyw X0xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JEDIRq0N; spf=pass (google.com: domain of 3uogrxaykco0hjgtcqvddvat.rdbaxcjm-bbzkprz.dgv@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3uoGRXAYKCO0hjgTcQVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id f8sor847639qtb.16.2019.03.19.16.56.43 for (Google Transport Security); Tue, 19 Mar 2019 16:56:43 -0700 (PDT) Received-SPF: pass (google.com: domain of 3uogrxaykco0hjgtcqvddvat.rdbaxcjm-bbzkprz.dgv@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JEDIRq0N; spf=pass (google.com: domain of 3uogrxaykco0hjgtcqvddvat.rdbaxcjm-bbzkprz.dgv@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3uoGRXAYKCO0hjgTcQVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CF4+E5UIa39xAKg6YCWVn7zIouVA3+WI4DKW8uAVCQw=; b=JEDIRq0NpHszfqFfgtVD61U2sHtyH+5HwG104koBNiR1CVnOdbZIQ4T7vm1xgqB50H thW4tUOnS/p6aXoascAN+Dz6Gdx60R0hL2NJtBGym4V5OdgxsWlooDMVXhqauD5dvIf0 9+CLQTjHPP5q5QCRpzsZTUK0lbWDcn9aM5ow9098GJcCbaDlHtZLL8xqoZoW3weRMuVU Kgiw2eXJz/3tDBSIvexT6rGnLTcBKSeiNpmE4SWVOOBbgwyWNVKTStkLtZKteam1R6sI KT563q/OieuZG9lPrc1cm2wdB93lDHzC3hFQkJ9EXZhD7gqcLNh6exFuVacN12aIAOqa yjEQ== X-Google-Smtp-Source: APXvYqwuz5jKuNXMD5ZfZA8ooeSpOd7bbNe9/PlToDa4czqg8Eac9fU4fj1gxy1+OtwlgZ9K0uuqCz4n/Cc= X-Received: by 2002:ac8:277d:: with SMTP id h58mr4998590qth.31.1553039802970; Tue, 19 Mar 2019 16:56:42 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:18 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-7-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 6/7] refactor header includes to allow kthread.h inclusion in psi_types.h 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 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 kthread.h can't be included in psi_types.h because it creates a circular inclusion with kthread.h eventually including psi_types.h and complaining on kthread structures not being defined because they are defined further in the kthread.h. Resolve this by removing psi_types.h inclusion from the headers included from kthread.h. Signed-off-by: Suren Baghdasaryan Acked-by: Johannes Weiner --- drivers/spi/spi-rockchip.c | 1 + include/linux/kthread.h | 3 ++- include/linux/sched.h | 1 - kernel/kthread.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 3912526ead66..cdb613d38062 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 2c89e60bc752..0f9da966934e 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -4,7 +4,6 @@ /* Simple interface for creating and stopping kernel threads without mess. */ #include #include -#include __printf(4, 5) struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), @@ -198,6 +197,8 @@ bool kthread_cancel_delayed_work_sync(struct kthread_delayed_work *work); void kthread_destroy_worker(struct kthread_worker *worker); +struct cgroup_subsys_state; + #ifdef CONFIG_BLK_CGROUP void kthread_associate_blkcg(struct cgroup_subsys_state *css); struct cgroup_subsys_state *kthread_blkcg(void); diff --git a/include/linux/sched.h b/include/linux/sched.h index 1549584a1538..20b9f03399a7 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/kernel/kthread.c b/kernel/kthread.c index 5942eeafb9ac..be4e8795561a 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include From patchwork Tue Mar 19 23:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 10860597 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 B2E831515 for ; Tue, 19 Mar 2019 23:56:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5882994B for ; Tue, 19 Mar 2019 23:56:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80BFB2994E; Tue, 19 Mar 2019 23:56: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 7FE812994B for ; Tue, 19 Mar 2019 23:56:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D84436B000E; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D0D616B0010; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) 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 B899D6B0266; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by kanga.kvack.org (Postfix) with ESMTP id 8E00C6B000E for ; Tue, 19 Mar 2019 19:56:48 -0400 (EDT) Received: by mail-io1-f72.google.com with SMTP id r21so395534iod.12 for ; Tue, 19 Mar 2019 16:56:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=frwiutCdP4rIs7VzndCw++HxcxANOWIj7MX63sPxLHXva7BJegHFk5E8k0JDBMfd8k YfhsbA11AjAFk88MBzxNucffm9oR7nhGY64XelN0klXImZgpi3gn1YJl64ppFNEa15Ft PwNo6zYGbcIwbz19c5lMETv6eESaQ6u+O4JfX0aav4ePtpDH4qfQkZYh1n2qBiY41A0m 4tdgYyWDpjcRAtYyGlhtg2CHAFEqncWEz+4S4PJGm1tRgFprF78z47eiNaSXqNH3TX60 Tt1TfUqZSi79VzoLqSQU5+2rCzKUFUu8xWmiciVfClkR496RM1Zgu8k9hctzbyGt4+f7 BYrg== X-Gm-Message-State: APjAAAV+bspQegUf5KJKgcJPKf6g0LW5QpKJzWzVDulZvE7M6rNbmoLN Qf0aslhIBCb1614F4MiVjU6sdGCF5F3wLdd2M75xN35c/ovuv4m5v492iGttkDzEemAWKqzNe0C zxQka9DDqQQxZ9Peqck51NIt5U5wzelDAkb5TTfIm3a/zJ5vg798Hdgj8S6iJ2msPVw== X-Received: by 2002:a5d:93d9:: with SMTP id j25mr3522017ioo.305.1553039808218; Tue, 19 Mar 2019 16:56:48 -0700 (PDT) X-Received: by 2002:a5d:93d9:: with SMTP id j25mr3521943ioo.305.1553039805942; Tue, 19 Mar 2019 16:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553039805; cv=none; d=google.com; s=arc-20160816; b=gU2WDh6/44ojjesOApS0R+q5hRWUFCnVJu7yeJ2kCw5u6XxLV+dmKcWW6A+o/vcXc+ DyFeCHhH8IyBnNiKzSdJz6VWUKaB6/5CB9goSrE3bO7h5KxOUW92wSZq+yGWwjcBmP3n djiILftpS3cGRN9HjilnkQAGDa0rnkjNEq/JX0QdTVCSnGC3PTvz7pNmf8hTcVZW6W8a FF8Pi4V4pT0Ec3JBrLL7L+9jPCMxfeT913+T4IZ4wDxq6FhGE6qiNloYZJ/IS+4+TqeP tcesvB03fPWkYL8DIbZcjOOup/QI7+4zT5yik5HGWObsnbXvxVBMX6ZgLWmfbk4qlht1 VRpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=G/8yf8ZH6IhtnJY5Nr+21G/lg9StD5xPeQYUEqsSwjYsQTkPXEYM7rsQWy8nA8zcE/ IJlyXlkVly6mbKqb5T12J9MUWRrsAVjYrjZadoaiHYM5zCdll6wi0e62MRRZQVKeu089 LzZmFADUSBdKx9OISTHuJhcuJxsZpWZnFR0hKaix26aLqmcG87s6RA+ToLMXCHLO6zQD e2ffe8qpd9XrONq/lWDu7dyxMFt4AW7ESi0trQkoOVifctYvWkAYaGHrMyqD4UBz0RR/ uwKClPICRgkuQ07wV0DV8k53fw7aA5NrnC/6DiQIvJbk0SiZq5N2+YT7+tGo9Vboz4Wv WZ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tDTLBAGv; spf=pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3vYGRXAYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id q67sor568684ita.3.2019.03.19.16.56.45 for (Google Transport Security); Tue, 19 Mar 2019 16:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=tDTLBAGv; spf=pass (google.com: domain of 3vygrxaykcpakmjwftyggydw.ugedafmp-eecnsuc.gjy@flex--surenb.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=3vYGRXAYKCPAkmjWfTYggYdW.Ugedafmp-eecnSUc.gjY@flex--surenb.bounces.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=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rD12kcdJr70evYUchULXAeHxr2qtqjk4mpPoyT7DzFU=; b=tDTLBAGvjP1aWgYAToI0jrG0Ojb4KLFuFfahjHLMvszYkeiDWwjY8SDWm8y8Y6WwEs bBCOKw2P63Q8prUZUD8b3ryydHwgB97IFkWB7kzy0bZoIBMU+NvZSonG+RJ2DUKznRWn z3umqoYZGp6l8nguV4DH/oDPrhh1yVkqukzZYMR+pU4Lx4uYvNrSKP1Q4uygTaAfk0mJ wYHGTXwAcx9775B0pBTXyPbYgC2IXzIHF4Wiua/7EQBM+74psKEm1ZwRZYfJca+EUvUk INuX2eRdG1lW7MPgHg/NuMNtdgrYvjehTAQH2Uwp/DjwxIl1uiP95K1uhpcM9XPynU/t TXrg== X-Google-Smtp-Source: APXvYqyeblFB8b2GIjj6UvR07OrEL8oGXI1Wd4F+PP4czPiRT2vkBl2eKgsnemwdtOo2inYGl/8y5CuGRR0= X-Received: by 2002:a24:7d8a:: with SMTP id b132mr3009072itc.20.1553039805672; Tue, 19 Mar 2019 16:56:45 -0700 (PDT) Date: Tue, 19 Mar 2019 16:56:19 -0700 In-Reply-To: <20190319235619.260832-1-surenb@google.com> Message-Id: <20190319235619.260832-8-surenb@google.com> Mime-Version: 1.0 References: <20190319235619.260832-1-surenb@google.com> X-Mailer: git-send-email 2.21.0.225.g810b269d1ac-goog Subject: [PATCH v6 7/7] psi: introduce psi monitor 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 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 | 107 +++++++ include/linux/psi.h | 8 + include/linux/psi_types.h | 82 ++++- kernel/cgroup/cgroup.c | 71 ++++- kernel/sched/psi.c | 494 ++++++++++++++++++++++++++++++- 5 files changed, 742 insertions(+), 20 deletions(-) diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..4fb40fe94828 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,110 @@ 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: + +