From patchwork Thu Oct 18 20:23:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10648105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33238112B for ; Thu, 18 Oct 2018 20:23:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2425428D8F for ; Thu, 18 Oct 2018 20:23:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1882528D94; Thu, 18 Oct 2018 20:23:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BFB928D8F for ; Thu, 18 Oct 2018 20:23:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A671D6B0010; Thu, 18 Oct 2018 16:23:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9BF9B6B0266; Thu, 18 Oct 2018 16:23:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 815086B0269; Thu, 18 Oct 2018 16:23:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 5529E6B0010 for ; Thu, 18 Oct 2018 16:23:37 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id k3-v6so2122188qta.23 for ; Thu, 18 Oct 2018 13:23:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:subject:date:message-id :in-reply-to:references; bh=rRSaxONrZWxSfcObSyXaZynV5IrpMUJ0BUHUIDN5YaE=; b=e9P6yHgDFsL8v0q4Qeq0u4ka9JGIYDJ2I13WtDi9OWiyLQ9DhFoM/RCtz5LO+nQG1B TGSUjU1cY8qe9DHSXvGknFZBBfaVwkZgfdJQ2DtA8IKaRS3rn2iMh0LUQLc5Pr/FCpjR 3zrwKnH1ZgdJy0jgWUjijjuObOYjD4OsoUtQy0tG0073wN1y9hr+GYW5fGfyIrZ3KsLJ 5fjKfI7db29eEkeIZSDsgaldJiqYM9MgU7HNOOyKWE+MfDYG/OSt69pNpBePTOvrdPbt w72jSMp6XK4L5MCF+dc+YzgFYxKVJ4FaBBwgk+Jzu1VnV8tEEA/ENktFJI0tkh+bUF5a +1cw== X-Gm-Message-State: ABuFfoi/iH+7MWoDICxe2V17I+UUbefnvkIdBS0+ZrybF1I3RyIvDZ7G Vnmb8JqBF3JZ2TvBzOZCw6GrdtPbo0VG/MCsH5a/buH4hL8BBGCRGmIVgNnTleFDm3viTVzMagj UscV+8T/9o6g87guQ7siycWXmVXGiOZ6MfQfG1TW9Kgb2bj9uBP99D5fuQDWoVq5Z7Tx9MRW2ca 5Wvam105RhN7wEuwA5MnePSphBBToHI+4Rp6uK0iWB6GbsH0m5GHmFwLgNNPOLLZCaY29iWQakj QuSuGTGPH67tMWyuLxc3lH1lq0WX3dB+X+rxaOqKbTbGyzPu0mq2LagYe6N9N+dwtibRXQ/N3fv mFgsACDBWgdCIy8A2EOMKFpMIp8XxgDy2SHnio7YdqmlPt/cMprN4Xkfz1Fj0pRrcRc/MZ3TvMx z X-Received: by 2002:ae9:de46:: with SMTP id s67-v6mr3649823qkf.257.1539894217113; Thu, 18 Oct 2018 13:23:37 -0700 (PDT) X-Received: by 2002:ae9:de46:: with SMTP id s67-v6mr3649791qkf.257.1539894216481; Thu, 18 Oct 2018 13:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539894216; cv=none; d=google.com; s=arc-20160816; b=J6eqdVZUCh3/SuKNdKv1DXZJuEGAt/i5iNB+R05MWLRFRwSl5n2p25lpJK073QT30L 5upH6CZkqeCOA8NrzgNXnqxz9gFVSXJ4RMCdt449bsV/4iFKq4e9zKqKEymvUBvyq23L q4vU8pFFPNX/+lJ6II+9nowdx+oRGuwn0G8e4sGUnJBcU671+qLCQVND5gjazRK3a7TT zBQWq5Xrlccs8YiRZ7kL79cEdxl9C3meM+A1FU9dn7IXMo6BKu2RdXMCBnp8ZH1RMyj2 lu/0hdNP1taZfPJzX2Bapas1yHtqlX9nPaoAGHfEx5l/wEUWZmBFHLp+rfG0COIFsjY8 re+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rRSaxONrZWxSfcObSyXaZynV5IrpMUJ0BUHUIDN5YaE=; b=OCbXfuNBiuOxdgreyuyo09tsgzNzSO4LwA7tIjCv70yFZR0DrSD0RM2R7mfMXrk6oX gLMmYDMiJp2UzpNb5BC7nnwDmRlbvz8fLNr4zyZtkalH4M1g54mOxRmA2PMQq7WJpNwR 3zcZz+V+YG/5QP1rBoQaBqIcBekWI6Z1w3YPfbDSndy4kIDjhnFJxxdg3WtqmcM73IDu HNYaEcoATT6AMVlc8mQ4fFx4QHFSVOizY/RtcVcK/xmFj3/Rv5MPHuwYVD4d1xC6eQE2 ucZvwc956uIiQaQO41yOGKXzVCSq0o5KQnmUvhHCoJEHM5Lp7AATB1WmNuUox6cIJBVN 3b6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=sYnIKpWZ; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u75-v6sor3451743qku.16.2018.10.18.13.23.36 for (Google Transport Security); Thu, 18 Oct 2018 13:23:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=sYnIKpWZ; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of josef@toxicpanda.com) smtp.mailfrom=josef@toxicpanda.com 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-Smtp-Source: ACcGV62G7ya4wMwJkdmFy96WMrqdf+XZFz2cKbWI2in4JRemu28Kc13+O7n5qHte247QRx/a8tgXUA== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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.