Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1052529yba; Sat, 4 May 2019 20:25:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9HpHVWCY+fPkv7Tap/JLog0CillAthDpCMs3OF8vN4mxSU6YCl/7djYy2C9MLkZq8XUDm X-Received: by 2002:a17:902:f205:: with SMTP id gn5mr22372104plb.207.1557026744456; Sat, 04 May 2019 20:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557026744; cv=none; d=google.com; s=arc-20160816; b=ZHaanY61sOyZP5RdEcFemiyusLw1ynphZQsHhG9F25UoRLu14WcozsGT7CIucsnbG9 DDNqvnscxB3i+iDwC78R31jGLLWvjvvDmBZkZW+ItjpG6mY7ZHhLmQsOkWmln6ORZQd+ l+zUCkKLbzwIIX2nvXPGxqnN8tB/4Cva8ue3aYhZUKWua27t6US3M0yp5xt0BdNtWLxn qcIieJbiBiTNSWGaE2A3WJG6czRjn0RR3HMGj5HjUhyKADWqzM4jwpamcTzSxi5CS60l VIftHOMc1uKu2eg4ChOTPzmu8HSXzzxvIf3a8dwFEl7zKatocvlZZTMVGefbeYcLA/qN MDLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:in-reply-to:references :subject:cc:to:from:date:message-id; bh=JDUdwnnFg7sTg7vYlKZYfR7A7HhaiDSzXRQUmqMh8as=; b=tPrQmm2RCbCrIPW8IMPQLO4N7Ua2P33rorMCcW6XtkjMAKN2o9/uIGwHIx03ih8feP Zn8Hf/lSjnGRdLgDFSLn4vPjfU3NFXuxpkllW/TLehf1Z/UNpcu7mW9elIudwvexNtLv LRRga6+LP5Gu18HnC4hhn6Lno3O56GUXsEag2z+sVg+G+ugm60pB3iDxNQdu09TMf+E5 yfOwdSX892Jj+oWOnBlTrT4A4v/911EhRzfgdUD8QzqZ/bgnQsdAE4COo0tFX9CvRrBS t8X7y32eevsUspn+GdnXYm2cYMzQy5AelIgmnW7QgGEAztxVEEvUNy3hry9sZabSeg3l Ww6Q== ARC-Authentication-Results: i=1; mx.google.com; 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 t22si1685059pgg.292.2019.05.04.20.25.29; Sat, 04 May 2019 20:25:44 -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; 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 S1727573AbfEEDSn convert rfc822-to-8bit (ORCPT + 99 others); Sat, 4 May 2019 23:18:43 -0400 Received: from prv1-mh.provo.novell.com ([137.65.248.33]:46786 "EHLO prv1-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbfEEDSn (ORCPT ); Sat, 4 May 2019 23:18:43 -0400 Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Sat, 04 May 2019 21:17:48 -0600 Message-Id: <5CCE55D6020000F900063F38@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.0 Date: Sat, 04 May 2019 21:17:42 -0600 From: "Gang He" To: , , , "Gang He" Cc: , , Subject: Re: [PATCH V2 2/2] ocfs2: add locking filter debugfs file References: <20190429083353.1410-1-ghe@suse.com> In-Reply-To: <20190429083353.1410-1-ghe@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Guys, If you have time, please help to review these two patches. The patch logic is very simple, but it can help us to control lock resource dump length. In product environment, there are lots of lock resources in memory as time goes by. Thanks Gang >>> On 2019/4/29 at 16:33, in message <20190429083353.1410-1-ghe@suse.com>, Gang He wrote: > Add locking filter debugfs file, which is used to filter lock > resources dump from locking_state debugfs file. > We use d_filter_secs field to filter lock resources dump, > the default d_filter_secs(0) value filters nothing, > otherwise, only dump the last N seconds active lock resources. > This enhancement can avoid dumping lots of old records. > The d_filter_secs value can be changed via locking_filter file. > > Compared with v1, the main change is to add CONFIG_OCFS2_FS_STATS > macro definition judgment. > > Signed-off-by: Gang He > --- > fs/ocfs2/dlmglue.c | 38 ++++++++++++++++++++++++++++++++++++++ > fs/ocfs2/ocfs2.h | 2 ++ > 2 files changed, 40 insertions(+) > > diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c > index dccf4136f8c1..554d37d52510 100644 > --- a/fs/ocfs2/dlmglue.c > +++ b/fs/ocfs2/dlmglue.c > @@ -3006,6 +3006,8 @@ struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void) > kref_init(&dlm_debug->d_refcnt); > INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking); > dlm_debug->d_locking_state = NULL; > + dlm_debug->d_locking_filter = NULL; > + dlm_debug->d_filter_secs = 0; > out: > return dlm_debug; > } > @@ -3104,11 +3106,33 @@ static int ocfs2_dlm_seq_show(struct seq_file *m, > void *v) > { > int i; > char *lvb; > + u32 now, last = 0; > struct ocfs2_lock_res *lockres = v; > + struct ocfs2_dlm_debug *dlm_debug = > + ((struct ocfs2_dlm_seq_priv *)m->private)->p_dlm_debug; > > if (!lockres) > return -EINVAL; > > + if (dlm_debug->d_filter_secs) { > + now = ktime_to_timespec(ktime_get()).tv_sec; > +#ifdef CONFIG_OCFS2_FS_STATS > + if (lockres->l_lock_prmode.ls_last > > + lockres->l_lock_exmode.ls_last) > + last = lockres->l_lock_prmode.ls_last; > + else > + last = lockres->l_lock_exmode.ls_last; > +#endif > + /* > + * Use d_filter_secs field to filter lock resources dump, > + * the default d_filter_secs(0) value filters nothing, > + * otherwise, only dump the last N seconds active lock > + * resources. > + */ > + if ((now - last) > dlm_debug->d_filter_secs) > + return 0; > + } > + > seq_printf(m, "0x%x\t", OCFS2_DLM_DEBUG_STR_VERSION); > > if (lockres->l_type == OCFS2_LOCK_TYPE_DENTRY) > @@ -3258,6 +3282,19 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super > *osb) > goto out; > } > > + dlm_debug->d_locking_filter = debugfs_create_u32("locking_filter", > + 0600, > + osb->osb_debug_root, > + &dlm_debug->d_filter_secs); > + if (!dlm_debug->d_locking_filter) { > + ret = -EINVAL; > + mlog(ML_ERROR, > + "Unable to create locking filter debugfs file.\n"); > + debugfs_remove(dlm_debug->d_locking_state); > + dlm_debug->d_locking_state = NULL; > + goto out; > + } > + > ocfs2_get_dlm_debug(dlm_debug); > out: > return ret; > @@ -3269,6 +3306,7 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super > *osb) > > if (dlm_debug) { > debugfs_remove(dlm_debug->d_locking_state); > + debugfs_remove(dlm_debug->d_locking_filter); > ocfs2_put_dlm_debug(dlm_debug); > } > } > diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h > index 8efa022684f4..f4da51099889 100644 > --- a/fs/ocfs2/ocfs2.h > +++ b/fs/ocfs2/ocfs2.h > @@ -237,6 +237,8 @@ struct ocfs2_orphan_scan { > struct ocfs2_dlm_debug { > struct kref d_refcnt; > struct dentry *d_locking_state; > + struct dentry *d_locking_filter; > + u32 d_filter_secs; > struct list_head d_lockres_tracking; > }; > > -- > 2.21.0