From patchwork Fri Aug 5 03:38:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CGEL X-Patchwork-Id: 12936845 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 34021C00140 for ; Fri, 5 Aug 2022 03:39:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79BA48E0002; Thu, 4 Aug 2022 23:39:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74B598E0001; Thu, 4 Aug 2022 23:39:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 613338E0002; Thu, 4 Aug 2022 23:39:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4F4018E0001 for ; Thu, 4 Aug 2022 23:39:28 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 255FE1601D4 for ; Fri, 5 Aug 2022 03:39:28 +0000 (UTC) X-FDA: 79764134016.15.D024143 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf25.hostedemail.com (Postfix) with ESMTP id BEE96A002C for ; Fri, 5 Aug 2022 03:39:27 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id gj1so1611802pjb.0 for ; Thu, 04 Aug 2022 20:39:27 -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=8sfhr26tDeV/L6Ozp357rvkDwH/uFe9BTr+eNIF+xXU=; b=X1hd/w3YEpI3L9ZDpSiZE2PikM1J7Pe3b8stV716zhBQWlz5e/jFp5EH4iS8/6rGkk TKOdqWCPnjrkfyLSGL5pvtbR3/A2S+XuCZ+urLJfRtlj599saXjaXOlWWHvnxRpWNd/b QZLzHt9z5becYsv0gERZb+yxWXpU2B954h/wAUSJ08jYBNg2lJ8cdVQ2RCD+u/LflDVE PE8t4Zn6TnS0BM99pdboDpgOC62MN9l+nJqRbVoR3P80Nqr15VlGnHEy1d02qmr0zGyw Z6oZ/B6G60t/z4fwAmgRk9PhXW4VUNyiDBeVjA7vmHbEQo5MutdenqAGulC9XBaH0AQi kxow== 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=8sfhr26tDeV/L6Ozp357rvkDwH/uFe9BTr+eNIF+xXU=; b=b5D4TMnhGpdWolMUggw9rbY8hzkCPbzcnIqhV76av7Xtft+j85vUD6EyajNAA3EyHt F8tf7ea0QsQmP3mkibCxCSADonvVTfcSnJd1rAyLbsMr30mIc5IQ3WDfpnlPonlqsB8y iD1kYW0HaipQ3sMwl+V2g2tJk4eKl5fH5XIGcegKzbwjdI8EkmKdGYn1hsgcPvwxLKgC FAP/xmYghI1H19UdOZMWxrnI7oK6ZW/578G4ayVyLaaT8yiNB27gW/I40gAo1YQXl+Vw 1faXlHg777FvG0yyTqc+yXdErgdT3is6WEuLhD4tIpDWXVzxXJ1CBRujFhiyc7Al+H9o qEFw== X-Gm-Message-State: ACgBeo2AjqH5r9A1/IcoMtNTKzyxflFCm9KTH8k5HdpWXA5h0J0JeXS+ YRV5GndAYEloCzn10khhGes= X-Google-Smtp-Source: AA6agR5923Jd70u1CMa/1BKAWCZxfqiG1OIy0Fvu624VKXl6nFsBzl39y13ZzjHWnaJxGJnh1AsWbA== X-Received: by 2002:a17:902:8693:b0:16c:db86:1c86 with SMTP id g19-20020a170902869300b0016cdb861c86mr4805594plo.9.1659670766619; Thu, 04 Aug 2022 20:39:26 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id n15-20020a170903110f00b0016ef1e058e5sm1683706plh.295.2022.08.04.20.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 20:39:26 -0700 (PDT) From: cgel.zte@gmail.com X-Google-Original-From: yang.yang29@zte.com.cn To: akpm@linux-foundation.org, bsingharora@gmail.com Cc: corbet@lwn.net, willy@infradead.org, yang.yang29@zte.com.cn, david@redhat.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, CGEL ZTE Subject: [PATCH] filemap: Make the accounting of thrashing more consistent Date: Fri, 5 Aug 2022 03:38:39 +0000 Message-Id: <20220805033838.1714674-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=1659670767; a=rsa-sha256; cv=none; b=ISu+fdFk2WPEJCVHbnX7DhROWMrZebrGQKY0Q4/uPH6w/oLVW40VXGGBuGoUjrVEPYOfZB b2eWvewPcTUvqxRg9reuOnTsw5YbdsuoK5OorE8YgCELf6cbGtbFJ6AXVULkpuPmH5VXAO A8CGVYn9qZ5HQefPhjPoxRjJGcTiYjk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="X1hd/w3Y"; spf=pass (imf25.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659670767; 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=8sfhr26tDeV/L6Ozp357rvkDwH/uFe9BTr+eNIF+xXU=; b=Z8zxm2M7nzgoSCgySw9lAIW0TrIuweKEzjnTjLIZEoyK+6YcqJBdIubAp0N0g9AkDeajaB DeRB3V92l1qch1XLnSNXw+nrTy32dEmZJYxzckUn81/wBeOIk3ViHjFOvWF6e6e4Kg2Ebm dU6GSeFT8fUkq6S0TwB3yBtBS/nqJXc= X-Stat-Signature: znd47kjrib31aqo9dxutfor1ubhrmgxe X-Rspamd-Queue-Id: BEE96A002C Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="X1hd/w3Y"; spf=pass (imf25.hostedemail.com: domain of cgel.zte@gmail.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=cgel.zte@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1659670767-597205 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]. So let delayacct account both the thrashing of page cache and anonymous pages, this could make the codes more consistent and simpler. [1] commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") Signed-off-by: Yang Yang Signed-off-by: CGEL ZTE Acked-by: Joonsoo Kim --- Documentation/accounting/delay-accounting.rst | 2 +- mm/filemap.c | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Documentation/accounting/delay-accounting.rst b/Documentation/accounting/delay-accounting.rst index 241d1a87f2cd..7103b62ba6d7 100644 --- a/Documentation/accounting/delay-accounting.rst +++ b/Documentation/accounting/delay-accounting.rst @@ -13,7 +13,7 @@ a) waiting for a CPU (while being runnable) b) completion of synchronous block I/O initiated by the task c) swapping in pages d) memory reclaim -e) thrashing page cache +e) thrashing f) direct compact g) write-protect copy diff --git a/mm/filemap.c b/mm/filemap.c index 15800334147b..cfe15e89b3c2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1221,15 +1221,11 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, struct wait_page_queue wait_page; wait_queue_entry_t *wait = &wait_page.wait; bool thrashing = false; - bool delayacct = false; unsigned long pflags; if (bit_nr == PG_locked && !folio_test_uptodate(folio) && folio_test_workingset(folio)) { - if (!folio_test_swapbacked(folio)) { - delayacct_thrashing_start(); - delayacct = true; - } + delayacct_thrashing_start(); psi_memstall_enter(&pflags); thrashing = true; } @@ -1329,8 +1325,7 @@ static inline int folio_wait_bit_common(struct folio *folio, int bit_nr, finish_wait(q, wait); if (thrashing) { - if (delayacct) - delayacct_thrashing_end(); + delayacct_thrashing_end(); psi_memstall_leave(&pflags); } @@ -1378,17 +1373,13 @@ void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep, struct wait_page_queue wait_page; wait_queue_entry_t *wait = &wait_page.wait; bool thrashing = false; - bool delayacct = false; unsigned long pflags; wait_queue_head_t *q; struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); q = folio_waitqueue(folio); if (!folio_test_uptodate(folio) && folio_test_workingset(folio)) { - if (!folio_test_swapbacked(folio)) { - delayacct_thrashing_start(); - delayacct = true; - } + delayacct_thrashing_start(); psi_memstall_enter(&pflags); thrashing = true; } @@ -1435,8 +1426,7 @@ void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep, finish_wait(q, wait); if (thrashing) { - if (delayacct) - delayacct_thrashing_end(); + delayacct_thrashing_end(); psi_memstall_leave(&pflags); } }