Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2447468imm; Sat, 16 Jun 2018 19:02:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKItZpqnWEmQSCMpr7CFYm0I94YpsBGH8MJsc4KSxzjmRZULTbmVnX1pr8FpEy4et/ppXpFi X-Received: by 2002:a63:b44f:: with SMTP id n15-v6mr6338667pgu.389.1529200937759; Sat, 16 Jun 2018 19:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529200937; cv=none; d=google.com; s=arc-20160816; b=EzzuIDszdAE7xN6dH8DInkVssdTdoJZaJB7OCKAJWtMRgggGzO/K+yAAMIvqNmWIzA /+VZVzNh5SPCFmrZySdocJrTflDOVzcH2dfVAmx5x5NwTvs4tmpvK5JYPm1xgCdd5S6B WI0rdnPEaHwV/tYN5mBdBS2VLA8Z/5dFYBejnPopFt9Y3kjDa9d0Qpp9MqkQyGpQ1DT1 jTbs+BgcPjU3JYqDviY9fB7wqb2xXpJKHlukSSwdr2SUr/OFUjSGFXuHWQAsYeOwzsTE c+gQy7Yz9foA/9U8tf2xXPmux0aeB4DGnZZBD1wgMl0O0Yvk3/4nTpdHtKOAVTLD+hrT pqEA== 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=yX7COoR3qpQTI44IF0CKAN0FYL15jSRAoxDg2ICiPI0=; b=CsgotaVuVU/msqgVVDtMsWLwk3ykwcuJVZtSrQc674vXP9HN2aEjoCPf2goh2lqkr8 IzIdmzE7KbfTLBRmFgzUPM1FybJScG7Jw2SzlT8i4xS0/TlXrkTHRJoJbQVSmRoO9JNQ rJiJ9Y89HKdHbXe9UvNsqtDCuGeQxG+EZTnanbRMZI99qrRBfcC5MskdGdVy65YaVb66 lbseSLtWOoKUSchwM/MvI3VkLtsK+Zen0dUmCADL6heJQjOr6qcWDlizHDrDI9FMWAym ouKJM4YRs7/wtGwrPfR1DFpVZTDl7htLaq4wtlo6PusyEBOB3T9V2O/VU6cYIF7TnTPj QTgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Il0H28C2; 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 l1-v6si9684518pgb.187.2018.06.16.19.02.03; Sat, 16 Jun 2018 19:02:17 -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=Il0H28C2; 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 S934202AbeFQCBT (ORCPT + 99 others); Sat, 16 Jun 2018 22:01:19 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59016 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933899AbeFQCBF (ORCPT ); Sat, 16 Jun 2018 22:01:05 -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=yX7COoR3qpQTI44IF0CKAN0FYL15jSRAoxDg2ICiPI0=; b=Il0H28C25zfV0VHkQ/z2BP/sL j2GFiYIFRFfED9aSWwB1+B4IVgHafUbnt2fXg3t4xTCj7BKHTRNWKn4IKbf+P656D6wj9xIxnqx7f t+yqsmGtLBHByfm1mwnHPeCwaJC6tX2zcK/h15FZJluKs/1JCia/yBgv7vE3VlhzlQjAvK1NuOw2l DjedgD9yrLSJ9FS3Sc68HzAKy1tommRyJsU4mMa6Mb6oEER/8uJjlxTaUNHqs2Ziftg4j6E64bBqO q1/AKSp8CLOXI/TZ3cXDergYlYCdI1bTJoLZWThBMcC+8gyVisw4T5bhh/lVL9/vSB8hMSwCKORwM 0+WGU0XAg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUN04-0001Lt-WA; Sun, 17 Jun 2018 02:01:04 +0000 From: Matthew Wilcox To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Jan Kara , Jeff Layton , Lukas Czerner , Ross Zwisler , Christoph Hellwig , Goldwyn Rodrigues , Nicholas Piggin , Ryusuke Konishi , linux-nilfs@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH v14 39/74] mm: Convert delete_from_swap_cache to XArray Date: Sat, 16 Jun 2018 19:00:17 -0700 Message-Id: <20180617020052.4759-40-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180617020052.4759-1-willy@infradead.org> References: <20180617020052.4759-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 a450a1d40b19..470570dac9e8 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 ca18407a79aa..5cd42d05177e 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; @@ -243,14 +242,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 03822f86f288..0448b1b366d9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -753,7 +753,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.17.1