From patchwork Wed Feb 1 08:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13123908 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 7D838C38142 for ; Wed, 1 Feb 2023 08:15:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08E106B0071; Wed, 1 Feb 2023 03:15:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 015986B0072; Wed, 1 Feb 2023 03:15:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF9196B0078; Wed, 1 Feb 2023 03:15:55 -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 CC4CB6B0071 for ; Wed, 1 Feb 2023 03:15:55 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9037D1A0958 for ; Wed, 1 Feb 2023 08:15:55 +0000 (UTC) X-FDA: 80418014670.10.6A2E13C Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf17.hostedemail.com (Postfix) with ESMTP id 9D0DC40009 for ; Wed, 1 Feb 2023 08:15:52 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Yim0mhiQ; spf=pass (imf17.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.31 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=1675239353; 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=nyKIH4npBgki+u3LaIk18NKDxk0QboSZRdNwFfrS+Js=; b=uAQhooAURSR6l8VMs1WjZolgfSCWTBXmv+6JVvY5CIYaOUt9ucTtsIMY2shIx74+n0hADW /iU44aOhIbLj7mQ7Z3mKXTxcDdg/5dc/4H0Zx+9XuAD0aB+v3nx0PxZQdsTPjlOt4vRb4n VJ+MBXrpLL99kKdUt/DXhPnAdxhf77s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Yim0mhiQ; spf=pass (imf17.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.31 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=1675239353; a=rsa-sha256; cv=none; b=JJuXpJbYfwfBd0oTTUYFS1q3vWvxLVXmGsRW4xG5KbEZMSpNj8wsMNpFgmn90W1NkEGcqn P0mCm1px/HKEl6s7AWAtHV/4fuv7S9/p9LQeOk3y3srDg2rR+SdnAyH2sd5j7NToPQDcvD DLPZXQSXRmfJdk23HwYarqY6CSc15nM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675239352; x=1706775352; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rPrGcIj89a11CQlBxzKDqL6gWLThA/UusWkoD0XYuRs=; b=Yim0mhiQgDSfW/KXoIJSjx/scy8qSnsbhQdsrfLKWf6ilJGdoKErcGUV mLQ0FSLzygYIJsbvK+8AGTDazboedXn2I14ZduTu6KA9K1wQBJ8GH/riq jNMl4/pL1xGZEGlop57yy22sRV44QGxTqQCOMvKcdHnNqHjwdZcbR+6/l IJweguXL5iiX3TX3FtibA7ZoGwDGBvqv7/GK8deZT5c+oSXO3EJ+Z8KV6 NC7rrNzZwaOqTXlYZo6DDwfDGME5eeikzWM0Mxr/bwkbxREEuwyAtneah 0n2pZ69f64ff6otP2/KLYE6N90YY4DggY7WKu6/NDxtXmpkAd530x1qKj Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390471661" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="390471661" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2023 00:15:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="753580314" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="753580314" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2023 00:15:46 -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 v2 0/5] folio based filemap_map_pages() Date: Wed, 1 Feb 2023 16:17:32 +0800 Message-Id: <20230201081737.2330141-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: qdgbxdjn98samxy7yejxt1em4sjithdr X-Rspamd-Queue-Id: 9D0DC40009 X-HE-Tag: 1675239352-771818 X-HE-Meta: U2FsdGVkX1+cW+FMD5iCLCvZUyu786/QeDC56ST5Aa8R6wYweDfzXm9WaQ8UGqtlwI328AsAJthzm7FllsqO+iQI3V1p2u2iH9rHz+BA/FSiIXIt6yMUlWHvbe66R/R+SN2PiARG38G060LOZDlXcgDZvEJN+wUo2vrt8cVrPHBCdCM7pHGjY01J2nbLNd8c7isANXnBWEgqxtD0lVzaUZH9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, 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() uses page granularity even when underneath folio is large folio. Making it use folio based granularity allows batched refcount, rmap and mm counter update. Which brings performance gain. This sereis tries to bring batched refcount, rmap and mm counter for filemap_map_pages(). Testing with a micro benchmark like will-it-scale.pagefault on a 48C/96T IceLake tbox showed: - batched rmap brings around 15% performance gain - batched refcount brings around 2% performance gain Patch 1 enabled the fault around for share file page write fault. As David suggested here: [1] 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 [1] https://lore.kernel.org/linux-mm/e14b4e9a-612d-fc02-edc0-8f3b6bcf4148@redhat.com/ Change from v1: - Update the struct page * parameter of *_range() to index in the folio as Matthew suggested - Fix indentations problem as Matthew pointed out - Add back the function comment as Matthew pointed out - Use nr_pages than len as Matthew pointed out - Add do_set_pte_range() as Matthew suggested - Add function comment as Ying suggested - Add performance test result to patch 1/2/5 commit message Patch 1: - Adapt commit message as Matthew suggested - Add Reviweed-by from Matthew Patch 3: - Restore general logic of page_add_file_rmap_range() to make patch review easier as Matthew suggested Patch 5: - Add perf data collected to understand the reason of performance gain Yin Fengwei (5): mm: Enable fault around for shared file page fault filemap: add function filemap_map_folio_range() rmap: add page_add_file_rmap_range() mm: add do_set_pte_range() filemap: batched update mm counter,rmap when map file folio include/linux/mm.h | 2 + include/linux/rmap.h | 2 + mm/filemap.c | 119 ++++++++++++++++++++++++++++++------------- mm/memory.c | 71 +++++++++++++++++++++----- mm/rmap.c | 66 +++++++++++++++++++----- 5 files changed, 199 insertions(+), 61 deletions(-)