Received: by 10.192.165.148 with SMTP id m20csp3364908imm; Sun, 29 Apr 2018 21:32:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrgjTuaBKWmOr2L67blT9UIdO2KX/bi3tQJ8wbPPSzXKwLpXTWJLltbaoovn1bFzc5ujSCh X-Received: by 2002:a63:6344:: with SMTP id x65-v6mr9070916pgb.34.1525062766650; Sun, 29 Apr 2018 21:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525062766; cv=none; d=google.com; s=arc-20160816; b=wAmdqCd23JVHA8HRxBQi8JDBrAHrxjg976Rza4Z8do5PWpWghE2pNLyoiKsBqTo1KR N/FG2EJAoooZzlCK1gugcVw1+1TAQ2aAjK7RYwXgXLnjnD3OWdw7Y2BAlQH6X0KdTdZG EfDWHGPRSW7hxeCqn3Z0eppyhwejkKjIyuEAEqadJwyJ6ci8vCfJUyTB2d+o1jRlyi7T +3IoEU23fyqYRorcc56gBwfTbFd7Fmcgb+sGTQlrVYHK75tGYvLHE7d1HOT3kAgDaJg7 QsLn7L7ZPt3MU8jCIXV99BnbVegb3ozHR0VNrt1mqWQPfNheTS7A9rYRriwwU6Md5JVq +eGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from:arc-authentication-results; bh=1WwB86sOMdFySOo5/qTvBMb/SY9j41sMiuvpZD8vTyY=; b=zJVyLtBAeFzObglg54S8Uwc5EL8cOBMbUyCtCyalIjt1zB/lSeOGxfSc8Z1UXVQ6zY KW3aknSd1DwpbV71nCq/bXkQMxLEWWqP5Qos2syWzT9jGnD9UzNnKtiiGo9JgMS1NW+v J1Mno+Yh1op8iWocOE72XVvPehzUi4DH+ydZR80yXUVaWONq0LFfDm/XV9TLUAQBLcy4 SreMFKdD/9nm19ayaaYgamNL7XqfFEDgBBjwBarEQ3qS+rGWfSua8uo5qzXihrLtYPUX 2ZfdsINpWem5v7BEg/0F67ogH6d4rG7zTC+YCXEtAPdJVmdztgRGYou3Jcxn1wOa+vAS p8rQ== 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 d30-v6si6653589pld.92.2018.04.29.21.32.32; Sun, 29 Apr 2018 21:32:46 -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 S1751628AbeD3EcO (ORCPT + 99 others); Mon, 30 Apr 2018 00:32:14 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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; } }