From patchwork Mon Apr 30 04:31:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10370749 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 0AA1260234 for ; Mon, 30 Apr 2018 04:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF608289C6 for ; Mon, 30 Apr 2018 04:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4271289CC; Mon, 30 Apr 2018 04:32:56 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 733CA289C6 for ; Mon, 30 Apr 2018 04:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750957AbeD3EcN (ORCPT ); Mon, 30 Apr 2018 00:32:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:38758 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbeD3EcM (ORCPT ); Mon, 30 Apr 2018 00:32:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0FFFCAD0B; Mon, 30 Apr 2018 04:32:11 +0000 (UTC) From: NeilBrown To: "Paul E. McKenney" , Trond Myklebust , Mathieu Desnoyers , Anna Schumaker Date: Mon, 30 Apr 2018 14:31:30 +1000 Subject: [PATCH 2/4] NFS: use cond_resched() when restarting walk of delegation list. Cc: linux-nfs@vger.kernel.org, Lai Jiangshan , Josh Triplett , Steven Rostedt , linux-kernel@vger.kernel.org Message-ID: <152506269057.7246.14981035798693301405.stgit@noble> In-Reply-To: <152506256513.7246.13171564155614823841.stgit@noble> References: <152506256513.7246.13171564155614823841.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- fs/nfs/delegation.c | 3 +++ 1 file changed, 3 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; } }