Received: by 2002:a4a:301c:0:0:0:0:0 with SMTP id q28-v6csp1122935oof; Tue, 25 Sep 2018 08:32:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62TbWL6pG8My8aPwT8Ttgt0HQ2z/TqBu8C/NYjCETx9G6vzcRKwxBeaiEzIl2pTD5FZWDTI X-Received: by 2002:aa7:88d3:: with SMTP id p19-v6mr1748181pfo.160.1537889563941; Tue, 25 Sep 2018 08:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537889563; cv=none; d=google.com; s=arc-20160816; b=QM0OK/xT5q7Mf8tG5udz3VFf6MAw8tHjKLwNuOqH82R/CpdPFLqJnZICD95TGrUW0M tIi9ACjmr8vVOV98hy8rGOFx5wHKkUI15pnxuEnOmcfucAyevVzo8wxXElfcpIOGQU7Y nq4Rm9sKbtEFSGJ1EwKpXBn+VwRBtOwA4TOxfrR/in3P51jCGcmQ7gjxnHaGRHZqYQnq fd89/aXQ5Vwz0tlT4qaj4YP+TOwY+dtqewhR8KDxdjpSz6/7etsYnPaQwhfUyh0t2y+6 uVJ+NZPXWuOIdjYVOwDoVNmoVX5DSjOwjuHoPYj6JQTfAvWPW4LFoU2XtP/j3sbo5StF thmg== 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=ku7/MRL/ppjtTHGZe2O1XF901LokT9maZEyU9FpjnHE=; b=U1VxDdBpJz9+C4Nxg1O5kuCSpO832kfsxkTUCFAdwlz8QVEl8E5UAL1RqsnVndQgY9 pliFC1Ka0QM/n1qsS/aS9Ey8WUgmRw/XWDwhkkku1Ahx4Gz3mwTPZZqna53ydB0wrFW7 4ZVKWAlUUXx+SZK8Vs9F/mpHJxHOvQuPdgv7W5wWHPVxsrxqRr4PEmVksyFziAFlndwN kXs4RCh+IIq4QtXjjBUEg/Bwi9AdQqrPwhFWftLiHd1nYBbwoW+H3oiPKauZHb4G9oR3 4xXWDeOmRXsm6lvCk7sp9abRTdZxS6ZxdPq5OVmTwPj39P2txZWsM7Fh53pKJzJFETM8 0m9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=QENpwOrr; 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 e37-v6si2695185plb.313.2018.09.25.08.32.28; Tue, 25 Sep 2018 08:32:43 -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=QENpwOrr; 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 S1729890AbeIYVia (ORCPT + 99 others); Tue, 25 Sep 2018 17:38:30 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:36300 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729861AbeIYVi3 (ORCPT ); Tue, 25 Sep 2018 17:38:29 -0400 Received: by mail-qt1-f194.google.com with SMTP id e26-v6so1627439qtq.3 for ; Tue, 25 Sep 2018 08:30:27 -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=ku7/MRL/ppjtTHGZe2O1XF901LokT9maZEyU9FpjnHE=; b=QENpwOrr/7ZhS366ZP7w913/Hs2ElSqyKva/3kYfiaWk0+nhF6n+0Oa0FNzB+IV9Ye w8PDsT3mG1ZBqJSQto0v1fNNqZiiuYsf8CdazEuwY8dEGoeye7fn2Mkgzrzd1pmXKusw ihZdiUq10sVQ4cocO/MxEM+S/6DBh0Z4tjeMK4z44d/zCWr8qs0/nJDyXikVoXRDdTDk mtZ+7pr6nbyNre5aGEML/ZNBB8ndkk8vZSu7Mhd0VOqKcMyDsa5hBcEYJLYdoh4dLmog MdEJGU9LhxBcsHxVKFbrTgk52uT33H2FKS0kYhrbYjBC841r9NXAD4ZgSSGqzActbwAG 2dfw== 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=ku7/MRL/ppjtTHGZe2O1XF901LokT9maZEyU9FpjnHE=; b=Ij+KOY+BwJyJlmfA3FDdI1lxi1Nqvewd9xBQe9aW6XcU/6U+C1CpIt25+3c9xGLZtj LdSSqIFYSt1XLieN1Hs82EShtjTEoUkK1vS+QK9xT68wQtBR8XF+aZalKmKBxc55on98 ObBy4GEG+NY/3aeesHh0E5Ynj/rLLmUB1ss8sJUsVQCbai7N2DLC/rb0QY3aUANarBS8 YCjEktxK6I+192f/ytnSqvolPx3Y3MMUZ9gXu8d/4BAdYPRfjWan+SBVLRHoLrne93gM KOl/sucHCvVQZC/GSPnSqwR3PRRgGDUUiGQTCiaCVGRnK0NevoGSrI0aO77HitRDQk2c pflw== X-Gm-Message-State: ABuFfoiTbsDKDSz3PqOwltQLtaOBbZcrEP2vdGhPJQ0KcjjVYSUZw2CC 5seSyiJS58pTugACgT2HhF9YNg== X-Received: by 2002:a0c:93c1:: with SMTP id g1-v6mr1226748qvg.136.1537889427517; Tue, 25 Sep 2018 08:30:27 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id l16-v6sm1642913qtk.30.2018.09.25.08.30.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Sep 2018 08:30:26 -0700 (PDT) From: Josef Bacik To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-btrfs@vger.kernel.org, riel@redhat.com, hannes@cmpxchg.org, tj@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 7/8] mm: add a flag to indicate we used a cached page Date: Tue, 25 Sep 2018 11:30:10 -0400 Message-Id: <20180925153011.15311-8-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180925153011.15311-1-josef@toxicpanda.com> References: <20180925153011.15311-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 724514be03b2..10a0118f5485 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 49b35293fa95..75a8b252814a 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); @@ -2618,8 +2619,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