From patchwork Mon Jan 30 12:54:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13121034 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 C0AFEC54EED for ; Mon, 30 Jan 2023 12:53:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 435016B0072; Mon, 30 Jan 2023 07:53:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E6046B0073; Mon, 30 Jan 2023 07:53:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AD326B0074; Mon, 30 Jan 2023 07:53:22 -0500 (EST) 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 1DD486B0072 for ; Mon, 30 Jan 2023 07:53:22 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D90D21A068F for ; Mon, 30 Jan 2023 12:53:21 +0000 (UTC) X-FDA: 80411456202.11.B046A61 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf30.hostedemail.com (Postfix) with ESMTP id 6FE2F80015 for ; Mon, 30 Jan 2023 12:53:19 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Uhg+/VSK"; spf=pass (imf30.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.24 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=1675083200; 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=mcLis1mALd9DB+QrFTqjpmqzBm2WgR249GHv6h2ICUo=; b=aYEdTGvFrIaq8gWvWvQH2Z/Q52uCl0GcCCUvSLIAMr8+M+xIPw1uzpTDVQ/yhlP78TwuMo rLEXL/C7hGawRdObRY/4ldFNyxiFoH6pMiNXZ4R+n+739ddq3jQBL3ztDWvwLtcllex8oS ufZNmZfp+BmG6ExRalCwGjjz8lVMrs4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Uhg+/VSK"; spf=pass (imf30.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.24 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=1675083200; a=rsa-sha256; cv=none; b=H5/334+Upo9i1KGVXzsq/ILaAiq24/CrIBR0V6vwz28eUfOdAs0IZkzNZmB3AAVEsdtrhz mpwSgg2SIBpT8S32dO4yY8UnLML5r89TF21gz03SuXOVItUCbPNwqrP8ApJJWWePl6knXh +/GnRgFOoKqKFzggJWL5ZMoQSan3QGk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675083199; x=1706619199; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rtNe814i+wma/hY2A03DsE4S+Gf/PreWOibxJuQyjTU=; b=Uhg+/VSKj4zOVmacnlvuxptWA7AkJJylAeY17jy2L2NdOPgIXcqcGupF eohHbSqW5jCb+SfDtQyln6mnTxRYT7cRnrDF/40rcOUuzvxPI/Z+6hG5W 6JCUftVP2VGT585GeIG3GAMe4elc1v5Ezp682fhnyszpxgzul/+i6FRAC ga/Ip+VJAso7G4DTKMSIRtsZMvooiMngJYOYSEUGCmGaURoFuq1+sxqw2 yJbWZGHpDj2S+5iZDn2T+AxJnK5WyzRdoOuOAnp0dbuZKH4IKiAPD+uWl ohmzatAY7zAmTeE+D+zqXOwNIlDmI+x+J46UzPBG6bG+6Uvjs0U+50vca g==; X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="328823608" X-IronPort-AV: E=Sophos;i="5.97,258,1669104000"; d="scan'208";a="328823608" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 04:53:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="614014984" X-IronPort-AV: E=Sophos;i="5.97,258,1669104000"; d="scan'208";a="614014984" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by orsmga003.jf.intel.com with ESMTP; 30 Jan 2023 04:53:15 -0800 From: Yin Fengwei To: willy@infradead.org, david@redhat.com, linux-mm@kvack.org Cc: dave.hansen@intel.com, tim.c.chen@intel.com, ying.huang@intel.com, fengwei.yin@intel.com Subject: [RFC PATCH 0/5] folio based filemap_map_pages() Date: Mon, 30 Jan 2023 20:54:59 +0800 Message-Id: <20230130125504.2509710-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6FE2F80015 X-Stat-Signature: tbx1sqheroop3k9zcwzsqjxcdbonq8dk X-HE-Tag: 1675083199-365097 X-HE-Meta: U2FsdGVkX1+pZSAYizV2fH4IWfbsLT9riP7Nio4KEOWDv0FyzSm8cTI4s9lpOJTE8GTle+hve9+CYX5rXT9MUdtkC/mu8VcAgX35PCOQ9vadUjm+d0u71guOmUG/WY55rMyKu1C88rWGRLivfZUJUNBk6R//D2HreZ7xj9ElCgBNp9ok5yc7auiZGfqLTFP5XGRLZEAnV/FaZmHOeIOH8Z3K5Q5x1P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== 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: Current filemap_map_pages() still use page granularity even when the underneath folio is large folio. Making it use folio based granularity allows batched refcount, rmap and mm counter opertion. Which brings some level performance gain. This series tries to update filemap_map_pages() do_set_pte() page_add_file_rmap() to bring batched refcount, rmap and mm counter in. Patch 1 enabled the fault around for shared file page write fault. As David suggested here: https://lore.kernel.org/linux-mm/e14b4e9a-612d-fc02-edc0-8f3b6bcf4148@redhat.com/ Patch 2 update filemap_map_pages() to do map based on folio granularity and batched refcount update Patch 3,4,5 Enable batched rmap and mm counter Function testing: - two days daily usage: boot to xfs GUI, kernel build, editor and browser Performance testing: - kernel build: no obvious performance impact - micro benchmark: will-it-scale:page_fault3 (shared file write fault) Patch 1 brings 3.75X performance gain - micro benchmark: will-it-scale:page_fault3 like but with file read fault - Patch 2 brings about 2% performance gain (batched refcount) - Patch 3,4,5 brings about 15% performance gain (batched rmap and mm counter) Yin Fengwei (5): mm: Enable fault around for shared file page fault filemap: do file page mapping with folio granularity rmap: add page_add_file_rmap_range() mm: add do_set_pte_entry() filemap: batched update mm counter,rmap when map file folio include/linux/mm.h | 2 + include/linux/rmap.h | 2 + mm/filemap.c | 106 +++++++++++++++++++++++++++++-------------- mm/memory.c | 25 +++++++++- mm/rmap.c | 70 +++++++++++++++++----------- 5 files changed, 143 insertions(+), 62 deletions(-)