Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1032995imu; Wed, 28 Nov 2018 03:38:02 -0800 (PST) X-Google-Smtp-Source: AFSGD/VILEjCiM4D9ZZGOqdOszESRONm4Hr8K18FD1Wl3ZaQElsd+USHYY+yeyQ0gUwLrFgIOWuR X-Received: by 2002:a63:2ac9:: with SMTP id q192mr32826907pgq.58.1543405082580; Wed, 28 Nov 2018 03:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543405082; cv=none; d=google.com; s=arc-20160816; b=nn3BwBLI++41rDt/PQFD7zmuvAAmA4+YSoGGxwKo1M8fjXDJ3hKtZAs4d/w8NpMs00 vE79PuYjFecK14Zaf0MAPB/ByxK0E+ZMIRKGruMI9LbNOvEiiRZnM1sNgpbJWPQbu8nO SQdPsXjF2QxvzQyaYjp0yPjnKHeb8V+i78d+bssrd3zwvwNP0Um+0YJ1vj/9I2lo6ZrC pN/eAAcbMX4jZf89Dj7XjSE68CCEKFOyHBvWJkduWovOCH2gvvGXrPmxTlZhgtrksLP7 80VYibcwMcGUJk0q7bwoCnfyNajLhI4bqNMfzKoYOtjPv0F6VR8P2uYjJN5aDkhp1nIP mEuw== 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:references:in-reply-to:date:cc:to:from:subject :message-id; bh=0HhLMdEBbTxDO26usXtQVGyF5x4TUjha7ZofvYd8GOo=; b=sVjaQOQ3lJlv+mGCkxYq1FV/b24lcw29tdEKJcD1V2icI0ZetA45/l2Y19//Y4cc1y kMBm/I9vXoSuzguJfSAz2xKg4GT9YU9CRffKWlFM5xzljhaLaQPS8jL2+hFrvla8IMOu CfJ3crpiL1SowkCNJr+1OqbYCw/z5TVqVVD1SDZXRdOOC3bVi3wTnkICuyRKRHs9O9Ro 4u7cCD3blpXCpBvWMm2/N05emKbXhF4eJ9kqPE9oEaoz9sZEVLhDb4tmwI6Dw0rUY0Wd YnxbXzP/bg1jW8v7YB4Vc6tXapjvMNRXN9PpPDUZIx3Kj/izE5azNIQGSwx/Gfpq/5+h CDiA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h32si7114757pgh.276.2018.11.28.03.37.46; Wed, 28 Nov 2018 03:38:02 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbeK1Wi3 (ORCPT + 99 others); Wed, 28 Nov 2018 17:38:29 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:36993 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbeK1Wi3 (ORCPT ); Wed, 28 Nov 2018 17:38:29 -0500 Received: by mail-yb1-f195.google.com with SMTP id d18-v6so10461742yba.4 for ; Wed, 28 Nov 2018 03:37:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=0HhLMdEBbTxDO26usXtQVGyF5x4TUjha7ZofvYd8GOo=; b=OUdbpWhL2TzJ9v9U0f0eGi0aVxjrNRGAbXsbLs17WmaQ380Cx+eMxRU0MXhy/7bFJf u23+oeSOOrt0ivq8MMtXnpi5xoufl2cTKOXuj+xx83dMeo8Czhiyq5Cv5EpL6nEK0KFQ bF0P0xWAFIM+9UEoq+A+cEnet0XX9UDUEn11dS5rqZ+dzTtdzwTVsEW7dALWUjDMXcv2 2tqAni6sc0h8XnGaFrMNOmrskOMztJrOuJo/oE8iOZnzgi4M1MPg/lUZCxNUOkLwf9OB HZc7j2migz8LxEKwRx4w9d2JNoB8bWgPkCuMYw6LI1nH+XE166uL9LYem9HmmAkNlyGj uuZA== X-Gm-Message-State: AA+aEWa1A99pGChQfoX8FTW6fEtxSG9bL9KxYictTDexlKhEzXzsqoZ2 F7EV/95bT4AKy4aqP2ca9Mqpilxie7wnQQ== X-Received: by 2002:a5b:7c6:: with SMTP id t6-v6mr23403666ybq.406.1543405027478; Wed, 28 Nov 2018 03:37:07 -0800 (PST) Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com. [71.70.156.158]) by smtp.gmail.com with ESMTPSA id h75sm4713340ywa.50.2018.11.28.03.37.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 03:37:06 -0800 (PST) Message-ID: <9bba46b3f9b67a3a52c3a1f22caa9cd7cdabfca7.camel@redhat.com> Subject: Re: [PATCH] locks: fix performance regressions. From: Jeff Layton To: NeilBrown , "J. Bruce Fields" , kernel test robot Cc: LKML , lkp@01.org, linux-nfs@vger.kernel.org Date: Wed, 28 Nov 2018 06:37:05 -0500 In-Reply-To: <87k1kyowdf.fsf@notabene.neil.brown.name> References: <20181127060102.GF6163@shao2-debian> <20181127174315.GA29963@parsley.fieldses.org> <87mupup0ot.fsf@notabene.neil.brown.name> <87k1kyowdf.fsf@notabene.neil.brown.name> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.2 (3.30.2-2.fc29) 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 Wed, 2018-11-28 at 11:53 +1100, NeilBrown wrote: > The kernel test robot reported two performance regressions > caused by recent patches. > Both appear to related to the global spinlock blocked_lock_lock > being taken more often. > > This patch avoids taking that lock in the cases tested. > > Reported-by: kernel test robot > Signed-off-by: NeilBrown > --- > > Hi Jeff, > you might like to merge these back into the patches that introduced > the problem. > Or you might like me to re-send the series with these merged in, > in which case, please ask. > Thanks Neil, This looks great. I'll go ahead and toss this patch on top of the pile in linux-next for now. Would you mind resending the series with this patch merged in? I took a quick stab at squashing it into the earlier patch, but there is some churn in this area. Maybe you can also turn that Reported-by: into a Tested-by: in the changelog afterward? > And a BIG thank-you to the kernel-test-robot team!! > Absolutely! We love you guys! > Thanks, > NeilBrown > > fs/locks.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index f456cd3d9d50..67519a43e27a 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -444,6 +444,13 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) > { > struct file_lock *f; > > + /* > + * As ctx->flc_lock is held, new requests cannot be added to > + * ->fl_blocked_requests, so we don't need a lock to check if it > + * is empty. > + */ > + if (list_empty(&fl->fl_blocked_requests)) > + return; > spin_lock(&blocked_lock_lock); > list_splice_init(&fl->fl_blocked_requests, &new->fl_blocked_requests); > list_for_each_entry(f, &fl->fl_blocked_requests, fl_blocked_member) > @@ -749,6 +756,20 @@ int locks_delete_block(struct file_lock *waiter) > { > int status = -ENOENT; > > + /* > + * If fl_blocker is NULL, it won't be set again as this thread > + * "owns" the lock and is the only one that might try to claim > + * the lock. So it is safe to test fl_blocker locklessly. > + * Also if fl_blocker is NULL, this waiter is not listed on > + * fl_blocked_requests for some lock, so no other request can > + * be added to the list of fl_blocked_requests for this > + * request. So if fl_blocker is NULL, it is safe to > + * locklessly check if fl_blocked_requests is empty. If both > + * of these checks succeed, there is no need to take the lock. > + */ > + if (waiter->fl_blocker == NULL && > + list_empty(&waiter->fl_blocked_requests)) > + return status; > spin_lock(&blocked_lock_lock); > if (waiter->fl_blocker) > status = 0; -- Jeff Layton