Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2689905imm; Thu, 18 Oct 2018 20:34:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV63YuvDmb8zf/wqgJ9h7yvR4aqdW3kU2KW3L37ABKkIafkzjxfB0SlyoHklUAZRsLl2Mu8Cb X-Received: by 2002:a62:62c3:: with SMTP id w186-v6mr33196818pfb.5.1539920085069; Thu, 18 Oct 2018 20:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539920085; cv=none; d=google.com; s=arc-20160816; b=nKKSef53VFJYlxBC/MIrWxR5o/q3B+V6WlaieQHQRaFrxsf3495V8kTXorcVJIbVxt 63Q8xHOgu8G0GC3cYupiQl3nz5O3l5aA2n7Fex6zNpmq6ZAnf+Oo0DAItsIcpd5AyeEj hxB3PdBlEetvE3XyWYKJ/AeDvGnR+ZjzDcmyjGvyt0iQqNHSFvul7SZ7svu3WR6xFgtm 98YlGNQ/2OPDUeeMl2BEB+nwdpXuyBwh1F8fH/WOoN3NL2qWTtUIje3Dos2aZvuSqAX2 p+FNX73J3Z+e8zk6/gN98a62lJr1jP/G6UcCYkbcbKupqGSn+FoDJrmRmzqvy5V+q2u8 n/sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Or+vkhaGcDS5k4Y5osuy7SvfqjraWgp46xKH683ZvcY=; b=YC9sNmyYUju+FOkXMIC8HQizh9qhHsj8/a4LI7HLSfA2Uj/DB9m9LxPmPAYjX0sQ7l I0flmXOTAKnbAxWslrkhOOD9AJ82JyLxikUBp+lgrZOJu/En5GgYx76HDwJr2olJhUNt Me7NSU/w8DDwtsANUM9jahuMYl1L6qGV3lUGYa6pBMlJw4WG+3izNYgMfNq+YL9XrYj/ 9Pa0rI5pw/pQf9IZCrB/ATd6FMuPd/ujIeRfbfs8QlCw+wJIJHkqXmN0iP6PxrMs0GGV AKP5zAALtnmBMQo3dKNkTvpj0oOid8YpkZDruMtTOqWJW5v8+k5d4pax0LjcGx3hPO7f KVVw== ARC-Authentication-Results: i=1; mx.google.com; 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 m5-v6si21758225pgi.327.2018.10.18.20.34.28; Thu, 18 Oct 2018 20:34:45 -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; 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 S1726930AbeJSLiP (ORCPT + 99 others); Fri, 19 Oct 2018 07:38:15 -0400 Received: from ipmailnode02.adl6.internode.on.net ([150.101.137.148]:20058 "EHLO ipmailnode02.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbeJSLiP (ORCPT ); Fri, 19 Oct 2018 07:38:15 -0400 Received: from ppp59-167-129-252.static.internode.on.net (HELO dastard) ([59.167.129.252]) by ipmail02.adl6.internode.on.net with ESMTP; 19 Oct 2018 14:04:03 +1030 Received: from dave by dastard with local (Exim 4.80) (envelope-from ) id 1gDLY3-0006ar-00; Fri, 19 Oct 2018 14:34:03 +1100 Date: Fri, 19 Oct 2018 14:34:02 +1100 From: Dave Chinner To: Josef Bacik Cc: kernel-team@fb.com, hannes@cmpxchg.org, linux-kernel@vger.kernel.org, tj@kernel.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, riel@fb.com, linux-mm@kvack.org Subject: Re: [PATCH 5/7] mm: add a flag to indicate we used a cached page Message-ID: <20181019033402.GK18822@dastard> References: <20181018202318.9131-1-josef@toxicpanda.com> <20181018202318.9131-6-josef@toxicpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181018202318.9131-6-josef@toxicpanda.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 18, 2018 at 04:23:16PM -0400, Josef Bacik wrote: > 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; This is really saying the page has been initialised by a prior fault attempt, not that "we used a cached page". "cached page" is a horribly overloaded term - I suspect we should not overload it more, especially as the flag get cleared if the cached page is not up to date (i.e. the data on it hasn't been fully initialised). FAULT_FLAG_PAGE_INITIALISED? Cheers, Dave. -- Dave Chinner david@fromorbit.com