From patchwork Mon Aug 15 07:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CGEL X-Patchwork-Id: 12943212 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 487DCC00140 for ; Mon, 15 Aug 2022 07:33:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D4626B0073; Mon, 15 Aug 2022 03:33:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 984958D0001; Mon, 15 Aug 2022 03:33:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 872FE6B0075; Mon, 15 Aug 2022 03:33:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 784836B0073 for ; Mon, 15 Aug 2022 03:33:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 53880A0550 for ; Mon, 15 Aug 2022 07:33:21 +0000 (UTC) X-FDA: 79801011402.18.2F24D60 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf27.hostedemail.com (Postfix) with ESMTP id CC13E40002 for ; Mon, 15 Aug 2022 07:33:20 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id ha11so6298351pjb.2 for ; Mon, 15 Aug 2022 00:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=cKbaTTFL2IC8He8O8jud48JZ4f+oP72hz9bddVAZhgk=; b=kTytc0xv5Fr3mYRJ2r1UtrYF8SSwlNsxLirYL1oPuslZgJULKU4nXNp3v4peq5MNZR dU1wmbW/g2jE4TMIdO9tK9LecaSJ5/H/a/UhdPi45kHihLmepbwz0LWm3DZgbPWqZntT YaYNjPFeZ6TEANS1v4Eb7/ujfw6oRBfOuFlHvpZO1FDav9BsZxaCgw5cM17TyQstSVWk 1NtVq2SPMiiRD3+iVYyt/2UmfsHslPrvXbnwYvbRRqiVWvCRbcibcV35ATUcnHBM/fgb QQCdxjzRFoWIliaFHSaEOqzbm3JrA4hZHDhQAwRkfe2ncSms70ePlbLWvrXDaLhJnaVi S/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=cKbaTTFL2IC8He8O8jud48JZ4f+oP72hz9bddVAZhgk=; b=4VTLXFX/FPPSLy4XNKyY3ZBWuOSOGUdUemsAo+k7AqoLTKRKMul1RyynyTMedds6+F bRZ6TY6mtgYUr4PY4D8b4O8LzUnTYoOGYuI3FN/UaoaiPX0kcLJbU+1DXi5jopFL0bjb bdCTeTnh74Y2hGCRqWCPiscR2OPCGkCqaBi1MQKnWwcAHZ0hytQfGJICzZpYaERnmM0a NBvdF0DQCv7GX5Gdoykrh3ERlVH5iWuovKLhDVYtZHaD4NCiUZLAYSjQEkgHuBu5+lN8 tikAJr2bW9RPgSCS7YbK32p4YTlrsWDTFTrNI0+W5mvDNfFOFX4rGOws+9YUj7bJSj/7 riMg== X-Gm-Message-State: ACgBeo2wkW9azcdlorDrUN9C7lbp2liHBwsvQhCSVqOic0vTet03jYiA ITWBwWJuT6QGC4Wgyblla90= X-Google-Smtp-Source: AA6agR6Qq9TPjqwFTh+pRvFKiRSSih2opS5+KjoOgU9ST1XfxSIASlvyd5EyhD6z/SoxgenWWJhFeQ== X-Received: by 2002:a17:90a:fb4b:b0:1f3:1cbb:8912 with SMTP id iq11-20020a17090afb4b00b001f31cbb8912mr26605895pjb.239.1660548799830; Mon, 15 Aug 2022 00:33:19 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id w6-20020a1709029a8600b0016a33177d3csm6396537plp.160.2022.08.15.00.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 00:33:19 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: yang.yang29@zte.com.cn To: akpm@linux-foundation.org, iamjoonsoo.kim@lge.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yang Yang , CGEL ZTE , Ran Xiaokai , wangyong Subject: [PATCH v2 2/2] mm/page_io: count submission time as thrashing delay for delayacct Date: Mon, 15 Aug 2022 07:28:37 +0000 Message-Id: <20220815072835.74876-1-yang.yang29@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660548800; a=rsa-sha256; cv=none; b=qRnxq9dZb0sacDB/g1cNofE7h3MAmiKJSvsVUNIjU3Z8vCC9zbFkZa0S6+DvxqP9NL33EE OZ13d7RFOZUmrh2awFHd9wtAw1ibwbrK5XHOkzUefPeFx7ZOqfwsiL0Mx/zpT0GfdJaPk5 4LpoFH+NPsU8I5hH6hd+0W52+f6dt+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660548800; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=cKbaTTFL2IC8He8O8jud48JZ4f+oP72hz9bddVAZhgk=; b=7Z6exoPIiuCihaa6H/aqFOmpRqBxfJpBMNVQ/YMplGMJ3SZS32UrJGDK6q2ga+2baV26aB fYj0fyjXx4OvpU5YlQeYCZ7GbrZEQuv50TrCiG3ieH188BC6L2a65O1EQGlQUmmOgVuOO8 TIVtNa8fWsTx+E6ttNMPLX2uAzWDNuA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kTytc0xv; spf=pass (imf27.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: jqrqyawem7pkfugqdyndm517ypudsnaf X-Rspamd-Queue-Id: CC13E40002 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kTytc0xv; spf=pass (imf27.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.216.44 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1660548800-954440 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: Yang Yang Once upon a time, we only support accounting thrashing of page cache. Then Joonsoo introduced workingset detection for anonymous pages and we gained the ability to account thrashing of them[1]. Likes PSI, we count submission time as thrashing delay because when the device is congested, or the submitting cgroup IO-throttled, submission can be a significant part of overall IO time. This patch is based on "delayacct: support re-entrance detection of thrashing accounting". [1] commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") Signed-off-by: Yang Yang Signed-off-by: CGEL ZTE Reviewed-by: Ran Xiaokai Reviewed-by: wangyong Cc: Joonsoo Kim --- Change for v2: - use bool in_thrashing instead of unsigned long dflags --- mm/page_io.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 68318134dc92..653a2adcfdd9 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -453,18 +453,21 @@ int swap_readpage(struct page *page, bool synchronous, struct swap_info_struct *sis = page_swap_info(page); bool workingset = PageWorkingset(page); unsigned long pflags; + bool in_thrashing; VM_BUG_ON_PAGE(!PageSwapCache(page) && !synchronous, page); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageUptodate(page), page); /* - * Count submission time as memory stall. When the device is congested, - * or the submitting cgroup IO-throttled, submission can be a - * significant part of overall IO time. + * Count submission time as memory stall and delay. When the device + * is congested, or the submitting cgroup IO-throttled, submission + * can be a significant part of overall IO time. */ - if (workingset) + if (workingset) { + delayacct_thrashing_start(&in_thrashing); psi_memstall_enter(&pflags); + } delayacct_swapin_start(); if (frontswap_load(page) == 0) { @@ -513,8 +516,10 @@ int swap_readpage(struct page *page, bool synchronous, bio_put(bio); out: - if (workingset) + if (workingset) { + delayacct_thrashing_end(&in_thrashing); psi_memstall_leave(&pflags); + } delayacct_swapin_end(); return ret; }