[linux-next,v3,2/4] sched/psi: Avoid update triggers and rtpoll_total when it is unnecessary
Message ID | 202310101641075436843@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp47346vqb; Tue, 10 Oct 2023 01:41:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHM33/s5TZzAVOk8C/YdoeVXg9AjGu6drXju4kpcq5hgem+NbFqpkl5ehnXVmYuPl2cIaOt X-Received: by 2002:a05:6a21:a586:b0:16b:bbca:4a5d with SMTP id gd6-20020a056a21a58600b0016bbbca4a5dmr9838087pzc.62.1696927313458; Tue, 10 Oct 2023 01:41:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696927313; cv=none; d=google.com; s=arc-20160816; b=H0FCvIHnxbKtr462/T6hbhzPl6YCDFozJ7r9cftcet4d52ufP1ygrfCOj5EIMm0zvE poCopqP/xDT8MvruH99FW2ldVuWI/ARObit/HL6b1p5sFn10YOQ4RHcnRM0HwicnOVuk bf5r3tqWs+u8Em8NckYn3O5FS2DZ2eCxlbSwT5hPwN5vm9Tsa2fJtMrvEUdpagVq3ynV oQY4fmnkHCRspOQtLbvg6I98oMQqju0rDjFNiYp5hKttGHzTYsvncVIg/yTLHVElWNA/ QCstMYbZgje/D9VdJsyCmUO780ujpaNq3jiCmEGirthOmBNyK0vsA2w9EOusGA2ais08 w4aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:references :in-reply-to:message-id:date; bh=rOb8ILo6pQZ8USk/qmdg8jlai7R0kGZv3vF1vREfADM=; fh=Pxs9OYgLaqfGHLffXBxFlX9cWm93gqtjC9dMGI2r+W0=; b=A5eakpuHLuU3bQKAg5WoRPjvghfXORjAQUw3tHcOmZlxIryJASs8B4QGPc7CuHaO0w nRTAeSuKVPFTiHpE/zgUyE6DwpTieMuuKFuebkSRGg2iAsmoSThT1npwDeIjh94VPy9N ORsjfBMApLyPrUpmsxwUVycZdJn3/EK+mhzjWsSuqkZbwkil07o62fMZ4YLx67nEOKEU Zvr8fxvLLv+Z9Wz/fnJQXyrGjZHITg0S2/Hv4PyixFXyWgNCOIJROwxebIsW32m83U+f 6IuTnPagx+NGo5A/GAaZ9Eh/maaWK14fIioofckCjy8Ic4ZkENdZclaLKcuD/URqvKOL v9Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u3-20020a170902b28300b001b9ed021929si5950664plr.225.2023.10.10.01.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:41:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A732D812A959; Tue, 10 Oct 2023 01:41:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbjJJIl0 (ORCPT <rfc822;rua109.linux@gmail.com> + 20 others); Tue, 10 Oct 2023 04:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbjJJIlY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 10 Oct 2023 04:41:24 -0400 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC212B7 for <linux-kernel@vger.kernel.org>; Tue, 10 Oct 2023 01:41:21 -0700 (PDT) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4S4Trt6KwHz4xVbs; Tue, 10 Oct 2023 16:41:18 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl1.zte.com.cn with SMTP id 39A8f4oH037767; Tue, 10 Oct 2023 16:41:04 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Tue, 10 Oct 2023 16:41:07 +0800 (CST) Date: Tue, 10 Oct 2023 16:41:07 +0800 (CST) X-Zmail-TransId: 2b0465250e23ffffffffc85-c9adb X-Mailer: Zmail v1.0 Message-ID: <202310101641075436843@zte.com.cn> In-Reply-To: <ZST/WggW4hSVs9d4@gmail.com> References: CAJuCfpFabCn8gcuLV322RKC=xzVm0C+64HQP+CkFNJZ4VO42ZA@mail.gmail.com,202310101109350209198@zte.com.cn,ZST/WggW4hSVs9d4@gmail.com Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <mingo@kernel.org>, <surenb@google.com>, <peterz@infradead.org>, <hannes@cmpxchg.org> Cc: <linux-kernel@vger.kernel.org>, <juri.lelli@redhat.com>, <mingo@redhat.com> Subject: =?utf-8?q?=5BPATCH_linux-next_v3_2/4=5D_sched/psi=3A_Avoid_update_t?= =?utf-8?q?riggers_and_rtpoll=5Ftotal_when_it_is_unnecessary?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 39A8f4oH037767 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 65250E2E.002/4S4Trt6KwHz4xVbs X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:41:38 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779357255067851733 X-GMAIL-MSGID: 1779357255067851733 |
Series |
sched/psi: Optimize the process of updating triggers and rtpoll_total
|
|
Commit Message
Yang Yang
Oct. 10, 2023, 8:41 a.m. UTC
From: Yang Yang <yang.yang29@zte.com.cn> When psimon wakes up and there are no state changes for rtpoll_states, it's unnecessary to update triggers and rtpoll_total because the pressures being monitored by user had not changed. This will help to slightly reduce unnecessary computations of psi. Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> Cc: Zhang Yunkai <zhang.yunkai@zte.com.cn> Cc: Ran Xiaokai <ran.xiaokai@zte.com.cn> --- kernel/sched/psi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Comments
* yang.yang29@zte.com.cn <yang.yang29@zte.com.cn> wrote: > From: Yang Yang <yang.yang29@zte.com.cn> > > When psimon wakes up and there are no state changes for rtpoll_states, > it's unnecessary to update triggers and rtpoll_total because the pressures > being monitored by user had not changed. > This will help to slightly reduce unnecessary computations of psi. > > Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > Cc: Zhang Yunkai <zhang.yunkai@zte.com.cn> > Cc: Ran Xiaokai <ran.xiaokai@zte.com.cn> > --- > kernel/sched/psi.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index be853f227e40..143f8eb34f9d 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -704,11 +704,12 @@ static void psi_rtpoll_work(struct psi_group *group) > } > > if (now >= group->rtpoll_next_update) { > - update_triggers(group, now, &update_total, PSI_POLL); > group->rtpoll_next_update = now + group->rtpoll_min_period; > - if (update_total) > + if (changed_states & group->rtpoll_states) { > + update_triggers(group, now, &update_total, PSI_POLL); > memcpy(group->rtpoll_total, group->total[PSI_POLL], > sizeof(group->rtpoll_total)); > + } Yeah, so I believe we may have been talking past each other for past versions of this patch: why is this patch modifying the order of the modification to group->rtpoll_next_update? It should do the below sequence, nothing more - see the patch attached below. This is basically a combination of patches #2 and #3. And then the final patch removes the now superfluous 'update_total' parameter, which is always true. Here are the commits I applied to tip:sched/core: e03dc9fa0663 sched/psi: Change update_triggers() to a 'void' function ... 80cc1d1d5ee3 sched/psi: Avoid updating PSI triggers and ->rtpoll_total when there are no state changes 3657680f38cd sched/psi: Delete the 'update_total' function parameter from update_triggers() I rewrote the changelogs for readability. Thanks, Ingo ===================> From: Yang Yang <yang.yang29@zte.com.cn> Date: Tue, 10 Oct 2023 16:41:07 +0800 Subject: [PATCH] sched/psi: Avoid updating PSI triggers and ->rtpoll_total when there are no state changes When psimon wakes up and there are no state changes for ->rtpoll_states, it's unnecessary to update triggers and ->rtpoll_total because the pressures being monitored by the user have not changed. This will help to slightly reduce unnecessary computations of PSI. [ mingo: Changelog updates ] Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Peter Ziljstra <peterz@infradead.org> Link: https://lore.kernel.org/r/202310101641075436843@zte.com.cn --- kernel/sched/psi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index be853f227e40..79f8db0c6150 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -704,11 +704,12 @@ static void psi_rtpoll_work(struct psi_group *group) } if (now >= group->rtpoll_next_update) { - update_triggers(group, now, &update_total, PSI_POLL); - group->rtpoll_next_update = now + group->rtpoll_min_period; - if (update_total) + if (changed_states & group->rtpoll_states) { + update_triggers(group, now, &update_total, PSI_POLL); memcpy(group->rtpoll_total, group->total[PSI_POLL], sizeof(group->rtpoll_total)); + } + group->rtpoll_next_update = now + group->rtpoll_min_period; } psi_schedule_rtpoll_work(group,
> Yeah, so I believe we may have been talking past each other for past > versions of this patch: why is this patch modifying the order of the > modification to group->rtpoll_next_update? Yes it is, I may not have fully expressed the reasons clearly before. > I rewrote the changelogs for readability. Much grateful for your guidance and work. Learned a lot.
On Wed, Oct 11, 2023 at 2:15 PM Ingo Molnar <mingo@kernel.org> wrote: > > > * yang.yang29@zte.com.cn <yang.yang29@zte.com.cn> wrote: > > > From: Yang Yang <yang.yang29@zte.com.cn> > > > > When psimon wakes up and there are no state changes for rtpoll_states, > > it's unnecessary to update triggers and rtpoll_total because the pressures > > being monitored by user had not changed. > > This will help to slightly reduce unnecessary computations of psi. > > > > Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > > Cc: Zhang Yunkai <zhang.yunkai@zte.com.cn> > > Cc: Ran Xiaokai <ran.xiaokai@zte.com.cn> > > --- > > kernel/sched/psi.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > > index be853f227e40..143f8eb34f9d 100644 > > --- a/kernel/sched/psi.c > > +++ b/kernel/sched/psi.c > > @@ -704,11 +704,12 @@ static void psi_rtpoll_work(struct psi_group *group) > > } > > > > if (now >= group->rtpoll_next_update) { > > - update_triggers(group, now, &update_total, PSI_POLL); > > group->rtpoll_next_update = now + group->rtpoll_min_period; > > - if (update_total) > > + if (changed_states & group->rtpoll_states) { > > + update_triggers(group, now, &update_total, PSI_POLL); > > memcpy(group->rtpoll_total, group->total[PSI_POLL], > > sizeof(group->rtpoll_total)); > > + } > > Yeah, so I believe we may have been talking past each other for past > versions of this patch: why is this patch modifying the order of the > modification to group->rtpoll_next_update? > > It should do the below sequence, nothing more - see the patch attached > below. This is basically a combination of patches #2 and #3. > > And then the final patch removes the now superfluous 'update_total' > parameter, which is always true. > > Here are the commits I applied to tip:sched/core: > > e03dc9fa0663 sched/psi: Change update_triggers() to a 'void' function > ... > 80cc1d1d5ee3 sched/psi: Avoid updating PSI triggers and ->rtpoll_total when there are no state changes > 3657680f38cd sched/psi: Delete the 'update_total' function parameter from update_triggers() > > I rewrote the changelogs for readability. > > Thanks, > > Ingo > > ===================> > From: Yang Yang <yang.yang29@zte.com.cn> > Date: Tue, 10 Oct 2023 16:41:07 +0800 > Subject: [PATCH] sched/psi: Avoid updating PSI triggers and ->rtpoll_total when there are no state changes > > When psimon wakes up and there are no state changes for ->rtpoll_states, > it's unnecessary to update triggers and ->rtpoll_total because the pressures > being monitored by the user have not changed. > > This will help to slightly reduce unnecessary computations of PSI. > > [ mingo: Changelog updates ] > > Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > Signed-off-by: Ingo Molnar <mingo@kernel.org> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Suren Baghdasaryan <surenb@google.com> > Cc: Peter Ziljstra <peterz@infradead.org> > Link: https://lore.kernel.org/r/202310101641075436843@zte.com.cn This version looks correct to me. Acked-by: Suren Baghdasaryan <surenb@google.com> > --- > kernel/sched/psi.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index be853f227e40..79f8db0c6150 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -704,11 +704,12 @@ static void psi_rtpoll_work(struct psi_group *group) > } > > if (now >= group->rtpoll_next_update) { > - update_triggers(group, now, &update_total, PSI_POLL); > - group->rtpoll_next_update = now + group->rtpoll_min_period; > - if (update_total) > + if (changed_states & group->rtpoll_states) { > + update_triggers(group, now, &update_total, PSI_POLL); > memcpy(group->rtpoll_total, group->total[PSI_POLL], > sizeof(group->rtpoll_total)); > + } > + group->rtpoll_next_update = now + group->rtpoll_min_period; > } > > psi_schedule_rtpoll_work(group,
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index be853f227e40..143f8eb34f9d 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -704,11 +704,12 @@ static void psi_rtpoll_work(struct psi_group *group) } if (now >= group->rtpoll_next_update) { - update_triggers(group, now, &update_total, PSI_POLL); group->rtpoll_next_update = now + group->rtpoll_min_period; - if (update_total) + if (changed_states & group->rtpoll_states) { + update_triggers(group, now, &update_total, PSI_POLL); memcpy(group->rtpoll_total, group->total[PSI_POLL], sizeof(group->rtpoll_total)); + } } psi_schedule_rtpoll_work(group,