Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2647454imm; Thu, 9 Aug 2018 17:30:54 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx2FvNfS3lc4m8LP9c1DD2Dp0tgJMqZsO7RUVlLaK91pfNWaY1l76LQhVL1swVjE/131roN X-Received: by 2002:a63:9b19:: with SMTP id r25-v6mr4132495pgd.44.1533861053935; Thu, 09 Aug 2018 17:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533861053; cv=none; d=google.com; s=arc-20160816; b=r/ibf728f3/PJbnpWj6B/TplMuwnlN+AUzDjJCRxHuT1uUlB4/qCHlabblViNy4Oio XPX40oYxZgiHncbaUu0NeKAijJPFPGYqvBYuhyuur2qp6c9AmEDi4bWRjzwG+sIcneDS 72sMyUNftjU291v5TZRNuhMnJamWgFIcydXS/C8eo+lN/06Iso95pwDJz1d4bRNmibQg UkPXVotIrQHabP4DOqC3hc+ol9PZYNfQE9BLmtBXLujoiSZt5s90OQHfHpgO9e2j0hMl P4lCezd5yzGO6dtjQIChOsGXahGfGHSgIK08lmDdgYNt2D4KT/AbIXYLrcujbiU3it2y AdmQ== 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:arc-authentication-results; bh=eQ8AF+0GWEJoOoPXdi9yiWQU8p457tHTpNK4iiK6vVc=; b=Og7wGBvczQfB8qJa7JhH7Fh1oYvETpoLGUpNsHFP+FXfGlDzkiGvicaMRkurjSeOMq 2KRqchplBV4T0ifHbasl0fKIP+H5SuenyWzcquX7BzK7IPqrJPEyxkCEGFB8TU1cQhQo yW3Yvh3VIrEs+xj/HIDwBsoWUSvo+ycPj7OAuiVymsaP5i4ZO4HiZgIkuz0M+DeSM3WC QqJdIzh5tEEVmdGwXSrdO0s4YBe9iXnI9B7tRyEooh3X1aAv0Ce7gY8K2cydUjyTaRbM E2CGu1ZoMEo7yiJQrmJVy77zltYyHmhAg1SZ8Uz15cRV09oOCy2SNBey+CclG/BVDopl 2edA== 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 p3-v6si6565757plk.295.2018.08.09.17.30.38; Thu, 09 Aug 2018 17:30: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; 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 S1727303AbeHJC4n (ORCPT + 99 others); Thu, 9 Aug 2018 22:56:43 -0400 Received: from fieldses.org ([173.255.197.46]:49436 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726953AbeHJC4m (ORCPT ); Thu, 9 Aug 2018 22:56:42 -0400 Received: by fieldses.org (Postfix, from userid 2815) id EF707BD3; Thu, 9 Aug 2018 20:29:22 -0400 (EDT) Date: Thu, 9 Aug 2018 20:29:22 -0400 From: "J. Bruce Fields" To: NeilBrown Cc: Jeff Layton , Alexander Viro , Martin Wilck , linux-fsdevel@vger.kernel.org, Frank Filz , linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups Message-ID: <20180810002922.GA3915@fieldses.org> References: <153378012255.1220.6754153662007899557.stgit@noble> <20180809173245.GM23873@fieldses.org> <87lg9frxyc.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lg9frxyc.fsf@notabene.neil.brown.name> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 10, 2018 at 08:12:43AM +1000, NeilBrown wrote: > On Thu, Aug 09 2018, J. Bruce Fields wrote: > > > I think there's also a problem with multiple tasks sharing the same > > lock owner. > > > > So, all locks are exclusive locks for the same range. We have four > > tasks. Tasks 1 and 4 share the same owner, the others' owners are > > distinct. > > > > - Task 1 gets a lock. > > - Task 2 gets a conflicting lock. > > - Task 3 gets another conflicting lock. So now we the tree is > > 3->2->1. > > - Task 1's lock is released. > > - Before task 2 is scheduled, task 4 acquires a new lock. > > - Task 2 waits on task 4's lock, we now have > > 3->2->4. > > > > Task 3 shouldn't be waiting--the lock it's requesting has the same owner > > as the lock task 4 holds--but we fail to wake up task 3. > > So task 1 and task 4 are threads in the one process - OK. > Tasks 2 and 3 are threads in two other processes. > > So 2 and 3 conflict with either 1 or 4 equally - why should task 3 be > woken? > > I suspect you got the numbers bit mixed up, Whoops. > but in any case, the "conflict()" function that is passed around takes > ownership into account when assessing if one lock conflicts with > another. Right, I know, but, let me try again: All locks are exclusive locks for the same range. Only tasks 3 and 4 share the the same owner. - Task 1 gets a lock. - Task 2 requests a conflicting lock, so we have 2->1. - Task 3 requests a conflicting lock, so we have 3->2->1. - Task 1 unlocks. We wake up task 2, but it isn't scheduled yet. - Task 4 gets a new lock. - Task 2 runs, discovers the conflict, and waits. Now we have: 3->2->4. There is no conflict between the lock 3 requested and the lock 4 holds, but 3 is not woken up. This is another version of the first problem: there's information we need (the owners of the waiting locks in the tree) that we can't determine just from looking at the root of the tree. I'm not sure what to do about that. --b.