Received: by 10.192.165.156 with SMTP id m28csp1187967imm; Fri, 13 Apr 2018 15:05:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx48JcEA5/hsTykgJrRl+GeuWidZ3+mgDa3FvBQAabP33dFAxz5t6/PNnoDO8A/9YJVZd60F7 X-Received: by 10.98.185.23 with SMTP id z23mr12983640pfe.180.1523657115870; Fri, 13 Apr 2018 15:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523657115; cv=none; d=google.com; s=arc-20160816; b=oprvzrZIhzCbEr79RfpVxdPCTnS9bqUdge6C053RQ+UsdqJ8KQr9sSsfKXR5tb7gyC umxzV5Qb+UoiQVyuhnO0KltvqfRnPD3NYrImg5hI6uYI0doJTUd45G7BRp8BLfjTGwsH okJI2MCRccsAkA36e0jh6iOzuJVe7s25mRC5PjQX2zuA23eeInd/R3I1MRIxRsLKO0U4 vZpKE2OCinL18zVKI/jsL7I52qH0WwK6qdQ5Y+ASvTrER1nItgP8oCPOpDyrC4dUPSSM izMgEhjFyaQXBi8Z/Uv3PsRYMORAG9DF1fybO+uCGJwg8TOXgm/hZmhrnvik7yUMh4kF ANfQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=nMYaCC3lpIVaXvbKDe3/sMjJvLH6pimgqUVCCPiSGuI=; b=AVPw1Om5g0ofvkqOH7R+mP10C9v+4Y0qJWOooet1vsOdrDwydu/Oln+XxaFR1vJMxv jcwyg8EZqA74XMzaPXkSLMhNuxqkj4IDb0JG/RjsAxU9us2Mml7g0BDH3/p5yq9KB+33 YcnvXVHx+abS6GNuj9pi5tZa6igK/OuN7affilnhvO12aRuQbqNeZIkmPP9G0nBdmkLF Tgg8mSkiRcEbhRcsGuEqDR5oueQLxQO9hmDKgmQks7Lnmyv10Bg3Ok/yUaNnteaIazkt MMiKkqa48d2ETkSrX3DdJwEIEKDNkmeyjhwKrJ4X+vwUW1xbgMj3juVkwa/jBcCT3/dd np2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=xX2NOvl7; 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 2si5295689pfk.291.2018.04.13.15.05.01; Fri, 13 Apr 2018 15:05:15 -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=xX2NOvl7; 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 S1752317AbeDMWDz (ORCPT + 99 others); Fri, 13 Apr 2018 18:03:55 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:42637 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbeDMWDw (ORCPT ); Fri, 13 Apr 2018 18:03:52 -0400 Received: by mail-oi0-f65.google.com with SMTP id 26-v6so119355ois.9 for ; Fri, 13 Apr 2018 15:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nMYaCC3lpIVaXvbKDe3/sMjJvLH6pimgqUVCCPiSGuI=; b=xX2NOvl7FCenQFpw2gZwzW5VXYX/GYuTxooE7VV6jSkdnJAHX7NKXx6TwknceSbaH0 LOI9Gag9CTWwQdyS8N4LXEf57cpSZnA+36W4aKT3bOkPQTbuAXDKvf3FRrpgEv4gHGW5 9MP5+YPxXr6RjpEx06KrBI8M0737DjrQGqx/H847rbaWgiKUTf1lq4UmRlkSZpD4LCKL m8CqUtQyPJw7khHqnnq7gS3PHyIWaL7mv6X4Mz2Y5n6zOwaK6fMGzk32ja9UnJ2o/eku DIyoYFnWt0MwdgfIAj/gEMFEg9P2O4xPERI7x3UDpwNmVXewdlNfIcKp5bpDMdISWdhk Muqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nMYaCC3lpIVaXvbKDe3/sMjJvLH6pimgqUVCCPiSGuI=; b=EZ1SzXB9teOUNAV9cr8TYdUvKGh7m19H7hFBZSiov/fz19T7yqa1NQ+WY+y/1Lta+x rmYU/3AqFceWaPaKQWySbWgqyVH/Pa/UlOmF2ffmwxvpM8ytHpE+WGDMzil1Mi5s7YWU Qf06fpd+wd9Vyio4mWmQa9Ztov1bJFQaqcO+/eqB0fdvlgGrl04vdePiuI+VmlCYJ/eX hqMyTgdZ0CwceSd5LT344aVcHDiNyp4j/tHtNpKBrjqMPxiqTIs6WP3fPL72rOmxeD2n hodN8T3MiLearsoRYPRUqubtuzi7HNZ3h03quPmxcW3KB2xQTlFMEMM0nZkVVWRbTXBf jbHA== X-Gm-Message-State: ALQs6tCs+fxKUw5rOr+r7porGKInqrFHBYGuH2sJM3P8+BBUa4lGNWXs QLCI9GpsfdfVp359QLfrE+hvPDTLRXucatx0d0xHbQ== X-Received: by 2002:aca:b5c2:: with SMTP id e185-v6mr9006653oif.166.1523657031560; Fri, 13 Apr 2018 15:03:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2435:0:0:0:0:0 with HTTP; Fri, 13 Apr 2018 15:03:51 -0700 (PDT) In-Reply-To: References: <152246892890.36038.18436540150980653229.stgit@dwillia2-desk3.amr.corp.intel.com> <152246901060.36038.4487158506830998280.stgit@dwillia2-desk3.amr.corp.intel.com> <20180404094656.dssixqvvdcp5jff2@quack2.suse.cz> <20180409164944.6u7i4wgbp6yihvin@quack2.suse.cz> From: Dan Williams Date: Fri, 13 Apr 2018 15:03:51 -0700 Message-ID: Subject: Re: [PATCH v8 15/18] mm, fs, dax: handle layout changes to pinned dax mappings To: Jan Kara Cc: linux-nvdimm , Jeff Moyer , Dave Chinner , Matthew Wilcox , Alexander Viro , "Darrick J. Wong" , Ross Zwisler , Dave Hansen , Andrew Morton , Christoph Hellwig , linux-fsdevel , linux-xfs , Linux Kernel Mailing List , Mike Snitzer , Paul McKenney , Josh Triplett 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 Mon, Apr 9, 2018 at 9:51 AM, Dan Williams wrote: > On Mon, Apr 9, 2018 at 9:49 AM, Jan Kara wrote: >> On Sat 07-04-18 12:38:24, Dan Williams wrote: > [..] >>> I wonder if this can be trivially solved by using srcu. I.e. we don't >>> need to wait for a global quiescent state, just a >>> get_user_pages_fast() quiescent state. ...or is that an abuse of the >>> srcu api? >> >> Well, I'd rather use the percpu rwsemaphore (linux/percpu-rwsem.h) than >> SRCU. It is a more-or-less standard locking mechanism rather than relying >> on implementation properties of SRCU which is a data structure protection >> method. And the overhead of percpu rwsemaphore for your use case should be >> about the same as that of SRCU. > > I was just about to ask that. Yes, it seems they would share similar > properties and it would be better to use the explicit implementation > rather than a side effect of srcu. ...unfortunately: BUG: sleeping function called from invalid context at ./include/linux/percpu-rwsem.h:34 [..] Call Trace: dump_stack+0x85/0xcb ___might_sleep+0x15b/0x240 dax_layout_lock+0x18/0x80 get_user_pages_fast+0xf8/0x140 ...and thinking about it more srcu is a better fit. We don't need the 100% exclusion provided by an rwsem we only need the guarantee that all cpus that might have been running get_user_pages_fast() have finished it at least once. In my tests synchronize_srcu is a bit slower than unpatched for the trivial 100 truncate test, but certainly not the 200x latency you were seeing with syncrhonize_rcu. Elapsed time: 0.006149178 unpatched 0.009426360 srcu