From patchwork Mon Feb 26 19:46:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Levi Yun X-Patchwork-Id: 206900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2297072dyb; Mon, 26 Feb 2024 11:47:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVg+YhPc6f5m0UvqTOeQCnDUHK2KUsXD8QRL53pzhRlhO7FhkSedCcRTnR0+E4v6caycfzUixKYtloRYLI5SB7Cj0JQ8Q== X-Google-Smtp-Source: AGHT+IHqxrgQc3NpeSSnHpNMwp04tItgNrOdFoQ0LeoymF0QWKOVh9APaL7yvuptjzN543vNwuSh X-Received: by 2002:a05:6808:1b24:b0:3c1:a376:cdee with SMTP id bx36-20020a0568081b2400b003c1a376cdeemr223775oib.0.1708976825997; Mon, 26 Feb 2024 11:47:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708976825; cv=pass; d=google.com; s=arc-20160816; b=ATkCv/GIZ+IPqFWBfEI4ZAF+A/F3PsQFSJWR0Z3MKcDbyVZE66Z9nhrx2HEMMFhpB1 +lwARWfAR55mcttN0UgHucYhR9HuLynLcnMkTL3XxDzZK9p5pk8E2ybI0kdurAHdPcnW aOOqe+on9ZQKgqUrotb5AXQrsF4X3ko+4sbaiA61AlIzNma3zD4B3DpFz/MrwHNMJR4T htLY9V/rzxn/DP4SHrzDlhreqOg/vxQxVMW7mRRTbDuSTVC6HjUHoWO15irFzvO7Gx5O 75zAu10i4C9mP62eM3n+w0BktQUahHyEcQlX1FJ490GfrDqLUrMzht8pOeVPdmychE4e vylQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Ek2V91xP+64JAHW/SkXga3bXiJC6Qhuuv1X5zy2fbQc=; fh=KRxQ74lBjI6rXy1IqfQR654Eet6NH9msJ1QOOr4kDXc=; b=FD+vqWUybueeOqWtJKGG4QPyyKcUFXo284xF5sQrL7l1IOSLF4/MO76k1d+HlgEFEF hxvWwZMJilKyaa3yFXs8P8ftdcp8mQ+t2nqQV65eRhowIKBp7b4/bU93C7358uwaua05 LtRu7nkPw0Q3KPTym6RZ9fbWxFFbVWRAraj8HWomvY1b43aF/NQlJYdsGwnLq0LbFEDY X9EPYGToZ9bNPV7qpdpidfINZ7eOku+cTVHvV8tneWTMokpwMJsOhMWboHdI9NPDSJQY tLQnBmqsR1Lg0UuNPG3QbMiKOG47CLEtomqOzjlv5pMbxKmgzhti68DOc2oZWJ50WE7U eL0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hqqrgstT; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gv6-20020a056214262600b0068f1387c655si5769449qvb.187.2024.02.26.11.47.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:47:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hqqrgstT; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82266-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82266-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B61EE1C20DFD for ; Mon, 26 Feb 2024 19:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64A1E130AE8; Mon, 26 Feb 2024 19:46:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hqqrgstT" Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2927A60BA1 for ; Mon, 26 Feb 2024 19:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708976812; cv=none; b=A+qIYwSoCk8LE0i45PXLiqyWpvErvWaIAst6WbAz1J33kLt9eJoY5o/z6PbvHsh//2vIEBMULH6/HU1374ascAXv00KhDke/FfqbDPEgHzOSgug+jh7nQtn7jwPYDzIuFHcArfRsdW4I+T5QIakGTjlp7hY86e0Vys/3/e0oPn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708976812; c=relaxed/simple; bh=yMSkd40jQ58IsjTFcyz6Y0aROzLE9aRQL+3vxznmzos=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BGIXPk086pQ4Y3BYa6bmNl5jhgwksqugvXsI1uVlwDrwdV+wEdI6s4zAOjZggASbWQYhvoIDYA1BObK9xQ0ew80T4XkyBa3rHZvqoFTnD/1bzR+ylA6FNo6ldRT4jz8lN7YNs5gsEtibcP8nwal/mh3h6GFkWr2EG03HK0OKBgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hqqrgstT; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d208be133bso54655101fa.2 for ; Mon, 26 Feb 2024 11:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708976809; x=1709581609; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ek2V91xP+64JAHW/SkXga3bXiJC6Qhuuv1X5zy2fbQc=; b=hqqrgstTWoiW4MH3bmBsIW/jABm5EFevS0hi1CtJQzNkbmdx0V54XiYUjEm+n0AhiS JhtSKtDFZ/I2tkCxhcNbf2lUPg1y0K0eh4Ys6h84wkyWdd3XG8f8SZhGn4D99Y7VfC6S u9GIy8zgjzsgK71TtWewyW4E4SbW36qkMjWpe4+olnFprjLzTNgsmTe6vJQjbfft42m5 9BhhKbiIVzUgzgNgIaxJrttomrUmFQj6y0SO9TItvCzsaujgM6krm3GrKxnEq1PHaM9X xZSmFLPjrhjYaQ+BoNXQ0xh10tspFZWOWBy1Tq7wn+AYm6VoS1t/BMC0Qb6rm9l4+hPE l6Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708976809; x=1709581609; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ek2V91xP+64JAHW/SkXga3bXiJC6Qhuuv1X5zy2fbQc=; b=JwZ95eqNq1/D+BQ+crdaYsQgGmk2KmCgVDYdyXlmuNh9jU/SdKhjspC3YLll7YQgrG +1hbgWYmg3CbuSHlXFNqXNt47pvpeaODrWqq6TsR9jFgI409uKUbSP+lxJ9I4hXViDyY taRP6rXDs7c0YJ4SXo3vEEfPFck2mpmr/uojtRXDzBni/vrKs859DSUE73LDMEMJwpAm YA4WSfVK3gvdJglIpG2HiSN6ZvaxCNN3LlTCwgQBabAE8zRuqqZIhuBO+HLap/B7Lpos h5WkE5gMXW++gRq/xiabmE2zM2tSl4niJVWi5GQ/B4fOVu9tlUjgynvZriJhFoq7hTZD t6bA== X-Gm-Message-State: AOJu0YylR3i+JvsYhlWwZMA2r5yacrSJw6kTEW9o8uiIXfqPCf1vsQ9w F3XITwhxh6Qu2lbQqccy3M6wLNti82plL4apJPqX8JoOpOERPYFk X-Received: by 2002:a2e:80d3:0:b0:2d2:8c9a:c4e5 with SMTP id r19-20020a2e80d3000000b002d28c9ac4e5mr2272204ljg.18.1708976808940; Mon, 26 Feb 2024 11:46:48 -0800 (PST) Received: from localhost.localdomain (host86-133-224-40.range86-133.btcentralplus.com. [86.133.224.40]) by smtp.gmail.com with ESMTPSA id x1-20020a05600c2a4100b0041292306f2csm12728453wme.16.2024.02.26.11.46.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 26 Feb 2024 11:46:48 -0800 (PST) From: Levi Yun To: hannes@cmpxchg.org, surenb@google.com, peterz@infradead.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, Levi Yun Subject: [PATCH] psi: Fix avg trigger being fired unexpectedly. Date: Mon, 26 Feb 2024 19:46:42 +0000 Message-ID: <20240226194642.47530-1-ppbuk5246@gmail.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791992084213003660 X-GMAIL-MSGID: 1791992084213003660 commit 915a087e4c473("psi: Fix trigger being fired unexpectedly at initial") fixes unexpected event fired when group->total accumlated for PSI_POLL. But, for PSI_AVGS, win->value should be initialized with group->total[PSI_AVGS]. Moreover, to get exact initial value for win->value, it should be set under each trigger lock to synchronize each rtpoll/avgs_works. Signed-off-by: Levi Yun Acked-by: Suren Baghdasaryan --- kernel/sched/psi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.39.2 diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 7b4aa5809c0f..e7f66ab2ad3e 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -1323,9 +1323,6 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, t->state = state; t->threshold = threshold_us * NSEC_PER_USEC; t->win.size = window_us * NSEC_PER_USEC; - window_reset(&t->win, sched_clock(), - group->total[PSI_POLL][t->state], 0); - t->event = 0; t->last_event_time = 0; t->of = of; @@ -1336,6 +1333,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, if (privileged) { mutex_lock(&group->rtpoll_trigger_lock); + window_reset(&t->win, sched_clock(), + group->total[PSI_POLL][t->state], 0); if (!rcu_access_pointer(group->rtpoll_task)) { struct task_struct *task; @@ -1361,6 +1360,9 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, } else { mutex_lock(&group->avgs_lock); + window_reset(&t->win, sched_clock(), + group->total[PSI_AVGS][t->state], 0); + list_add(&t->node, &group->avg_triggers); group->avg_nr_triggers[t->state]++;