From patchwork Fri Dec 15 22:04:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10116209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C398C6019C for ; Fri, 15 Dec 2017 22:13:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B672E29D7C for ; Fri, 15 Dec 2017 22:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB6FE2A1B7; Fri, 15 Dec 2017 22:13:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CE9A29D7C for ; Fri, 15 Dec 2017 22:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932193AbdLOWIg (ORCPT ); Fri, 15 Dec 2017 17:08:36 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:47353 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756776AbdLOWFl (ORCPT ); Fri, 15 Dec 2017 17:05:41 -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=EFxy/TwEZuiKwQSKChzg5PuhKY9COU1WnQ5ZFx1Cwc4=; b=D56BgYfpJw5FPTYQD6vD0OfB1 Pn5aXCdTmMnCLxzmjpc7JiV1WjTsFNbOs4Fp+CxnSZYK6wB629nBy5GpOMhuJpgg8eURYr4U0CLBy PPa92v2cXP7dclr2CEe4vMxgB1MYU6Hi3HBhIaYEzZJqlWYr3xDSF71QWxFchnpxL/xDmhe80Aa05 Tj/jzTpRACqDOXn99hbIhB8OQGe7PeosR9LGRnF3Ewr0QqV0D4Ja6a14Tp5Yw4iNqmHYt0FW3uYmM KVJLMN/QzmkD91ZoP/WM7QslQbgYZEYoatQ8rVRg26yh8TVfwETB2Izb6ui4NioUybiXHdrNSGaQX qKzz8wxSg==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1ePy6H-00027c-9M; Fri, 15 Dec 2017 22:05:01 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Ross Zwisler , David Howells , Shaohua Li , Jens Axboe , Rehas Sachdeva , Marc Zyngier , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-nilfs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-usb@vger.kernel.org, linux-raid@vger.kernel.org Subject: [PATCH v5 38/78] mm: Convert huge_memory to XArray Date: Fri, 15 Dec 2017 14:04:10 -0800 Message-Id: <20171215220450.7899-39-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171215220450.7899-1-willy@infradead.org> References: <20171215220450.7899-1-willy@infradead.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox Quite a straightforward conversion. Signed-off-by: Matthew Wilcox --- mm/huge_memory.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 28909c475ee5..5a41b00d86bd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2379,7 +2379,7 @@ static void __split_huge_page_tail(struct page *head, int tail, if (PageAnon(head) && !PageSwapCache(head)) { page_ref_inc(page_tail); } else { - /* Additional pin to radix tree */ + /* Additional pin to page cache */ page_ref_add(page_tail, 2); } @@ -2450,13 +2450,13 @@ static void __split_huge_page(struct page *page, struct list_head *list, ClearPageCompound(head); /* See comment in __split_huge_page_tail() */ if (PageAnon(head)) { - /* Additional pin to radix tree of swap cache */ + /* Additional pin to swap cache */ if (PageSwapCache(head)) page_ref_add(head, 2); else page_ref_inc(head); } else { - /* Additional pin to radix tree */ + /* Additional pin to page cache */ page_ref_add(head, 2); xa_unlock(&head->mapping->pages); } @@ -2568,7 +2568,7 @@ bool can_split_huge_page(struct page *page, int *pextra_pins) { int extra_pins; - /* Additional pins from radix tree */ + /* Additional pins from page cache */ if (PageAnon(page)) extra_pins = PageSwapCache(page) ? HPAGE_PMD_NR : 0; else @@ -2664,17 +2664,14 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) spin_lock_irqsave(zone_lru_lock(page_zone(head)), flags); if (mapping) { - void **pslot; + XA_STATE(xas, &mapping->pages, page_index(head)); - xa_lock(&mapping->pages); - pslot = radix_tree_lookup_slot(&mapping->pages, - page_index(head)); /* - * Check if the head page is present in radix tree. + * Check if the head page is present in page cache. * We assume all tail are present too, if head is there. */ - if (radix_tree_deref_slot_protected(pslot, - &mapping->pages.xa_lock) != head) + xa_lock(&mapping->pages); + if (xas_load(&xas) != head) goto fail; }