From patchwork Tue May 16 00:05:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhy Kumykov X-Patchwork-Id: 9728215 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 482E4602B4 for ; Tue, 16 May 2017 00:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FD40285FD for ; Tue, 16 May 2017 00:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34637289D6; Tue, 16 May 2017 00:05:15 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 C16BA285FD for ; Tue, 16 May 2017 00:05:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753325AbdEPAFH (ORCPT ); Mon, 15 May 2017 20:05:07 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:33861 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753083AbdEPAFF (ORCPT ); Mon, 15 May 2017 20:05:05 -0400 Received: by mail-pf0-f169.google.com with SMTP id 9so30945469pfj.1 for ; Mon, 15 May 2017 17:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=nQ58XSNMyNasnvPjQzEDHIyMt67KM6ehcfOsWr9KRrg=; b=aBvouOKP1YYpOtS/tdEdtgg6Gb92Jz1ZYo23Ue7d38bF2KGcPzghqY1oS6cjFEE1Ub gQDDBulya0TpxNzgAzTK/YdK7TZEKYXKJDgAkel8tbwG6cEPwDSQXkge+6UWO2RlY9pe +FCL30YBrVPk6La34QAiM4kOXsmuVszArG9DZS5RSi7Ith2vXLZDYsyMOp18bZHcTnkY 0XiR7c0VvU9nZbUeX46HCS9vNypetHxWg1tuEcuITPWJlXa+dq1rxxalxXKNyc9/nrX7 d9dTqiYg4IhhgxHuiy9UwTThYEci/JfzIvS3QRYTsPS6Y2xBXZNhfx8i4ONOVr4bEjG6 pY6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nQ58XSNMyNasnvPjQzEDHIyMt67KM6ehcfOsWr9KRrg=; b=X943vzhrok7bd827jPPPGqNOl9ZbBURPGYDhjniALB9q5tyvkCUlGZX0jG+A1vpH3/ 8J1dLeOKVJOM+miBc/jCuawVpciY6exJIoyKCih6p5O40PYEzoa6JTH6j1p4I4qtodIr 4th66pr8i6VAAbTSqINPxC/UzK/2CXcyLmFmRkwGOoH8gYi1n+kWLj/kuPAmFtQs09Nj cPdE1mtRxDFfxymWt7Poa2Rfi18xYPz4Q/YYwny/Y6rkgOUdbEvRmi399r2SZDXmt8kc aeCs/Ft6CrnVB2EWXxT/XZ+O3kQhemn70BGoYzvUN/FJzQJ/QdGppzNawwp8o+u2VJZN F1Mw== X-Gm-Message-State: AODbwcBx6jgfIfZo7+3KE2L4ur+vt674ChbmYvfko/IlbY6IsPQC1C5p 2OEBZxxXnXJ0QQssk/CPTvFG2kmiJnL2/y0qAA== X-Received: by 10.84.128.65 with SMTP id 59mr11846473pla.121.1494893104904; Mon, 15 May 2017 17:05:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.168.74 with HTTP; Mon, 15 May 2017 17:05:04 -0700 (PDT) From: Khazhismel Kumykov Date: Mon, 15 May 2017 17:05:04 -0700 Message-ID: Subject: Hang/soft lockup in d_invalidate with simultaneous calls To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, I'm seeing behavior in d_invalidate, if multiple threads call d_invalidate on the same tree at the same, behavior time blows up and all the calls hang with large enough trees/enough simultaneous callers. (e.g. a directory w/ 100k entries in d_subdir, and 5 or so threads calling d_invalidate was able to hang my test VMs) This seems to be due to thrashing on the dentry locks in multiple threads tightly looping calling d_walk waiting for a shrink_dentry_list call (also thrashing the locks) to complete. (d_invalidate loops calling d_walk so long as any dentry in the tree is in a dcache shrink list). There was a similar report recently "soft lockup in d_invalidate()" that proposed in the d_invalidate d_walk to ignore dentries marked as in a shrink list already, which does prevent this hang/lockup in this case as well, although I'm not sure it doesn't violate the contract for d_invalidate. (Although the entries in a shrink list should be dropped eventually, not necessarily by the time d_invalidate returns). If someone more familiar with the dcache could provide input I would appreciate. A reliable repro on mainline is: - create a mountpoint with DCACHE_OP_REVALIDATE, e.g. fuse passthrough - create a directory and populate with ~100k files with content to populate dcache - create some background processes opening/reading files in this folder (5 while true; cat $file was enough to get an indefinite hang for me) - cause the directory to need to be invalidated (e.g., make_bad_inode on the directory) This results in the background processes all entering d_invalidate and hanging, while with just one process in d_invalidate (e.g., stat'ing a file in the dir) things go pretty quickly as expected. (The proposed patch from other thread) d_lru_del(dentry); khazhy diff --git a/fs/dcache.c b/fs/dcache.c index 7b8feb6..3a3b0f37 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1364,7 +1364,7 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry) goto out; if (dentry->d_flags & DCACHE_SHRINK_LIST) { - data->found++; + goto out; } else { if (dentry->d_flags & DCACHE_LRU_LIST)