Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp279564imm; Tue, 7 Aug 2018 18:53:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwLGUqwSCLCDstdWYepPp7ZG6CA4pl7mdwHKs7AzoTjzAJXIVhfE8WQVJkkWg39VMqtVLKe X-Received: by 2002:a17:902:760d:: with SMTP id k13-v6mr684067pll.56.1533693231206; Tue, 07 Aug 2018 18:53:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533693231; cv=none; d=google.com; s=arc-20160816; b=ljTO4dsKzL0PpbGprZoEg48AoQpCVTnLZxyF1azwspmqfvrdZ7Q2aTk1nCATsa4PFH OHqnGS5EOr9pPqbxQyvaNAp77ZfiCiz8M4e0HawngFXrxc70km5OHkRdSEc8k94oSAZu 9pro98MIKmet3rvqkKXJSLWNtfhYZydq9ADWtn+KRXP3IV2yOBQdZ3X5Wo5Ewspka8V0 tzXBTTEq4HpNrFjlcKlTTHDa/swNMAQRyhkn3BUbfokKLVfoxLRskkCbYCjhHFZc0tN4 yjCCUoZsTs1q/26fpzG0eTbpA0hc+UxkLVuSWzhUvLzmMswNXU1DlC6eAuo8dMda229j 9ISQ== 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:cc:subject:date:to:from :arc-authentication-results; bh=4+BTaQxlJHOb7NpDRKnbzr+tROiD/ogHZIB85+ACAFA=; b=DgI6Fg4X4tT2phAHcizt548HPbsttQW2VXxpqZoX9OvaxKdtoX8xyGdmrmOQKMriXz o/WPnkyMz5UngpBt9YYDxKDWklqMudQoD8OMUyyC9obqvZGu7xjqzkVRtW4SJCxhxJcR vYLLdj6osO0tHiAjMJqaRJZiHsgMwI9CcVyQGwceSkgi3/9zaD5ZL+l6hGynwXnTMphP 8ZnUeC3kzEo98JB6rIyiH4q8SDwOHdobaRZU5Qk8iUohXXCG9vQoJ8Z8RMXPNWcx6klp J+0mqDpv6nB3EMG3fEmUudS5JncOB1KYKt19FuJQeoUJzCU3obT1NB1A4TTn5/fNEF+S 7yBg== 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 k38-v6si2606088pgm.335.2018.08.07.18.53.36; Tue, 07 Aug 2018 18:53:51 -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 S1727062AbeHHEJT (ORCPT + 99 others); Wed, 8 Aug 2018 00:09:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:59090 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725774AbeHHEJT (ORCPT ); Wed, 8 Aug 2018 00:09:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "Cc" Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 31719AE92; Wed, 8 Aug 2018 01:52:05 +0000 (UTC) From: NeilBrown To: Jeff Layton , Alexander Viro Date: Wed, 08 Aug 2018 11:51:07 +1000 Subject: [PATCH 0/4] locks: avoid thundering-herd wake-ups Cc: "J. Bruce Fields" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Martin Wilck Message-ID: <153369219467.12605.13472423449508444601.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 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 (4): 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 bool. fs/locks: create a tree of dependent requests. fs/cifs/file.c | 2 - fs/locks.c | 142 +++++++++++++++++++++++++-------------- include/linux/fs.h | 5 + include/trace/events/filelock.h | 16 ++-- 4 files changed, 103 insertions(+), 62 deletions(-) -- Signature