From patchwork Wed Feb 1 08:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13123909 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 5ED6BC05027 for ; Wed, 1 Feb 2023 08:15:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D37556B0072; Wed, 1 Feb 2023 03:15:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC0ED6B0078; Wed, 1 Feb 2023 03:15:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B396B6B007B; Wed, 1 Feb 2023 03:15:57 -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 A332D6B0072 for ; Wed, 1 Feb 2023 03:15:57 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8B6101C652E for ; Wed, 1 Feb 2023 08:15:57 +0000 (UTC) X-FDA: 80418014754.18.2E77179 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by imf02.hostedemail.com (Postfix) with ESMTP id 783C680009 for ; Wed, 1 Feb 2023 08:15:55 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Yk90htaX; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf02.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675239355; 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:in-reply-to:references:references:dkim-signature; bh=yfqeLOXHYvN5fcwbZ9XofDXQxkaJPcCjRUHM4TDaFeQ=; b=1HPjp84jQIvhSejhDx1PJI5afxZb6O4AQfuyBo8CMY1+Kb/CtLMIQ/cWj+fB/FcSz4B1nh v53LTWTqJD+DjQk3g28/nqkU9fTw0SFBwFjCyyvCaY6PNCEbvwngsn8b/zvCEH0C7TsLsb TdzlZzzrK6Sev87PGEQMWHdaD4ZdEJs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Yk90htaX; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf02.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675239355; a=rsa-sha256; cv=none; b=7z2V7aFzJnQ89w8vjQ4aNSoscTy+kNHIu5x/MZvEtEnECdNk6DpJPqDrduj1DEN0dI0J5x wy9bBf2IpPObRlq4XL3zR1Y79dmhY+ho8dpO5SI3zwmwMYuZBxqDi4nq66fj211MDCLcwC 1cN5Fzzrlyq1zxeFW7YJKuNlkxYk+GA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675239355; x=1706775355; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j54FK8ufy2534q2LDgpNKoMNxEN51fsbb9NuCT+dCvw=; b=Yk90htaXGDN7gn/bi334G/1Eaa7g6ypkF/zVGCmpNM2O4oIFgXLhEvwi tb4PZPvsYEz+mXodnGtn3f52QoUDU8OrT7rBf7wkUrZOvf14F/cb+fd9k ugWaTfK4VfD/UEK7Ggu2RF1vrrght9OECLhUVxmLanMp7EiRiQ3TXOZ8+ W4tZQML3ozYf6XFFSRTh3UBtPAILKUDoHqZj2Hjcn7RQRzHelhyKBBt8t xw3d70XqROHhmk7sUkVHbV7n6q17ZgULDpA2YQulnjL6P5V5z+B7XLZ9j nwSOBgJdQIlXJvITWG9oiFpPxf0LkpzXbCX8lCb/9mMWSIdcfZzkD420w g==; X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="390471670" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="390471670" 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:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10607"; a="753580320" X-IronPort-AV: E=Sophos;i="5.97,263,1669104000"; d="scan'208";a="753580320" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2023 00:15:48 -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 1/5] mm: Enable fault around for shared file page fault Date: Wed, 1 Feb 2023 16:17:33 +0800 Message-Id: <20230201081737.2330141-2-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230201081737.2330141-1-fengwei.yin@intel.com> References: <20230201081737.2330141-1-fengwei.yin@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 783C680009 X-Stat-Signature: 5dce1t4yof4n5xwgh7a3yxm9rej3mr6c X-HE-Tag: 1675239355-561498 X-HE-Meta: U2FsdGVkX1+Sq/qSzqkXyhfxk3+15euMTFoaUsx93xYm1UgafVoP5yuIu5OnPfJWBGfdM57AeLksRpUlQgSuxeyf0VF9rvDRlqUNSLRH3g+LqDkE2YLP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pfwsx6C0c2iqz1MAvnzDMODYIxq8K2+GfmU= 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 shared fault handler can also benefit from fault-around. While it is uncommon to write to MAP_SHARED files, applications that do will see a huge benefit with will-it-scale:page_fault3 (shared file write fault) improving by 375%. Signed-off-by: Yin Fengwei Reviewed-by: Matthew Wilcox (Oracle) --- mm/memory.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index 7a04a1130ec1..51c04bb60724 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4546,6 +4546,17 @@ static vm_fault_t do_shared_fault(struct vm_fault *vmf) struct vm_area_struct *vma = vmf->vma; vm_fault_t ret, tmp; + /* + * Let's call ->map_pages() first and use ->fault() as fallback + * if page by the offset is not ready to be mapped (cold cache or + * something). + */ + if (should_fault_around(vmf)) { + ret = do_fault_around(vmf); + if (ret) + return ret; + } + ret = __do_fault(vmf); if (unlikely(ret & (VM_FAULT_ERROR | VM_FAULT_NOPAGE | VM_FAULT_RETRY))) return ret;