LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Anna Schumaker <anna.schumaker@netapp.com>
Cc: linux-nfs@vger.kernel.org, Lai Jiangshan <jiangshanlai@gmail.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] NFS: use cond_resched() when restarting walk of delegation list.
Date: Mon, 30 Apr 2018 14:31:30 +1000	[thread overview]
Message-ID: <152506269057.7246.14981035798693301405.stgit@noble> (raw)
In-Reply-To: <152506256513.7246.13171564155614823841.stgit@noble>

In three places we walk the list of delegations for an nfs_client
until an interesting one is found, then we act of that delegation
and restart the walk.

New delegations are added to the end of a list and the interesting
delegations are usually old, so in many case we won't repeat
a long walk over and over again, but it is possible - particularly if
the first server in the list has a large number of uninteresting
delegations.

In each cache the work done on interesting delegations will often
complete without sleeping, so this could loop many times without
giving up the CPU.

So add a cond_resched() at an appropriate point to avoid hogging the
CPU for too long.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 fs/nfs/delegation.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index af32365894c8..76ab1374f589 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -508,6 +508,7 @@ int nfs_client_return_marked_delegations(struct nfs_client *clp)
 			err = nfs_end_delegation_return(inode, delegation, 0);
 			iput(inode);
 			nfs_sb_deactive(server->super);
+			cond_resched();
 			if (!err)
 				goto restart;
 			set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
@@ -904,6 +905,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
 			}
 			iput(inode);
 			nfs_sb_deactive(server->super);
+			cond_resched();
 			goto restart;
 		}
 	}
@@ -1020,6 +1022,7 @@ void nfs_reap_expired_delegations(struct nfs_client *clp)
 			}
 			iput(inode);
 			nfs_sb_deactive(server->super);
+			cond_resched();
 			goto restart;
 		}
 	}

  parent reply	other threads:[~2018-04-30  4:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  4:31 [PATCH 0/4 V2] Avoid quadratic search when freeing delegations NeilBrown
2018-04-30  4:31 ` [PATCH 3/4] rculist: add list_for_each_entry_from_rcu() NeilBrown
2018-04-30  5:20   ` Josh Triplett
2018-04-30 13:43     ` Paul E. McKenney
2018-04-30 15:14       ` Steven Rostedt
2018-04-30 15:35         ` Paul E. McKenney
2018-05-01  3:11           ` [PATCH 3/4 v2] " NeilBrown
2018-05-01 14:14             ` Paul E. McKenney
2018-05-01 21:34               ` NeilBrown
2018-04-30  4:31 ` [PATCH 1/4] NFS: slight optimization for walking list for delegations NeilBrown
2018-04-30 15:17   ` Steven Rostedt
2018-05-31  5:23     ` [PATCH 1/4 v2] " NeilBrown
2018-06-04 21:31       ` Steven Rostedt
2018-04-30  4:31 ` NeilBrown [this message]
2018-04-30  4:31 ` [PATCH 4/4] NFS: Avoid quadratic search when freeing delegations 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=152506269057.7246.14981035798693301405.stgit@noble \
    --to=neilb@suse.com \
    --cc=anna.schumaker@netapp.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=trond.myklebust@primarydata.com \
    --subject='Re: [PATCH 2/4] NFS: use cond_resched() when restarting walk of delegation list.' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).