From patchwork Thu Mar 30 20:06:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Cerasuolo X-Patchwork-Id: 77409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp128461vqo; Thu, 30 Mar 2023 13:59:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ZmXeljpMHkzVIyfL5FEu80Bz6jX/rLSgL0+aa8uQ8Lr9hQ5Ao1an58TAH819GxkEO8f8HD X-Received: by 2002:a17:902:d2c7:b0:19d:1834:92b9 with SMTP id n7-20020a170902d2c700b0019d183492b9mr34488297plc.56.1680209946948; Thu, 30 Mar 2023 13:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680209946; cv=none; d=google.com; s=arc-20160816; b=MWaIf7I1++jyQKKuuqrz9S6ln3+JLj/JLkZ2UwcGopuNMfYgUlWI5dF75ytpVzWf8Y ywgnTQH+znXlwuq9I9q9RKcp5mq8fyzRL0ru9YkumEAe3Nn5FkrqLnVruChBEKdtqry6 qmkTEsEo7LXqsFZe0Eh2k3BrWg/684hhuQgqF1R83kQKBlRBHQKmL7rBlqMPF8g99K+A a7JW9Frslj9UnxM/2b5a2lg2RAJINQqw6yafS1/gQLbhBaZWmY8QWrQjRyyUSxAB/gzB 5q9N+FgJkoVIyXPd/B4/nuLrsAP9VJ/EJBVJCx98O31GuOWVPx4H7MfTcZ/zPUqh7Wgp 9l/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p1vTstqwimUvhUc8A7ZyPgFdk3wEGUrShLMTBVm4/iM=; b=D18BR86OalL8uKc2lSBpR62KHrzBsM72Q4yqXwRPd/Tq2FgSpJWvDjxqy8mKG6u/te 4oPeb9pyOyAI+0+OKqHmBZ05bBAdjwcUQ5j9fz0qJHCUFmgwalUwif0ekxcYB6Dc03B8 /0RP7wIm/OmksGPps8c0C7wUgv5k8XrV9EtyEudCzrO9gKFPurBukdBPC0tzuRSDeLqY ds7XHK4BmBMUV+hkKypnARPKYOt0Ha1H9xVzpHv4fJ07pUu0u88sTqAlygVySbWonRgY dXu0RylweZxs5c1O3I+nXWgxfUxY6pbqQ+jMbzjFPVsiKHpttcslp9165ghpR7HxRqhm 4X0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QIwwRr3l; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w23-20020a1709027b9700b001a067e3b1edsi324776pll.592.2023.03.30.13.58.54; Thu, 30 Mar 2023 13:59:06 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QIwwRr3l; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbjC3UGv (ORCPT + 99 others); Thu, 30 Mar 2023 16:06:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjC3UGm (ORCPT ); Thu, 30 Mar 2023 16:06:42 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D388310429 for ; Thu, 30 Mar 2023 13:06:26 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id ew6so81125913edb.7 for ; Thu, 30 Mar 2023 13:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680206785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p1vTstqwimUvhUc8A7ZyPgFdk3wEGUrShLMTBVm4/iM=; b=QIwwRr3lPxhfPEaXuJDlemsrxwiiDdu0W6jvdcUwhEvIbIwRjQeGlItXcaCFLC1KhX SVvvPsxUo3gAICj2U+YhzScry6w9RjDHUgm2MLwKqGXmYkvIBwX1hUfD5eq/UlTeoY9X 9j3/G14YOKZNLbMtyJNPDUkMxKs9FL48B8WlpFJGkuMWxd6neNJ8y7hpFVVEzFwKAb0K rQzKrtANkzlB8gMcS3PitHgTh8pMwnP/aOwVXvgjdlbrYKSK08Qv/t2iv3wjdKL32p/H yB/CaOO08C2kS4zpf6O2UvCtkFye+tvvK9F2uXe6xK09rY/SbZp6P1mRW6QZx0hyjTkY j5Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680206785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p1vTstqwimUvhUc8A7ZyPgFdk3wEGUrShLMTBVm4/iM=; b=m5m+pWFJHvX3gfefl7tu1sjvyLczcCjIzR+4VvdpMc0Wdldssm728BsET9jAKSb4yr +4on0OsVyndMEUjqZhc00T1K1XHv4E5YcVBP+1W0bFrxPzUarTFOepuQR5tq9vJMAbK/ UhDyaxcpuIeWLAQtWMxm7rXgjVpr2DZ537r2yBowt6FD/fFLJmEeDztV7T0erGanGTL/ VpWyxHIFUb6Hk6yfvo4lUVVJaHcklL9WWiI/+M0he/T3/j4k88rEIqLnoOK/EcNFzTkU yqJ7/6VrKwTaHgUu5Fhqr2SXI8XFEzK6VziyMQTHiBeFaFg0VIi10k+Mvup4qWPuvr8n G92A== X-Gm-Message-State: AAQBX9c2Z9fhBBWHaD7a2wK7m5+nKZTwbBMLqURkv638ASXotP68F9uG S6Py+kzFENTUOQ3iRvGsJhQF2fCj1Fldzw== X-Received: by 2002:a17:906:d1cf:b0:8b1:7aaa:4c25 with SMTP id bs15-20020a170906d1cf00b008b17aaa4c25mr26620215ejb.29.1680206784945; Thu, 30 Mar 2023 13:06:24 -0700 (PDT) Received: from lelloman-5950.. (host-80-182-134-1.retail.telecomitalia.it. [80.182.134.1]) by smtp.gmail.com with ESMTPSA id g17-20020a1709064e5100b009312cc428e4sm161101ejw.165.2023.03.30.13.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 13:06:24 -0700 (PDT) From: Domenico Cerasuolo To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, surenb@google.com, brauner@kernel.org, chris@chrisdown.name, hannes@cmpxchg.org, Domenico Cerasuolo Subject: [PATCH v7 3/4] sched/psi: extract update_triggers side effect Date: Thu, 30 Mar 2023 22:06:13 +0200 Message-Id: <20230330200614.132354-4-cerasuolodomenico@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330200614.132354-1-cerasuolodomenico@gmail.com> References: <20230330200614.132354-1-cerasuolodomenico@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761827825266658928?= X-GMAIL-MSGID: =?utf-8?q?1761827825266658928?= This change moves update_total flag out of update_triggers function, currently called only in psi_poll_work. In the next patch, update_triggers will be called also in psi_avgs_work, but the total update information is specific to psi_poll_work. Returning update_total value to the caller let us avoid differentiating the implementation of update_triggers for different aggregators. Suggested-by: Johannes Weiner Signed-off-by: Domenico Cerasuolo Acked-by: Johannes Weiner --- kernel/sched/psi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index a3d0b5cf797a..f3df6a8ff493 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -430,11 +430,11 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) return growth; } -static u64 update_triggers(struct psi_group *group, u64 now) +static u64 update_triggers(struct psi_group *group, u64 now, bool *update_total) { struct psi_trigger *t; - bool update_total = false; u64 *total = group->total[PSI_POLL]; + *update_total = false; /* * On subsequent updates, calculate growth deltas and let @@ -462,7 +462,7 @@ static u64 update_triggers(struct psi_group *group, u64 now) * been through all of them. Also remember to extend the * polling time if we see new stall activity. */ - update_total = true; + *update_total = true; /* Calculate growth since last update */ growth = window_update(&t->win, now, total[t->state]); @@ -485,10 +485,6 @@ static u64 update_triggers(struct psi_group *group, u64 now) t->pending_event = false; } - if (update_total) - memcpy(group->rtpoll_total, total, - sizeof(group->rtpoll_total)); - return now + group->rtpoll_min_period; } @@ -622,6 +618,7 @@ static void psi_rtpoll_work(struct psi_group *group) { bool force_reschedule = false; u32 changed_states; + bool update_total; u64 now; mutex_lock(&group->rtpoll_trigger_lock); @@ -686,8 +683,12 @@ static void psi_rtpoll_work(struct psi_group *group) goto out; } - if (now >= group->rtpoll_next_update) - group->rtpoll_next_update = update_triggers(group, now); + if (now >= group->rtpoll_next_update) { + group->rtpoll_next_update = update_triggers(group, now, &update_total); + if (update_total) + memcpy(group->rtpoll_total, group->total[PSI_POLL], + sizeof(group->rtpoll_total)); + } psi_schedule_rtpoll_work(group, nsecs_to_jiffies(group->rtpoll_next_update - now) + 1,