From patchwork Thu Mar 30 10:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Cerasuolo X-Patchwork-Id: 77108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1051495vqo; Thu, 30 Mar 2023 04:24:53 -0700 (PDT) X-Google-Smtp-Source: AKy350aNmtKlSK5pebhid5YxuayDJzmoP2yYuTdSWNk6s1JLzxdP7vr7iP4bAVHAjHTwM1/ZpP1P X-Received: by 2002:a17:907:6ea8:b0:930:a3a1:bede with SMTP id sh40-20020a1709076ea800b00930a3a1bedemr30783319ejc.50.1680175493289; Thu, 30 Mar 2023 04:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680175493; cv=none; d=google.com; s=arc-20160816; b=gqavBGDXd5/fZWgyKWj+BjYC0pYR/bzkUETefoAAm0vF9PqM/9SIRyZI7WGYlgxF/N oFYq95rklxSj4r9OHz9qba08KJn43qH90EcqkMsKlZtYq90dTPNs5e+a+UA+kW0ElYqa CMyGDW6ppsDK1ke3nwTCbR7FJcI+GPXOm4sqzXl6DabYzhEXD+3aJ63y7639gsv2Q2wf UpCpTpx9C71QYw1ZcqZi5m26OaOekxhZdyN5DDY+BE6gnfLPvaily7d0MD0W8EHDYmR4 GuDyjnT8oo9U6vSg4r8eL4TzogM9F6HafX+oZc4HqzFd50V++W0FWF2PiRn+fO2FiXrG Imxg== 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=DabLmlPAR6m4lEHiIymX5mk05czL45ywvl8igfY/SAFmrkTice7nRj3JdJO94JKZQ+ vLc6aaOQYys72W/tkUu5fmK4cLrMQrZPZt7PMwjfvlTXz0BXHUjmUEZNzNZUq5c4eYfR TP/5P81/nyFD4IApkoXn7ho+sWtuCoAw1qCTQS/z5SlFdyCBZo8eTcM8pkhEkgmmpM4o ZsxOLPqrrhirNibZekPE2KABuJB38PFBH10PMD0bt0WJV2R/E/olMnc/5kAfLtGy1N2/ vmbRSkTnpUzCdBE5ldBASQVitvUN/KhrvqFH+MmuOFGj/RAWs6Sc1GuiGRgnS2xtWhpE OJ6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SAhdUE8R; 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 qw40-20020a1709066a2800b009333dc257b0si36660592ejc.350.2023.03.30.04.24.28; Thu, 30 Mar 2023 04:24:53 -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=SAhdUE8R; 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 S231213AbjC3KzN (ORCPT + 99 others); Thu, 30 Mar 2023 06:55:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbjC3Kyj (ORCPT ); Thu, 30 Mar 2023 06:54:39 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7307A9B for ; Thu, 30 Mar 2023 03:54:37 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id h8so74754601ede.8 for ; Thu, 30 Mar 2023 03:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680173676; 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=SAhdUE8RtpQp3xboOBAvlJrDteDAvPjfKGtWDLGIdmtp9P7WRiag+VrAVmfymEHsE/ o8E2OYYoSRb98hpU90/eNIl+MtzGq+fqSzOXEjNMx/LI2BCxISMoyd0bcD5HFsx2PjSj hhFc5Gfmm0gnuyBIBnhfyXkK1IRFjdcLMnIN9LHeucdUqINXnB9CTi6AON1QzPWwlVfY 071VqgphGsCt6FvotWE751IidWNnh0Wglb2BOI8ivJ/gYA9FNtXvW1J8/ExgDCO3f580 OzctikEjP0ldMyjBWHzCcrMtSzJTHL0hrAoVokxBLjUSBjaJpAuSNCyMjJ0wlLuzVZFG X9SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680173676; 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=xYFnnTCegyTZh9es6Nuc1w+x2Oftn2o2O3xpnkOsHVTqTZYLp2uMT8rVYeA0aJdjbJ NFxIaPpDg4qVbdnkQdrZBoAY8q3FCX6PylTA5EPRW1EZRpc0YEJ+rZBe8ns8i7edh/5m INXfyXPuVWbQO0W+VY7BvbIGt9rmUylWiV5CW3aOq+06Pq9daBA9EQJWaxWnaRYkXPQI uSSx7MT36FwAw/Aj4MUCVGd1BiMRSR1ovuiIEgKLoqGoVeazN6g9fa+fxruI/xhrqFi8 Me9L7T4ocw9Vn/Q9+bW+bLvJ8LdE0KD0wasNTrX/FjSLLJHhPnHM5fbtGATBqZy7mVSv uG6w== X-Gm-Message-State: AAQBX9don+pmXbWUABy/lhXfn4puV2rmQyGc3AvjuPhLMD2MGSd9e7ko 8oJGeQyy82h7HIAdLygSnnrBvemwNpFaoA== X-Received: by 2002:a17:906:1cda:b0:920:3263:d643 with SMTP id i26-20020a1709061cda00b009203263d643mr20687377ejh.72.1680173676021; Thu, 30 Mar 2023 03:54:36 -0700 (PDT) Received: from lelloman-5950.. (host-80-182-134-1.pool80182.interbusiness.it. [80.182.134.1]) by smtp.gmail.com with ESMTPSA id hb6-20020a170906b88600b0093120a11a5dsm17639628ejb.92.2023.03.30.03.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 03:54:35 -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 v6 3/4] sched/psi: extract update_triggers side effect Date: Thu, 30 Mar 2023 12:54:17 +0200 Message-Id: <20230330105418.77061-4-cerasuolodomenico@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230330105418.77061-1-cerasuolodomenico@gmail.com> References: <20230330105418.77061-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?1761791698239357045?= X-GMAIL-MSGID: =?utf-8?q?1761791698239357045?= 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 Acked-by: Suren Baghdasaryan --- 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,