Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5333058ybv; Tue, 11 Feb 2020 13:42:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwcn1lPeSnaJFh/MjbJeLKFHYwzJcRU6mXfjqM/ULkldIxuwCkm8GwYnM7uXl6brXjrh+hC X-Received: by 2002:a9d:4c06:: with SMTP id l6mr7000453otf.161.1581457351185; Tue, 11 Feb 2020 13:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581457351; cv=none; d=google.com; s=arc-20160816; b=cbEFcVqL2ZiJUR209fE+3PecDSUd1GxSsWUDTn4Rq88N0Ye+3cFRGP+pP2x1aH/bnK 8TvQ8po4oCdwqsgKTztT3yniqIKMOixONrE/szInp7+CNPsut05Qu5IPKKCMn2QO4pmF YnUlVwPl1k6hHK0gPRSBwyDVvDzkURJ4VDv8zEU9fQRmUGEPDLOXDVi0WD/LoGZNHApi nY5j3LlXwQki7RDB6Aym0kkzbKld6Mfm7eEuX8Vmotzh82rwbrLve6aTgvcFJNaJNzDT pw8uW+eoEJuZ8xI470tkwSji1yrejeNXmFXw0dP6+XJ8pVzNAYDW2aL2MSPhLN8gxPGr owUg== 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=extxsRRjmkIJZEh/sTfq/VSUaht64zLviDFgNerAR0E=; b=iDRN2p9Z+xY7jpeUKdFxDwfgZCmYQMJaqs2Uqf7RdGgpJbUkUwUpzA+K/ajNbeD1B9 y0lsnP/vJuRMPhbDmrzdlN7MRaxeLPx5k89vnw5ErMDMiEYSANdYd/YoLi+iYz1XSVK+ CRJicQANrVw463hOiaAbRwoMkpCboZXF1thIVmMKaLmw9/EDbTU9Pp8FaMxQVXJusk3f UAUi7frDTWvEPEO9Z/S+tr13WWHkH62eDYDfYGJLrHVaea4iKURY6j/Fzlrc/e3FefHT KaiJ+3y7w9AzOnW2fOnFYrQZp4iVVQfqErza/DO8LmeFydTbKZLC54gOst1GsE655f9Z 2leQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=I1xwH6By; 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 w142si2280235oia.132.2020.02.11.13.42.19; Tue, 11 Feb 2020 13:42:31 -0800 (PST) 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=I1xwH6By; 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 S1731938AbgBKU7w (ORCPT + 99 others); Tue, 11 Feb 2020 15:59:52 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:46092 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729286AbgBKU7w (ORCPT ); Tue, 11 Feb 2020 15:59:52 -0500 Received: by mail-oi1-f196.google.com with SMTP id a22so14163572oid.13 for ; Tue, 11 Feb 2020 12:59:52 -0800 (PST) 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=extxsRRjmkIJZEh/sTfq/VSUaht64zLviDFgNerAR0E=; b=I1xwH6Byix/62gQ54cfQkAhK3Jz6DZUnPEusCbQQ20skEH7t7q1ersOxFM2h8eTjFq W7bs4biU+p5p2rBb8nacmQ+AyuU973vMUnU/taHRlqpu4s2LfDLV9nh68R67/9IHN54V Zh1uALOWVcrlvsNNTZj0JZWfKbx+OG02U4MDSQGMPZxKTRuUDEWL3k7FpR4YqEPKNedQ mbTRld4FShJFNSCJLfhgOHJtcCGpyJIJ05CACfqm36E8Iq18xxlsLL5OWXDS1sXJ/AEq eWX5eMKrKADz9NYuNYEImIqQzMkm5dSAeKK6nzyOMYNcJHbAsQb7Ua1pJrY91i0sa1G7 ooQA== 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=extxsRRjmkIJZEh/sTfq/VSUaht64zLviDFgNerAR0E=; b=duHyUSHguPOanrmXcmzIxFfH6bNnvV1qkRCjKkIxo/2tAnUeLT7adTPqhcO5CEf/80 wKMpZWL/qg0bpLZ1e/DdbCiuNCNR8hbhMXJ6EpfjRq93VEJXrkZaAw8hRzUXRPz+OQWN 4VVZEKVEX4K1a5bAm3Bwff1yhcqnRm3luTVcGTnxAtBWwd6R2irkzzCQK+vAfVMWDKkR GzEzaR1I3CZKIMpt/7WTDvvNaVu1FTKm/C6HNMeU43SW1+iP7VGEU2pctHYi4ErK3HXO eb4IMXthiFU4eTKr15N/lodhGZ0oRfEQbO+i9TU61aUJ/2jq1TkfszvHzfKUSRVh9he0 Me8A== X-Gm-Message-State: APjAAAVU1kzZYhvUQ35m3ZoaG5JZZcEQ/un2wx4uBRZEHQPeGYmWhQEb QgHxYi+cWAozDLhwHMONV2zVxTYWsrJoAItS/bBXrw== X-Received: by 2002:aca:3f54:: with SMTP id m81mr3957419oia.73.1581454791852; Tue, 11 Feb 2020 12:59:51 -0800 (PST) MIME-Version: 1.0 References: <20200208193445.27421-1-ira.weiny@intel.com> <20200208193445.27421-8-ira.weiny@intel.com> <20200211080035.GI10776@dread.disaster.area> <20200211201430.GE12866@iweiny-DESK2.sc.intel.com> In-Reply-To: <20200211201430.GE12866@iweiny-DESK2.sc.intel.com> From: Dan Williams Date: Tue, 11 Feb 2020 12:59:40 -0800 Message-ID: Subject: Re: [PATCH v3 07/12] fs: Add locking for a dynamic DAX state To: Ira Weiny Cc: Dave Chinner , Linux Kernel Mailing List , Alexander Viro , "Darrick J. Wong" , Christoph Hellwig , "Theodore Y. Ts'o" , Jan Kara , linux-ext4 , linux-xfs , linux-fsdevel 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 Tue, Feb 11, 2020 at 12:14 PM Ira Weiny wrote: > > On Tue, Feb 11, 2020 at 07:00:35PM +1100, Dave Chinner wrote: > > On Sat, Feb 08, 2020 at 11:34:40AM -0800, ira.weiny@intel.com wrote: > > > From: Ira Weiny > > > > > > DAX requires special address space operations but many other functions > > > check the IS_DAX() state. > > > > > > While DAX is a property of the inode we perfer a lock at the super block > > > level because of the overhead of a rwsem within the inode. > > > > > > Define a vfs per superblock percpu rs semaphore to lock the DAX state > > > > ???? > > oops... I must have forgotten to update the commit message when I did the > global RW sem. I implemented the per-SB, percpu rwsem first but it was > suggested that the percpu nature of the lock combined with the anticipated > infrequent use of the write side made using a global easier. > > But before I proceed on V4 I'd like to get consensus on which of the 2 locking > models to go with. > > 1) percpu per superblock lock > 2) per inode rwsem > > Depending on my mood I can convince myself of both being performant but the > percpu is very attractive because I don't anticipate many changes of state > during run time. OTOH concurrent threads accessing the same file at run time > may also be low so there is likely to be little read contention across CPU's on > the per-inode lock? > > Opinions? As one who thought a global lock would be reasonable relative to how often dax address_space_operations are swapped out (on the order of taking cgroup_threadgroup_rwsem for write), I think a per-superblock lock is also an ok starting point. We can always go to finer grained locking in the future if we see evidence that the benefits of percpu are lost to stopping the world at the superblock level.