Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1237025imm; Wed, 26 Sep 2018 14:10:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZIeqxzrPafbm+xr6UGv71tRMDiqA3PRZuV3qJ9c2W4ik0OTAXqu7O2DIYzwtdVkf09zFA X-Received: by 2002:a17:902:9302:: with SMTP id bc2-v6mr7851172plb.280.1537996206549; Wed, 26 Sep 2018 14:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537996206; cv=none; d=google.com; s=arc-20160816; b=rP0SfGU4zFwUe54wIsmp3f1zHZWilVciLobShChvAygOAkggG9CmMYEug9aVIZ0KTZ 5Qgf43r2J2hy73GhbwSN2JWNTQa2r7t1XvbevZ1hY8d+l2XZ7aCywe7yYbvlbED3aCFD HbaE8TFWBkyZzoz8XntaKiM7KraG8mEB+1zySvFCJ27oQ7ExpzzXz7M1WW2wdakl6t3i 6+MNmDuyJbBigrbxYOPHyu5T0u09h/KOf/xa1cRqwT7euuLWGeXeUbBX1gLjDFD8zZcB k95N8FW4DVnje0NC3AmRxpH23jHnZ+1Yzd8GyjJXDUQ3smlVxz9AzgIlJIOV9TSJuejG Uudw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature; bh=rRSaxONrZWxSfcObSyXaZynV5IrpMUJ0BUHUIDN5YaE=; b=QCxdzrtXVL2gdfcPf1ymoWx44uMYP3wjCUy1Rwm8kcOTcTi6Is0EcRAy9ZBRvvZ8Ow UDxrnOH0m6Udgxvx7Z8DIdbZfiRUgg+3ldXCu1LllPh6zXssassWN5J1lR6ZglR6UBEP jhLcONUZpqBou6yNLGufRL4S9XgDOSGfLUHME4Zo0fk4XUk01IQrbjZkBnqtQss1YWX1 Cl8XHP9LYoA+hafHohHJQ0OIZ0YRjQBaQKr4wOmdojkHGtloGmYFZkotYzcPCBd/lO7h zECDjHg8wEop4sCtiwDrt9dliN/UzfdKuqk9fFowmo09GUP0Vi3/ZrvgdxEi2lnAZ98V edQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=cMCnruOr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb8-v6si70486plb.178.2018.09.26.14.09.51; Wed, 26 Sep 2018 14:10:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=cMCnruOr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbeI0DYD (ORCPT + 99 others); Wed, 26 Sep 2018 23:24:03 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:39633 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727296AbeI0DYC (ORCPT ); Wed, 26 Sep 2018 23:24:02 -0400 Received: by mail-qt1-f194.google.com with SMTP id c25-v6so493542qtp.6 for ; Wed, 26 Sep 2018 14:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=rRSaxONrZWxSfcObSyXaZynV5IrpMUJ0BUHUIDN5YaE=; b=cMCnruOrfxbswXpQ+LzDNW4YBVLUWDQs7bq7X5QQbmFe7IBXo+BpnpXZ5nYL+NtYUu UmQOdRfXvT1X04/qw5qRpxkrQHPA9jdosXRIjLUl63CsIpykwMRlwwk/l9e21291y+Il RTMGa1o+lcurVhm+IrAgprHHyRMmR9Q34XHI1p9+jyEySWWfd0/sGQRtQ0sm1r1/OTYR Jn4qDuTHXr1vCpWOEV5xBltDo+2f4ntWFKOsFfmgVmZN08cvjpw0dJcEIgDceEBJqAxt /zQ0Z7X8q4v+RVYpOm8Cnq8jVqw7E/fQDxH+bhVROQZiPF3i35ff81yOhbZzjGw05Nmr vLBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=rRSaxONrZWxSfcObSyXaZynV5IrpMUJ0BUHUIDN5YaE=; b=lUzCXwyVAzyMw8ps8QuWu2j7CLFdyHMVLt0EY53BOD6D15zbGxT+atYcmbC+ihUB7z ODpwC1+bQIkCqSH1U9m3aTIOiNjrH0F70BhYN3rSFX3wp+gEsAdAW6KBqi5cgmWxm/gL OLE9H5Xy/P1YyhNv+xaWfUaHp0L5kk06BLLioR1Ckw1Ng7TWye2/cEiqG2/FnGrQ47D7 RWWMroNeUD/x2Lf2/5LgrA94AnYb5nYBu5sFDsWScymiLYK7Ummwp+Is5I7lDez5bdD8 oqDFO74h6/Kw/KFcdQNetxmnjHl1XSO5/NNWhdV9CYGRBQMKm3+/No9ZqvWCWV4BV5aT WZEg== X-Gm-Message-State: ABuFfoji0qJq/8kkiKu1LlaqBUzoVxCVDlHXbcCLVKpOHZSLMZKQCw+j eO0Biu8X+KUXWbpKRsVqmVLJ+g== X-Received: by 2002:ac8:2a81:: with SMTP id b1-v6mr6223154qta.286.1537996151881; Wed, 26 Sep 2018 14:09:11 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id u3-v6sm59038qku.46.2018.09.26.14.09.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 14:09:10 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, tj@kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, riel@redhat.com, linux-mm@kvack.org, linux-btrfs@vger.kernel.org Subject: [PATCH 7/9] mm: add a flag to indicate we used a cached page Date: Wed, 26 Sep 2018 17:08:54 -0400 Message-Id: <20180926210856.7895-8-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180926210856.7895-1-josef@toxicpanda.com> References: <20180926210856.7895-1-josef@toxicpanda.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is preparation for dropping the mmap_sem in page_mkwrite. We need to know if we used our cached page so we can be sure it is the page we already did the page_mkwrite stuff on so we don't have to redo all of that work. Signed-off-by: Josef Bacik --- include/linux/mm.h | 6 +++++- mm/filemap.c | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 4a84ec976dfc..a7305d193c71 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -318,6 +318,9 @@ extern pgprot_t protection_map[16]; #define FAULT_FLAG_USER 0x40 /* The fault originated in userspace */ #define FAULT_FLAG_REMOTE 0x80 /* faulting for non current tsk/mm */ #define FAULT_FLAG_INSTRUCTION 0x100 /* The fault was during an instruction fetch */ +#define FAULT_FLAG_USED_CACHED 0x200 /* Our vmf->page was from a previous + * loop through the fault handler. + */ #define FAULT_FLAG_TRACE \ { FAULT_FLAG_WRITE, "WRITE" }, \ @@ -328,7 +331,8 @@ extern pgprot_t protection_map[16]; { FAULT_FLAG_TRIED, "TRIED" }, \ { FAULT_FLAG_USER, "USER" }, \ { FAULT_FLAG_REMOTE, "REMOTE" }, \ - { FAULT_FLAG_INSTRUCTION, "INSTRUCTION" } + { FAULT_FLAG_INSTRUCTION, "INSTRUCTION" }, \ + { FAULT_FLAG_USED_CACHED, "USED_CACHED" } /* * vm_fault is filled by the the pagefault handler and passed to the vma's diff --git a/mm/filemap.c b/mm/filemap.c index 5212ab637832..e9cb44bd35aa 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2556,6 +2556,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) if (cached_page->mapping == mapping && cached_page->index == offset) { page = cached_page; + vmf->flags |= FAULT_FLAG_USED_CACHED; goto have_cached_page; } unlock_page(cached_page); @@ -2619,8 +2620,10 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) * 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. */ - if (unlikely(!PageUptodate(page))) + if (unlikely(!PageUptodate(page))) { + vmf->flags &= ~(FAULT_FLAG_USED_CACHED); goto page_not_uptodate; + } /* * Found the page and have a reference on it. -- 2.14.3