Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2628011imm; Thu, 9 Aug 2018 17:04:14 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyRjj0bCFKgRrvFwZrPOT1jTM9lmuR7e2QnWU+oh9U2omVUTd/m/SceoiqAL6sZTy6QxC8A X-Received: by 2002:a17:902:403:: with SMTP id 3-v6mr3940857ple.39.1533859454467; Thu, 09 Aug 2018 17:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533859454; cv=none; d=google.com; s=arc-20160816; b=qvPfqgZTpqXH4z10oxz1lLFkFm3Sjy/suuJ8m4iLoJSsfto55RCD25u0Edr2fww70z h4NX/zo/GIF8DaI5H770N20fWSTuHUuY57cZqZ9tUqk1iQ7Amx9I9pukkv7WODqLLy+J 5bsdxuA9KsQp7UcN23LcXXM6aKqSgjBy4NQ/X7FCoqqIkmgb5OvTQ7ewkRCxQUfTf5Kh 814DkxmOGUhH8E7tuiAv3bcp4fZ21MCuvgt6DbYrgmKYhMX4dr1tu85VKLZA06lZUmY6 xWAzsnKVXZBVaUKZsENBqFOoV7Hlfai41PsB66SF7yYcI7pkWuY5xbq/0mDj1KDXUZUt 1BIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:references :in-reply-to:subject:cc:date:to:from:arc-authentication-results; bh=Vaisa4RRDazyj35A1648YB43+IP8+3GFua4jag1XH5U=; b=PnXhAJSwfWs4vnb7BCoxTashoWmiyQjwxhV4iLUcObsEu27vkVCwn4MucQY21pfaMt NeGCri41y8a1njD1krTa3RWhY2hsZNiO1msaq1VMoQKlyzv6kg4YS4bJPEYkOKTdzVxV NT6kiWX88nWoyCX/Yxmg7PXvd3XHhFdcO60QTxmJSEx9YZA8xGkdndZlzxSlbNQ1e0wf 5FvPftZ1DWC9sz0fQY64VBCmTV5k1xuLDSEVqRigzcQR1VY/afISarSwTnDSaOzaspOh uCp/XjALR9q9rFH/fEg/E10kuWel7n1D1zBQkUm5hDj+vyaWFc0Be8FslRTmHBMUMwm1 N23w== ARC-Authentication-Results: i=1; mx.google.com; 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 h65-v6si7777005pfg.197.2018.08.09.17.03.59; Thu, 09 Aug 2018 17:04:14 -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; 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 S1727639AbeHJCXa (ORCPT + 99 others); Thu, 9 Aug 2018 22:23:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:43806 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727218AbeHJCXa (ORCPT ); Thu, 9 Aug 2018 22:23:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 508B0AD37; Thu, 9 Aug 2018 23:56:14 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Jeff Layton Date: Fri, 10 Aug 2018 09:56:07 +1000 Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Wilck Subject: Re: [PATCH 0/4] locks: avoid thundering-herd wake-ups In-Reply-To: <20180809130001.GG23873@fieldses.org> References: <153369219467.12605.13472423449508444601.stgit@noble> <20180808195445.GD23873@fieldses.org> <20180808200912.GE23873@fieldses.org> <20180808212832.GF23873@fieldses.org> <04ffa27c29d2bff8bd9cb9b6d4ea6b6fd3969b6c.camel@kernel.org> <20180809130001.GG23873@fieldses.org> Message-ID: <877ekzrt60.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, Aug 09 2018, J. Bruce Fields wrote: > On Wed, Aug 08, 2018 at 06:50:06PM -0400, Jeff Layton wrote: >> That seems like a legit problem. >>=20 >> One possible fix might be to have the waiter on (1,2) walk down the >> entire subtree and wake up any waiter that is waiting on a lock that >> doesn't conflict with the lock on which it's waiting. >>=20 >> So, before the task waiting on 1,2 goes back to sleep to wait on 2,2, it >> could walk down its entire fl_blocked subtree and wake up anything >> waiting on a lock that doesn't conflict with (2,2). >>=20 >> That's potentially an expensive operation, but: >>=20 >> a) the task is going back to sleep anyway, so letting it do a little >> extra work before that should be no big deal > > I don't understand why cpu used by a process going to sleep is cheaper > than cpu used in any other situation. > >> b) it's probably still cheaper than waking up the whole herd > > Yeah, I'd like to understand this. > > I feel like Neil's addressing two different performance costs: > > - the cost of waking up all the waiters > - the cost of walking the list of waiters > > Are they equally important? Probably not. Reducing wakeups is likely the most important. > > If we only cared about the former, and only in simple cases, we could > walk the entire list and skip waking up only the locks that conflict > with the first one we wake. We wouldn't need the tree. Yes, we could do that. It would probably make the code simpler. It would mean doing the conflicts() tests when performing wake-up rather than prior to going to sleep. In general it would mean doing the tests more often, as the tree effectively records the results of the previous time conflicts() was run. You might get a quadratic effect though ... wouldn't you want to skip anything that conflicts with anything that has been woken? If the tree-management code turns out to be too complex, it would certainly be an option. I think the tree approach should result in less total CPU usage.. Thanks for the thought - taking this simple approach really hadn't occurred to me. :-( NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlts1JcACgkQOeye3VZi gbkx8A/7BrroKFHv98IaALqQisj0VrPtO2da+PfQWiF3gVhs4+GJ0LrTt/9hRCdQ qKMOIjIRI8uJ+SVJGMsga4s/9bGYgN0I2P8THms91GtxabQOVPSiXC1cJXCLvGny JAYwZpcsVvOXyb2PKOI6X1tQe7HTuakykSJW5S0sMMSU3YEJXNRaIJVRmOqlhI8u TIyeSDoJodcscKc7d6IajtuaBRDYh4N6M+1pKXIiOgfMC/yVokbvK5EGp9vApDCk PK+XJnushEwraWi8F+2zPhevbTvjXuCavMpdi9PC7gC2gMKNoze1keAq99Z+ho7K E+taUIb3pkxm+D8Eu44bAcJQ0n3JrJb4N5Z3RU+ye3xVUIAuU0c6UbLrH90lLl0i sgPvZo5xTpzgkFlrJ7+euo4iisoKDzHTU5I8x10ig412ofLiH4AE7lprpaGFDNyy EMUTu7l5JjDEBQvoWlAAC8AJ0Aiy97ipLRuUyfhJFDR7GlzubGm09xeWoLpUf9c4 WuSVGTOQ79tOWTsTGTEkqWaAR3sqaKeJECXNPMBLiPZk0CkEUYrWMG/BSvCsXegp oi4EIh6i9CJaBN5nokmH+mTvNrdADaNZx3OyFU1VmtcXTVeU3lpKwJ4aE0HdDHpV YLcVO26qg6nqoA9ILqHtAdrdoDSGs6dd2bZA7eMkAG2iBcd5Fgw= =zWer -----END PGP SIGNATURE----- --=-=-=--