All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 27/28] lustre: llite: control concurrent statahead instances
Date: Sun, 14 Oct 2018 14:58:17 -0400	[thread overview]
Message-ID: <1539543498-29105-28-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1539543498-29105-1-git-send-email-jsimmons@infradead.org>

From: Fan Yong <fan.yong@intel.com>

It is found that if there are too many concurrent statahead
instances, then related statahead RPCs may accumulate on the
client import (for MDT) RPC lists
(imp_sending_list/imp_delayed_list/imp_unreplied_lis), as to
seriously affect the efficiency of spin_lock under the case
of MDT overloaded or in recovery. Be as the temporarily solution,
restrict the concurrent statahead instances.

If want to support more concurrent statahead instances, please
consider to decentralize the RPC lists attached on related import.

Signed-off-by: Fan Yong <fan.yong@intel.com>
WC-bug-id: https://jira.whamcloud.com/browse/LU-11079
Reviewed-on: https://review.whamcloud.com/32690
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 .../staging/lustre/lustre/llite/llite_internal.h   | 13 +++++++-
 drivers/staging/lustre/lustre/llite/llite_lib.c    |  1 +
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 37 ++++++++++++++++++++++
 drivers/staging/lustre/lustre/llite/statahead.c    | 24 ++++++++++----
 4 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index ad380f1..359bd53 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -504,6 +504,9 @@ struct ll_sb_info {
 	int		       ll_rw_stats_on;
 
 	/* metadata stat-ahead */
+	unsigned int		ll_sa_running_max; /* max concurrent
+						    * statahead instances
+						    */
 	unsigned int	      ll_sa_max;     /* max statahead RPCs */
 	atomic_t		  ll_sa_total;   /* statahead thread started
 						  * count
@@ -1063,7 +1066,15 @@ enum ras_update_flags {
 /* statahead.c */
 #define LL_SA_RPC_MIN	   2
 #define LL_SA_RPC_DEF	   32
-#define LL_SA_RPC_MAX	   8192
+#define LL_SA_RPC_MAX		512
+
+/* XXX: If want to support more concurrent statahead instances,
+ *	please consider to decentralize the RPC lists attached
+ *	on related import, such as imp_{sending,delayed}_list.
+ *	LU-11079
+ */
+#define LL_SA_RUNNING_MAX	256
+#define LL_SA_RUNNING_DEF	16
 
 #define LL_SA_CACHE_BIT	 5
 #define LL_SA_CACHE_SIZE	(1 << LL_SA_CACHE_BIT)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index a5e65db..fae7e50 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -116,6 +116,7 @@ static struct ll_sb_info *ll_init_sbi(void)
 	}
 
 	/* metadata statahead is enabled by default */
+	sbi->ll_sa_running_max = LL_SA_RUNNING_DEF;
 	sbi->ll_sa_max = LL_SA_RPC_DEF;
 	atomic_set(&sbi->ll_sa_total, 0);
 	atomic_set(&sbi->ll_sa_wrong, 0);
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index d8ef090..10dc7a8 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -714,6 +714,42 @@ static ssize_t stats_track_gid_store(struct kobject *kobj,
 }
 LUSTRE_RW_ATTR(stats_track_gid);
 
+static ssize_t statahead_running_max_show(struct kobject *kobj,
+					  struct attribute *attr,
+					  char *buf)
+{
+	struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+					      ll_kset.kobj);
+
+	return snprintf(buf, 16, "%u\n", sbi->ll_sa_running_max);
+}
+
+static ssize_t statahead_running_max_store(struct kobject *kobj,
+					   struct attribute *attr,
+					   const char *buffer,
+					   size_t count)
+{
+	struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+					      ll_kset.kobj);
+	unsigned long val;
+	int rc;
+
+	rc = kstrtoul(buffer, 0, &val);
+	if (rc)
+		return rc;
+
+	if (val <= LL_SA_RUNNING_MAX) {
+		sbi->ll_sa_running_max = val;
+		return count;
+	}
+
+	CERROR("Bad statahead_running_max value %lu. Valid values are in the range [0, %d]\n",
+	       val, LL_SA_RUNNING_MAX);
+
+	return -ERANGE;
+}
+LUSTRE_RW_ATTR(statahead_running_max);
+
 static ssize_t statahead_max_show(struct kobject *kobj,
 				  struct attribute *attr,
 				  char *buf)
@@ -1171,6 +1207,7 @@ static ssize_t ll_nosquash_nids_seq_write(struct file *file,
 	&lustre_attr_stats_track_pid.attr,
 	&lustre_attr_stats_track_ppid.attr,
 	&lustre_attr_stats_track_gid.attr,
+	&lustre_attr_statahead_running_max.attr,
 	&lustre_attr_statahead_max.attr,
 	&lustre_attr_statahead_agl.attr,
 	&lustre_attr_lazystatfs.attr,
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 8f3ff7f..336f1cf 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -1472,23 +1472,34 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
 	struct ll_statahead_info *sai = NULL;
 	struct task_struct *task;
 	struct dentry *parent = dentry->d_parent;
-	int rc;
+	struct ll_sb_info *sbi = ll_i2sbi(parent->d_inode);
+	int first = LS_FIRST_DE;
+	int rc = 0;
 
 	/* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */
-	rc = is_first_dirent(dir, dentry);
-	if (rc == LS_NOT_FIRST_DE) {
+	first = is_first_dirent(dir, dentry);
+	if (first == LS_NOT_FIRST_DE) {
 		/* It is not "ls -{a}l" operation, no need statahead for it. */
 		rc = -EFAULT;
 		goto out;
 	}
 
+	if (unlikely(atomic_inc_return(&sbi->ll_sa_running) >
+				       sbi->ll_sa_running_max)) {
+		CDEBUG(D_READA,
+		       "Too many concurrent statahead instances, avoid new statahead instance temporarily.\n");
+		rc = -EMFILE;
+		goto out;
+	}
+
+
 	sai = ll_sai_alloc(parent);
 	if (!sai) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	sai->sai_ls_all = (rc == LS_FIRST_DOT_DE);
+	sai->sai_ls_all = (first == LS_FIRST_DOT_DE);
 	/*
 	 * if current lli_opendir_key was deauthorized, or dir re-opened by
 	 * another process, don't start statahead, otherwise the newly spawned
@@ -1504,8 +1515,6 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
 	lli->lli_sai = sai;
 	spin_unlock(&lli->lli_sa_lock);
 
-	atomic_inc(&ll_i2sbi(parent->d_inode)->ll_sa_running);
-
 	CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
 	       current->pid, parent);
 
@@ -1545,6 +1554,9 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry)
 	spin_unlock(&lli->lli_sa_lock);
 	if (sai)
 		ll_sai_free(sai);
+	if (first != LS_NOT_FIRST_DE)
+		atomic_dec(&sbi->ll_sa_running);
+
 	return rc;
 }
 
-- 
1.8.3.1

  parent reply	other threads:[~2018-10-14 18:58 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-14 18:57 [lustre-devel] [PATCH 00/28] lustre: more assorted fixes for lustre 2.10 James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 01/28] lustre: osc: osc_extent_tree_dump0() implementation is suboptimal James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 02/28] lustre: llite: Read ahead should return pages read James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 03/28] lustre: ptlrpc: missing barrier before wake_up James Simmons
2018-10-17 22:43   ` NeilBrown
2018-10-21 22:48     ` James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 04/28] lustre: ptlrpc: Do not assert when bd_nob_transferred != 0 James Simmons
2018-10-17 23:13   ` NeilBrown
2018-10-21 22:44     ` James Simmons
2018-10-22  3:26       ` NeilBrown
2018-11-04 21:29         ` James Simmons
2018-11-04 23:59           ` NeilBrown
2018-10-14 18:57 ` [lustre-devel] [PATCH 05/28] lustre: uapi: add back LUSTRE_MAXFSNAME to lustre_user.h James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 06/28] lustre: ldlm: ELC shouldn't wait on lock flush James Simmons
2018-10-17 23:20   ` NeilBrown
2018-10-20 17:09     ` James Simmons
2018-10-22  3:44       ` NeilBrown
2018-10-14 18:57 ` [lustre-devel] [PATCH 07/28] lustre: llite: pipeline readahead better with large I/O James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 08/28] lustre: hsm: add kkuc before sending registration RPCs James Simmons
2018-10-14 18:57 ` [lustre-devel] [PATCH 09/28] lustre: mdc: improve mdc_enqueue() error message James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 10/28] lustre: llite: Update i_nlink on unlink James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 11/28] lustre: llite: use security context if it's enabled in the kernel James Simmons
2018-10-17 23:34   ` NeilBrown
2018-10-20 17:49     ` James Simmons
2018-10-22  3:47       ` NeilBrown
2018-10-23 23:07         ` James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 12/28] lustre: ptlrpc: do not wakeup every second James Simmons
2018-10-29  0:03   ` NeilBrown
2018-10-29  1:35     ` Patrick Farrell
2018-10-29  2:41       ` NeilBrown
2018-10-29  3:42         ` James Simmons
2018-10-29 14:17           ` Patrick Farrell
2018-11-04 20:53         ` James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 13/28] lustre: ldlm: check lock cancellation in ldlm_cli_cancel() James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 14/28] lustre: ptlrpc: handle case of epp_free_pages <= PTLRPC_MAX_BRW_PAGES James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 15/28] lustre: llite: fix for stat under kthread and X86_X32 James Simmons
2018-10-18  1:48   ` NeilBrown
2018-10-22  3:58     ` NeilBrown
2018-11-04 21:35       ` James Simmons
2018-11-05  0:03         ` NeilBrown
2018-10-14 18:58 ` [lustre-devel] [PATCH 16/28] lustre: statahead: missing barrier before wake_up James Simmons
2018-10-18  2:00   ` NeilBrown
2018-10-21 22:52     ` James Simmons
2018-10-22  4:04       ` NeilBrown
2018-11-04 20:52         ` James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 17/28] lustre: ldlm: Make lru clear always discard read lock pages James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 18/28] lustre: mdc: expose changelog through char devices James Simmons
2018-10-30  6:41   ` NeilBrown
2018-11-04 21:31     ` James Simmons
2018-11-05  0:13       ` NeilBrown
2018-10-14 18:58 ` [lustre-devel] [PATCH 19/28] lustre: uapi: add missing headers in lustre UAPI headers James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 20/28] lustre: obdclass: deprecate OBD_GET_VERSION ioctl James Simmons
2018-10-18  2:12   ` NeilBrown
2018-10-20 18:52     ` James Simmons
2018-10-22  4:08       ` NeilBrown
2018-10-14 18:58 ` [lustre-devel] [PATCH 21/28] lustre: llite: enhance vvp_dev data structure naming James Simmons
2018-10-18  2:15   ` NeilBrown
2018-10-20 18:55     ` James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 22/28] lustre: clio: update spare bit handling James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 23/28] lustre: llog: fix EOF handling in llog_client_next_block() James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 24/28] lustre: llite: IO accounting of page read James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 25/28] lustre: llite: disable statahead if starting statahead fail James Simmons
2018-10-14 18:58 ` [lustre-devel] [PATCH 26/28] lustre: mdc: set correct body eadatasize for getxattr() James Simmons
2018-10-14 18:58 ` James Simmons [this message]
2018-10-14 18:58 ` [lustre-devel] [PATCH 28/28] lustre: llite: restore lld_nfs_dentry handling James Simmons
2018-10-22  4:36 ` [lustre-devel] [PATCH 00/28] lustre: more assorted fixes for lustre 2.10 NeilBrown
2018-10-23 22:34   ` [lustre-devel] [PATCH] lustre: lu_object: fix possible hang waiting for LCS_LEAVING NeilBrown
2018-10-29  3:31     ` James Simmons
2018-10-29  4:31       ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539543498-29105-28-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.