Received: by 10.213.65.68 with SMTP id h4csp356029imn; Tue, 13 Mar 2018 06:38:12 -0700 (PDT) X-Google-Smtp-Source: AG47ELsjOOx7Udw6NKaD5oihPxhakYSE6gAmURJ5uiYTuoYKU7hPHfwBnhMc7eRjvVvnlkaSv6OH X-Received: by 10.101.96.212 with SMTP id r20mr526644pgv.139.1520948292201; Tue, 13 Mar 2018 06:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948292; cv=none; d=google.com; s=arc-20160816; b=akcn0uJvET63QL1fetHyhFVkUzlcGa3NAOPAd+n18CkdiFyb6kjws863IHlvtocf36 4LCkEBjZ3CXnSiGbkfvP/TCA/3CfdTkioQKgXbbJHubH38LW+ZK16XVmj03z9smNwEPR zjL+RQlr7xlkDhUjXfC2KIvVjuhg7mnf0NEXTENyXOSAHq2YRU4lI291qA7FwyEnEUUX K8zgT+mscTiGsOQC2FFk+KaSOFGl6dM/+SGYnMF9CyG5EcUNV+ZIQs7uhBsMUSNyNqmQ fnJvEGoDSDiKjT+pZuiSUu2yq62rOiT4WEi351k42qTfBtVqvq6ojmQBV2qT8o99LDUN tgTQ== 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=rXzXhtVcMtSI73Tb4Vc4OGoMQ9ed2P7MXl58GYL2T3o=; b=m9Uqbvd0E/uDrlFXUhXcb+zjXqWZpyqdXLht/cZ+F6CLkXR5QPWuoP2/ofSeq8BvS4 hPPZ8szbkxACRh5wKnl1ss4Jbd6Y0Qk3j5tgH7gwqCCUNxBzEj6TQR7hrBGtAqcm8tfi WxIaLBTGSRikHCRWA1KQAYM01mC0wqgaDH7MXZgLrfJJGpD/2N3kbzR3pa1zTdSHsner fsf3B48G8fitH9D77x9QA8J/P4bsbdb6Zl+wlur8cdGHxm+rr79h/hW/Prb2II6sBky7 kt/c/EXsEXap72grPZMvBj+w/4fUt9b/2XDXhnPg7G1VEe+1P26BpJRDPbpKndQvUDUn xLVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=S4uPXcxW; 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 x22si135257pfm.321.2018.03.13.06.37.58; Tue, 13 Mar 2018 06:38:12 -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=S4uPXcxW; 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 S1752884AbeCMNg3 (ORCPT + 99 others); Tue, 13 Mar 2018 09:36:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35498 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932640AbeCMN1D (ORCPT ); Tue, 13 Mar 2018 09:27:03 -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=rXzXhtVcMtSI73Tb4Vc4OGoMQ9ed2P7MXl58GYL2T3o=; b=S4uPXcxWlcwOHLLb5P5lqs3Ca h/+cLv4bBUfkg8bu3iqb2LT+aLFeAnANR+gdj+Wdem1TrvT0NmRQf0x7S6/ryxAo4SXblFw3d7ahz xSbkeqMppVXWHa58ukmB0eBF+M4pEXfnXshQQShwqD9rOguZGzHiyOVx7CySu4mEkBVwte8jncO+v 6VNrBIMBxSEwsTRczBKEdgBmPSwsNlGYOgehKM8yhbeT2UHVUnh3mkPiede1N6BjRbN1sGK5iFSLa 3PpARw0pu5r+aMinmRaoy8huLxC1+A9Urqfv3GsjOH1D7yYXDmVAaNM1PSxDFgFSnYhmFY6VFLhhV t0rUgu0Yw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxG-0004kT-Gv; Tue, 13 Mar 2018 13:27:02 +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 47/61] shmem: Convert shmem_alloc_hugepage to XArray Date: Tue, 13 Mar 2018 06:26:25 -0700 Message-Id: <20180313132639.17387-48-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 xa_find() is a slightly easier API to use than radix_tree_gang_lookup_slot() because it contains its own RCU locking. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index fb06fb3e644a..a0a354a87f3b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1416,23 +1416,17 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, struct shmem_inode_info *info, pgoff_t index) { struct vm_area_struct pvma; - struct inode *inode = &info->vfs_inode; - struct address_space *mapping = inode->i_mapping; - pgoff_t idx, hindex; - void __rcu **results; + struct address_space *mapping = info->vfs_inode.i_mapping; + pgoff_t hindex; struct page *page; if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) return NULL; hindex = round_down(index, HPAGE_PMD_NR); - rcu_read_lock(); - if (radix_tree_gang_lookup_slot(&mapping->i_pages, &results, &idx, - hindex, 1) && idx < hindex + HPAGE_PMD_NR) { - rcu_read_unlock(); + if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1, + XA_PRESENT)) return NULL; - } - rcu_read_unlock(); shmem_pseudo_vma_init(&pvma, info, hindex); page = alloc_pages_vma(gfp | __GFP_COMP | __GFP_NORETRY | __GFP_NOWARN, -- 2.16.1