Received: by 10.213.65.68 with SMTP id h4csp356930imn; Tue, 13 Mar 2018 06:39:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELvNOGQysa4N7vX1vcTcUM8OYN68YDtzUza2zFFlwLFCOo4KBJKCLgh6/fRQ41/LNdvX8b00 X-Received: by 10.98.100.69 with SMTP id y66mr656215pfb.111.1520948389251; Tue, 13 Mar 2018 06:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520948389; cv=none; d=google.com; s=arc-20160816; b=M8yy4Lk+UGQiRPNmqUbjilRWgU7h3OTh1sT03QB0xwluf5wW2xViBg73AXVuABihio 1lOypHn1kUR6JztkbEfA+1XzqaWMNEagnXTj0GGmXJMbGqTrLEX0VYxmmcqbv3W24FIe jtH4OADX5Sf/pl9SzAMd7lukB4O7SIsBhVJdIKCdtulgXYXDQ/xUhl1XvXp3tzjOSEQt dOw7CJXbTlhUv/NH63DQ1w0gqZMJMltMi2r44dqAu8GJXQEAnhj4fgxD/s/wG40J7gI3 L8K/KHv6NJZ72jZ5u/GEXSOs1AtTZmv6wwq9b0i5vxzfuaekoKQ/REcOg+Ujm80mDsJ5 Svjw== 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=s45HmMDP7/Lh87o/Az3eaE9LOfvR4oj5fV0qPSxpKec=; b=g+XEeGfC2fAqqHwk9V5B6KPGe6l4K1xh/9ckvRRnbuAL9xyZraDUH0xNO8lb9Il1z5 dftXXNPLHjwKhOmGjDcnicdolsZ3WdkLHdLmyhejH4/v0Kts9IxQPsLCcqGF3ldhs0Hy E/CER7UlEkD/JNP42l7FsivKOweCAgZBkNk13w+M+TEvN521CtGwah9nfNBRowzYiSXo d6AdUpfKisSh8hRl/DAPZoCKhMgQBDyi6GTTw7BPSksWKOJZ58fZX2zOOdLwnWmxixUM PjalUQVmYvj5jZTznbv8c93L/IFdyEFZBR/mPWn4XBbbgXMZ8pUxUHBBfsh5rbJswJOV DdGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=erigPmuO; 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 d16-v6si127374pll.504.2018.03.13.06.39.35; Tue, 13 Mar 2018 06:39:49 -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=erigPmuO; 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 S932749AbeCMNg2 (ORCPT + 99 others); Tue, 13 Mar 2018 09:36:28 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35522 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932647AbeCMN1E (ORCPT ); Tue, 13 Mar 2018 09:27:04 -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=s45HmMDP7/Lh87o/Az3eaE9LOfvR4oj5fV0qPSxpKec=; b=erigPmuOigWy/x3GbDyXMBYoF xWKGuCm4S0R4csWw7C9o913Cg2uGgmTGbraYeNEQ+sqTBOahln8utBUPjv4PvsvqS/1M2XtYntw/y g2Difg8l9J6yw7Dpr75PzOUffP3Y41fK2f+goGmg0gj4NrKDKW1wjVi/vo0/QkBk2eOW4AmoAy+m+ 9qdo4dx/m63cG/F3PzzSF1lRNDNVmjYwS1bJB10gaNu7kNmLpU9N8x+TwbRGrVhqdgSzpP0fHfMBo rkXR8s9pviSsvHOwK3+ljmxixQ5GKc87XbTBzHvA4kMuV4duewYX0x5yNBLHjIA1+/HOQmF/MeiFa pwZWkJ4YA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1evjxH-0004kf-15; Tue, 13 Mar 2018 13:27:03 +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 48/61] shmem: Convert shmem_free_swap to XArray Date: Tue, 13 Mar 2018 06:26:26 -0700 Message-Id: <20180313132639.17387-49-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 This is a perfect use for xa_cmpxchg(). Note the use of 0 for GFP flags; we won't be allocating memory. Signed-off-by: Matthew Wilcox --- mm/shmem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index a0a354a87f3b..cfbffb4b47a2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -635,16 +635,13 @@ static void shmem_delete_from_page_cache(struct page *page, void *radswap) } /* - * Remove swap entry from radix tree, free the swap and its page cache. + * Remove swap entry from page cache, free the swap and its page cache. */ static int shmem_free_swap(struct address_space *mapping, pgoff_t index, void *radswap) { - void *old; + void *old = xa_cmpxchg(&mapping->i_pages, index, radswap, NULL, 0); - xa_lock_irq(&mapping->i_pages); - old = radix_tree_delete_item(&mapping->i_pages, index, radswap); - xa_unlock_irq(&mapping->i_pages); if (old != radswap) return -ENOENT; free_swap_and_cache(radix_to_swp_entry(radswap)); -- 2.16.1