From patchwork Wed Dec 15 10:49:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoyang Huang X-Patchwork-Id: 12678005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC06C433F5 for ; Wed, 15 Dec 2021 10:50:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 304E26B0071; Wed, 15 Dec 2021 05:50:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 28DBC6B0073; Wed, 15 Dec 2021 05:50:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12E9A6B0074; Wed, 15 Dec 2021 05:50:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay029.a.hostedemail.com [64.99.140.29]) by kanga.kvack.org (Postfix) with ESMTP id F0F886B0071 for ; Wed, 15 Dec 2021 05:50:27 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id B50FE80391 for ; Wed, 15 Dec 2021 10:50:17 +0000 (UTC) X-FDA: 78919709274.04.A348879 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) by imf14.hostedemail.com (Postfix) with ESMTP id 277D610001A for ; Wed, 15 Dec 2021 10:50:16 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id j11so19862767pgs.2 for ; Wed, 15 Dec 2021 02:50:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id; bh=ZzQS3th7hwfmksndYKtDaBuS9CE4JtvSUqsyMZ9SvIk=; b=GYXQPk+Q8aWzdFNuOVKQ0A2as5WNDhTB6X/2j+tdaLuVXu0/zB34dOKm3K4xhqnc7l ZaOL8b83bJ5SfVhDPmwSkvC7BDainnTfeF5DX56g1ekizcCEByEQsUliZmILOOMYGUuI HB7oA84dOUtidKOZeFUEcl1uqKNsyBrOQw0efD5LXiGAdwsAJ+KJQNGdO84L0ip2+8qD 3lie3K6dxSSYylqxSpu2P9qRzcWD6h4uyl9cFqMk6dY9IZ0+3VFKA6B/xwwZ7EW7qIjq Qagpvv3Vx9FuT9cFs2SEAJpO5JKxhy5OX/A+19gj5/dDJIgPoM95ZgMAm3EA+Qj2UkR+ 4tLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id; bh=ZzQS3th7hwfmksndYKtDaBuS9CE4JtvSUqsyMZ9SvIk=; b=zCAtQgaGOZNB2D5lYEo+AUIKKCDKv0YWw8NnOZzcA4zNlWCk/EGVysi/SlPoQnmiZ4 t17LmTwJi8jyj3SjfY+FQFeja0onGR1M2XIKjOA0umEBDp2JW66kQQat6gjLT+a3s4d2 U2X5wCZ0XtDXAlUS/F2/q652H7KfsUdfOLL5tKwf8XZHFZjKsfJhstP+eGFVQRq93viP tdmHqeGS0EeIgf9PGj4KbS6TQdTOvO2XCcAIZnaQD7VobTNXaf9wNKaaCyieebfLkAvg 0/OnFQTWZYtYCx8OdWpkp2mTFx+ey05QJyTKuQgaPJC9DtJNNHgYoOTvgRex5BWFl5gf Ehqw== X-Gm-Message-State: AOAM53291gUo6tAmVXQMnMMjqxTlygl+lFDWAMCBVScc6HmGR32lVeu3 Vye+SVWsrfr0JJiLXvhJ3pc= X-Google-Smtp-Source: ABdhPJz9CexpSzxo/fA2khIF/BuWyvBAWCGk8K/PrskteNMpuJWJNNHK8UU+CE5emAKMly2dZUbxVA== X-Received: by 2002:a63:cd49:: with SMTP id a9mr7430769pgj.607.1639565416237; Wed, 15 Dec 2021 02:50:16 -0800 (PST) Received: from bj03382pcu.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id y25sm2345050pfa.12.2021.12.15.02.50.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Dec 2021 02:50:15 -0800 (PST) From: Huangzhaoyang To: Johannes Weiner , Zhaoyang Huang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] psi: introduce rt property for trigger Date: Wed, 15 Dec 2021 18:49:59 +0800 Message-Id: <1639565399-15629-1-git-send-email-huangzhaoyang@gmail.com> X-Mailer: git-send-email 1.7.9.5 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=GYXQPk+Q; spf=pass (imf14.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.215.179 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Queue-Id: 277D610001A X-Stat-Signature: zwn655f4d3aahno13368cw6s5d9secdc X-Rspamd-Server: rspam04 X-HE-Tag: 1639565416-997614 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Zhaoyang Huang There are several pratical reasons to introduce such a rt flag to let the trigger wake up within the window, 1. WINDOW_MIN_US=500ms is too big for some scenarios where the trigger is expected to launch some behavious on the resource under pressure. 2. Window size works as both of average factor and wakeup timing value. However, user could expect seperate value on this two roles. eg, we expect to watch the pressure as 'SOME 100/1000ms' and got triggered whenever it reached. Signed-off-by: Zhaoyang Huang --- include/linux/psi_types.h | 3 +++ kernel/sched/psi.c | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index 0a23300..6c83c75 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -124,6 +124,9 @@ struct psi_trigger { /* Tracking window */ struct psi_window win; + /*real time trigger flag*/ + u32 rt; + /* * Time last event was generated. Used for rate-limiting * events to one per window diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 1652f2b..e1f08aa 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -145,6 +145,7 @@ #include #include "sched.h" +extern unsigned int sysctl_sched_latency; static int psi_bug __read_mostly; DEFINE_STATIC_KEY_FALSE(psi_disabled); @@ -458,9 +459,12 @@ static void psi_avgs_work(struct work_struct *work) static void window_reset(struct psi_window *win, u64 now, u64 value, u64 prev_growth) { + struct psi_trigger *t = container_of(win, struct psi_trigger, win); + win->start_time = now; win->start_value = value; win->prev_growth = prev_growth; + t->rt = t->rt ? 5 : 0; } /* @@ -542,6 +546,17 @@ static u64 update_triggers(struct psi_group *group, u64 now) if (growth < t->threshold) continue; + /* wakeup if trigger has rt and at least 5 sched_latency surpassed*/ + if (t->rt && growth >= t->threshold) { + u64 rt_trigger_time = min(t->last_event_time + t->win.size, + sysctl_sched_latency * t->rt + t->last_event_time); + if (now < rt_trigger_time) + continue; + if (cmpxchg(&t->event, 0, 1) == 0) + wake_up_interruptible(&t->event_wait); + t->rt += 5; + } + /* Limit event signaling to once per window */ if (now < t->last_event_time + t->win.size) continue; @@ -1116,13 +1131,14 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, enum psi_states state; u32 threshold_us; u32 window_us; + u32 rt = 0; if (static_branch_likely(&psi_disabled)) return ERR_PTR(-EOPNOTSUPP); - if (sscanf(buf, "some %u %u", &threshold_us, &window_us) == 2) + if (sscanf(buf, "some %u %u %u", &threshold_us, &window_us, &rt) >= 2) state = PSI_IO_SOME + res * 2; - else if (sscanf(buf, "full %u %u", &threshold_us, &window_us) == 2) + else if (sscanf(buf, "full %u %u %u", &threshold_us, &window_us, &rt) >= 2) state = PSI_IO_FULL + res * 2; else return ERR_PTR(-EINVAL); @@ -1152,6 +1168,7 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, t->last_event_time = 0; init_waitqueue_head(&t->event_wait); kref_init(&t->refcount); + t->rt = rt ? 5 : 0; mutex_lock(&group->trigger_lock);