public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Greg Thelen <gthelen@google.com>,
	Dave Chinner <david@fromorbit.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [ 45/63] fs/dcache.c: add cond_resched() to shrink_dcache_parent()
Date: Mon,  6 May 2013 15:56:23 -0700	[thread overview]
Message-ID: <20130506225325.732944542@linuxfoundation.org> (raw)
In-Reply-To: <20130506225314.802167948@linuxfoundation.org>

3.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Greg Thelen <gthelen@google.com>

commit 421348f1ca0bf17769dee0aed4d991845ae0536d upstream.

Call cond_resched() in shrink_dcache_parent() to maintain interactivity.

Before this patch:

	void shrink_dcache_parent(struct dentry * parent)
	{
		while ((found = select_parent(parent, &dispose)) != 0)
			shrink_dentry_list(&dispose);
	}

select_parent() populates the dispose list with dentries which
shrink_dentry_list() then deletes.  select_parent() carefully uses
need_resched() to avoid doing too much work at once.  But neither
shrink_dcache_parent() nor its called functions call cond_resched().  So
once need_resched() is set select_parent() will return single dentry
dispose list which is then deleted by shrink_dentry_list().  This is
inefficient when there are a lot of dentry to process.  This can cause
softlockup and hurts interactivity on non preemptable kernels.

This change adds cond_resched() in shrink_dcache_parent().  The benefit
of this is that need_resched() is quickly cleared so that future calls
to select_parent() are able to efficiently return a big batch of dentry.

These additional cond_resched() do not seem to impact performance, at
least for the workload below.

Here is a program which can cause soft lockup if other system activity
sets need_resched().

	int main()
	{
	        struct rlimit rlim;
	        int i;
	        int f[100000];
	        char buf[20];
	        struct timeval t1, t2;
	        double diff;

	        /* cleanup past run */
	        system("rm -rf x");

	        /* boost nfile rlimit */
	        rlim.rlim_cur = 200000;
	        rlim.rlim_max = 200000;
	        if (setrlimit(RLIMIT_NOFILE, &rlim))
	                err(1, "setrlimit");

	        /* make directory for files */
	        if (mkdir("x", 0700))
	                err(1, "mkdir");

	        if (gettimeofday(&t1, NULL))
	                err(1, "gettimeofday");

	        /* populate directory with open files */
	        for (i = 0; i < 100000; i++) {
	                snprintf(buf, sizeof(buf), "x/%d", i);
	                f[i] = open(buf, O_CREAT);
	                if (f[i] == -1)
	                        err(1, "open");
	        }

	        /* close some of the files */
	        for (i = 0; i < 85000; i++)
	                close(f[i]);

	        /* unlink all files, even open ones */
	        system("rm -rf x");

	        if (gettimeofday(&t2, NULL))
	                err(1, "gettimeofday");

	        diff = (((double)t2.tv_sec * 1000000 + t2.tv_usec) -
	                ((double)t1.tv_sec * 1000000 + t1.tv_usec));

	        printf("done: %g elapsed\n", diff/1e6);
	        return 0;
	}

Signed-off-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/dcache.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1238,8 +1238,10 @@ void shrink_dcache_parent(struct dentry
 	LIST_HEAD(dispose);
 	int found;
 
-	while ((found = select_parent(parent, &dispose)) != 0)
+	while ((found = select_parent(parent, &dispose)) != 0) {
 		shrink_dentry_list(&dispose);
+		cond_resched();
+	}
 }
 EXPORT_SYMBOL(shrink_dcache_parent);
 



  parent reply	other threads:[~2013-05-06 23:47 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 22:55 [ 00/63] 3.4.44-stable review Greg Kroah-Hartman
2013-05-06 22:55 ` [ 01/63] USB: serial: option: Added support Olivetti Olicard 145 Greg Kroah-Hartman
2013-05-06 22:55 ` [ 02/63] USB: option: add a D-Link DWM-156 variant Greg Kroah-Hartman
2013-05-06 22:55 ` [ 03/63] ARM: at91: Fix typo in restart code panic message Greg Kroah-Hartman
2013-05-06 22:55 ` [ 04/63] powerpc: Add isync to copy_and_flush Greg Kroah-Hartman
2013-05-06 22:55 ` [ 05/63] powerpc/spufs: Initialise inode->i_ino in spufs_new_inode() Greg Kroah-Hartman
2013-05-06 22:55 ` [ 06/63] mwifiex: Use pci_release_region() instead of a pci_release_regions() Greg Kroah-Hartman
2013-05-06 22:55 ` [ 07/63] mwifiex: Call pci_release_region after calling pci_disable_device Greg Kroah-Hartman
2013-05-06 22:55 ` [ 08/63] usb/misc/appledisplay: Add 24" LED Cinema display Greg Kroah-Hartman
2013-05-06 22:55 ` [ 09/63] USB: add ftdi_sio USB ID for GDM Boost V1.x Greg Kroah-Hartman
2013-05-06 22:55 ` [ 10/63] USB: ftdi_sio: correct ST Micro Connect Lite PIDs Greg Kroah-Hartman
2013-05-06 22:55 ` [ 11/63] usbfs: Always allow ctrl requests with USB_RECIP_ENDPOINT on the ctrl ep Greg Kroah-Hartman
2013-05-06 22:55 ` [ 12/63] usb-storage: CY7C68300A chips do not support Cypress ATACB Greg Kroah-Hartman
2013-05-06 22:55 ` [ 13/63] s390/memory hotplug: prevent offline of active memory increments Greg Kroah-Hartman
2013-05-06 22:55 ` [ 14/63] xen/time: Fix kasprintf splat when allocating timer%d IRQ line Greg Kroah-Hartman
2013-05-06 22:55 ` [ 15/63] serial_core.c: add put_device() after device_find_child() Greg Kroah-Hartman
2013-05-06 22:55 ` [ 16/63] arm: set the page table freeing ceiling to TASK_SIZE Greg Kroah-Hartman
2013-05-06 22:55 ` [ 17/63] gianfar: do not advertise any alarm capability Greg Kroah-Hartman
2013-05-06 22:55 ` [ 18/63] tty: fix up atime/mtime mess, take three Greg Kroah-Hartman
2013-05-06 22:55 ` [ 19/63] fbcon: when font is freed, clear also vc_font.data Greg Kroah-Hartman
2013-05-06 22:55 ` [ 20/63] tracing: Use stack of calling function for stack tracer Greg Kroah-Hartman
2013-05-06 22:55 ` [ 21/63] tracing: Fix stack tracer with fentry use Greg Kroah-Hartman
2013-05-06 22:56 ` [ 22/63] tracing: Remove most or all of stack tracer stack size from stack_max_size Greg Kroah-Hartman
2013-05-06 22:56 ` [ 23/63] tracing: Fix off-by-one on allocating stat->pages Greg Kroah-Hartman
2013-05-06 22:56 ` [ 24/63] tracing: Check return value of tracing_init_dentry() Greg Kroah-Hartman
2013-05-06 22:56 ` [ 25/63] tracing: Reset ftrace_graph_filter_enabled if count is zero Greg Kroah-Hartman
2013-05-06 22:56 ` [ 26/63] i2c: xiic: must always write 16-bit words to TX_FIFO Greg Kroah-Hartman
2013-05-06 22:56 ` [ 27/63] sysfs: fix use after free in case of concurrent read/write and readdir Greg Kroah-Hartman
2013-05-06 22:56 ` [ 28/63] Fix initialization of CMCI/CMCP interrupts Greg Kroah-Hartman
2013-05-06 22:56 ` [ 29/63] PCI / ACPI: Dont query OSC support with all possible controls Greg Kroah-Hartman
2013-05-06 22:56 ` [ 30/63] PCI/PM: Fix fallback to PCI_D0 in pci_platform_power_transition() Greg Kroah-Hartman
2013-05-06 22:56 ` [ 31/63] Wrong asm register contraints in the futex implementation Greg Kroah-Hartman
2013-05-06 22:56 ` [ 32/63] Wrong asm register contraints in the kvm implementation Greg Kroah-Hartman
2013-05-06 22:56 ` [ 33/63] fs/fscache/stats.c: fix memory leak Greg Kroah-Hartman
2013-05-06 22:56 ` [ 34/63] mm: allow arch code to control the user page table ceiling Greg Kroah-Hartman
2013-05-06 22:56 ` [ 35/63] ALSA: snd-usb: try harder to find USB_DT_CS_ENDPOINT Greg Kroah-Hartman
2013-05-06 22:56 ` [ 36/63] ALSA: usb-audio: disable autopm for MIDI devices Greg Kroah-Hartman
2013-05-06 22:56 ` [ 37/63] ALSA: usb-audio: Fix autopm error during probing Greg Kroah-Hartman
2013-05-06 22:56 ` [ 38/63] ARM: 7702/1: Set the page table freeing ceiling to TASK_SIZE Greg Kroah-Hartman
2013-05-06 22:56 ` [ 39/63] ASoC: max98088: Fix logging of hardware revision Greg Kroah-Hartman
2013-05-06 22:56 ` [ 40/63] hrtimer: Fix ktime_add_ns() overflow on 32bit architectures Greg Kroah-Hartman
2013-05-06 22:56 ` [ 41/63] hrtimer: Add expiry time overflow check in hrtimer_interrupt Greg Kroah-Hartman
2013-05-06 22:56 ` [ 42/63] drivers/rtc/rtc-cmos.c: dont disable hpet emulation on suspend Greg Kroah-Hartman
2013-05-06 22:56 ` [ 43/63] cgroup: fix an off-by-one bug which may trigger BUG_ON() Greg Kroah-Hartman
2013-05-06 22:56 ` [ 44/63] clockevents: Set dummy handler on CPU_DEAD shutdown Greg Kroah-Hartman
2013-05-06 22:56 ` Greg Kroah-Hartman [this message]
2013-05-06 22:56 ` [ 46/63] LOCKD: Ensure that nlmclnt_block resets block->b_status after a server reboot Greg Kroah-Hartman
2013-05-06 22:56 ` [ 47/63] md: bad block list should default to disabled Greg Kroah-Hartman
2013-05-06 22:56 ` [ 48/63] NFSv4: Handle NFS4ERR_DELAY and NFS4ERR_GRACE in nfs4_open_delegation_recall Greg Kroah-Hartman
2013-05-06 22:56 ` [ 49/63] nfsd4: dont close read-write opens too soon Greg Kroah-Hartman
2013-05-06 22:56 ` [ 50/63] nfsd: Decode and send 64bit time values Greg Kroah-Hartman
2013-05-06 22:56 ` [ 51/63] wireless: regulatory: fix channel disabling race condition Greg Kroah-Hartman
2013-05-06 22:56 ` [ 52/63] ipc: sysv shared memory limited to 8TiB Greg Kroah-Hartman
2013-05-06 22:56 ` [ 53/63] ixgbe: fix EICR write in ixgbe_msix_other Greg Kroah-Hartman
2013-05-06 22:56 ` [ 54/63] jbd2: fix race between jbd2_journal_remove_checkpoint and ->j_commit_callback Greg Kroah-Hartman
2013-05-06 22:56 ` [ 55/63] ext4: fix journal callback list traversal Greg Kroah-Hartman
2013-05-06 22:56 ` [ 56/63] ext4: fix online resizing for ext3-compat file systems Greg Kroah-Hartman
2013-05-06 22:56 ` [ 57/63] ext4: fix Kconfig documentation for CONFIG_EXT4_DEBUG Greg Kroah-Hartman
2013-05-06 22:56 ` [ 58/63] mmc: at91/avr32/atmel-mci: fix DMA-channel leak on module unload Greg Kroah-Hartman
2013-05-06 22:56 ` [ 59/63] KVM: X86 emulator: fix source operand decoding for 8bit mov[zs]x instructions Greg Kroah-Hartman
2013-05-06 22:56 ` [ 60/63] x86: Eliminate irq_mis_count counted in arch_irq_stat Greg Kroah-Hartman
2013-05-06 22:56 ` [ 61/63] mmc: core: Fix bit width test failing on old eMMC cards Greg Kroah-Hartman
2013-05-06 22:56 ` [ 62/63] mmc: atmel-mci: pio hang on block errors Greg Kroah-Hartman
2013-05-06 22:56 ` [ 63/63] mfd: adp5520: Restore mode bits on resume Greg Kroah-Hartman
     [not found] ` <CAKocOOOxtJMoqWVgPLcrCJZ0kJuJ-QF0vQEU6Vk70n4J=+9ttw@mail.gmail.com>
2013-05-07 19:20   ` [ 00/63] 3.4.44-stable review Shuah Khan

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=20130506225325.732944542@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@fromorbit.com \
    --cc=gthelen@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox