Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4323855imm; Fri, 18 May 2018 03:14:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpH/QwUToMQmCaETIn+rqBRKe59uT0XhFaoAXS4fkeVWOYhn5gVPJ8uocjFC6XgGn8lrg+x X-Received: by 2002:a62:6a0a:: with SMTP id f10-v6mr8650233pfc.99.1526638477262; Fri, 18 May 2018 03:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526638477; cv=none; d=google.com; s=arc-20160816; b=yF1CLCWS7cMCqypx2uBvJpUt+glEchefy0jl1gkhasgJEvwXAvz+ds7sSPAbU0RrkL +ovrcf7EwP4pm/oiQp7HdZIu9OlJGfFOvsKEhBp5UW5PhFhe02jRhb1n9R2rtgjs+bu4 15Mvxniz1s0BC1XeGB/miOsuITSrZNOZw2kIq1rfukBuWdH0qPO4Zx1HpXWh40E45QY5 Iy0dfJ/MiehLehCREoZwUPIt+QncXBcYyo82wcbEoWUZ8yIqQKOmj5PZCmk4Tzkxkw+w bPH05bwGHBs7YPAMyFzYjmM7TpA1DTjkQcmmuTK9swphZQw9uy9KI+6YxvluGarMzc+I OkBQ== 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:arc-authentication-results; bh=qm4u/9qeRVIM/WfUPGdx1ub6Q/QPZ7hbohNSF7LMbK4=; b=iXThruvOcyvRkES5/o0AB3xSsWZRuD3/GH1ImJ02neusbZDvBROgJY/cTiGFcPSnhW MHzfAipt2JM0tZUrRbFP1KGwHHUo9ZeLqBC1sebEmUMSDsw/HwIkDF8M33nBG5NDqxWW 2GHOcGzIY7rxTqd8fIzlPpDueomgAvlezrfu/vReH6H3u/1Ps9GuufGi35DtaYDEsr2g HC4q0YC2lrOq0qr+VGm33ra7x7y9XfiMTgqRc3ZKmSeLhnmgVZ2qVknKF9MStnCLP4Ia Q6yZrA0CX0i24IoJVPV064V1CrlQag7rjWMwrNS5tN3r3hGz7SqEwKQGMn9bjXdVhf3p ArgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZN1T3AOG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14-v6si5531486pgc.664.2018.05.18.03.14.23; Fri, 18 May 2018 03:14:37 -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=@gmail.com header.s=20161025 header.b=ZN1T3AOG; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752528AbeERKOA (ORCPT + 99 others); Fri, 18 May 2018 06:14:00 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:36925 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbeERKN6 (ORCPT ); Fri, 18 May 2018 06:13:58 -0400 Received: by mail-qk0-f196.google.com with SMTP id r28-v6so3691111qkk.4; Fri, 18 May 2018 03:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=qm4u/9qeRVIM/WfUPGdx1ub6Q/QPZ7hbohNSF7LMbK4=; b=ZN1T3AOGu3+/vQMbRTi+tfPMyLQG0+8t21/xB3ANG4hWX7JdG4cujvTOtpNnd5GQX9 hiM+cIRiMlvufvAa1I6FmbV07djkPrLLrTq9exlNgbQ7gWrNIwEBZbJvtNodUP5lSbST eexOly2A3GkLHzS7hJJ4xp8H84+pKaqewHSiVa3tyricij0LokLHSFGJjkM6c3Ib3g0w UG1coeo4YnIPQX8nMPmCXeIy19BOixIqrAPk7Hdp3d2AVEUD4gpt1/Va863D3GVB/Zrn TFAEASI/2oeWEleqjx0Yiv1giwoaApBay2pzVNB4/DI7T/KEcwVRTrRq2WfRiraXw8YB nu1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=qm4u/9qeRVIM/WfUPGdx1ub6Q/QPZ7hbohNSF7LMbK4=; b=USPu1Rr0EX9TLH8Hn3j8kWhjBVphiLnuVTMWhRT+POGYLt43J3I9LEnDi4hMSPj8E2 vJ+Ud0yDZSq7Wpcw6gNoQ9WasGA1UaaKTUkfYCD2GSoYhwilLYdZn2UOYPz0hQKWIG8S hFVA0g5NrULJKOTih3q3mgqjCVzY++7n/aLF56IdFpshMmOEWmdYJwIfDb8ocNibekNB MPBodZ3v7XRRZIAlfBUozQLOu3Mc3Hvr9gBjNjs+QtZmFi43iSPJu8R2LxIDNXuymCaZ svWYhG36m8GQmxaHdRhHiE6t/sCVhopgDvV5PU6kT6IQKqO44CCZb+uqnOrr3inFiWWI rvdw== X-Gm-Message-State: ALKqPweiZKwi00FuQgli4u00dtRX2NGC1eP+Ud/2IfJxmeF9enR1kMfR OZS6HKeVpqWtmqRykyfPa/uJNi8a3A== X-Received: by 2002:a37:a684:: with SMTP id p126-v6mr1678933qke.256.1526638437401; Fri, 18 May 2018 03:13:57 -0700 (PDT) Received: from kmo-pixel (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id q23-v6sm5417942qta.20.2018.05.18.03.13.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 03:13:56 -0700 (PDT) Date: Fri, 18 May 2018 06:13:53 -0400 From: Kent Overstreet To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Dave Chinner , darrick.wong@oracle.com, tytso@mit.edu, linux-btrfs@vger.kernel.org, clm@fb.com, jbacik@fb.com, viro@zeniv.linux.org.uk, willy@infradead.org Subject: Re: [PATCH 03/10] locking: bring back lglocks Message-ID: <20180518101353.GA15403@kmo-pixel> References: <20180518074918.13816-1-kent.overstreet@gmail.com> <20180518074918.13816-7-kent.overstreet@gmail.com> <20180518095102.GE12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180518095102.GE12217@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 11:51:02AM +0200, Peter Zijlstra wrote: > On Fri, May 18, 2018 at 03:49:04AM -0400, Kent Overstreet wrote: > > bcachefs makes use of them - also, add a proper lg_lock_init() > > Why?! lglocks are horrid things, we got rid of them for a reason. They > have terrifying worst case preemption off latencies. Ah. That was missing from your commit message. > Why can't you use something like per-cpu rwsems? Well, a) in my use case, lg_global_lock() pretty much isn't used in normal operation, it's only called when starting mark and sweep gc (which is not needed anymore and disabled by default, it'll eventually get rolled into online fsck) and for device resize b) I'm using it in conjection with percpu counters, and technically yes I certainly _could_ use per-cpu sleepable locks (mutexes would make more sense for me than rwsems), there's a bit of a clash there and it's going to be a bit ugly and messy and it's more work for me. (this_cpu_ptr() no longer makes any sense in that case, so it'd mean auditing and converting all the code that touches the relevant data structures). If you're really that dead set against lglocks I might just come up with a new lock with similar semantics, that doesn't break this_cpu_ptr() but sleeps if the global lock is held...