Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1232267rwb; Thu, 4 Aug 2022 20:43:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5IGo+RmqEcbKLapcmtlIXSZ+M/I2cGTvimHuO8Zyz/ra+dx5LMyWAFkv4YjVh81gq5J+VG X-Received: by 2002:a17:906:5d0b:b0:72f:b107:c09f with SMTP id g11-20020a1709065d0b00b0072fb107c09fmr3757031ejt.639.1659671001389; Thu, 04 Aug 2022 20:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659671001; cv=none; d=google.com; s=arc-20160816; b=yXNvsp/Itv0QnQpw5NNml2eN6Dn8cgG64WmsWXsKe9t/EtM6SYBg5nynSr/4Nn2slE MzzoACuOXs/CzXF1anMOg4o9Ll0ICpnWsjpK+B6csDgXIPPnbQAClr/FScZrSOgnHEit GwZ3ZRRMblqIcmU6/+D1WwqK9zhIqCZM53fXsigNHoxF+cTRm473wah0GNxCvHUf2VlJ iuiyPw0z2KFOza3luRrdvMCRqYaTC1FTDIBP/lquGH4p6Aqof2/8lu6unKoDOBYG7VYm Ecw8Zr2D77/VgdYBCdYNg9QqEBH2ZDDiVsePs/W+FnV8aBXcrgbJsjod6UEN7UDyQr7T Hmfw== 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:cc:to:from:dkim-signature; bh=8sfhr26tDeV/L6Ozp357rvkDwH/uFe9BTr+eNIF+xXU=; b=cLDKJfDsVIXDjWQhgt6dQiBgtGAW807+VoxF01YWpOpwzN3n2QluTq0o5gI617KQbA BOlVXCjiuDBvFq6ycYfp2np2t9nP6O3U9TyN9z8Rde0qpbnFVIkWif8DMp9zFGZ/zbo7 YBleDW8rwyIWAsZ17Ty5mB61P2XIKt8waGQjkuj+5e7tZ9MVw8/B4tFzedQ9Rir/Lihj 9oILK0+v0y6J1U8u5wTVlnZh+3NZGJG2SuPH9GN9/+7dhleYMKhaxA4bZt3koPoutErc RIjibNxShnXLsLTdeC3r2hUaU0JYhy8QT5YDZKiVQctglH2e3krhTigSew5KLqwqB8OL ZTEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="X1hd/w3Y"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r9-20020a05640251c900b0043df391fc57si1155203edd.542.2022.08.04.20.42.56; Thu, 04 Aug 2022 20:43:21 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="X1hd/w3Y"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235352AbiHEDjb (ORCPT + 99 others); Thu, 4 Aug 2022 23:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiHEDj1 (ORCPT ); Thu, 4 Aug 2022 23:39:27 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 250F952DFD; Thu, 4 Aug 2022 20:39:27 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id a8so1549079pjg.5; 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=XcPsSmfk9dHebbX4wxiKpBc/zTKZKqUOESEqTg8eZuOZebWkUIrzOo27LL33HR+LjW lJzqeAGIiNkGYaa3eGrk4QgmztoeCpq+qovz5O9Zv/ODnSb7kYpUsDhQizm80n1gOVuP NckhgzCTq/3fQAAIIyC1c7Hyu4ujPWa2UZ3h847Fw4wwkJlJIfkJnXJuiBva4XqefXv/ xoVtat1Lxb2iOglVCbeH0mv9PyfaGIl60RASX/xEZFSjge7CkTZqCRabhFruydQOGkm3 P41iYOe73BT3ZgweVfetMvYG+6ydA5GWSbOODvC+amLSOM35YMMAFPuzKTup/1TfWtz4 1PYA== X-Gm-Message-State: ACgBeo2PgWbja+sE5oOge+Lin4rBtdNMNeNwK2eGEnVi9GPFTKItNUgu r8wNhCBobNHwt3S6SonP07o= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 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 --- 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); } } -- 2.25.1