[linux-next] sched/psi: avoid unnecessary resetting min update period when destroy trigger
Message ID | 202304171611545861530@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1961242vqo; Mon, 17 Apr 2023 01:21:38 -0700 (PDT) X-Google-Smtp-Source: AKy350abuOK1bs5sJpqwdVeY1hG9QDcVLPbsieVfcTc7neFJStEC+HdEBo55hkpHJ/lm+EXg7NCg X-Received: by 2002:a05:6a00:b4f:b0:63b:5f78:d6db with SMTP id p15-20020a056a000b4f00b0063b5f78d6dbmr18692878pfo.21.1681719697804; Mon, 17 Apr 2023 01:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719697; cv=none; d=google.com; s=arc-20160816; b=k4Ud6ZzfkvRiM7t0DVlZ3Y4EpqyKbBvyjHOxCOMbtta+FQtGeiBdl7VjhPprW2EPAu RZiT7EE1uycGktcf0TxWJnAwZbm9OwZvqHERb67xcLfwOJgLjE/Ihx2nD17fGUf7qKKW iJixWWPKAz3ZpzHURjsycuBZPSoi8hYr8RHkWsSUhckCZMIn0PbvFeg1Yw/+hkLjlqQe aytvCTXzTLSS3EP1S/5xCzZRGvLYThERNtZ1QyTqGTPqQj2hFp/QIbeD6NmvCrSdRTYW wVkhgRfS/lT4CTch/RZBcHHpGr8OnOZUNN9v5QhfVvGAXI++CBkFiqxpDdhewWR21gmF xBzw== 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:message-id:date; bh=KazbJfYixT4si0awy+dqi8MEZ72swZN/yv4+BQpJJKo=; b=pF2/PNS3T1gkVdinqV8yh72n5xk7XhgtY2ORYgB0lSCjR19KQG8Y7qRaQ4kzSCfZ1/ 8xlSKZB+BWqLwW2cZvBbVbsyIfQJiShkChgH4f/ABRh7T70IP5MIhPLUI6ZabRkajEBm qe1Og8AO5E61OjAAtE1sgYXYdCVBz27lVHmSktkeX2H1SYdpc90ryzOWR9eIYLODsoer v4989rd3Q9xlrG3tEqqDOnOBWHLrIuAnaE/HQ/3+51OaY6NsR4otjAfcRkhCocPg20tm dDSxKsWZu2J9RhMHyWcQEDgIsYsCGLY57pwpjkHhiG+XIA6btMsDQRCwNx2mQnDvqvTc AuIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d69-20020a621d48000000b00639b0f72b5esi11358972pfd.55.2023.04.17.01.21.23; Mon, 17 Apr 2023 01:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbjDQIMt (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 04:12:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjDQIMp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 04:12:45 -0400 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737CA558A for <linux-kernel@vger.kernel.org>; Mon, 17 Apr 2023 01:12:06 -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 mxct.zte.com.cn (FangMail) with ESMTPS id 4Q0KXF6Rhtz4xq1X; Mon, 17 Apr 2023 16:11:57 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl2.zte.com.cn with SMTP id 33H8BqU3072551; Mon, 17 Apr 2023 16:11:52 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 17 Apr 2023 16:11:54 +0800 (CST) Date: Mon, 17 Apr 2023 16:11:54 +0800 (CST) X-Zmail-TransId: 2b03643cff4afffffffff01-c5680 X-Mailer: Zmail v1.0 Message-ID: <202304171611545861530@zte.com.cn> Mime-Version: 1.0 From: <yang.yang29@zte.com.cn> To: <hannes@cmpxchg.org>, <surenb@google.com> Cc: <mingo@redhat.com>, <linux-kernel@vger.kernel.org>, <juri.lelli@redhat.com> Subject: =?utf-8?q?=5BPATCH_linux-next=5D=C2=A0sched/psi=3A_avoid=C2=A0unnec?= =?utf-8?q?essary_resetting_min_update_period_when=C2=A0destroy=C2=A0trigger?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 33H8BqU3072551 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 643CFF4D.000/4Q0KXF6Rhtz4xq1X X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763410913794879796?= X-GMAIL-MSGID: =?utf-8?q?1763410913794879796?= |
Series |
[linux-next] sched/psi: avoid unnecessary resetting min update period when destroy trigger
|
|
Commit Message
Yang Yang
April 17, 2023, 8:11 a.m. UTC
From: Yang Yang <yang.yang19@zte.com.cn> Psi_group's poll_min_period is determined by the min window size of psi_trigger when creating new triggers. While destroying a psi_trigger, there is no need to reset poll_min_period if the destroying psi_trigger not had the min windows size, since in this condition poll_min_period will keep the same as before. Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> --- kernel/sched/psi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
Comments
On Mon, Apr 17, 2023 at 1:12 AM <yang.yang29@zte.com.cn> wrote: > > From: Yang Yang <yang.yang19@zte.com.cn> > > Psi_group's poll_min_period is determined by the min window size of > psi_trigger when creating new triggers. While destroying a psi_trigger, > there is no need to reset poll_min_period if the destroying psi_trigger > not had the min windows size, since in this condition poll_min_period > will keep the same as before. Nice optimization. > > Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> Acked-by: Suren Baghdasaryan <surenb@google.com> > --- > kernel/sched/psi.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c > index 02e011cabe91..12869585cf89 100644 > --- a/kernel/sched/psi.c > +++ b/kernel/sched/psi.c > @@ -1359,11 +1359,16 @@ void psi_trigger_destroy(struct psi_trigger *t) > group->nr_triggers[t->state]--; > if (!group->nr_triggers[t->state]) > group->poll_states &= ~(1 << t->state); > - /* reset min update period for the remaining triggers */ > - list_for_each_entry(tmp, &group->triggers, node) > - period = min(period, div_u64(tmp->win.size, > - UPDATES_PER_WINDOW)); > - group->poll_min_period = period; > + /* > + * Reset min update period for the remaining triggers iff the destroying > + * trigger had the min window size. > + */ > + if (group->poll_min_period == div_u64(t->win.size, UPDATES_PER_WINDOW)) { > + list_for_each_entry(tmp, &group->triggers, node) > + period = min(period, div_u64(tmp->win.size, > + UPDATES_PER_WINDOW)); > + group->poll_min_period = period; > + } > /* Destroy poll_task when the last trigger is destroyed */ > if (group->poll_states == 0) { > group->polling_until = 0; > -- > 2.25.1
>On Mon, Apr 17, 2023 at 1:12 AM <yang.yang29@zte.com.cn> wrote: >> >> From: Yang Yang <yang.yang19@zte.com.cn> >> >> Psi_group's poll_min_period is determined by the min window size of >> psi_trigger when creating new triggers. While destroying a psi_trigger, >> there is no need to reset poll_min_period if the destroying psi_trigger >> not had the min windows size, since in this condition poll_min_period >> will keep the same as before. > > Nice optimization. > >> Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > Acked-by: Suren Baghdasaryan <surenb@google.com> Hi, would you please take a review? Thanks!
>On Mon, Apr 17, 2023 at 1:12 AM <yang.yang29@zte.com.cn> wrote: >> >> From: Yang Yang <yang.yang19@zte.com.cn> >> >> Psi_group's poll_min_period is determined by the min window size of >> psi_trigger when creating new triggers. While destroying a psi_trigger, >> there is no need to reset poll_min_period if the destroying psi_trigger >> not had the min windows size, since in this condition poll_min_period >> will keep the same as before. > > Nice optimization. > >> Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > Acked-by: Suren Baghdasaryan <surenb@google.com> Hi, would you please take a review? Thanks!
> On Mon, Apr 17, 2023 at 1:12 AM <yang.yang29@zte.com.cn> wrote: >> >> From: Yang Yang <yang.yang19@zte.com.cn> >> >> Psi_group's poll_min_period is determined by the min window size of >> psi_trigger when creating new triggers. While destroying a psi_trigger, >> there is no need to reset poll_min_period if the destroying psi_trigger >> not had the min windows size, since in this condition poll_min_period >> will keep the same as before. > > Nice optimization. > >> >> Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > > Acked-by: Suren Baghdasaryan <surenb@google.com> Hi, would you please take a review? Thanks!
On Tue, Apr 25, 2023 at 8:32 PM Yang Yang <yang.yang29@zte.com.cn> wrote: > > > On Mon, Apr 17, 2023 at 1:12 AM <yang.yang29@zte.com.cn> wrote: > >> > >> From: Yang Yang <yang.yang19@zte.com.cn> > >> > >> Psi_group's poll_min_period is determined by the min window size of > >> psi_trigger when creating new triggers. While destroying a psi_trigger, > >> there is no need to reset poll_min_period if the destroying psi_trigger > >> not had the min windows size, since in this condition poll_min_period > >> will keep the same as before. > > > > Nice optimization. > > > >> > >> Signed-off-by: Yang Yang <yang.yang29@zte.com.cn> > > > > Acked-by: Suren Baghdasaryan <surenb@google.com> > > Hi, would you please take a review? I guess this is a ping for PeterZ to queue this patch in his tree. Peter, any issues with accepting this patch? > Thanks!
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 02e011cabe91..12869585cf89 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -1359,11 +1359,16 @@ void psi_trigger_destroy(struct psi_trigger *t) group->nr_triggers[t->state]--; if (!group->nr_triggers[t->state]) group->poll_states &= ~(1 << t->state); - /* reset min update period for the remaining triggers */ - list_for_each_entry(tmp, &group->triggers, node) - period = min(period, div_u64(tmp->win.size, - UPDATES_PER_WINDOW)); - group->poll_min_period = period; + /* + * Reset min update period for the remaining triggers iff the destroying + * trigger had the min window size. + */ + if (group->poll_min_period == div_u64(t->win.size, UPDATES_PER_WINDOW)) { + list_for_each_entry(tmp, &group->triggers, node) + period = min(period, div_u64(tmp->win.size, + UPDATES_PER_WINDOW)); + group->poll_min_period = period; + } /* Destroy poll_task when the last trigger is destroyed */ if (group->poll_states == 0) { group->polling_until = 0;