Received: by 10.223.185.116 with SMTP id b49csp4141722wrg; Mon, 19 Feb 2018 11:56:22 -0800 (PST) X-Google-Smtp-Source: AH8x224742GfCrJjgcGpY2kLy5PrD0ofw8ZsRnbU1NTGxsaSvSfaWPZstsfpmp5SYNu7je83Eure X-Received: by 10.101.82.70 with SMTP id q6mr12965768pgp.67.1519070182256; Mon, 19 Feb 2018 11:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519070182; cv=none; d=google.com; s=arc-20160816; b=M3TnESG/yihVieAWrU/GQMQ7zYst3WqBdUI3PKNLZK7hVn4g3O5sETWDvDVxusqSc2 4YupW1qRkexhRtPpaXHrpKsoPKJwebECwXwcNAPwFbdGy1WwIcsbJxkqT7d/wXKXXyGS nZVeZ+NHHGNE5iP/WDixlBj9LQTZmULl9L4ji++0ZUNzk+jgquEBrLWuQVBXDcTjoAAK jYPbl0FYSnb5wxTIuAKEuhKUf6lsZzXO6KHAauIasKiICAKxacPL2P3NZWMQcI40J41T 3YzuYD8zdrBJdjhJyb9yf87l7KkgBHe/sh2AnMBM5LChOMUBqfwg6y3wFq4YIoFEvBiL KgUA== 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=j5pDIqf50EsZxYZWaGmKMavIJ2QRmGDC2U3e//jW2W8=; b=nDW2ni/AMnk+F+BEcFBjajNewfLoYamws919WJ1BNGalXsIhq1mZ7KhgFTZtSfuXgi no82eSRviy1a+1GvQUv5bdPhDb1QhkFWLcfFAlPJoHEY+PAqo0RXA8b4Mb/TyKN7K3vH pfb4RU86L5xuEPj/Z1bmWSHxNHKt4wb8TTe/cG5a2Ji86Y7arAMVuL6qM3RRyeJdKu0H qg6cqVYQsI9+kzIk3V5QgBk7lW7n6S5RdM/y/aj37D/Fndw8adquM8VxC6o/i7wiWBW+ uy7r0X0boOHB7eQHZizqUmLZuVCwk0QO3JcTzyA30iRZKMEfihQFNW4do+nrOZLIjo/X f23g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=K0IhffAJ; 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 5-v6si4540031plx.742.2018.02.19.11.56.08; Mon, 19 Feb 2018 11:56:22 -0800 (PST) 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=K0IhffAJ; 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 S1753887AbeBSTzA (ORCPT + 99 others); Mon, 19 Feb 2018 14:55:00 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44848 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753752AbeBSTqV (ORCPT ); Mon, 19 Feb 2018 14:46:21 -0500 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=j5pDIqf50EsZxYZWaGmKMavIJ2QRmGDC2U3e//jW2W8=; b=K0IhffAJj9kS0M6V6g1uW6AtY +OVtaRhEMeUS3RDUhJ35nhwAQl9Fhl+0kYvrUvITc6QuZqnGlTy4kL4HWDXWaNjvyz+MVJGjERBxH UPZ+k2V64n7XaHNxax61ckm/JiC1hoS+rER4Jtby91IZ4LSF4z4sJPgMSAkGApSbbp75ITPGMiYNv dWKvSlRkW2/xcv5H7iAHH4Md+BEPYsQs60oN1FEwrJakM6S0vvmmKyLNdjOn76YUGgH8go4inuSmD BQULO+ROyd0UxZitis+BZQa0v8iR7boZhxNsckvAv7YlToNYRgetGlh3zcrRkFfnpoJQ+uu72Wrwm jjdM1Hg+Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1enrOF-0001rm-R9; Mon, 19 Feb 2018 19:46:19 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v7 37/61] mm: Convert delete_from_swap_cache to XArray Date: Mon, 19 Feb 2018 11:45:32 -0800 Message-Id: <20180219194556.6575-38-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180219194556.6575-1-willy@infradead.org> References: <20180219194556.6575-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 5933f02a3219..8c6f46797b82 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -406,7 +406,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); @@ -581,7 +581,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 a57b5ad4c503..219e3b4f09e6 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->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->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->pages); - __delete_from_swap_cache(page); + __delete_from_swap_cache(page, entry); xa_unlock_irq(&address_space->pages); put_swap_page(page, entry); diff --git a/mm/vmscan.c b/mm/vmscan.c index 93f4b4634431..3eb9f7c732bb 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -697,7 +697,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->pages, flags); put_swap_page(page, swap); } else { -- 2.16.1