Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2365888imm; Thu, 18 Oct 2018 13:26:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV61VHppwM2+olMuuFSKEH90EnhIFtURg1gZ6qEo8gKqHUhizgaI8Sef9EL99nEDmz7Qatb5E X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr32829578pfu.134.1539894370211; Thu, 18 Oct 2018 13:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539894370; cv=none; d=google.com; s=arc-20160816; b=PB8TxhRp0HXZ2ydm8ZwEefajHcdU9uYvroHY2axiwfMNVvW4sTZH6eptqkFBSgsZZb 10z99WDI6e4iWjWW1MSUkFzwVugClLEj2u6epzKwjJEvPairdWIEAcc38ZOtw+ByUvfc /PmY0GDyxDMMWQ+/kZ/YoiDNQbhAX1oNPmPVa/EpIcdhE0x+gSxkrOIp5iuzGNiJMbM6 Nz94WIwPFDeE5fkPYJp7xyQ3QAAHljoMvodtt8sFaSSAcnAgmTMw3Ix2XG3RmhajqHUs B0CudreAs3XGQsQCDQNVmxUb9bRKNWuNSyJUjjL4fFO3HQHWV+g18x/Nv2DrvZxuKvhr HZEw== 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=V/dTO3PAeiMDO7h1Ee0fBFc+ASMJ9qUW02OWB6+Q0qS63VT1c/XDuJ8GS4kLFrO0+a IxqFKFlxryLsuyfXWd7ZAKQw34mgvzf3keSKah9EmcvMWovlLPvxp8zX2hLcp1w0CoC/ ipcWfQmUeTyoz4nJkmEBFZisoEssXqRF12fBAvxuKkuPtob33qeQU2VdIgupmE5CmR+b DvFO1qul0BM7pPbHHIIzgHLdsVMW2QJ6FRUXWnfjRgCjyLmzUBARwmw0qEyfsYGs+mOx YnGHrJ1FE5L4wHay2CqGsfvfLttYmFa67zxE483tsMJAFSkQDUNcVuJmkGRymWa8mZHS jRnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=sYnIKpWZ; 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 p70-v6si7218071pgp.53.2018.10.18.13.25.54; Thu, 18 Oct 2018 13:26:10 -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=sYnIKpWZ; 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 S1727302AbeJSE0S (ORCPT + 99 others); Fri, 19 Oct 2018 00:26:18 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:34387 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbeJSE0R (ORCPT ); Fri, 19 Oct 2018 00:26:17 -0400 Received: by mail-qk1-f194.google.com with SMTP id p6-v6so19699522qkg.1 for ; Thu, 18 Oct 2018 13:23:36 -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=sYnIKpWZb0ethNv7ygrSHuJM9bQ6yfODonTwuNpvn0aI3FJoNvgjPlgWfQoMmpR9gd 7KRCq4lfipETSrHqyEqxuaddeM6zru6h3oAj8UJ5ykK1EBWDbIiAodZcibkyhUoAeBGy rD+gE3mR4nq06NrFz1vZrWP4WHOoRZjdK/HfW9puyW+5LilQXWGBL+cwUrZMBQBx5Dmb TaT/v+QFKp3TUaOn357uQhnB8TbIpUsCjB7mfJY97nZyBVWA317u1+V2sumi31QG+D3Q gNSmWotTbFD1mmUwlAeAibeuaiBJgKswHrw7ri/QJqkOO2D1moAu7/MGP0weNtMfSGzd YYNQ== 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=UrGiBGcf358fkbF2bt7Xh+yQvyxV//XzHWO/eVdyvAAsyVotlr+Gvvt6VEOujEl1Fw GLMlQNa6HR1krcU/8ogLFlfS2MubHV/Zmt4Yxs7AbbSddSRF/cp3chs0LUk2gHVUOb37 vLKfz8OdvRnuXDOPAmkl5eEg5ceM5pHE2Sw97IY7nmxgYrVkZaLX67/Rpsthee73il/b EuVCN6ah6nP2uya7JeuAPXNF5sYuu+/UxHSL87/h+3llXZGJujrIjyB4W2ccnvqQnBKX E4+3bcPi6y0IcoggqR4jqZUwp5Bf1CpKnSXE2Z6mz80ybQwp86WC/GV6nYsiCr10GsJx zuvA== X-Gm-Message-State: ABuFfohkPHFgBj1OXYb0NM8TqwCIiS+aNotGplx9XWUh9ZW5xtfubgxH 3vcii+JmTbMCuG610kmzwUdGSW1jcIQeug== X-Received: by 2002:a37:4dc5:: with SMTP id a188-v6mr30144112qkb.326.1539894216216; Thu, 18 Oct 2018 13:23:36 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id a13-v6sm13703972qkg.94.2018.10.18.13.23.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 13:23:35 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, david@fromorbit.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, riel@fb.com, linux-mm@kvack.org Subject: [PATCH 5/7] mm: add a flag to indicate we used a cached page Date: Thu, 18 Oct 2018 16:23:16 -0400 Message-Id: <20181018202318.9131-6-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181018202318.9131-1-josef@toxicpanda.com> References: <20181018202318.9131-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