Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp723589pxf; Wed, 7 Apr 2021 09:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx39UfOyxbQCycsJdThp79I7rKZ1Uby9v2IpKh8kgOndmeK6Ph1J8LKuBmGr7atgqo7/JrP X-Received: by 2002:a17:906:8a65:: with SMTP id hy5mr4940491ejc.250.1617814767317; Wed, 07 Apr 2021 09:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617814767; cv=none; d=google.com; s=arc-20160816; b=VJMsW03VWDfv9398ieraANtvndQi/za3u9btulLaNaSkeOef8CPIPHIFmqkl5lZ0AJ iiHQuSdH41iSV1cwzObd5WqSNhcc3ogozKOqxV4ErlPdjRY0XvcPKyojslS/UTcqTIO3 dfqSq62p1244Zcu99n2IZk97xoCc+4lDtj8zX3b9OAsSz7eqgu2cHPd2BGWqKMxYHLZ2 tqKFI1alwQPU84Em/YYjc5vn1LUMimKDb3/X/3+6JzRmZPbVlbRs0nFGvw3pH1JzXwft VQjvdJR01QheyjEQP9jwrrX/d2GQ7sBjeDytP+UeLhN/fml8BhIsLbD5BTwDrHlbNr8k JQkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=ju1TjADkBaEpCEmd9Uqz5VcWNno1/6nZtl53IX9hdVk=; b=Mk597yMo4CfVPoT4QAFzEnx0UpizTzvupyvFfSxlhXqXioWz2tT4DhE8JFZO3yJDYg uTB2EfHLrYAWtedkWtXOmkY/VTq11MDrZq1G50ctrGB9mye8ulz62QVBhMyXpwTKd214 1cYFVNya0BZ0jYzqwxpNbWv127GUi42x94EpcZY7Q60XGQxzLb4gMkrV4ZWPI+kMxvGK rnKRvi8RSGBE+KfggO/6mRAvTJbtNHOFd4Vx2RRAeTGQxn5UAeF8hIayNdR8wFbULuj2 MeCMj0W6V3xGkcNvjGmkUqFnH7bqv5BPnXtauN36icbzvLVFBe1TM8Z6oC7Txj3lHTkl eLGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-11-ed header.b="/HgvOzN+"; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b=Rcx14jUF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si18654552edd.185.2021.04.07.09.59.04; Wed, 07 Apr 2021 09:59:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org header.s=srv-11-ed header.b="/HgvOzN+"; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-11-rsa header.b=Rcx14jUF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343900AbhDGBx2 (ORCPT + 99 others); Tue, 6 Apr 2021 21:53:28 -0400 Received: from server.lespinasse.org ([63.205.204.226]:50997 "EHLO server.lespinasse.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347841AbhDGBvx (ORCPT ); Tue, 6 Apr 2021 21:51:53 -0400 DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-ed; t=1617759903; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=ju1TjADkBaEpCEmd9Uqz5VcWNno1/6nZtl53IX9hdVk=; b=/HgvOzN+4gZlXg2dAh/dfK0OJzmp3nnbAfpOyKVZoxCdy/rO8VsbHIDa7Q1uVsUm7LtGD bvH0KxRDERX19z8BQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-11-rsa; t=1617759903; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=ju1TjADkBaEpCEmd9Uqz5VcWNno1/6nZtl53IX9hdVk=; b=Rcx14jUFCUpobMRsi8OfvXrqjWZOos2yAkHdBv79ZVxOdRacMFpS8AsU3XbW3uHcixZB0 /TCi7hSxf0Z6Nynm7jE5MjAn5NeNb1Gn/QZTRkp0ETZkiK1cXV4QS0m13vSMNRHM11eblxb fSh42ACDbmP4crGwYQmmZGl0TyO87HVPSbgMucCnANko0TsXp7XbIRZ3sNlx2q7DSpjk7It 9dUw6OVWwxnTC5OfRNzODM+M75isQYJRrL/a1oFedkln0KPu80bmhZro68EOOo0NyCF3V+t PBGZA0rAdIUXBGvMRZAqO246iJzXzfXJhxoSZCEnQRoaI+mhig14LMymHUZQ== Received: from zeus.lespinasse.org (zeus.lespinasse.org [IPv6:fd00::150:0]) by server.lespinasse.org (Postfix) with ESMTPS id 5048116064D; Tue, 6 Apr 2021 18:45:03 -0700 (PDT) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 42E6D19F31E; Tue, 6 Apr 2021 18:45:03 -0700 (PDT) From: Michel Lespinasse To: Linux-MM Cc: Laurent Dufour , Peter Zijlstra , Michal Hocko , Matthew Wilcox , Rik van Riel , Paul McKenney , Andrew Morton , Suren Baghdasaryan , Joel Fernandes , Rom Lemarchand , Linux-Kernel , Michel Lespinasse Subject: [RFC PATCH 32/37] f2fs: implement speculative fault handling Date: Tue, 6 Apr 2021 18:44:57 -0700 Message-Id: <20210407014502.24091-33-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210407014502.24091-1-michel@lespinasse.org> References: <20210407014502.24091-1-michel@lespinasse.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We just need to make sure f2fs_filemap_fault() doesn't block in the speculative case as it is called with an rcu read lock held. Signed-off-by: Michel Lespinasse --- fs/f2fs/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index d26ff2ae3f5e..c1cfdc3ec98e 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -37,7 +37,12 @@ static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf) struct inode *inode = file_inode(vmf->vma->vm_file); vm_fault_t ret; - down_read(&F2FS_I(inode)->i_mmap_sem); + if (vmf->flags & FAULT_FLAG_SPECULATIVE) { + if (!down_read_trylock(&F2FS_I(inode)->i_mmap_sem)) + return VM_FAULT_RETRY; + } else { + down_read(&F2FS_I(inode)->i_mmap_sem); + } ret = filemap_fault(vmf); up_read(&F2FS_I(inode)->i_mmap_sem); @@ -171,6 +176,7 @@ static const struct vm_operations_struct f2fs_file_vm_ops = { .fault = f2fs_filemap_fault, .map_pages = filemap_map_pages, .page_mkwrite = f2fs_vm_page_mkwrite, + .speculative = true, }; static int get_parent_ino(struct inode *inode, nid_t *pino) -- 2.20.1