From patchwork Wed Jan 17 20:21:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10172761 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 C7C66601E7 for ; Thu, 18 Jan 2018 10:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B73A426255 for ; Thu, 18 Jan 2018 10:14:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB82A262FF; Thu, 18 Jan 2018 10:14:42 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 327A426255 for ; Thu, 18 Jan 2018 10:14:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8117D6E72D; Thu, 18 Jan 2018 09:43:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A1746E1C4 for ; Wed, 17 Jan 2018 20:23:14 +0000 (UTC) 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=nDbSNQtY3I32d6R0AQMGtIlXjATZUM/TBTgCd5AKpiA=; b=MN4v26tzHiZB6R+Hk3zmusuUY +pu9Srd/sL/BJ9P7ObG+bnphV3pKEOIN5kdRFQlqAMn6h8C4nraM0Y9PCd84Co2v/5IERdFERb+S3 a7dgBBcUZleKdvb3DgUQIePAyqtpKqAiz2S1jgRnnWJJbJXlNc1z/9p3paUVBPJQs4bDnTFTOjBpD hN4nQ+zEPxMchcDMWHSobhw92MeC9ynbdhCLVaAE3PRRMQ5N02pdpG5be+cCnAq4sKrZcOKCh3hUZ Gxde4v9fSJE3ufVQErRwh1nKfNHo5TkBV0OqpqArJ7/eQLnPaJMGAkxeyarYWWZ37kQUD0YSBIiZk zRa7DnlrA==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1ebuEi-0006KT-5U; Wed, 17 Jan 2018 20:23:04 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Date: Wed, 17 Jan 2018 12:21:56 -0800 Message-Id: <20180117202203.19756-93-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180117202203.19756-1-willy@infradead.org> References: <20180117202203.19756-1-willy@infradead.org> Cc: linux-s390@vger.kernel.org, David Howells , linux-nilfs@vger.kernel.org, Matthew Wilcox , linux-sh@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-usb@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stefano Stabellini , linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, Bjorn Andersson , linux-btrfs@vger.kernel.org Subject: [Intel-gfx] [PATCH v6 92/99] f2fs: Convert pids radix tree to XArray X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox The XArray API works out rather well for this user. Signed-off-by: Matthew Wilcox --- fs/f2fs/super.c | 2 -- fs/f2fs/trace.c | 60 ++++----------------------------------------------------- fs/f2fs/trace.h | 2 -- 3 files changed, 4 insertions(+), 60 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 708155d9c2e4..d608edffe69e 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2831,8 +2831,6 @@ static int __init init_f2fs_fs(void) { int err; - f2fs_build_trace_ios(); - err = init_inodecache(); if (err) goto fail; diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c index bccbbf2616d2..f316a42c547f 100644 --- a/fs/f2fs/trace.c +++ b/fs/f2fs/trace.c @@ -16,8 +16,7 @@ #include "f2fs.h" #include "trace.h" -static RADIX_TREE(pids, GFP_ATOMIC); -static spinlock_t pids_lock; +static DEFINE_XARRAY(pids); static struct last_io_info last_io; static inline void __print_last_io(void) @@ -57,28 +56,13 @@ void f2fs_trace_pid(struct page *page) { struct inode *inode = page->mapping->host; pid_t pid = task_pid_nr(current); - void *p; set_page_private(page, (unsigned long)pid); - if (radix_tree_preload(GFP_NOFS)) - return; - - spin_lock(&pids_lock); - p = radix_tree_lookup(&pids, pid); - if (p == current) - goto out; - if (p) - radix_tree_delete(&pids, pid); - - f2fs_radix_tree_insert(&pids, pid, current); - - trace_printk("%3x:%3x %4x %-16s\n", + if (xa_store(&pids, pid, current, GFP_NOFS) != current) + trace_printk("%3x:%3x %4x %-16s\n", MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev), pid, current->comm); -out: - spin_unlock(&pids_lock); - radix_tree_preload_end(); } void f2fs_trace_ios(struct f2fs_io_info *fio, int flush) @@ -120,43 +104,7 @@ void f2fs_trace_ios(struct f2fs_io_info *fio, int flush) return; } -void f2fs_build_trace_ios(void) -{ - spin_lock_init(&pids_lock); -} - -#define PIDVEC_SIZE 128 -static unsigned int gang_lookup_pids(pid_t *results, unsigned long first_index, - unsigned int max_items) -{ - struct radix_tree_iter iter; - void **slot; - unsigned int ret = 0; - - if (unlikely(!max_items)) - return 0; - - radix_tree_for_each_slot(slot, &pids, &iter, first_index) { - results[ret] = iter.index; - if (++ret == max_items) - break; - } - return ret; -} - void f2fs_destroy_trace_ios(void) { - pid_t pid[PIDVEC_SIZE]; - pid_t next_pid = 0; - unsigned int found; - - spin_lock(&pids_lock); - while ((found = gang_lookup_pids(pid, next_pid, PIDVEC_SIZE))) { - unsigned idx; - - next_pid = pid[found - 1] + 1; - for (idx = 0; idx < found; idx++) - radix_tree_delete(&pids, pid[idx]); - } - spin_unlock(&pids_lock); + xa_destroy(&pids); } diff --git a/fs/f2fs/trace.h b/fs/f2fs/trace.h index 67db24ac1e85..157e4564e48b 100644 --- a/fs/f2fs/trace.h +++ b/fs/f2fs/trace.h @@ -34,12 +34,10 @@ struct last_io_info { extern void f2fs_trace_pid(struct page *); extern void f2fs_trace_ios(struct f2fs_io_info *, int); -extern void f2fs_build_trace_ios(void); extern void f2fs_destroy_trace_ios(void); #else #define f2fs_trace_pid(p) #define f2fs_trace_ios(i, n) -#define f2fs_build_trace_ios() #define f2fs_destroy_trace_ios() #endif