From patchwork Fri May 29 02:58:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11577633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F129513B4 for ; Fri, 29 May 2020 03:37:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3D0220721 for ; Fri, 29 May 2020 03:37:49 +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="tmPXNoJJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3D0220721 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 2CE0F800BE; Thu, 28 May 2020 23:37:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 254B180010; Thu, 28 May 2020 23:37:43 -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 0B0D8800BE; Thu, 28 May 2020 23:37:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E2AD980010 for ; Thu, 28 May 2020 23:37:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A87058245571 for ; Fri, 29 May 2020 03:37:42 +0000 (UTC) X-FDA: 76868347164.02.crack86_4348b57165448 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 924D240E1 for ; Fri, 29 May 2020 03:37:42 +0000 (UTC) X-Spam-Summary: 2,0,0,c825aab8560634f6,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3870:3871:3872:4321:5007:6261:6653:7576:7903:8957:10004:11026:11232:11473:11658:11914:12043:12296:12297:12555:12895:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21324:21451:21627:30054,0,RBL:198.137.202.133:@infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: crack86_4348b57165448 X-Filterd-Recvd-Size: 3116 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 May 2020 03:37:42 +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=J5D9xGGBSFhSBZQFLLkizdfmJQQ9VTJ9BzrD2DVYvp4=; b=tmPXNoJJJGdFoOD9J9FNwV0VEG vFXMqfk659WjQZQNq4OsTpO9+bbMIluzsW9as8ai4xUzMZiwvpBF+pxGXTOHb7qNZPQMxjrOpP4O7 lE1dZJR5/WSStJBy/e405ENAcOHwzzHPub3qO71+/MuO4BkUXBU1AVJJFMMOjErjX177jCs6TYu7g ueTGMIPy7uhepQMpWjUEzL7Z9qNGmt/TPOhy6hYpe+28I0QXRAmNtJWrUrz1pcLBy+gk6ZU+bjnsi mqtGjz6r7evdRWP2Wn8wWzKXuMej4o1naXk7t1H7TkVB/2PHztDC0C/Vb+QfSnu4u5v2FGsGpRNI1 a4qtLI6w==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jeVE3-0008TD-Ou; Fri, 29 May 2020 02:58:27 +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 v5 31/39] mm: Support storing shadow entries for large pages Date: Thu, 28 May 2020 19:58:16 -0700 Message-Id: <20200529025824.32296-32-willy@infradead.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200529025824.32296-1-willy@infradead.org> References: <20200529025824.32296-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 924D240E1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 large store, but for now we have to use a loop to store one shadow entry in each entry. 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 9c760dd7208e..0ec7f25a07b2 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 = 1; + unsigned int i, nr = 1, entries = 1; mapping_set_update(&xas, mapping); /* hugetlb pages are represented by a single entry in the xarray */ if (!PageHuge(page)) { - xas_set_order(&xas, page->index, compound_order(page)); - nr = compound_nr(page); + entries = nr = hpage_nr_pages(page); + if (!shadow) { + xas_set_order(&xas, page->index, thp_order(page)); + entries = 1; + } } VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(PageTail(page), page); - VM_BUG_ON_PAGE(nr != 1 && shadow, page); - xas_store(&xas, shadow); - xas_init_marks(&xas); + for (i = 0; i < entries; i++) { + xas_store(&xas, shadow); + xas_init_marks(&xas); + xas_next(&xas); + } page->mapping = NULL; /* Leave page->index set: truncation lookup relies upon it */