Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp802226ybi; Sun, 30 Jun 2019 00:27:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwS6JdKOg/09tb8WDO6BMYsEW+ewktbYT+yna+jo2oR1J1o5TRPiH0A08XbPqVS6lrgSBxA X-Received: by 2002:a63:d4c:: with SMTP id 12mr18461316pgn.30.1561879665732; Sun, 30 Jun 2019 00:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561879665; cv=none; d=google.com; s=arc-20160816; b=yR5NkBXmN0yEAeEZUG6DixSrVt7VBS4lsL/DJyBt24NpdDu4Jo23Wr155OXXW2s3zu Qx1VcsbuAzaEbdS5surMESKtUcZ0eUUb05Xx9+ypVR+se57noLLQ+EMHGI9tpZNIcxSF Ish31vTWnFR4049G3Kvj1LIM01KuHYo7o+F8epW/eJ0LyvT/tk38bbANWii90C1rOOfB kBSYlY/LZ2iylrp2hv2xl4KnKpQCd2VtfvRE1zn3FTkqbATT1zH2R4bt27qQperjzTry /p7pSm1N/hDFtA3eTQb0Cm7esqEbzzNcEaJtLzz4rJqFY5T8ahAlCfJehlOyq/+zIHS1 qj8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0ifuX0GPUPwU8sJc/BBSReUnmOObSyjtXhS37cebQo4=; b=iC46RymldLY3QRB3J5l3Punaft8OOUxaRSFQW2vWCfp2UC8xTVeNyTc1mcid04Q2a8 m8AxD2Yrg83efdteERZvpPwB1ah9hQDknMDx1+wIEu5hygj2bV6LyCzhSL//SMkYv7m+ 89iwcgBHRDQQ6iRXAuMxfTM3fGtsrgRUeFfBae3oOthY0WokUjsVl/Y36dksSWdAU7yh FVk54KbdTIJ9ixbhGxuxqhMTFQaKZXwn/g+iOXWoK1ZsTGnM9RkRfSHxckb01ONStSGb 4jndSft88hoCJylxrSamsJqlZqb2zVdPYAFmTkgR+tSTIfbOndGKNGYllR7mhg9Sn9xe GwLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=LU835ZbJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y13si6692850pgq.172.2019.06.30.00.27.27; Sun, 30 Jun 2019 00:27:45 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=LU835ZbJ; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbfF3H1X (ORCPT + 99 others); Sun, 30 Jun 2019 03:27:23 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:42127 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfF3H1X (ORCPT ); Sun, 30 Jun 2019 03:27:23 -0400 Received: by mail-ot1-f67.google.com with SMTP id l15so10280003otn.9 for ; Sun, 30 Jun 2019 00:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0ifuX0GPUPwU8sJc/BBSReUnmOObSyjtXhS37cebQo4=; b=LU835ZbJa6zElZNkXLBkWXoIWv0zK5xbEYX9CWP5Tf/akdP5trCGEfpuxDozkOC7bx tQUcIxoINIM+CEi9IRccQJySPhwZ25NmI6sp+AUWSckXq39KldCbbbpCUCdtr7U5FqmS JZWDf/EV1vZJxZJt9Hp4Rmr4lfSgGpuXx35W44uFwcc5gz5iJcQ8d2x0/kVxjbJwKAMZ zJdbi/BO1uliKiutjuwvCpUSl6KpJCoMb6XetG3BAfi0FKTktexTzuJ5KZbUq0xlNwin cFAYQxjjwQpPsbCZ0gLyBIJRre7DPRBKg5qnIinCJ1x1F966ivSqXFFGmmKlbypcwng/ tCfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0ifuX0GPUPwU8sJc/BBSReUnmOObSyjtXhS37cebQo4=; b=I55/1aCFicQlYAI+yLDbX9zAVMRmHgJZMUpz5GgV0SmXRbJvzSL4qCRk4KHkIN31ho vFNvQ/AZkVzJrml0KcAW2b359yfHytxKseX0j8SFTFOeaeDw1PdIUspvUsJJreZWF6oE kWP6ZPGWOgmjMMwJjb4s65TRBJwHitLN76yM7VwpGWkj1HfyeOt0iphEOPN1e0miLNlp vx+7j6gxP51Uk1B6uVjNzQc6sVPsOnmZwF2K0N1ahj5Y+FMrVC90Qcj+At3FKjjG9kDl Ppb/uRpDw3TuySeZ02/AU71MIhmrVzb9ReX+6OTLZxRtkRr57QdUEaDHvu4BzXjYUlXV KtGA== X-Gm-Message-State: APjAAAXF7GQJ/q5liIMGyE9UlZ9alzGwdBEWMFHJQe3w0x/kaSWSSmah ZLCHpQDptm/joF7zA9Gk3MEHNZs2tEAMsiNATLkvRw== X-Received: by 2002:a9d:470d:: with SMTP id a13mr14638073otf.126.1561879642668; Sun, 30 Jun 2019 00:27:22 -0700 (PDT) MIME-Version: 1.0 References: <156159454541.2964018.7466991316059381921.stgit@dwillia2-desk3.amr.corp.intel.com> <20190627123415.GA4286@bombadil.infradead.org> <20190627195948.GB4286@bombadil.infradead.org> <20190629160336.GB1180@bombadil.infradead.org> In-Reply-To: <20190629160336.GB1180@bombadil.infradead.org> From: Dan Williams Date: Sun, 30 Jun 2019 00:27:11 -0700 Message-ID: Subject: Re: [PATCH] filesystem-dax: Disable PMD support To: Matthew Wilcox Cc: linux-nvdimm , Jan Kara , stable , Robert Barror , Seema Pandit , linux-fsdevel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 29, 2019 at 9:03 AM Matthew Wilcox wrote: > > On Thu, Jun 27, 2019 at 07:39:37PM -0700, Dan Williams wrote: > > On Thu, Jun 27, 2019 at 12:59 PM Matthew Wilcox wrote: > > > > > > On Thu, Jun 27, 2019 at 12:09:29PM -0700, Dan Williams wrote: > > > > > This bug feels like we failed to unlock, or unlocked the wrong entry > > > > > and this hunk in the bisected commit looks suspect to me. Why do we > > > > > still need to drop the lock now that the radix_tree_preload() calls > > > > > are gone? > > > > > > > > Nevermind, unmapp_mapping_pages() takes a sleeping lock, but then I > > > > wonder why we don't restart the lookup like the old implementation. > > > > > > We have the entry locked: > > > > > > /* > > > * Make sure 'entry' remains valid while we drop > > > * the i_pages lock. > > > */ > > > dax_lock_entry(xas, entry); > > > > > > /* > > > * Besides huge zero pages the only other thing that gets > > > * downgraded are empty entries which don't need to be > > > * unmapped. > > > */ > > > if (dax_is_zero_entry(entry)) { > > > xas_unlock_irq(xas); > > > unmap_mapping_pages(mapping, > > > xas->xa_index & ~PG_PMD_COLOUR, > > > PG_PMD_NR, false); > > > xas_reset(xas); > > > xas_lock_irq(xas); > > > } > > > > > > If something can remove a locked entry, then that would seem like the > > > real bug. Might be worth inserting a lookup there to make sure that it > > > hasn't happened, I suppose? > > > > Nope, added a check, we do in fact get the same locked entry back > > after dropping the lock. > > > > The deadlock revolves around the mmap_sem. One thread holds it for > > read and then gets stuck indefinitely in get_unlocked_entry(). Once > > that happens another rocksdb thread tries to mmap and gets stuck > > trying to take the mmap_sem for write. Then all new readers, including > > ps and top that try to access a remote vma, then get queued behind > > that write. > > > > It could also be the case that we're missing a wake up. > > OK, I have a Theory. > > get_unlocked_entry() doesn't check the size of the entry being waited for. > So dax_iomap_pmd_fault() can end up sleeping waiting for a PTE entry, > which is (a) foolish, because we know it's going to fall back, and (b) > can lead to a missed wakeup because it's going to sleep waiting for > the PMD entry to come unlocked. Which it won't, unless there's a happy > accident that happens to map to the same hash bucket. > > Let's see if I can steal some time this weekend to whip up a patch. Theory seems to have some evidence... I instrumented fs/dax.c to track outstanding 'lock' entries and 'wait' events. At the time of the hang we see no locks held and the waiter is waiting on a pmd entry: [ 4001.354334] fs/dax locked entries: 0 [ 4001.358425] fs/dax wait entries: 1 [ 4001.362227] db_bench/2445 index: 0x0 shift: 6 [ 4001.367099] grab_mapping_entry+0x17a/0x260 [ 4001.371773] dax_iomap_pmd_fault.isra.43+0x168/0x7a0 [ 4001.377316] ext4_dax_huge_fault+0x16f/0x1f0 [ 4001.382086] __handle_mm_fault+0x411/0x1390 [ 4001.386756] handle_mm_fault+0x172/0x360