Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1499719imm; Wed, 8 Aug 2018 19:08:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzeTxQQKSGveQZfBztf1WLpMjBSDWl5CMx4PzLbLarRdByjNO8K+N03fcagyxOCVAP6Br+w X-Received: by 2002:a65:57c9:: with SMTP id q9-v6mr216075pgr.128.1533780519802; Wed, 08 Aug 2018 19:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533780519; cv=none; d=google.com; s=arc-20160816; b=ig34ZK92+PH7YbOOKUSQyKdcHGWjt6PsPpGGFZlTLpXKA0TBwQRub71+crX6UlYc2i DOkBsLgM7Uy8h4164vyJ5gHDNteo0vbHzcukdmNe1CaFAc0m+xaCHUMMsa2mQJzalTWO Jb9Kigx0gpfl0LjvcbJN2/DGKQkDdGHjRg1jkCNHBY6WO9cPhMhv1j3hgmsO+NPxX1kl VTNDgkwHiZD9zrIwaZaRdBETG/idQfOXmCDa+Uu7p+v672ue5FthWH/Yds5GYOuKp1C9 g2J+rusLgIaOu6x/Ox2ydJskMThnC3zZxuphafu4AsIn+nlI5WeNoUzL3auTY3v/gRN5 KBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:cc:subject:date:to:from :arc-authentication-results; bh=r+aX8lyDyXKHMEdj+0tefE9VOQKIXD+1fpQaQfB+nyM=; b=I+jkoyUC002ZsKIvUc6STGME4HFf37yfkpMtq2nn3jh2YS7G8ljMNyehKf1epnoa/U ifgdvUpJJHJX+VN/YCRxTQYHK6YxgPSxumPhej8zU41v8M5VrRvYyAKaw81M8HE3mwKY Vkp9SFnIE0cEkuB/ovMsAs317W4rkUnmUvvjq/uD6YCI1DAyoGajU0s2Kjcd+pnWv6rA dLumZtanhwcfrz0q6MZEe/E+7CJ7EiJ/HM3JGoxj5p3cSWe9D+tGWkL+o4n6oboa4t2c xyLBV4SV1O4Y9Sl0NuKZTAXvzhZarlGYN6VnA4Tc3lOTkmWY5Ks/Njd0ILIvD+2tjtz9 D/aw== 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 t188-v6si5406536pfd.148.2018.08.08.19.08.24; Wed, 08 Aug 2018 19:08:39 -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 S1727525AbeHIE3t (ORCPT + 99 others); Thu, 9 Aug 2018 00:29:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:60380 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725757AbeHIE3t (ORCPT ); Thu, 9 Aug 2018 00:29:49 -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 93DDEAB99; Thu, 9 Aug 2018 02:07:25 +0000 (UTC) From: NeilBrown To: Jeff Layton , Alexander Viro Date: Thu, 09 Aug 2018 12:04:41 +1000 Subject: [PATCH 0/5 - V2] locks: avoid thundering-herd wake-ups Cc: "J. Bruce Fields" , Martin Wilck , linux-fsdevel@vger.kernel.org, Frank Filz , linux-kernel@vger.kernel.org Message-ID: <153378012255.1220.6754153662007899557.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series adds "wake_non_conflicts()" to wake up any waiters that are being added beneath a lock that they don't actually conflict with, even though they conflict with a parent which conflict with the top-level blocker. Thanks for Bruce for highlighting this issue. This series hasn't been tested beyond compile-test. Original description: 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. Testing shows that lock-acquisitions-per-second is now fairly stable even as number of contending process goes to 1000. Without this patch, locks-per-second drops off steeply after a few 10s of processes. There is a small cost to this extra complexity. At 20 processes running a particular test on 72 cores, the lock acquisitions per second drops from 1.8 million to 1.4 million with this patch. For 100 processes, this patch still provides 1.4 million while without this patch there are about 700,000. NeilBrown --- NeilBrown (5): fs/locks: rename some lists and pointers. fs/locks: allow a lock request to block other requests. fs/locks: change all *_conflict() functions to return a new enum. fs/locks: split out __locks_wake_one() fs/locks: create a tree of dependent requests. fs/cifs/file.c | 2 fs/locks.c | 228 ++++++++++++++++++++++++++++++--------- include/linux/fs.h | 5 + include/trace/events/filelock.h | 16 +-- 4 files changed, 186 insertions(+), 65 deletions(-) -- Signature