[linux-next,2/3] sched/psi: Avoid update triggers and rtpoll_total when it is unnecessary
Message ID | 202310092030430136422@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1834103vqo; Mon, 9 Oct 2023 05:32:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMHnqg10S2kbNmbylKEVrjjC+eOiKF/gorKBahWpcJ5kbNFJbnWjLA8u2n7OPzHLAI1jJu X-Received: by 2002:a05:6a20:4417:b0:16b:a5fb:eee5 with SMTP id ce23-20020a056a20441700b0016ba5fbeee5mr8013687pzb.28.1696854772123; Mon, 09 Oct 2023 05:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854772; cv=none; d=google.com; s=arc-20160816; b=S9gU+P4CUyoHe/PwYE29IfaJfcJihkI3eol8KNV8aVdKug4UJsrBjzOzbbcS2ZtC52 I0yIU9S1NBXx/K7+fL9qzTD1A8HPlOLUIHSdddLe21Yv7ai5gzFRJ/qGSMb0ZdJHDD8c XBAPFFLdP02yzXpYdi6n3k07Cvd5maNlsr6CfTW6DPqWwL1o8UaNvix3+qxznFP7OlrF KrOKy3Ab+7f626TX8+j6yetYtpewO7jmNu+K8m+MDCJnTr9OJTERBegitVbD0hLywroc pCu3hnei1b6wy6onNldMv+sEXrmBKykPmCWxqV9O7TN3EV9JqC1Kx/OMj9nLOJOJun6x 5JTQ== 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=UxK+NRIThpoEjWcqhG1rhYVbEoCLUM2XZuE8Iluq2AQ=; fh=QA5pAs70psIMGwCg98gn5bGA5RYRu0ubnZRcj3fF3SU=; b=Q+sjAuyfcF2bwrLG5nTEotRIGd6hjK2/Hd/DgW3fBfvmpOcWOh/2UACXcQ1nPqEvEY IkS16Luc2lfAv9bT61jFn0xmcq2JceVn0G9xg4ZFQK2PxeGA5ZmF+ShIwJFn/+K+cS/h hzd9XUGj4UHcRMp/cJG4wA3QiJ5Cu/g9BvrxE5bWnkb3TNPCnQFOAjGXr0ttVEmxA3wI yKiAlUOiuwBeUJTKR/jH1mbP5l8sc9FrD+3tZrq/zhzaYzBhpBn6JGzOYUEfCQJYM1b3 iu+G3Ootm1p+f3+UhuLd3O77L6Q4IyepAwj5bxJjvXDW5b91GFjw1P+TfhTjbhgq8EpV ojOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l18-20020a656812000000b00565cc12ee24si9456906pgt.874.2023.10.09.05.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:32:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 83060804C667; Mon, 9 Oct 2023 05:32:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376530AbjJIMch (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Mon, 9 Oct 2023 08:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346541AbjJIMcW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 08:32:22 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 754B1211F for <linux-kernel@vger.kernel.org>; Mon, 9 Oct 2023 05:30:49 -0700 (PDT) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4S3z072YT1z4xPYY; Mon, 9 Oct 2023 20:30:47 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl2.zte.com.cn with SMTP id 399CUeF1008403; Mon, 9 Oct 2023 20:30:40 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp05[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Oct 2023 20:30:43 +0800 (CST) Date: Mon, 9 Oct 2023 20:30:43 +0800 (CST) X-Zmail-TransId: 2b076523f2730b8-e8417 X-Mailer: Zmail v1.0 Message-ID: <202310092030430136422@zte.com.cn> In-Reply-To: <ZSPayGSz6HQBp+3W@gmail.com> References: CAJuCfpHV+Tf+-YqdWFwQNAeQJU5aqOM56R2GzbehFaFQcHuxAg@mail.gmail.com,202310071421311735972@zte.com.cn,ZSPayGSz6HQBp+3W@gmail.com Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <mingo@kernel.org>, <surenb@google.com>, <peterz@infradead.org> Cc: <hannes@cmpxchg.org>, <mingo@redhat.com>, <linux-kernel@vger.kernel.org>, <juri.lelli@redhat.com> Subject: =?utf-8?q?=5BPATCH_linux-next_2/3=5D_sched/psi=3A_Avoid_update_trig?= =?utf-8?q?gers_and_rtpoll=5Ftotal_when_it_is_unnecessary?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 399CUeF1008403 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6523F277.000/4S3z072YT1z4xPYY X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 05:32:49 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778156291723326049 X-GMAIL-MSGID: 1779281189628858775 |
Series |
sched/psi: Optimize the process of updating triggers and rtpoll_total
|
|
Commit Message
Yang Yang
Oct. 9, 2023, 12:30 p.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. And update group->rtpoll_next_update after called update_triggers() and update rtpoll_total. This will prevent bugs if update_triggers() uses group->rtpoll_next_update in the future, and it makes more sense to set the next update time after we finished the current update. Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> Suggested-by: Suren Baghdasaryan <surenb@google.com> Suggested-by: Ingo Molnar <mingo@kernel.org> --- kernel/sched/psi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 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. > > And update group->rtpoll_next_update after called update_triggers() and > update rtpoll_total. This will prevent bugs if update_triggers() uses > group->rtpoll_next_update in the future, and it makes more sense > to set the next update time after we finished the current update. > 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; So please also split out the second change into a separate patch as well, as it's an unrelated patch to the state-change optimization. We have a "one conceptual change per patch" rule for most things. Thanks, Ingo
On Mon, Oct 9, 2023 at 5:52 AM 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. > > > > And update group->rtpoll_next_update after called update_triggers() and > > update rtpoll_total. This will prevent bugs if update_triggers() uses > > group->rtpoll_next_update in the future, and it makes more sense > > to set the next update time after we finished the current update. > > > 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; > > So please also split out the second change into a separate patch as well, > as it's an unrelated patch to the state-change optimization. I think that the second part could have been done in the first patch to place the "group->rtpoll_next_update = now + group->rtpoll_min_period" line at the right place from the beginning. Also when posting the next version please add the version number to all the patch titles in the patchset, not only to the cover letter. That helps with finding the latest version. Thanks! > > We have a "one conceptual change per patch" rule for most things. > > Thanks, > > Ingo
> I think that the second part could have been done in the first patch > to place the "group->rtpoll_next_update = now + > group->rtpoll_min_period" line at the right place from the beginning. Thanks for your advice, if we strict follow "one conceptual change per patch" rule, I think "group->rtpoll_next_update = ..." should be in another patch. > Also when posting the next version please add the version number to > all the patch titles in the patchset, not only to the cover letter. > That helps with finding the latest version. > Thanks! Get it, thanks to your reminder. I treat the split-up patches as new patches previously, so didn't add the version number. I will add version number in follow-up patches. > One small comment above and when you post the V2 please include > peterz@infradead.org. Peter is hosting PSI in his tree, so he is the > maintainer you absolutely need :) I get the maintainer information from get_maintainer.pl, it said Peter is a reviewer, maybe get_maintainer.pl should update ? Johannes Weiner <hannes@cmpxchg.org> (maintainer:PRESSURE STALL INFORMATION (PSI)) Suren Baghdasaryan <surenb@google.com> (maintainer:PRESSURE STALL INFORMATION (PSI)) Peter Ziljstra <peterz@infradead.org> (reviewer:PRESSURE STALL INFORMATION (PSI))
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,