From patchwork Tue Feb 28 12:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13154851 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 62F05C64ED6 for ; Tue, 28 Feb 2023 12:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C20926B0073; Tue, 28 Feb 2023 07:22:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD0796B0075; Tue, 28 Feb 2023 07:22:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A981A6B0078; Tue, 28 Feb 2023 07:22:25 -0500 (EST) 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 9C54D6B0073 for ; Tue, 28 Feb 2023 07:22:25 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5C6AE140898 for ; Tue, 28 Feb 2023 12:22:25 +0000 (UTC) X-FDA: 80516613450.10.3FD8046 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf14.hostedemail.com (Postfix) with ESMTP id B7164100011 for ; Tue, 28 Feb 2023 12:22:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=U4rzDlYQ; spf=pass (imf14.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677586943; a=rsa-sha256; cv=none; b=39WC8wTUpi86ev9SiZJ3Lq4OPG28J8TlbMladG9yHPP0kKrlMuFTyhJt1hliocnGqBYkSQ QZsO7iV1Qu0YVHHh+Djs3ZFWYJnMshpJkgQF3PBoPtWSRQ/fgNx/Lckyjf9MTkNw2PUOvM f3+O044fxphs5h1gW1vtrrGG/5wm8Bg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=U4rzDlYQ; spf=pass (imf14.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677586943; 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=8CCTACIokd6lumOwooISOZeSrg+XfP7EhgH5bx6dObY=; b=3YxmezWTKFQIII00A0KQGs+vPAAqcjZU1GsjuzIDhIzpox8aEMC5ZjVjxvR/wqG5mc9ZJq TQyrYULHlmctMnvyvpakHX8qVi+iTHxSQgOYkZvN2lBBkg+v3G20icWJNAdv1Mup8evje5 e22LKDys9ErxJrxLhJz4x5ps6xMhtRI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677586942; x=1709122942; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=L27Zdio292A6VkhJ+Nha9TCtcxlnAsOwyRvPmRT7/js=; b=U4rzDlYQEvI0Ho/A72+UnV0RnfU/p60dg8nvOgi903jOWVeGzXThOt7C pa7CkHPqYlnv7FNLJl/2nnOyOXHmCbaz9nmi2NLHgay5l3+p0NIirNaJ7 ixXmd4ErStnshBLmMojWPTcIzeVSELhMBoqFYI7xbIUDGsDHOMPpFFnAG kko8zpLKckiWvyBo9MxbcVVWBTCUIbnyDMc6t3WSY3j4anPRjbwVcTWs9 Lp4VIpfweTbEWNPgzWN+961xFwBWj7XJJqfCBfjRXDEolYKFU7pTxQFsE wyDd1rJb6UyEnoWEjCtbRQoiRiiR6p0XIEBDDGt4M895FeDM6hNlRW+rF w==; X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="317921166" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="317921166" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2023 04:22:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10634"; a="1003220712" X-IronPort-AV: E=Sophos;i="5.98,221,1673942400"; d="scan'208";a="1003220712" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by fmsmga005.fm.intel.com with ESMTP; 28 Feb 2023 04:21:55 -0800 From: Yin Fengwei To: linux-mm@kvack.org, akpm@linux-foundation.org, willy@infradead.org, sidhartha.kumar@oracle.com, mike.kravetz@oracle.com, jane.chu@oracle.com, naoya.horiguchi@nec.com Cc: fengwei.yin@intel.com Subject: [PATCH v2 0/5] batched remove rmap in try_to_unmap_one() Date: Tue, 28 Feb 2023 20:23:03 +0800 Message-Id: <20230228122308.2972219-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: B7164100011 X-Rspamd-Server: rspam01 X-Stat-Signature: hpoy9xeabujed7m6n8qo7me96t6hjn1y X-HE-Tag: 1677586942-163878 X-HE-Meta: U2FsdGVkX18Q3TT7wiCtolZmvrHjSd3W4wYwh6t1/TTGEPH3kiynb/gnPYUzMRBLooomAogmFLqZ5BdjxHpHW5nmJrLG5XDeVwz0HD00i7UBHUwChb0rvceFmdHseUgfv8R9AENY20qDCGfv1cFULDm8WA3VmlapIYyngWbERl4pNTX5Ii5s4uMgZf2HbBAceHatPqh2jHMe+Cpjve+JsVcAzSJ7Ijg8VwqQKUyH4p8nCWu0FiH1ozQ6IQCcKO53lR+tTACz/f5w9C1C2EGriKBfnkh6TuJ59VuQLllVgPSgaIdeoybmPHb+V4B01gv7tTv4OKMIbYdToTCkokGkj32bQ5QHaV8uES1EvzJ21M6xfNm3eCDZJZcH+TtV4y84ZPdEyC3MkVVi7fF/X2HqSVLWobSyjYep+qfYj3igDB7RWlQkv5uTqdEKAFfxSAKQ5ywcxv2gBelWphMBGM8VS+Xe9Nba+IKVXEg3fvE1Kvtt4/Tv4hVFX1adhAPtdyHcOTkL4Cl3E6aqxVWDyPZBps7f0k9T/UXKgas8JhiKcKuX7rNWCh4N1RpB6K453BV5daSrjW9VEIjg/qA6mA53OaODUNKV+hE0QcRF/8fCruNFFqJxeohDlSXq2qa03sojfFoxLTsS0IKGzOe2DOK7NTYBhUZIcJ+uPZAz3TTaIk11myJg4/F4noG237Z56nHjyrtStq3GFCbHQUQdhfUw0k9zxHQFF2V0rZkynboqdHoO9BZ9Y9J65vy/LA73T7zhDg+/krPYUU6sa88cEGbGMp68xouoJ24nhMorr+nQG8X3gIB4GzNoBykm/cN2Lsh7jlRBv9WwlEA/8np8KY4qzUprxCdN/GztrOGjRdhmPYk7h7+4kuKbvhUZKY48wSBO3CELAOn3UNYklKMGQLrHyALt9XpwgZ7e7AKdj9Kw1eFH1o+Y06DegrBO6NfuP6ivEygn1K5Rb6zNAuBixU5 hUW+sn+F 3YWsiTOSKMikv8sPKsGDWz7MuX5Bn2nvipexifFFx0ILiAYxwGbWa/+TC4SQdrqAdWlfd6iVMp5Td/LEiBYMj+c8DsZtUm232znuqGzOCmFcI9TRudMjNSsztQIuRMzENhhJIvr/1o6pVtdX1+9zsYrXVrmlRa1VEUdvLFwEi4KbfeMIwifVJ3kw5NpxhqPYplDye 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: This series is trying to bring the batched rmap removing to try_to_unmap_one(). It's expected that the batched rmap removing bring performance gain than remove rmap per page. The changes are organized as: Patch1/2 move the hugetlb and normal page unmap to dedicated functions to make try_to_unmap_one() logic clearer and easy to add batched rmap removing. To make code review easier, no function change. Patch3 cleanup the try_to_unmap_one_page(). Try to removed some duplicated function calls. Patch4 adds folio_remove_rmap_range() which batched remove rmap. Patch5 make try_to_unmap_one() to batched remove rmap. Testing done with the V2 patchset in a qemu guest with 4G mem + 512M zram: - kernel mm selftest to trigger vmscan() and final hit try_to_unmap_one(). - Inject hwpoison to hugetlb page to trigger try_to_unmap_one() call against hugetlb. - 8 hours stress testing: Firefox + kernel mm selftest + kernel build. This series is based on next-20230228. Changes from v1: - General - Rebase the patch to next-20230228 - Patch1 - Removed the if (PageHWPoison(page) && !(flags & TTU_HWPOISON) as suggestion from Mike Kravetz and HORIGUCHI NAOYA - Removed the mlock_drain_local() as suggestion from Mike Kravetz _ Removed the comments about the mm counter change as suggestion from Mike Kravetz Yin Fengwei (5): rmap: move hugetlb try_to_unmap to dedicated function rmap: move page unmap operation to dedicated function rmap: cleanup exit path of try_to_unmap_one_page() rmap:addd folio_remove_rmap_range() try_to_unmap_one: batched remove rmap, update folio refcount include/linux/rmap.h | 5 + mm/page_vma_mapped.c | 30 +++ mm/rmap.c | 623 +++++++++++++++++++++++++------------------ 3 files changed, 398 insertions(+), 260 deletions(-)