From patchwork Fri Jun 3 07:12:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 12868714 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 E23B1C433EF for ; Fri, 3 Jun 2022 07:13:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 589106B0071; Fri, 3 Jun 2022 03:13:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53A866B0073; Fri, 3 Jun 2022 03:13:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FDE16B0074; Fri, 3 Jun 2022 03:13:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 317C06B0071 for ; Fri, 3 Jun 2022 03:13:57 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 36439328AF for ; Fri, 3 Jun 2022 07:13:56 +0000 (UTC) X-FDA: 79536060072.30.27DCE77 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2086.outbound.protection.outlook.com [40.107.237.86]) by imf08.hostedemail.com (Postfix) with ESMTP id 15A0B160047 for ; Fri, 3 Jun 2022 07:13:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YWZ0DQUwQ2NglbknGst5acNXuxfAyFssBH5b+SC2rHJTddxQ9e6/OhHwBFmtXtZ5TH+2dBZYasfyNpUPV5Ry6waeuxnAU8rTIhuB/JgG+Yd+QWR8o1f51ErI3ImGe4/hp470BX8RHnY71GnOROtH5ysD+dFvBDXaQfv0aeeRshx0/vYtJtAPlOWDnER18YKOjbgz6IjWFtvAQXitg/1uqI5jS5/r+8NU9P1yTHYJ5rHcer21YfiY138mMtsScnS7wwcY96IpF69zWW6G2UJtz0plnVuaakIdUysbv4ETA14OS65gRUiqTnmt/2AwbOYGjfRIuxSGmIPf3nT8sWSC5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KmmdSooXGWpO/T5ONgx0JQakMy2y4cSXwIusNyvvuYc=; b=gAD/8iJo2jfDY6dSZPIEOEru31eOD2hnVJ7u77FjyzTy2rmWHwvfc161mYDSb6rVyvcrRRcmMCoczAcdDykLnkll93UUKFaGZdgxIfJDtO/Ls01lLlmBd33xwlRDFtgBisNHU3XrXhrUkCQBG95ZVn+RqT/TD1XWOreFx5AZqOgZCLFAIQfDLvClYVvtDP0w3i6Wq1UK9MDinf1qpFrYn0i+JS7diCSUcEhL3iUjZinpVzrkvJdXF6I4xOkMQxgZqVjMsar2fAjKNO4R1Jb97ruodmPPMLJ7mxuStpsA9VW+3YHHTVKzaKva5/nscG+8BfO4xhk2PPxUGT1WoRu4zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KmmdSooXGWpO/T5ONgx0JQakMy2y4cSXwIusNyvvuYc=; b=trsexLMiBHKIYUgmVotpAfjryXDXpjvLMzHeGF1ZB3ePFIqeCiQKITTJGfJqJhl2owd/A3QL6fhHliZSbCDo5Pevc5QwfUlhkIN3YqYZfggSGTMJalGST374uRzF0pOcqUPNtkZMxaKlmR4bE/+UJhb1k44DwxWbftK3iVKbfn6Noq87Qswr2/Ke+8EGcuo2cFBTpFesAZFUyzzC5KTRFYK1/I0ffL6h+J/r5rG9h1yan3nNN02lCQuYOz/JkqU3mYShJ4byuyELsSUH8WlDNjdt0037VFZXD++N7FdRJyb7tM5dpwVRh729F6zeaG+wCTYArkaycsvj/VLuNhrC+g== Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by BN6PR12MB1650.namprd12.prod.outlook.com (2603:10b6:405:3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Fri, 3 Jun 2022 07:13:52 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::59cf:d090:5d26:6e7b]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::59cf:d090:5d26:6e7b%5]) with mapi id 15.20.5314.013; Fri, 3 Jun 2022 07:13:52 +0000 From: Alistair Popple To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alistair Popple Subject: [PATCH] mm/filemap.c: Update comments in filemap_fault() Date: Fri, 3 Jun 2022 17:12:33 +1000 Message-Id: <20220603071233.2296100-1-apopple@nvidia.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SJ0PR05CA0015.namprd05.prod.outlook.com (2603:10b6:a03:33b::20) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80bacc2b-efbe-47fb-9b2f-08da45309d42 X-MS-TrafficTypeDiagnostic: BN6PR12MB1650:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PGtmDsHhLJ9Um1Hq2SkN2py0c2ERWuw2v4chu1QAWg2j5ca3QuUtk5Wde06QtRAOq6WVqH90H+KhdeDCEnidX90CINlaWH2N+YfrhFVR2iZVIWzXf/8XD5Ize3nttkYW3L3poWeRmeFrWwASIa4uej8/AhsVGlCVVKgvvKmUCnK3yv90TbtJGF36E9Q8KglRkmZz7XA6jnIQzluBVdeA2xYDxtK9UpTsjwDWl64eSj2H4347dhUkZOyOR/MvrBgNtjg3vlouuGuCHHPoVdzv5sDUP186HGHYH12FykMfFDPmyVL/cpkNMTeX/xGfzLr2yP37aLxIJF63bAgdW7A+2rjIqrpvsp9IMPFV5W4V8F+DaSShGeQnIhmmgcE8SIbDLNeiSVobWr4MfPRmnahArwtXASbvENOepHKvQzgpuIUMbq9p9HtcYGsguFEnwPoVP+VHKZQfveUy6lq8FRk2Wj8q9N2LMnZsfzs1Afgh9uoTOA8/hqTj5G4qIUBre/0yrfjiD+sSNIJASTIYh50CDap4yxNwuagHZDyhQJDWDeQ/y2ymC5UbDbT8ZTN3O1kIHqrMBf7M908PfpKww7UTsEe/tWKLUpxyLhvqrYPAcASuHoWL5haWQoxKa+z07/VTgdUQh/IxFrHpl7f3cyGY9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(15650500001)(2906002)(186003)(6506007)(6916009)(316002)(8936002)(38100700002)(6666004)(6486002)(26005)(6512007)(5660300002)(83380400001)(86362001)(2616005)(508600001)(4326008)(66476007)(66946007)(36756003)(1076003)(66556008)(8676002)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +uXwU7h0et1KMCoS8RTSY5y0beAGpoGDiSFy088CIaNfg7jA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OblyciKzcziQG2EIXmkNB70KK4daJOs9QL3913ItM40+PArGMJanXBsZRJFVzfHc8r5X13aZMsGN4q3RRn0/sAptgb1z9Q3H6ZOdlF+eF+yUxSBFWiS9RnqlACydmUysth1swjvNoea3i3R2d46U7wtxAoxSOkn8SeOS3iqdJE5d8/wTxKl+PnFFyM5wB1+q/CBW/ZJ5g8XpBB+gqnf78u2psetZICh5gO8AYsZb9lvOxgC90hlZmDFDHkcbGSrM69fzCyDf7e400o3gwtyKGKd0Msa6gPxjwL/omHt6xI2oJmedQN+qlzUx4xrQYSC6/7dcAcMBYt6bmC4gs8o4ei6xr6TTF/Jvhr1JZfVv/mna56r/AfmaBK+bDul9FKOdw1uQdb3qGgjDRZ6vPi1zTQtjT5F4eoEt98S52Hgv6biHheeN/aC3Q0XziasPOqvct+fJoWALaNWqCcOsP0jky84nyN/E3EifYc5oCCwsrdsxyq/c1JR7AcFsW2bqFzH4aA7Bd+9WuxBwMC2f7BJYJ4WWfWJWt+OX7DrBGVOywIl+SoXDDvUD8N+agnyrk5CxbnEpHp5va81EeQXE3+sqV0xJfc7nQR+BJFpCUQoeYbLxWW6Q== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80bacc2b-efbe-47fb-9b2f-08da45309d42 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 07:13:52.7043 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gpLnp2VbW99zOqeyJgJEwB1CkIrNSdwQjJ7mnm9qBljLsejaw3c/e2eqJe4wsDtmX4gAButrGKY8vsJps3Ec7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1650 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 15A0B160047 X-Stat-Signature: mkgw8btxp4a5xah77rus7353ejrdpgss X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=trsexLMi; spf=none (imf08.hostedemail.com: domain of apopple@nvidia.com has no SPF policy when checking 40.107.237.86) smtp.mailfrom=apopple@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com X-HE-Tag: 1654240407-908293 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 code structure in filemap_fault() has evolved significantly since these comments were added making them out of date and slightly confusing. Update them to more accurately reflect the code. Signed-off-by: Alistair Popple --- The comments also suggest there is no performance concern in the page_not_uptodate path. This isn't entirely true, because this is a common path for MADV_RANDOM due to the lack of read-ahead/around. We always drop mmap_lock and retry when handling faults for !folio_test_uptodate(). Not dropping the lock resulted in a ~3-7% performance increase on a simple test on my local system. However we typically avoid holding mmap_lock during IO to reduce contention so not sure if changing that is worth pursuing or not? --- mm/filemap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 9a1eef6c5d35..407420ebd6dc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3168,8 +3168,9 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) VM_BUG_ON_FOLIO(!folio_contains(folio, index), folio); /* - * We have a locked page in the page cache, now we need to check - * that it's up-to-date. If not, it is going to be due to an error. + * We have a locked page in the page cache. Check that it's up-to-date. + * If not it is because there was no page in the page cache (only likely + * in the case of MADV_RANDOM) or due to error. */ if (unlikely(!folio_test_uptodate(folio))) { /* @@ -3214,10 +3215,9 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) page_not_uptodate: /* - * Umm, take care of errors if the page isn't up-to-date. - * Try to re-read it _once_. We do this synchronously, - * because there really aren't any performance issues here - * and we need to check for errors. + * Read in the page if it's not up-to-date. We have to do this + * synchronously so we can map the page to handle the fault or deal with + * errors. */ fpin = maybe_unlock_mmap_for_io(vmf, fpin); error = filemap_read_folio(file, mapping, folio);