Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1640710ybi; Wed, 3 Jul 2019 20:28:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa6gFTCaJq5ua/aqKpYDcb2EmpE4zLHtTHCkgH8xrootVcDj9OR8jTnASCmoWH82ERS+K4 X-Received: by 2002:a17:902:8546:: with SMTP id d6mr45399192plo.207.1562210889145; Wed, 03 Jul 2019 20:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562210889; cv=none; d=google.com; s=arc-20160816; b=TUNEiRVUG0AcFGjidcfAvLFFvF1QfCxZ5hCRh4vntHVaYfA3aD2DXHhd/i19uJam9t ZYfgn3efmAXOcsRlxaHdFw70lDoLonWsjAG14ZlrxylzvMYZ6+Hw3uvfa+dYXhIpHwid SzMG5eNWsSsnlLneuen5guiRSj6UmwIeblqQYTrHHU4UkPg1dfR9sKkPzijsTaQwbBE3 FYUThWVeayGmFWyspToJRYu9gvQamDwC66dAWnq8YxV2C+GKfiFrHaxClYv+b+L9bVQf O/x1gPWNK1WhZZjA8Y8dgbSftt2sfcJjQ2UfLXAEH0MCdOLxelGiBhzi5LZ/TsDqhtoM UkFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bfUuotpsA7QM4d+GD8HA3DqaH0YT4JnSqveOPEJHZmE=; b=PEXsSqTzqcOwkm1f1QzQj2sUgTxqQEkM70C4kdGp9zCP6Jy/0IWlYB+Gpr/xJeTL2a K0mmTWsUXdBvFAXhBS4hYy7xofoETdkPA9t0mcit43SfYQgj7KJLIhOcHdXYtxnD6+EJ YcaMNtivXHzaf4Wd4ejgVImrfhzR51D4Sa/1V8yy/Ue4GNiPmhv+t6JaQZUN9R3+gc5a A7GgXaX3e4zlTmgxCPb1Zev22zqiDz0KYxuUeKLkUZ0OeycLFOY6khHREQDcRK1s9KU+ 5m4nXD9QlRUGQASaP8RbZa8IoKBjoSiU5+v1ZMe4IMp7DdDgNRpB28D4rSP/7UTHNyhZ Yb+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DYj+iswC; 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 u21si3999070pgm.431.2019.07.03.20.27.50; Wed, 03 Jul 2019 20:28:09 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DYj+iswC; 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 S1727205AbfGDD1a (ORCPT + 99 others); Wed, 3 Jul 2019 23:27:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59376 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726964AbfGDD1a (ORCPT ); Wed, 3 Jul 2019 23:27:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bfUuotpsA7QM4d+GD8HA3DqaH0YT4JnSqveOPEJHZmE=; b=DYj+iswCGfqMvh6Vcet5Evj0Y GsyD8CyUisYULDtQjbA5vGZ/hNXgspOgh006SQe1+qr7TZT1AYlYjAkdkiYkjFqTvS8LExPkDsSrr uw06xq/QsEuX5TQP7ma8p2d9Mx/iXMiWVC7aIfPC7vnXkkQD9TrdwQwkpdfYAkHIxKz2R1N70Z84l 3xhXHDMy3VQY/86p5LEXocdyG1zM5kB6mQK24lQ51xK5okoPAGeaUuzjsH1kNEoroTvfk1i+U9esr G1GFk7RgJtLXqaHP8ZjaorampgpGJFFeAUoYwGLs6Y46p0O2fTKSxrdtPrKaMQi4oYQhBc4pdeaaj BiqQpmSNA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hisPA-0006Hf-Tn; Thu, 04 Jul 2019 03:27:28 +0000 Date: Wed, 3 Jul 2019 20:27:28 -0700 From: Matthew Wilcox To: Dan Williams Cc: linux-fsdevel , Jan Kara , Boaz Harrosh , stable , Robert Barror , Seema Pandit , linux-nvdimm , Linux Kernel Mailing List Subject: Re: [PATCH] dax: Fix missed PMD wakeups Message-ID: <20190704032728.GK1729@bombadil.infradead.org> References: <156213869409.3910140.7715747316991468148.stgit@dwillia2-desk3.amr.corp.intel.com> <20190703121743.GH1729@bombadil.infradead.org> <20190703195302.GJ1729@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 02:28:41PM -0700, Dan Williams wrote: > On Wed, Jul 3, 2019 at 12:53 PM Matthew Wilcox wrote: > > @@ -211,7 +215,8 @@ static void *get_unlocked_entry(struct xa_state *xas) > > for (;;) { > > entry = xas_find_conflict(xas); > > if (!entry || WARN_ON_ONCE(!xa_is_value(entry)) || > > - !dax_is_locked(entry)) > > + !dax_is_locked(entry) || > > + dax_entry_order(entry) < xas_get_order(xas)) > > Doesn't this potentially allow a locked entry to be returned for a > caller that expects all value entries are unlocked? It only allows locked entries to be returned for callers which pass in an xas which refers to a PMD entry. This is fine for grab_mapping_entry() because it checks size_flag & is_pte_entry. dax_layout_busy_page() only uses 0-order. __dax_invalidate_entry() only uses 0-order. dax_writeback_one() needs an extra fix: /* Did a PMD entry get split? */ if (dax_is_locked(entry)) goto put_unlocked; dax_insert_pfn_mkwrite() checks for a mismatch of pte vs pmd. So I think we're good for all current users. > > +#ifdef CONFIG_XARRAY_MULTI > > + unsigned int sibs = xas->xa_sibs; > > + > > + while (sibs) { > > + order++; > > + sibs /= 2; > > + } > > Use ilog2() here? Thought about it. sibs is never going to be more than 31, so I don't know that it's worth eliminating 5 add/shift pairs in favour of whatever the ilog2 instruction is on a given CPU. In practice, on x86, sibs is going to be either 0 (PTEs) or 7 (PMDs). We could also avoid even having this function by passing PMD_ORDER or PTE_ORDER into get_unlocked_entry(). It's probably never going to be noticable in this scenario because it's the very last thing checked before we put ourselves on a waitqueue and go to sleep.