Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp249742pxk; Thu, 17 Sep 2020 01:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8V5XUpZ9fSg8XLFkAcHuTo8+pfLmukmkTdvrMboaeedtL/1wgQtLxDngJdYdnsjshI9BS X-Received: by 2002:a17:906:8543:: with SMTP id h3mr28970713ejy.258.1600332646076; Thu, 17 Sep 2020 01:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600332646; cv=none; d=google.com; s=arc-20160816; b=ZAuV+zvrIcFTwZ6WULCtMhxZDFLCm/iJEOtpytxIisEZ4JialWngp/GmkkOY3E30mY lY92gT+a4gLTp69er+mVvxQmmhOvmGUQSW2NafNrmVGzQs49VSDxoKbDJA8HJXqfTshm 1h0sOSnNMU4NxXnyHRQ2Y8FdtCbeDYyzvBmm9Q8EThI65vDQylm2mOkmyhC75TJqFOCY M9w6Uoxafe6Posmw4wxv2G7+hqWBNwYpXcqAgWvTWgDq6WY/XS7+9baK75Cde39/z6uf NBcSwHHxkjeIgqIZCzbTk3V3CkdO1KZ+4HJAM3oR2lp0jzWAOFZwGQf5kNzPjBpNk7P4 lYSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+4QampOtxZxvRAUty8bTA358eCszSbUDjIuNSrNfs70=; b=0SAqmB73v9PUtwpPz5L4qeg4ETy3kHrA8/VPjArHStea9n71v7StqzXU5o5jUBNCIp zpk3d+23MiXkzM2rl/RhWxXqluhACjcf1KCEPMxPyoFbfHux0a2ZIXd6Ow0f8CNT9F/A aADBTWYvAt9XDhGjLqrTXhKFW+CxXWQUWWlWp6fAUsCGf5B/8tP+Jos+6779ipH2Jpb+ n3AioRcB+ELvn/dkgWCHSGjA+wkpvRWB2TFw0IHWQDaa2Bem34Bz7u/lpkHWo1B3gF6P J7Bi2go/UiBJNFxs5wTvQxAseXaMeO5tjz2K6xH6hW0sxG4Oyhp7xH3nfCE+Gz11N5qT pFqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZUZI0GKw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id i10si13880520edr.13.2020.09.17.01.50.23; Thu, 17 Sep 2020 01:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZUZI0GKw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726373AbgIQIsm (ORCPT + 99 others); Thu, 17 Sep 2020 04:48:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:41632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbgIQIsh (ORCPT ); Thu, 17 Sep 2020 04:48:37 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 0F85E206A1; Thu, 17 Sep 2020 08:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600332516; bh=yi+ytAgx6za/19uH7XwF6woib4Fz9kTbekZjb7IPr4w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZUZI0GKwdBeRxsYmtgk3CU2wo8gn25Nzi6q4xzvhuzEfHX5IIxJTrvnSI/YfwkJcK TxhnlM8C/8cAUAILAy0z4Vc/fdfzRxThnS0smPwfpRQ5VrK+OPBW1hDNnhbUPgyXmV 4vDNFiRFVns1MBqYnoretp4PK/SiOsyxXrSUU1kA= Date: Thu, 17 Sep 2020 09:48:31 +0100 From: Will Deacon To: Hou Tao Cc: peterz@infradead.org, Oleg Nesterov , Ingo Molnar , Dennis Zhou , Tejun Heo , Christoph Lameter , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jan Kara Subject: Re: [RFC PATCH] locking/percpu-rwsem: use this_cpu_{inc|dec}() for read_count Message-ID: <20200917084831.GA29295@willie-the-truck> References: <20200915140750.137881-1-houtao1@huawei.com> <20200915150610.GC2674@hirez.programming.kicks-ass.net> <20200915153113.GA6881@redhat.com> <20200915155150.GD2674@hirez.programming.kicks-ass.net> <20200915160344.GH35926@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 08:32:20PM +0800, Hou Tao wrote: > > Subject: locking/percpu-rwsem: Use this_cpu_{inc,dec}() for read_count > > From: Hou Tao > > Date: Tue, 15 Sep 2020 22:07:50 +0800 > > > > From: Hou Tao > > > > The __this_cpu*() accessors are (in general) IRQ-unsafe which, given > > that percpu-rwsem is a blocking primitive, should be just fine. > > > > However, file_end_write() is used from IRQ context and will cause > > load-store issues. > > > > Fixing it by using the IRQ-safe this_cpu_*() for operations on > > read_count. This will generate more expensive code on a number of > > platforms, which might cause a performance regression for some of the > > other percpu-rwsem users. > > > > If any such is reported, we can consider alternative solutions. > > > I have simply test the performance impact on both x86 and aarch64. > > There is no degradation under x86 (2 sockets, 18 core per sockets, 2 threads per core) > > v5.8.9 > no writer, reader cn | 18 | 36 | 72 > the rate of down_read/up_read per second | 231423957 | 230737381 | 109943028 > the rate of down_read/up_read per second (patched) | 232864799 | 233555210 | 109768011 > > However the performance degradation is huge under aarch64 (4 sockets, 24 core per sockets): nearly 60% lost. > > v4.19.111 > no writer, reader cn | 24 | 48 | 72 | 96 > the rate of down_read/up_read per second | 166129572 | 166064100 | 165963448 | 165203565 > the rate of down_read/up_read per second (patched) | 63863506 | 63842132 | 63757267 | 63514920 > > I will test the aarch64 host by using v5.8 tomorrow. Thanks. We did improve the preempt_count() munging a bit since 4.19 (I think), so maybe 5.8 will be a bit better. Please report back! Will