From patchwork Thu Nov 22 21:32:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10694871 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 600AC13BB for ; Thu, 22 Nov 2018 21:32:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 513A52C770 for ; Thu, 22 Nov 2018 21:32:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44EA12CE23; Thu, 22 Nov 2018 21:32:39 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 DB8732C770 for ; Thu, 22 Nov 2018 21:32:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2061A6B2D69; Thu, 22 Nov 2018 16:32:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1B8666B2D6A; Thu, 22 Nov 2018 16:32:37 -0500 (EST) 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 0577B6B2D6B; Thu, 22 Nov 2018 16:32:36 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id B48E36B2D69 for ; Thu, 22 Nov 2018 16:32:36 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id o17so3159730pgi.14 for ; Thu, 22 Nov 2018 13:32:36 -0800 (PST) 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:cc:subject:date :message-id:in-reply-to:references; bh=21pgTH4nPwYMtfybAiOSoRz5R27AR1FrdXTO1XlQXYY=; b=G8RNQxBfonY62ZqP5LHqX++llPff7NfQ40gjETlaw0Qn+zdLpy+9UgL4DA5oy19aKP K77wEfWhhKTaHQKUumwinxPKtcFahMRsZtxkuVPLoI5L5QZR+wpRzQDz22wVz6BnLmR7 tps+OixkUc2WspkRDZ1fiRbt53ASe9VkhGrwpJvMKtsdIejgkY+Er6Tot8ian8eVkA8w Rj/yb2e0pL+piWHE8M2u0EjQYK05tJ2nAIaHMIEJtTemXvjZHYnNXryCHrh23/3eCSQb yiBBzboNouxb6wlBly7KwfE/6D7HRGpy7FLyXBpiYDw7KYmT6DNW3U+pubFNAB59rLDZ 9+/g== X-Gm-Message-State: AA+aEWb+L73j4yoEAW/HMQhpQnjCKdVxK6EFjCRC5d/YVP1pyrAF7B9p P9kgcKap9kSkvXQ+JLc/2QLN87IKOOYTaj6WCY9KWM+l/ju/MMr7gYBcsXwpAGWT95HoMWPFsEM bvhohIfHg/VRjOccORq51+zJLOR+5WuKqXktmfn4ui+tpL1RJnzAAf0AWgu120xzqfg== X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr13137295plb.17.1542922356418; Thu, 22 Nov 2018 13:32:36 -0800 (PST) X-Google-Smtp-Source: AFSGD/Udk8mL4s9BJD6+JwIUXSeRUkpp5X9XXWFlzI0iTHXtv0LITKvDFdgOMdvfbo/Emws5T4xj X-Received: by 2002:a17:902:930b:: with SMTP id bc11mr13137261plb.17.1542922355741; Thu, 22 Nov 2018 13:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542922355; cv=none; d=google.com; s=arc-20160816; b=Io5CrqPtTEn1E1YRmwsIKBdSdkp+W6uPPcvtfwIlvl6mRDeFSXfsNXsgyuIjvYZrnn 4UZL0xIYRl0XcGKq402S8AW2P8sboyYVDj5/d+Ch271MDGs6ITskDkrr5ykv6RmRQ9e4 eQ0bb58B5uDWAf5bBEyGcufnQg2I8msNxyIreBnLDhQdlKP+SIzN5rEC+CiPjewEwzey WZR9GVfryoXbKIblyZq+D4z+OttyqgQYiYsb45zIIk7/cb7Dko6IIfXIoYZN0xlCIHpz IZQBNBAieHSuFZOoTuF1l9ZzL4FvJTGDeNKsxlbhwRWBx5AyYa9+5lcpLxx+4ZfIUclD S62w== 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:cc:to:from :dkim-signature; bh=21pgTH4nPwYMtfybAiOSoRz5R27AR1FrdXTO1XlQXYY=; b=yy7X9ShOi9QaqUnqRgwx4LwaiGU6BUYuuykHVnw9YR6Pw//CiyLT4J8aVdqn1o9RIj RNX55qtHsFuHY0ZBegCl9ck4Z9pTsvUGJ4TDJs/3W98yp3eqTLHu/4tJdxZKErEmCmUq p3T12bulRVGPe0z7MizKQzFCIUzAx6oD/cztkNQcxj3jNvOgWq6J3HcUToTqPjvi/59/ 1p8ePGBkcRrBpWQ/iJBmHAT3ce4S3zbnLzIXJfw3Wx0kO2uq7DX9r6AgRzCAE+zJ/m1C m2DnmstrRr9UB4DI/rA+p3kPBTT6PloCvroyCyRzd04KmDxP6kz9s9CN0xAu9cM3dUxh JVvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=eTFshXAg; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id e8si8528398pfc.248.2018.11.22.13.32.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 13:32:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=eTFshXAg; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=21pgTH4nPwYMtfybAiOSoRz5R27AR1FrdXTO1XlQXYY=; b=eTFshXAgAJQAxCBZKbL3dpgrn zKL49ibd5UXIuPJ/EeSFwG51NqZ3wDYUFs0YJKTtZycS6CDqvOK/7HThwURimjQFDD4F6RX4OXkJg 9LNGXXsQnbEjrGxeeMQcwLZoB8iUczK7rb/CUMJs3CW1y2TnrRJ700HWIgRJsJNmFiGzSMxZTuwSg wmAqGIZN5VC+J0nFZnWtGgtAS9pIvX5y1ZdQU5Bjw5BMKzYJ/dbRJ+05VoXtGkAfPljA3PoorTs20 hHKZkZgY9h07PpxFfbXG7YO566nn74Ocn6VJplwJxKdekSUozfD9ZPNKKyVzot0r337KNXvUJWcs1 Kabo2mRFA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPwaR-0003LR-8h; Thu, 22 Nov 2018 21:32:35 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Hugh Dickins , Matthew Wilcox Subject: [PATCH 1/2] mm: Remove redundant test from find_get_pages_contig Date: Thu, 22 Nov 2018 13:32:23 -0800 Message-Id: <20181122213224.12793-2-willy@infradead.org> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181122213224.12793-1-willy@infradead.org> References: <20181122213224.12793-1-willy@infradead.org> 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 After we establish a reference on the page, we check the pointer continues to be in the correct position in i_pages. There's no need to check the page->mapping or page->index afterwards; if those can change after we've got the reference, they can change after we return the page to the caller. Signed-off-by: Matthew Wilcox --- mm/filemap.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 81adec8ee02cc..538531590ef2d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1776,16 +1776,6 @@ unsigned find_get_pages_contig(struct address_space *mapping, pgoff_t index, if (unlikely(page != xas_reload(&xas))) goto put_page; - /* - * must check mapping and index after taking the ref. - * otherwise we can get both false positives and false - * negatives, which is just confusing to the caller. - */ - if (!page->mapping || page_to_pgoff(page) != xas.xa_index) { - put_page(page); - break; - } - pages[ret] = page; if (++ret == nr_pages) break;