Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1517557imm; Wed, 8 Aug 2018 19:36:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyTDStsfw13kcC82KyfwBzRDLm4D15QX5E1MroPOmJgIcmWBvhHpurRuvv+HtvzT7bnkXe/ X-Received: by 2002:a63:2fc6:: with SMTP id v189-v6mr256341pgv.61.1533782213779; Wed, 08 Aug 2018 19:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533782213; cv=none; d=google.com; s=arc-20160816; b=Dvhing6Hsou48SYcfocCnPR3YHz5FN0o6h9Tk6qHwm89N65E7sw73B46mFJvpSDqi+ 3E5xzrWAKVBuIeooi/1Sc2ROZLLBrgPWVNboH15RDv8MVB1Bv2mApdA8ws11OevS/NJe r03WVY1wBwbPqxLhVPODvV6udSsuPD3ZOJFxpyTxG4chXn9BnPyU1UZs2qBLoFIDAwCR rGogEarPs4hQnTGde6NV5qSMHuTV8NNXNN/WRjMEpKGrRpil35OOA5zEgL7Ae278Gtbs A97YTJxU4XUBJ1fAg/xDMfmFAhYq9S4RRK/hSLHAqgLShIxdJDa1NEHhbkNxPf5e2qu/ uzjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:content-language :content-transfer-encoding:mime-version:message-id:date:subject :in-reply-to:references:cc:to:from:domainkey-signature :dkim-signature:arc-authentication-results; bh=lX3kU6reiEYmcDSzlU/MnOU+BeAXSrWuHBGIM+P9Dvk=; b=Pa8R8haA4XKWoJF1laEttNffDpnFwEInhq8wKYsNMQ+GyaRoCm9/I5Y2kU+qxNgLXM /HLvb3cT4qJR2UpUE3zRzTnJWdgZ6agq9bGxLfjQ9AE5mEoIQzIpbxgzBRktyn1ew/JV AUJvByNlOlZkC5S0Lbe2AskXQtZzNMVGDI9KXWPtfTfX7y8zhJuraB+HlSxKabNek4gw vmIlVpuuQy+MAIttPmfela0acyB4lh0tLnIBxgsDPqqPGyDUIIR+R4xMGnRaUCqo4nRh UVgJfC4cghjgs973UF2H4IaVbfiCQeAP6/zwsXE9S6G1CYxlRZDXFvP+Nvekv+HrZTss rhcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mindspring.com header.s=dk12062016 header.b="OQMp/8q0"; 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=NONE dis=NONE) header.from=mindspring.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z68-v6si5978380pfz.163.2018.08.08.19.36.38; Wed, 08 Aug 2018 19:36:53 -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=@mindspring.com header.s=dk12062016 header.b="OQMp/8q0"; 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=NONE dis=NONE) header.from=mindspring.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727375AbeHIE6S (ORCPT + 99 others); Thu, 9 Aug 2018 00:58:18 -0400 Received: from elasmtp-galgo.atl.sa.earthlink.net ([209.86.89.61]:59448 "EHLO elasmtp-galgo.atl.sa.earthlink.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbeHIE6S (ORCPT ); Thu, 9 Aug 2018 00:58:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindspring.com; s=dk12062016; t=1533782149; bh=lX3kU6reiEYmcDSzlU/MnOU+BeAXSrWuHBGI M+P9Dvk=; h=Received:From:To:Cc:References:In-Reply-To:Subject:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding: X-Mailer:Content-Language:Thread-Index:X-ELNK-Trace: X-Originating-IP; b=OQMp/8q09z+Ke+tatS3UumehUzowhoEZkFxvPP/T5iR4K3 GPI2LC0bjB3Ml/+A4hIROefN5XyMOpWOLq6EG6+fzOCCDgtgSiHn7ji8cb3Hi0V7nKi KExNHZOW8z0Y7h7siWXqeiqOU34h4UbETypXUswPzDOBvEih2vYeMjhOTp6nWHc1H19 7zD0/1DByUprXg+U2ClmzPEsDuKUwlkoGgHJNSyR3UiNQFrHm2EE54o0J1H4P2ZqW7b yh4KwXCcm9CtK9Atp0xA3taMYm8ohZM2r5HOggw4AmvCqSEFC0LgH5hBm/xny6Hj4iR fg8M9hZwtwliz+zOsv8SFUXkUeDQ== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk12062016; d=mindspring.com; b=EYJtjs433sVE5yezZoIa5k/hZc+C62dlKcq7MFrgL28cYGBnFlVx9eqxJI2FrEmYV+G6CZrMosrRujaS4dSSE+nP6BqfO3MuEoLnjzHo+WklJxmt17Fpl53GqRgn0U63dXp6Q/+VJfWlm0qoi8G+yhc20JduKgwtDJUXQnvi2MmmjotfWnMKHfAaWNQ15EqQJoBtVReAhD3PdLDiMjENY4La8p52V5/0FRsQiSJrOepFIWp+syvLq1d8uo/9s1HQ/YyPBmaEWlt1VisWxecoxLe0ACMqiWbT0ROfoyKMX66bfnL0YcqxhsqFotsZfZibU/Hxv1dyQ8vA4gAox9FaMg==; h=Received:From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Mailer:Content-Language:Thread-Index:X-ELNK-Trace:X-Originating-IP; Received: from [76.105.143.216] (helo=FRANKSTHINKPAD) by elasmtp-galgo.atl.sa.earthlink.net with esmtpa (Exim 4) (envelope-from ) id 1fnVng-0000fx-TM; Wed, 08 Aug 2018 17:15:25 -0400 From: "Frank Filz" To: "'J. Bruce Fields'" , "'NeilBrown'" Cc: "'Jeff Layton'" , "'Alexander Viro'" , , , "'Martin Wilck'" References: <153369219467.12605.13472423449508444601.stgit@noble> <20180808195445.GD23873@fieldses.org> <20180808200912.GE23873@fieldses.org> In-Reply-To: <20180808200912.GE23873@fieldses.org> Subject: RE: [PATCH 0/4] locks: avoid thundering-herd wake-ups Date: Wed, 8 Aug 2018 14:15:24 -0700 Message-ID: <01b001d42f5c$ed082e20$c7188a60$@mindspring.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Content-Language: en-us Thread-Index: AQGA9keEcMCkmDAsuHSuCoEfEmhAOAG1/rx6AXpKEjmlQ0n5QA== X-ELNK-Trace: 136157f01908a8929c7f779228e2f6aeda0071232e20db4d71ea602dab1a2e163e1494380c7f8fd4350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 76.105.143.216 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Wed, Aug 08, 2018 at 03:54:45PM -0400, J. Bruce Fields wrote: > > On Wed, Aug 08, 2018 at 11:51:07AM +1000, NeilBrown wrote: > > > If you have a many-core machine, and have many threads all wanting > > > to briefly lock a give file (udev is known to do this), you can get > > > quite poor performance. > > > > > > When one thread releases a lock, it wakes up all other threads that > > > are waiting (classic thundering-herd) - one will get the lock and > > > the others go to sleep. > > > When you have few cores, this is not very noticeable: by the time > > > the 4th or 5th thread gets enough CPU time to try to claim the lock, > > > the earlier threads have claimed it, done what was needed, and released. > > > With 50+ cores, the contention can easily be measured. > > > > > > This patchset creates a tree of pending lock request in which > > > siblings don't conflict and each lock request does conflict with its parent. > > > When a lock is released, only requests which don't conflict with > > > each other a woken. > > > > Are you sure you aren't depending on the (incorrect) assumption that > > "X blocks Y" is a transitive relation? > > > > OK I should be able to answer that question myself, my patience for > > code-reading is at a real low this afternoon.... > > In other words, is there the possibility of a tree of, say, exclusive locks with > (offset, length) like: > > (0, 2) waiting on (1, 2) waiting on (2, 2) waiting on (0, 4) > > and when waking (0, 4) you could wake up (2, 2) but not (0, 2), leaving a process > waiting without there being an actual conflict. That implies that the order the locks were received in was: (0,4) (2,2) (1,2) (0,2) But couldn't (0,2) have been made only dependent on (0,4)? Of course then (1,2) is dependent on BOTH (2,2) and (0,2). Does this tree logic handle that case? On the other hand, there might be a fairness reason to make (0,2) wait for (1,2) even though it could have been granted concurrently with (2,2) since this dependency tree also preserves some of the order of lock requests. Frank