From patchwork Mon Jan 25 16:49:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 8112251 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9C02FBEEE5 for ; Mon, 25 Jan 2016 16:49:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D355520211 for ; Mon, 25 Jan 2016 16:49:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E5CD0202E6 for ; Mon, 25 Jan 2016 16:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932752AbcAYQte (ORCPT ); Mon, 25 Jan 2016 11:49:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59660 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757095AbcAYQtc (ORCPT ); Mon, 25 Jan 2016 11:49:32 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C11EB21A6; Mon, 25 Jan 2016 16:49:32 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0PGnUhq005382; Mon, 25 Jan 2016 11:49:30 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 1/2] cachefilesd can spin when disk space is short. From: David Howells To: linux-cachefs@redhat.com Cc: linux-nfs@vger.kernel.org, neilb@suse.de, steved@redhat.com, dhowells@redhat.com, linux-fsdevel@vger.kernel.org, jlayton@poochiereds.net, jsnow@redhat.com Date: Mon, 25 Jan 2016 16:49:30 +0000 Message-ID: <20160125164930.9670.46763.stgit@warthog.procyon.org.uk> In-Reply-To: <20160125164111.9466.79976.stgit@warthog.procyon.org.uk> References: <20160125164111.9466.79976.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: NeilBrown When cachefilesd finds that it needs to cull, but that culling doesn't achieve anything, it sets an alarm to wake it in 30 seconds to try again. But as read_cache_state() will detect that culling is still needed, it will immediately try again anyway. This results in 100% cpu usage of no value. This patch causes culling to be blocked until the 30 second alarm goes off. It also changes the test to decide whether to enter poll() after blocking signals to test exactly those values that might be changed by a signal. Testing these is important, testing anything else is pointless. Signed-off-by: NeilBrown Signed-off-by: David Howells Reviewed-by: Steve Dickson Reviewed-by: John Snow --- cachefilesd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 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/cachefilesd.c b/cachefilesd.c index 6658ba5..eaa1bb0 100644 --- a/cachefilesd.c +++ b/cachefilesd.c @@ -99,6 +99,7 @@ static struct object **cullready; static unsigned nr_in_build_table; static unsigned nr_in_ready_table; static int ncullable; +static bool cull_delayed; static const char *configfile = "/etc/cachefilesd.conf"; @@ -246,6 +247,7 @@ static void sigio(int sig) static void sigalrm(int sig) { jumpstart_scan = true; + cull_delayed = false; } /*****************************************************************************/ @@ -613,11 +615,11 @@ static void cachefilesd(void) /* sleep without racing on reap and cull with the signal * handlers */ - if (!scan && !reap && !cull) { + if (!scan && !reap && !(cull && !cull_delayed)) { if (sigprocmask(SIG_BLOCK, &sigs, &osigs) < 0) oserror("Unable to block signals"); - if (!reap && !cull) { + if (!reap && !stop && !jumpstart_scan) { if (ppoll(pollfds, 1, NULL, &osigs) < 0 && errno != EINTR) oserror("Unable to suspend process"); @@ -644,7 +646,7 @@ static void cachefilesd(void) if (cull) { if (nr_in_ready_table > 0) cull_objects(); - else if (nr_in_build_table == 0) + else if (nr_in_build_table == 0 && !cull_delayed) jumpstart_scan = true; } @@ -1364,6 +1366,7 @@ static void decant_cull_table(void) /* if nothing there, scan again in a short while */ if (nr_in_build_table == 0) { + cull_delayed = true; signal(SIGALRM, sigalrm); alarm(30); return;