Received: by 10.213.65.68 with SMTP id h4csp359016imn; Tue, 13 Mar 2018 06:43:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELtJ2ldzeOpLg+fyqq7wZwaU093L0MLbxPyxmx4jekwau1m1D+noU589TbuktFXXvFw4A17/ X-Received: by 10.99.111.78 with SMTP id k75mr553258pgc.414.1520948610012; Tue, 13 Mar 2018 06:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948609; cv=none; d=google.com; s=arc-20160816; b=W+/+UqIF/loWPfkzndjYqDbkCiCGIYcJzH1HOCbUeibESWCmRlf0HAKp4EG8ufZp3g WMBcaKIGtzMVNwaL7uJJPjxVPL6kTYiMRYXaVuuXOKbvbisN9kXZyzcjPI05yPfa1xrj MPxyzOJGgjAklTn2UBkckzCSpMj+kyYXhI97eJzvNR/qY7fObLO9sC3eetq0inbA9sfp o50uDRV7DpcIXCbkBu3Kt0swX+JlMVOgouRxzNxHkDzgZeM8c811bWGvt5JreRWkVlmo L4BRn4WCUa6vFTKhdKuf8vHqCuTYS2a2dasvcwxncg3A17N/JarEmuE8p74zUk13Cz56 ZeCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=z6/QpnQgw3ThGKL7LbX3qG6QK88M3BFln7q/9eWtS+U=; b=QwnzncvKS/q6P+ASC4x/iA1SlsbTP69XhULKhSFvnKbfH/FAghtPeX2/U8XTemYJEm tgYYgnqcz3Yu0vmAEtGMl8gohOdjsxFq5+lUATaJm7MDfV0imcHF4HTgykeLzLFpuJAo LB+SOwrQKHpUEhGTtfx3eAn2+22IbPb3cj3E5ApX8dqRNpKFg6pklviiDOt06tjjfd/D fZAe7+UhiL9UBKziRvEdWqZN+YEIAVh9qecZ7ENHiiUmzfV5mTAQ0OYXsStBBbSM7YTt PYEVTsIbdjjRNK3qI4NpKw3jkJGW6OBHjXOaL9RVWLHJVQdwrn7oQMYqI2XFTYCWrl4d yrYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pEykWP+4; 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 n14si140683pgu.110.2018.03.13.06.43.15; Tue, 13 Mar 2018 06:43:29 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pEykWP+4; 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 S932864AbeCMNl0 (ORCPT + 99 others); Tue, 13 Mar 2018 09:41:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35334 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932493AbeCMN06 (ORCPT ); Tue, 13 Mar 2018 09:26:58 -0400 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=z6/QpnQgw3ThGKL7LbX3qG6QK88M3BFln7q/9eWtS+U=; b=pEykWP+4czrKzVbM1kIHJ31Zw LuyqfH2NWDlq4adnHwLW8Ch13MlsjHxE+Igs5L8we/Gg4Yudg48bNjnm4l5D9EGDj6kYt+03B+v+w 6fX5pTlFwMAc1oxVYNHHiLomgzXPa0aKbMmXBoXUFW9OuJiJViT4X0NjgMdUwoNvLVDDRNyakL/M6 iY+lHO81t1HcowojWkJLqv6VVhuCIdzHcZQ5FywZK7C+AjLDVkfdQrB5D6flVPnqVaRlTnYCWDWbh aXiPMVVoNUpsd5eyJ+v/ei5DHBnZFCBalabvxkCw0B2JRYfQjTKtW34422c47CaPfZr5j8z0pNLYZ rcNwUylyA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxB-0004gj-DW; Tue, 13 Mar 2018 13:26:57 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Ryusuke Konishi , linux-nilfs@vger.kernel.org Subject: [PATCH v9 36/61] mm: Convert delete_from_swap_cache to XArray Date: Tue, 13 Mar 2018 06:26:14 -0700 Message-Id: <20180313132639.17387-37-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180313132639.17387-1-willy@infradead.org> References: <20180313132639.17387-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox Both callers of __delete_from_swap_cache have the swp_entry_t already, so pass that in to make constructing the XA_STATE easier. Signed-off-by: Matthew Wilcox --- include/linux/swap.h | 5 +++-- mm/swap_state.c | 24 ++++++++++-------------- mm/vmscan.c | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index dab96af23d96..0b6a47a46c55 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -404,7 +404,7 @@ extern void show_swap_cache_info(void); extern int add_to_swap(struct page *page); extern int add_to_swap_cache(struct page *, swp_entry_t, gfp_t); extern int __add_to_swap_cache(struct page *page, swp_entry_t entry); -extern void __delete_from_swap_cache(struct page *); +extern void __delete_from_swap_cache(struct page *, swp_entry_t entry); extern void delete_from_swap_cache(struct page *); extern void free_page_and_swap_cache(struct page *); extern void free_pages_and_swap_cache(struct page **, int); @@ -564,7 +564,8 @@ static inline int add_to_swap_cache(struct page *page, swp_entry_t entry, return -1; } -static inline void __delete_from_swap_cache(struct page *page) +static inline void __delete_from_swap_cache(struct page *page, + swp_entry_t entry) { } diff --git a/mm/swap_state.c b/mm/swap_state.c index 53e27894c1bc..a0a562fbc65f 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -154,23 +154,22 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp) * This must be called only on pages that have * been verified to be in the swap cache. */ -void __delete_from_swap_cache(struct page *page) +void __delete_from_swap_cache(struct page *page, swp_entry_t entry) { - struct address_space *address_space; + struct address_space *address_space = swap_address_space(entry); int i, nr = hpage_nr_pages(page); - swp_entry_t entry; - pgoff_t idx; + pgoff_t idx = swp_offset(entry); + XA_STATE(xas, &address_space->i_pages, idx); VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageSwapCache(page), page); VM_BUG_ON_PAGE(PageWriteback(page), page); - entry.val = page_private(page); - address_space = swap_address_space(entry); - idx = swp_offset(entry); for (i = 0; i < nr; i++) { - radix_tree_delete(&address_space->i_pages, idx + i); + void *entry = xas_store(&xas, NULL); + VM_BUG_ON_PAGE(entry != page + i, entry); set_page_private(page + i, 0); + xas_next(&xas); } ClearPageSwapCache(page); address_space->nrpages -= nr; @@ -246,14 +245,11 @@ int add_to_swap(struct page *page) */ void delete_from_swap_cache(struct page *page) { - swp_entry_t entry; - struct address_space *address_space; - - entry.val = page_private(page); + swp_entry_t entry = { .val = page_private(page) }; + struct address_space *address_space = swap_address_space(entry); - address_space = swap_address_space(entry); xa_lock_irq(&address_space->i_pages); - __delete_from_swap_cache(page); + __delete_from_swap_cache(page, entry); xa_unlock_irq(&address_space->i_pages); put_swap_page(page, entry); diff --git a/mm/vmscan.c b/mm/vmscan.c index 22bd3720b318..728d7e57cf11 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -689,7 +689,7 @@ static int __remove_mapping(struct address_space *mapping, struct page *page, if (PageSwapCache(page)) { swp_entry_t swap = { .val = page_private(page) }; mem_cgroup_swapout(page, swap); - __delete_from_swap_cache(page); + __delete_from_swap_cache(page, swap); xa_unlock_irqrestore(&mapping->i_pages, flags); put_swap_page(page, swap); } else { -- 2.16.1