Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3309853iob; Mon, 16 May 2022 18:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz444Ka2Z7UQinRrlPq1/y4q7W3Qf9OBourDR+U0Wa5NafqdpCqkmdtsa1MWq+okrChyoo X-Received: by 2002:a63:6886:0:b0:3c5:11f4:f055 with SMTP id d128-20020a636886000000b003c511f4f055mr17766955pgc.44.1652752717655; Mon, 16 May 2022 18:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652752717; cv=none; d=google.com; s=arc-20160816; b=IDtifWNFtd7TuVF4cRXSSbPx2ZPMNQzY6jrE8DR//L70CqWnHBQAywmeV/PJUmf+zf 3n9fw//cGH7lMvtEerfN6hievZ1PZp4wVhSAZ84uU126jPw5XDqqnkjesCSJSerJWm3z MqbNMo4UdXs6jlDgNuJNn0mHXRr1KrQ1WcKmC/eFBpMHB6I1GT1PLyGnXPjTuCKJOTDz czVc4yf+6iy000P7Yu8ibWRC/bJWxxkX6LcyUxhqLEUTp1MD2O7iOcLOd22k6su8JZiA 7ye38NZZuhob+WijYZDEl5NSBDJS0VdMjCN9O7ew9Mdfe100JFUKyg9MavanPDPu7jrK w1Hw== 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 :message-id:date:subject:to:from; bh=R6X7La7bWmVfSEuTYTcQRQ3nZ3ZJyVyfWgmyl6y9ucw=; b=BDd1AL/JA7/P4nGgDkWtWNn9iq7rYZTZdV/pvmTuptYEps991EI/7c1lq9jRhMhtRh iTwcge+y39xpaljmAFtMiETbPqITqaprfemS1yMR+pbVDbyNN+7pM42jFrAGUONbZuN2 GZiwCmooOnRb2pHMHXE5M/gtbChVU8a+kI3To0YvfnVCTcGt89WY1UpkRdwmc05JCWJ5 JoGPID+rrhmZKdsCJlFSvXJrfXhDFZLmM9kSwXRxlBc3aEBtNYzcO/RVjmQ63TPdlIYL XL/eEWirG5E0cWOzFkrl2MbAuMiLdHBCoE6btDKEdDsF6bcHAWm9ItY829wP53rivKcx Td9w== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pw16-20020a17090b279000b001df7dd9ea32si215657pjb.157.2022.05.16.18.58.26; Mon, 16 May 2022 18:58: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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239604AbiEPDRM (ORCPT + 99 others); Sun, 15 May 2022 23:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238156AbiEPDRI (ORCPT ); Sun, 15 May 2022 23:17:08 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DDF111C18; Sun, 15 May 2022 20:17:07 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L1ksZ6DQlzgYHC; Mon, 16 May 2022 11:15:46 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 11:17:05 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 11:17:05 +0800 From: Chen Wandun To: , , , , , Subject: [PATCH 1/2] psi: add support for multi level pressure stall trigger Date: Mon, 16 May 2022 11:35:23 +0800 Message-ID: <20220516033524.3130816-1-chenwandun@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Nowadays, psi events are triggered when stall time exceed stall threshold, but no any different between these events. Actually, events can be divide into multi level, each level represent a different stall pressure, that is help to identify pressure information more accurately. echo "some 150000 350000 1000000" > /proc/pressure/memory would add [150ms, 350ms) threshold for partial memory stall measured within 1sec time window. Signed-off-by: Chen Wandun --- include/linux/psi_types.h | 3 ++- kernel/sched/psi.c | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index c7fe7c089718..2b1393c8bf90 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -119,7 +119,8 @@ struct psi_trigger { enum psi_states state; /* User-spacified threshold in ns */ - u64 threshold; + u64 min_threshold; + u64 max_threshold; /* List node inside triggers list */ struct list_head node; diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 6f9533c95b0a..17dd233b533a 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -541,7 +541,7 @@ static u64 update_triggers(struct psi_group *group, u64 now) /* Calculate growth since last update */ growth = window_update(&t->win, now, total[t->state]); - if (growth < t->threshold) + if (growth < t->min_threshold || growth >= t->max_threshold) continue; t->pending_event = true; @@ -1087,15 +1087,18 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, { struct psi_trigger *t; enum psi_states state; - u32 threshold_us; + u32 min_threshold_us; + u32 max_threshold_us; u32 window_us; 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", &min_threshold_us, + &max_threshold_us, &window_us) == 3) 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", &min_threshold_us, + &max_threshold_us, &window_us) == 3) state = PSI_IO_FULL + res * 2; else return ERR_PTR(-EINVAL); @@ -1107,8 +1110,11 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, window_us > WINDOW_MAX_US) return ERR_PTR(-EINVAL); + if (min_threshold_us >= max_threshold_us) + return ERR_PTR(-EINVAL); + /* Check threshold */ - if (threshold_us == 0 || threshold_us > window_us) + if (max_threshold_us > window_us) return ERR_PTR(-EINVAL); t = kmalloc(sizeof(*t), GFP_KERNEL); @@ -1117,7 +1123,8 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group, t->group = group; t->state = state; - t->threshold = threshold_us * NSEC_PER_USEC; + t->min_threshold = min_threshold_us * NSEC_PER_USEC; + t->max_threshold = max_threshold_us * NSEC_PER_USEC; t->win.size = window_us * NSEC_PER_USEC; window_reset(&t->win, 0, 0, 0); -- 2.25.1