Received: by 10.223.148.5 with SMTP id 5csp6344609wrq; Wed, 17 Jan 2018 12:29:36 -0800 (PST) X-Google-Smtp-Source: ACJfBotkYI1paAQeOBa6lxoBpe3wCKS/t6goUNVsorjwfSaXRB5XsHxCGef89hzlPW3UT0obQqOo X-Received: by 10.84.133.47 with SMTP id 44mr12126457plf.65.1516220976162; Wed, 17 Jan 2018 12:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516220976; cv=none; d=google.com; s=arc-20160816; b=HoCqsY4Mu6SJ/RuvQrd7OwJtIyWkSngSCVMWcdo3+lVW/d2vGDpYPzLSk4lQN97fUo OzSd1jIpcnGSYHu3wKnxdzv9MXMJP6pr9/Q9OBRp4mP6L2kbjGWqixQDb6Sike4LsaiY EX07paIkRgjslYo56szYMKxhM3ttE25eKvPPjCsyk6NJipFkG9e/8b3yvCKrboTPzIMP 7gtrZURfbXHUZELkmpjFcu/IUyZyUK4i+VTvzm0VnODjjxqe9G3UrOv58nJJd1748vWB r1Rfxynhb99xxWuzm6dxkKY89j26WDkezi8R6kABneqcEvx+1ZLHIEW6mC1gUNe7pAVb 5QAA== 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=nDbSNQtY3I32d6R0AQMGtIlXjATZUM/TBTgCd5AKpiA=; b=FmluqWbOeGXcRRYoF87gfKKNqynUYH+7oanNcRxxxjXtvjJk2Vi6U0VjwG5Bf9ZLbw GwSUIdtHZmcg4D9vHeWSxu5g6Seeh8lyfSP5lzlMiQmp9ff6hdUM6IwRHqKvBQsMZneX NDVSNAL5x4MlI9S7TtGuc8m+js3WZInjSBsI1+99tgUoQW01E3I8aAK64xFw53AhZ7Xt pm2AdlAljPRykHWC24n2dxCLrQZ2QFsFMVFs8EYvPBFvz8mJ0SBjtJmVPf7w8fpsTuYs cAxKphEB0b+SmJncOA3uLWHS+TpJn/5q2qPFe7GkZHGV/YLGgruxeYoMOgZbMYy4waVA oaig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MN4v26tz; 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 h14si5066797pfj.360.2018.01.17.12.29.21; Wed, 17 Jan 2018 12:29:36 -0800 (PST) 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=MN4v26tz; 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 S1754145AbeAQU1t (ORCPT + 99 others); Wed, 17 Jan 2018 15:27:49 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:57673 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754009AbeAQUXF (ORCPT ); Wed, 17 Jan 2018 15:23:05 -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=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 Cc: Matthew Wilcox , 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, Bjorn Andersson , Stefano Stabellini , iommu@lists.linux-foundation.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, intel-gfx@lists.freedesktop.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, David Howells Subject: [PATCH v6 92/99] f2fs: Convert pids radix tree to XArray 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.15.1