From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99C9FC433E6 for ; Mon, 11 Jan 2021 14:26:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51DD9224B8 for ; Mon, 11 Jan 2021 14:26:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51DD9224B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DBF038D0032; Mon, 11 Jan 2021 09:26:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D94B28D0020; Mon, 11 Jan 2021 09:26:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAB108D0032; Mon, 11 Jan 2021 09:26:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id B58318D0020 for ; Mon, 11 Jan 2021 09:26:18 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 783A08245571 for ; Mon, 11 Jan 2021 14:26:18 +0000 (UTC) X-FDA: 77693719236.05.show33_561089c2750d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 621061802384F for ; Mon, 11 Jan 2021 14:26:18 +0000 (UTC) X-HE-Tag: show33_561089c2750d X-Filterd-Recvd-Size: 6572 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 Jan 2021 14:26:17 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id o19so38023786lfo.1 for ; Mon, 11 Jan 2021 06:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2Wa64N9rKhiG4UX9+YL6rV9eAtcd0ImwLw/TptbB5+Q=; b=qNsmEhZyVZLbqgWDWINYkkfG9Cmi5BiqsV1Al4c3KyHP5k0etJm8k0HJ8TCn7wjroU leBlRiSBoub4EqHQgUmU1bCMGKDNFDpuZecOM0wyk0mgkcBZulabztQ6gO6cpU6q/a06 zXpj5X5jQ2xA5mToEoM39yWBN0RB3+75gDLYohCcySvfiRT1j7KAKVrqeS0AapV+Px8M F0pFCYT+BZ5BgAan9q0RQYoXkpv3EAXnr2xQXqicBkjkllVoTw7dhsEBR5PGNc7GhxBn MWWnzEPStM8WgMyniRU41it68RQCCLbo91MXzBowZZbYiBb8ZUwgH019Mo7NFi2bWJgy McZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2Wa64N9rKhiG4UX9+YL6rV9eAtcd0ImwLw/TptbB5+Q=; b=HUksGWIFPrPCET4hKzA5arlcGfR1uY6EDn6n5fgmkjZdq+BHpPAeO6ifgr4sO0112d 81rWMOqjYwt/weDl7MWVHXQj5MaMn75NKtukYpjIbJ061K37CSSUIUTUNSBM0p/7v12P CvjmN6+or93uBJUTZvbqoHNaszhA/5JRdJeLbtlvvaWUGw2PZNij8MhU/QKDlZxKo42C fEHbHzaRTxp/kSj5FoccrwsNq5kTMixP/yzF3Yzd3dhyeYu4xNw2Q+x3jsYzGFRfTXwk HBVlUjn3ZaZ3qi9S4Im5y3tHC3FTtoph4xEoTepQvno87CfZnmuKAP8KJVTiiOLNag/d 81hA== X-Gm-Message-State: AOAM5316Txsi3JfKT37WfLUH91kcM6bPXrsnxtglCy97eNWh+UyM8sAI lm2UrRJOE+D5zDitDwEj8aFQZw== X-Google-Smtp-Source: ABdhPJyxuUfU2jBl8PcZXYeP9AlpPuGom3UdW8sC6/coPQEifEFV7KfYWvsRIYVhoy6xkPhja+Nlbg== X-Received: by 2002:ac2:4463:: with SMTP id y3mr6964845lfl.94.1610375176210; Mon, 11 Jan 2021 06:26:16 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id b31sm640363ljf.38.2021.01.11.06.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 06:26:15 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 927C1102238; Mon, 11 Jan 2021 17:26:20 +0300 (+03) Date: Mon, 11 Jan 2021 17:26:20 +0300 From: "Kirill A. Shutemov" To: Will Deacon Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Jan Kara , Minchan Kim , Andrew Morton , "Kirill A . Shutemov" , Linus Torvalds , Vinayak Menon , Hugh Dickins , kernel-team@android.com Subject: Re: [PATCH v2 1/3] mm: Cleanup faultaround and finish_fault() codepaths Message-ID: <20210111142620.ylv3ccrsubef62mi@box> References: <20210108171517.5290-1-will@kernel.org> <20210108171517.5290-2-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210108171517.5290-2-will@kernel.org> 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: On Fri, Jan 08, 2021 at 05:15:15PM +0000, Will Deacon wrote: > From: "Kirill A. Shutemov" > > alloc_set_pte() has two users with different requirements: in the > faultaround code, it called from an atomic context and PTE page table > has to be preallocated. finish_fault() can sleep and allocate page table > as needed. > > PTL locking rules are also strange, hard to follow and overkill for > finish_fault(). > > Let's untangle the mess. alloc_set_pte() has gone now. All locking is > explicit. > > The price is some code duplication to handle huge pages in faultaround > path, but it should be fine, having overall improvement in readability. > > Signed-off-by: Kirill A. Shutemov > Signed-off-by: Will Deacon > --- > fs/xfs/xfs_file.c | 6 +- > include/linux/mm.h | 12 ++- > include/linux/pgtable.h | 11 +++ > mm/filemap.c | 177 ++++++++++++++++++++++++++--------- > mm/memory.c | 199 ++++++++++++---------------------------- > 5 files changed, 213 insertions(+), 192 deletions(-) > > diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c > index 5b0f93f73837..111fe73bb8a7 100644 > --- a/fs/xfs/xfs_file.c > +++ b/fs/xfs/xfs_file.c > @@ -1319,17 +1319,19 @@ xfs_filemap_pfn_mkwrite( > return __xfs_filemap_fault(vmf, PE_SIZE_PTE, true); > } > > -static void > +static vm_fault_t > xfs_filemap_map_pages( > struct vm_fault *vmf, > pgoff_t start_pgoff, > pgoff_t end_pgoff) > { > struct inode *inode = file_inode(vmf->vma->vm_file); > + vm_fault_t ret; > > xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); > - filemap_map_pages(vmf, start_pgoff, end_pgoff); > + ret = filemap_map_pages(vmf, start_pgoff, end_pgoff); > xfs_iunlock(XFS_I(inode), XFS_MMAPLOCK_SHARED); > + return ret; > } > > static const struct vm_operations_struct xfs_file_vm_ops = { > diff --git a/include/linux/mm.h b/include/linux/mm.h > index ecdf8a8cd6ae..801dd99f733c 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -542,8 +542,8 @@ struct vm_fault { > * is not NULL, otherwise pmd. > */ > pgtable_t prealloc_pte; /* Pre-allocated pte page table. > - * vm_ops->map_pages() calls > - * alloc_set_pte() from atomic context. > + * vm_ops->map_pages() sets up a page > + * table from from atomic context. > * do_fault_around() pre-allocates > * page table to avoid allocation from > * atomic context. The typo Matthew has pointed out: diff --git a/include/linux/mm.h b/include/linux/mm.h index d3d4e307fa09..358fc8616d8b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -535,7 +535,7 @@ struct vm_fault { */ pgtable_t prealloc_pte; /* Pre-allocated pte page table. * vm_ops->map_pages() sets up a page - * table from from atomic context. + * table from atomic context. * do_fault_around() pre-allocates * page table to avoid allocation from * atomic context. -- Kirill A. Shutemov