Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp680504ybh; Thu, 12 Mar 2020 09:08:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrjDOtnI7T42u0FgtNuBAtRRjffphBu2HtYwDmvmcg6hS/S0zftA3nLUFqjshVTxjc7ZPR X-Received: by 2002:aca:b488:: with SMTP id d130mr3257679oif.72.1584029337769; Thu, 12 Mar 2020 09:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584029337; cv=none; d=google.com; s=arc-20160816; b=RdsCeB2cvfSKJh3Pb/SopG0m9CsGFvFSi26mkFcpgLOwbxyQs11fJ7GDJgCscBbwsg np6GbVq/D21z09rHdhMAU9lHLX7oTxaO6cGBJsCvbgyaagfWVI+SDYZmCEunBxL24ilV cSh6wnFLWL74TlUH6vOwQYTLawab45Y86xAkem3KoipPkIbrjie1LewkuEO7P4fgRbP6 1qa5owxZJL18ZACqzkU8zFZVsHdd3TSdxuIyrLjo7ifQjPjcvBqKzDLWFtFzEzoeBS5o QukIL1wJFXRvFInSztQrjGa5JU3+3WIbikmFm0ZA36zifXMnw6GLN+OImIlDYWz3HOUM eCZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=k2DKQlgbyOC9/p2tyJFfgudLvzI9KBST86uO21FB/HE=; b=Ca3AxivszIQsdVuH0um9pqRXCnXz/W85eNnpnvfgFQNtgzouQZ5EZzvVEiVEqwR9et U81QYQXvY5sOM2wC5AHjSofQ5Z9U3pjLHmhzxg4DJanfVjotEEp/tnRC3cx1BuwL8Gpq 1Q7r6BbOPlfCGOngXarQ9/VGsgNJO0Zy3z7f2bGvGyWL3lvvJB93ajlPyc838VDCFQ6x P9VQe/kKijkSUKHPlDrqUpzQdc/4dcnDr9IB7CORW3pUyC6FpH+AzQgawgM6yGoriZrU KKklIH389iAcogb8fKjavSSQ8YQkodC9hh5ntFHJFVweFyvdYq4ZGx4lg9AQH1NFTlEE ty9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=gxaOeubg; 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 m20si3181902otf.46.2020.03.12.09.08.40; Thu, 12 Mar 2020 09:08:57 -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=@linux-foundation.org header.s=google header.b=gxaOeubg; 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 S1727270AbgCLQIM (ORCPT + 99 others); Thu, 12 Mar 2020 12:08:12 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34925 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbgCLQIL (ORCPT ); Thu, 12 Mar 2020 12:08:11 -0400 Received: by mail-lj1-f194.google.com with SMTP id u12so7104944ljo.2 for ; Thu, 12 Mar 2020 09:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k2DKQlgbyOC9/p2tyJFfgudLvzI9KBST86uO21FB/HE=; b=gxaOeubgWCfcszroEzizTLF7jfTrElVOLETtRnOv7nnrl5pq44iR+1BpgLFx8gW0Xv ojpHVDgI5DzYKuBO4SuFbfiMaNHO8D2gcN75Yc1b6BHtKJsg+GSUTgv18HCqyhGAWYGL p0tUzHPHALi4izP3Bzi09sccOCHHZV8F1gpG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k2DKQlgbyOC9/p2tyJFfgudLvzI9KBST86uO21FB/HE=; b=sc0tA4dsTclNQvlA7Bukl9SCtoCDKNhAv80g5zRJzJo+JfRgY6o8s5gUfIizDt9IrB y2kk8sPCDDVbSUrWFto4nae18zy2UKpXF+urainLh7q3CWgJZbBaFkLbRytRkMzlGUly 6rwee7+v9ICH3aTe6jTxdI6qmnGbqR0RKwOW+FEhW7DftsMg42rwX/xdWc0/PpY8dWHY UQo7DmasHEI2kCiIxxTCxjS6FBZ+Jy1nJeYvCv+4TfUD3DjtnRUsyPqzYqGQipdL+k3V Ip0X1i09cstB/rd5yEH3Bfx5mjwn3k4Sbdcnt3PYLKOtF29nCxOanHrx4bY4fXW6AILi k+Hg== X-Gm-Message-State: ANhLgQ2BD3DBqW1n2W0pQs5kiIlnqXzOhLPlKGFo8FFVCxp3bS6qAic5 4uE8UvB2jCdDa9hrCL1ZCtUYVeT0pC4= X-Received: by 2002:a2e:b801:: with SMTP id u1mr5646304ljo.188.1584029287677; Thu, 12 Mar 2020 09:08:07 -0700 (PDT) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com. [209.85.208.172]) by smtp.gmail.com with ESMTPSA id e9sm17850738ljp.24.2020.03.12.09.08.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Mar 2020 09:08:06 -0700 (PDT) Received: by mail-lj1-f172.google.com with SMTP id r7so7063177ljp.10 for ; Thu, 12 Mar 2020 09:08:06 -0700 (PDT) X-Received: by 2002:a05:651c:555:: with SMTP id q21mr5548601ljp.241.1584029285717; Thu, 12 Mar 2020 09:08:05 -0700 (PDT) MIME-Version: 1.0 References: <20200308140314.GQ5972@shao2-debian> <34355c4fe6c3968b1f619c60d5ff2ca11a313096.camel@kernel.org> <1bfba96b4bf0d3ca9a18a2bced3ef3a2a7b44dad.camel@kernel.org> <87blp5urwq.fsf@notabene.neil.brown.name> <41c83d34ae4c166f48e7969b2b71e43a0f69028d.camel@kernel.org> <923487db2c9396c79f8e8dd4f846b2b1762635c8.camel@kernel.org> <36c58a6d07b67aac751fca27a4938dc1759d9267.camel@kernel.org> <878sk7vs8q.fsf@notabene.neil.brown.name> <875zfbvrbm.fsf@notabene.neil.brown.name> <0066a9f150a55c13fcc750f6e657deae4ebdef97.camel@kernel.org> <87v9nattul.fsf@notabene.neil.brown.name> <87o8t2tc9s.fsf@notabene.neil.brown.name> In-Reply-To: <87o8t2tc9s.fsf@notabene.neil.brown.name> From: Linus Torvalds Date: Thu, 12 Mar 2020 09:07:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [locks] 6d390e4b5d: will-it-scale.per_process_ops -96.6% regression To: NeilBrown Cc: Jeff Layton , yangerkun , kernel test robot , LKML , lkp@lists.01.org, Bruce Fields , Al Viro Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 9:42 PM NeilBrown wrote: > > It seems that test_and_set_bit_lock() is the preferred way to handle > flags when memory ordering is important That looks better. The _preferred_ way is actually the one I already posted: do a "smp_store_release()" to store the flag (like a NULL pointer), and a smp_load_acquire() to load it. That's basically optimal on most architectures (all modern ones - there are bad architectures from before people figured out that release/acquire is better than separate memory barriers), not needing any atomics and only minimal memory ordering. I wonder if a special flags value (keeping it "unsigned int" to avoid the issue Jeff pointed out) might be acceptable? IOW, could we do just smp_store_release(&waiter->fl_flags, FL_RELEASED); to say that we're done with the lock? Or do people still look at and depend on the flag values at that point? Linus