Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2748123ybh; Mon, 9 Mar 2020 12:11:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuFm8z0J7N7mX74gSblovXKk4lI4XCiAzZ9WVchnQiNQtxadCl8eT8EyPj6FaGRsLZ0ihkI X-Received: by 2002:a9d:6f86:: with SMTP id h6mr13396761otq.309.1583781064272; Mon, 09 Mar 2020 12:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583781064; cv=none; d=google.com; s=arc-20160816; b=mXM1eS4s4/4wxWUrnwl7Rnefc1EOrDd/4/Fxlfq8odvZD6pB+uFsTA4VGA8UIn5zO8 Tt+O+8D+A+WE42UFNL/V/C8Nx1xCyC/3wUFg6Kh8nno1ngmQGlQet92FuJUji91RIUQT xgTllURBZTo0ThEx0aXpUxn8Ye/8Q2QlXUh0wF28RV8x54BuFVluK8cGXrfrJDLpgPqt 88yw0yptIw6BdA/jxL2A2UTSCmK0iDi66sSQvlnPCQtq88VIeAzNNifj8E1gKJAcWnu5 WSdoljc4VLW/ZZjpuMyQ69DSKq6avea2KgopB4OJmi8C7iouDXcPUMB5AS/AVWX6M08/ 0acQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=j7dFerxVnLGtB1sBpzEexyXbPSJXxKkVE4PvxQ2czT0=; b=Y3sheXmhEzTBa4ka4geGSjicDMgluwgjZiKd/WH406WRWk3pszlbIa+jfYpeSlWg1u jLct7mLLcARYRknromlE8rYnzAdwAzKPQiibX2abYgMcQKvHWpeoYgQvWj0C5aavG7y3 S1ONY1Wk4/b6/i7qzi9n0cdZkuuXTPyI7E+MR6Vpaioex1ylJ1p9VcVR+xDpjRQbPDdW DWr890qkQGUe2BifU8AAkf0IGso3Yrk2CICAQEDvMbaV6vaCCB+hdDd7Ksl9+h+kp7fu pquhSjaZiy2PPtuZuVcWlzEXfhMRNB7NcNAM+iZpdXTA5XTcHpW2qL+i2e0soYG+scPv HPGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dRliLFre; 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 m7si4548810oie.138.2020.03.09.12.10.51; Mon, 09 Mar 2020 12:11:04 -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=dRliLFre; 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 S1727534AbgCITJT (ORCPT + 99 others); Mon, 9 Mar 2020 15:09:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:50236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbgCITJT (ORCPT ); Mon, 9 Mar 2020 15:09:19 -0400 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (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 E1D0B21655; Mon, 9 Mar 2020 19:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583780957; bh=nODn956GT+Zousmucyy1TimLViyW+Jtk5KlJzh6Pkds=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=dRliLFreS4QuAotNsnqlP6TY4DT8l3hH8N8wf/RkyPhfujQh/orwImYSqUtSxVHMw BzmSSzwwQcXX4DkwnSp16oKsmr/Itf/d4dLlrm36hLBgY/Bj2P1O9SID4hbOk8Uowp 7rCS9osoAB0U7wGXtmlHXcZ3R4QQXLPKQ9EXgm4Y= Message-ID: <1bfba96b4bf0d3ca9a18a2bced3ef3a2a7b44dad.camel@kernel.org> Subject: Re: [locks] 6d390e4b5d: will-it-scale.per_process_ops -96.6% regression From: Jeff Layton To: Linus Torvalds Cc: kernel test robot , yangerkun , LKML , lkp@lists.01.org, Neil Brown , Bruce Fields , Al Viro Date: Mon, 09 Mar 2020 15:09:15 -0400 In-Reply-To: <34355c4fe6c3968b1f619c60d5ff2ca11a313096.camel@kernel.org> References: <20200308140314.GQ5972@shao2-debian> <34355c4fe6c3968b1f619c60d5ff2ca11a313096.camel@kernel.org> Content-Type: multipart/mixed; boundary="=-bMosJv09m7X+Hcceq0Wv" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-bMosJv09m7X+Hcceq0Wv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Mon, 2020-03-09 at 13:22 -0400, Jeff Layton wrote: > On Mon, 2020-03-09 at 08:52 -0700, Linus Torvalds wrote: > > On Mon, Mar 9, 2020 at 7:36 AM Jeff Layton wrote: > > > On Sun, 2020-03-08 at 22:03 +0800, kernel test robot wrote: > > > > FYI, we noticed a -96.6% regression of will-it-scale.per_process_ops due to commit: > > > > > > This is not completely unexpected as we're banging on the global > > > blocked_lock_lock now for every unlock. This test just thrashes file > > > locks and unlocks without doing anything in between, so the workload > > > looks pretty artificial [1]. > > > > > > It would be nice to avoid the global lock in this codepath, but it > > > doesn't look simple to do. I'll keep thinking about it, but for now I'm > > > inclined to ignore this result unless we see a problem in more realistic > > > workloads. > > > > That is a _huge_ regression, though. > > > > What about something like the attached? Wouldn't that work? And make > > the code actually match the old comment about wow "fl_blocker" being > > NULL being special. > > > > The old code seemed to not know about things like memory ordering either. > > > > Patch is entirely untested, but aims to have that "smp_store_release() > > means I'm done and not going to touch it any more", making that > > smp_load_acquire() test hopefully be valid as per the comment.. > > Yeah, something along those lines maybe. I don't think we can use > fl_blocker that way though, as the wait_event_interruptible is waiting > on it to go to NULL, and the wake_up happens before fl_blocker is > cleared. > > Maybe we need to mix in some sort of FL_BLOCK_ACTIVE flag and use that > instead of testing for !fl_blocker to see whether we can avoid the > blocked_lock_lock? > How about something like this instead? (untested other than for compilation) Basically, this just switches the waiters over to wait for fl_blocked_member to go empty. That still happens before the wakeup, so it should be ok to wait on that. I think we can also eliminate the lockless list_empty check in locks_delete_block, as the fl_blocker check should be sufficient now. -- Jeff Layton --=-bMosJv09m7X+Hcceq0Wv Content-Disposition: attachment; filename="0001-locks-reinstate-locks_delete_lock-optimization.patch" Content-Type: text/x-patch; name="0001-locks-reinstate-locks_delete_lock-optimization.patch"; charset="UTF-8" Content-Transfer-Encoding: base64 RnJvbSBjMTc5ZDc3OWM5YjcyODM4ZWQ5OTk2YTY1ZDY4NmQ4NjY3OWQxNjM5IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBMaW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRh dGlvbi5vcmc+CkRhdGU6IE1vbiwgOSBNYXIgMjAyMCAxNDozNTo0MyAtMDQwMApTdWJqZWN0OiBb UEFUQ0hdIGxvY2tzOiByZWluc3RhdGUgbG9ja3NfZGVsZXRlX2xvY2sgb3B0aW1pemF0aW9uCgou Li5ieSB1c2luZyBzbXBfbG9hZF9hY3F1aXJlIGFuZCBzbXBfc3RvcmVfcmVsZWFzZSB0byBjbG9z ZSB0aGUgcmFjZQp3aW5kb3cuCgpb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