From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF8C2C433DF for ; Wed, 10 Jun 2020 20:39:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5745207ED for ; Wed, 10 Jun 2020 20:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hwWRASta" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5745207ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 28AC08D0019; Wed, 10 Jun 2020 16:39:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 213C48D000E; Wed, 10 Jun 2020 16:39:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F0F208D0019; Wed, 10 Jun 2020 16:39:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id D90F18D000E for ; Wed, 10 Jun 2020 16:39:03 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 98B5C180AEF50 for ; Wed, 10 Jun 2020 20:39:03 +0000 (UTC) X-FDA: 76914466566.25.mist28_380d4e126dce Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 665DD1804E3E1 for ; Wed, 10 Jun 2020 20:39:03 +0000 (UTC) X-HE-Tag: mist28_380d4e126dce X-Filterd-Recvd-Size: 3141 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 10 Jun 2020 20:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=WQYUHtaa1PlP1XkIa4APm8ZxDaohf3g/uelkXzjDEzk=; b=hwWRASta1tlG6WCdBl2KkJNJzr nvbYBTfI6Mu/K4m6gQEQMPCt4LO80m/FyuVq9tIMkJ18nlag0tghEzd0QiTIVzu0lZs0rset5WvKJ N5pJwzizSEwx+sOoPLBmjq8PrfTpbD7VTsJyaqD0x12p/HXI0yJPHzDqZo/Evn/z1uxGFBUvcHDVa UTyq1eTa+oiGoOwpFCZNYT+kWRClHGiofccsEnWMUQkHGAuKD8oKJPG52/BwQ3KvVEBHb4LlvZM9L HP0YPkLSaqemnXdZLxKTisKN+6Sj48890bydbdM0IWKzEuXCLJvnL1guhhfpRkJjy2LIRWjiFXayR FPX2gcfQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jj76b-0003Xd-0l; Wed, 10 Jun 2020 20:13:49 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 43/51] mm: Support storing shadow entries for THPs Date: Wed, 10 Jun 2020 13:13:37 -0700 Message-Id: <20200610201345.13273-44-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200610201345.13273-1-willy@infradead.org> References: <20200610201345.13273-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 665DD1804E3E1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable 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: From: "Matthew Wilcox (Oracle)" If the page is being replaced with a NULL, we can do a single store that erases the entire range of indices. Otherwise we have to use a loop to store one shadow entry in each index. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 78f888d028c5..17db007f0277 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -120,22 +120,27 @@ static void page_cache_delete(struct address_space = *mapping, struct page *page, void *shadow) { XA_STATE(xas, &mapping->i_pages, page->index); - unsigned int nr =3D 1; + unsigned int i, nr =3D 1, entries =3D 1; =20 mapping_set_update(&xas, mapping); =20 /* hugetlb pages are represented by a single entry in the xarray */ if (!PageHuge(page)) { - xas_set_order(&xas, page->index, compound_order(page)); - nr =3D compound_nr(page); + entries =3D nr =3D thp_nr_pages(page); + if (!shadow) { + xas_set_order(&xas, page->index, thp_order(page)); + entries =3D 1; + } } =20 VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageTail(page), page); - VM_BUG_ON_PAGE(nr !=3D 1 && shadow, page); =20 - xas_store(&xas, shadow); - xas_init_marks(&xas); + for (i =3D 0; i < entries; i++) { + xas_store(&xas, shadow); + xas_init_marks(&xas); + xas_next(&xas); + } =20 page->mapping =3D NULL; /* Leave page->index set: truncation lookup relies upon it */ --=20 2.26.2