From patchwork Sat Aug 26 09:22:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjiang Tu X-Patchwork-Id: 13366541 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 C2F18C83F18 for ; Sat, 26 Aug 2023 08:28:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F09F72800F1; Sat, 26 Aug 2023 04:28:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E92542800EE; Sat, 26 Aug 2023 04:28:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D59852800F1; Sat, 26 Aug 2023 04:28:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C6F922800EE for ; Sat, 26 Aug 2023 04:28:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1C12A0164 for ; Sat, 26 Aug 2023 08:28:16 +0000 (UTC) X-FDA: 81165578592.13.A707B40 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf23.hostedemail.com (Postfix) with ESMTP id 07AE6140018 for ; Sat, 26 Aug 2023 08:28:13 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693038495; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=Jq2tEZZrs23hjfw1Vx9R+euFlBIy3wBKNK2ZL4PWLEA=; b=m0/bJWMof6JWcYZty/KAxN7iKE92KtJoGrow4RUQXSCg/yJn2/hPRAhpbj/uz5+QQaB8VW jfvkBOXmIZuy84lyd4L5Zg3Opi7Fsq+HFrfLt5SXl0rrTiR2/NnII6Q2sSVa+6EL+LV81d lBxFBrLY8J4NJmpgWJing7OImvA0dt4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693038495; a=rsa-sha256; cv=none; b=EzUTuHG7aV7ESwAE9Ew8zqVFZsD4WuzgYs7sYq/UTJdntP+1pUk/9YzjDaea9/f7gXZdmd YNpLfscVP1PJSjFs0WkOjrtrBuEhEMFYL1Hg2hgXJsayZUs20IY1OC8h4Edp7uwfUSVN0R n5INIY54jWVRFlDVnDyutKweOvFfTbA= Received: from dggpeml500011.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RXqcF64SHzNn4K; Sat, 26 Aug 2023 16:24:29 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpeml500011.china.huawei.com (7.185.36.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 26 Aug 2023 16:28:05 +0800 From: Jinjiang Tu To: , , CC: Subject: [RFC PATCH 0/2] mm/gup: move pinned pages to unevictable list to avoid meaningless scan Date: Sat, 26 Aug 2023 17:22:38 +0800 Message-ID: <20230826092240.713105-1-tujinjiang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500011.china.huawei.com (7.185.36.84) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 07AE6140018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 64w8t44z7brbmrcj6rxfbuh5ej8i6a1o X-HE-Tag: 1693038493-254234 X-HE-Meta: U2FsdGVkX1/ad6b2xq599h6FLJtHJo5GMQ5PDD4/Ddlbt9p53kkTAjyzoj/U/+emURexOAwgZbv2tsbvjFWumpZHCuqQXPYIJT4yvVVDwVaN2nrklySKw9izbEQ4iD4ynTrZP56wEP43tmNM88xcOrCd9FX5iwRV8Qh5bZ3vM92yejYlhCJ7onWrAsQWnD0FPj4SAqfsQqme7rYFnHv2j0Oa/KzO/cDSmQSPioHpnQqoiYSm54xvj+e6TOWlWP5ePh8jZ60WxkYKxDMaTcokBfLSU8fI+wR+YPPzZBfzF21+p4x1QLIADZT11GiJvDPa2XG57LMLwX7+LNQ2+ow2oGSRc0FZfekb7+jsYZoPc1nK4fzjfZ/DBNcBiu/6xFjKVWm1NvUDtdyOEVkD4GD/L+UlddYDrDIW15a/ebQ7MGBvua5Ab7pD6phHLHTuwUw+lEfoEtVrM74Lda1wE/UgxrP5x3b1HB+U1RNMzCy2OxvPz9YM2nqEkTGOXqpTO0nqh5OAihnqrcoBY5BiMYdIFTsZhL2JQk1hzfGpy9LIHmklVJcevqTiUPio6FlGbG6zSI6Er0gJvtitG8ruEMWCFTS2T7Lis1TvZ5FmLMyofX4mXtLWDEjGP/5e+/f1Nsh1sE8VzAxuq3dWrreStRQkyWou9b5Hx6qbVQ+PoXXIYd6URwDSVbPEjRuE66YUu+/4h8vED3YedYBh5rbHVodpp9nnGFuTvLtHcOhWwyw3j5mM948zn5o42wDI/y/8EAMn8qday6ZB5yg5s+q5/+GRau12YLYl5lPjqZ+ZpQuIEfuPrNUYhEk1FmH7L1Q2+XquSQy5/lpIimqV3+Fwp9X2hGKa1sN5DP6vU9QCvI4xOFRd8hmyR5jeg/aOHBaX96m0ZG6qXH3XW3+vBzqOqHXQPVvWo7rgJ3Lar5A0cJf10nMq5JBbHXq4NKapVdzcTPGJsML/8o3velxU2QTJQJE zKPQhOPy Ti3bwUsDxQjeEqOQUI4SmDs8W9ag9IL7IhFX7RkLY3y6w1ye25iFVVj4DkQfpYrMk8FGzDqKgj6vabOzO2bJzME6QSSMie/ftmHzjZzeyUQSaQdIG/IUjIDNbuQ== 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: The pages pinned by GUP interfaces are unable to be swapped out. Currently, these pages are put into active/inactive list, leading to meaningless scan when reclaiming memory. Even worse, when we try to pin memory more than free memory, the system fails to response for long time, all tasks are reclaiming memory. However, the process takes long time to scan too much pinned pages, but only reclaim few pages. Because each scan takes too much time, during this time, some pages are swapped out again, some pages can be reclaimed again during next scan. As a result, the OOM condition is not easy to meet. I reproduce this problem by gup_test utility (CONFIG_GUP_TEST is needed). The system has 3.3G free memory, and I pins 4G memory by command './gup_test -b -m 4096'. The system will fail to response for 10+ minutes before triggering OOM. To solve this problem, this patchset moves pinned pages to unevictable list to avoid meaningless scanning during memory reclaim. Jinjiang Tu (2): mm/gup: move pinned pages to unevictable list to avoid meaningless scan mm/gup: remove folio_maybe_dma_pinned() calls in shrink_page_list() mm/gup.c | 13 +++++++++++++ mm/internal.h | 2 +- mm/vmscan.c | 12 ------------ 3 files changed, 14 insertions(+), 13 deletions(-)