Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2132342imm; Thu, 9 Aug 2018 07:50:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPykBOuq0bICgj9Mkehkd2xh/j9aBb4yZ13c/q3BpUNfLXsqqtSIX3SxG8ARmb43GMecPOzq X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr2339588plb.298.1533826255063; Thu, 09 Aug 2018 07:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533826255; cv=none; d=google.com; s=arc-20160816; b=Y+6gpoIOOIb4q7ThUDlgkw4BPEZK42GBPhQ9UJV8NpY/HKp4gLVyhELqqmEUOwcy+L 5kYxGLNUvCNC2Ior2qNTvBJ3i/MKavgXV5ewwfhk/6P8YKJAxoHCdixu3kvg7gd1apTY ZecRhg+fEAHyFJUQ4MMdUiuKipVv1wOHbCYv9EfM95Bp5pIiaM8HD+3/AnrsxCEtN/fa XNLNhIY+RPup//ZJ9WmfIylpPafPrzx2BH/i5Z5DvV0BdmyAjqe0j3TqKtexIitU0Phh EcIccPJoeSB9Sp5qe/TaSMKvOQdyQupGqmR7iLSzf7YYaASteRk0SWHjRKXWX0KGd1BP eN1Q== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=auHkF6GcpmTn0ZQ30S04+u3XzM1Iz8v9Q5JmIXERJWk=; b=DjZspVMRY95Ohc9QHl30r2cj89NJA6/1j/SqT3ckFSk2Qm18/PXdPXnMc599sqnSzz Uv0t6zwUD/bZCzUmCwCMfuKR8KrEZDPnBzj4GD9xJaxNtDX9rnu21hyNsUUtQ3o8XdeM eIoHSLCVbh3KGyFSQDAviIwR3FGFpWtBG4xOe4SdWAkXeE69PuZ2MO9Iaq+MZfUvIeYd WGy9349IreRaUM02mfiPeXofW2RpGYJHC4B93UnzOAqBswo02EvgoEnBV8hTtuwHEiav Xl1i5aS7I7ckcPRiaTqnhuXLAe4Qj21MfD7XOy5UPZEI+HCrjVp1nOa4m2XQVC2RiXM2 mGdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="K2VCe/p8"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4-v6si5533666plo.235.2018.08.09.07.50.40; Thu, 09 Aug 2018 07:50:55 -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=@kernel.org header.s=default header.b="K2VCe/p8"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732467AbeHIROc (ORCPT + 99 others); Thu, 9 Aug 2018 13:14:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:33638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732124AbeHIROc (ORCPT ); Thu, 9 Aug 2018 13:14:32 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC12021E97; Thu, 9 Aug 2018 14:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826157; bh=V72XnSvUa/hFMB7S9QoWPT+9JtHZpdqEsC4e7vv9dtc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=K2VCe/p8W4MpIM8d4ulhtbGQ4SlgzlDuGxubFoIT00jfVqFzRx7uaRUU/Nnjzl3LP hnbRAJl6NcIqNzAx7ZlX1v9qgMxehLIcGYcsqL48LEERcdoOD9OnSqYnGWv1XXwsPB 1AJ8wipHEpwP++kucerOJCeeMoJQZM0Uke3JxL2E= Message-ID: <4f9b616df9eb8ee5e29e1fd313edeca9fd97db90.camel@kernel.org> Subject: Re: [PATCH 0/4] locks: avoid thundering-herd wake-ups From: Jeff Layton To: "J. Bruce Fields" Cc: NeilBrown , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Wilck Date: Thu, 09 Aug 2018 10:49:15 -0400 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> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-08-09 at 09:00 -0400, J. Bruce Fields wrote: > On Wed, Aug 08, 2018 at 06:50:06PM -0400, Jeff Layton wrote: > > That seems like a legit problem. > > > > 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. > > > > 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). > > > > That's potentially an expensive operation, but: > > > > 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. > It's not any cheaper in that sense. It's just that this task is not slated to be doing any useful work anyway as it's going to sleep, so we aren't delaying any "real work" by this task by having it do this before returning to userland. It's already scheduled and holds the appropriate lock. The alternative would be to do this in the context of a different task, but that means extra context switching and spinlocking, etc. > > 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? > > 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. -- Jeff Layton