From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8168FC10F0E for ; Mon, 15 Apr 2019 13:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42EF520833 for ; Mon, 15 Apr 2019 13:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727375AbfDONnE convert rfc822-to-8bit (ORCPT ); Mon, 15 Apr 2019 09:43:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1815 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbfDONnD (ORCPT ); Mon, 15 Apr 2019 09:43:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4A364E92B; Mon, 15 Apr 2019 13:43:02 +0000 (UTC) Received: from llong.remote.csb (ovpn-122-46.rdu2.redhat.com [10.10.122.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A8F619C56; Mon, 15 Apr 2019 13:43:01 +0000 (UTC) Subject: Re: [PATCH-tip v3 02/14] locking/rwsem: Make owner available even if !CONFIG_RWSEM_SPIN_ON_OWNER From: Waiman Long To: Ingo Molnar Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying References: <20190410184231.6748-1-longman@redhat.com> <20190410184231.6748-3-longman@redhat.com> <20190411081224.GB4038@hirez.programming.kicks-ass.net> <29aca54a-536e-6e46-7e18-658914c34548@redhat.com> <20190412070209.GC129493@gmail.com> <20190412070545.GF11158@hirez.programming.kicks-ass.net> <20190412070904.GA45214@gmail.com> <33b0111b-fe0f-eefc-59f4-f06d84d9cacc@redhat.com> <277e9c8e-8913-b251-4c98-dd2d4997d643@redhat.com> <20190412164123.GA119547@gmail.com> <4aefd2cd-f303-99ed-ada9-e7ba2ae9cd3c@redhat.com> <00ce3ea9-0046-740f-6a6c-3b4aff2c3c6e@redhat.com> Openpgp: preference=signencrypt Autocrypt: addr=longman@redhat.com; prefer-encrypt=mutual; keydata= xsFNBFgsZGsBEAC3l/RVYISY3M0SznCZOv8aWc/bsAgif1H8h0WPDrHnwt1jfFTB26EzhRea XQKAJiZbjnTotxXq1JVaWxJcNJL7crruYeFdv7WUJqJzFgHnNM/upZuGsDIJHyqBHWK5X9ZO jRyfqV/i3Ll7VIZobcRLbTfEJgyLTAHn2Ipcpt8mRg2cck2sC9+RMi45Epweu7pKjfrF8JUY r71uif2ThpN8vGpn+FKbERFt4hW2dV/3awVckxxHXNrQYIB3I/G6mUdEZ9yrVrAfLw5M3fVU CRnC6fbroC6/ztD40lyTQWbCqGERVEwHFYYoxrcGa8AzMXN9CN7bleHmKZrGxDFWbg4877zX 0YaLRypme4K0ULbnNVRQcSZ9UalTvAzjpyWnlnXCLnFjzhV7qsjozloLTkZjyHimSc3yllH7 VvP/lGHnqUk7xDymgRHNNn0wWPuOpR97J/r7V1mSMZlni/FVTQTRu87aQRYu3nKhcNJ47TGY evz/U0ltaZEU41t7WGBnC7RlxYtdXziEn5fC8b1JfqiP0OJVQfdIMVIbEw1turVouTovUA39 Qqa6Pd1oYTw+Bdm1tkx7di73qB3x4pJoC8ZRfEmPqSpmu42sijWSBUgYJwsziTW2SBi4hRjU h/Tm0NuU1/R1bgv/EzoX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h7TqQBH Lk1eByJeVooUa/mqa2UdVJalc8B9NrAnLiyRsg72Nurwzvknv7anSgIkL+doXDaG21DgCYTD wGA5uquIgb8p3/ENgYpDPrsZ72CxVC2NEJjJwwnRBStjJOGQX4lV1uhN1XsZjBbRHdKF2W9g weim8xU= Organization: Red Hat Message-ID: Date: Mon, 15 Apr 2019 09:43:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <00ce3ea9-0046-740f-6a6c-3b4aff2c3c6e@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 15 Apr 2019 13:43:03 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/12/2019 10:24 PM, Waiman Long wrote: > On 04/12/2019 02:05 PM, Waiman Long wrote: > >>> [locking/rwsem] adc32e8877: will-it-scale.per_thread_ops -21.0% regression >> Will look into that also. > I can reproduce the regression on the same skylake system. > > The results of the page_fault1 will-it-scale test are as follows: > >  Threads   K2      K3       K4       K5 >  -------   --      --       --       -- >     20  5549772  5550332  5463961  5400064 >     40  9540445 10286071  9705062  7706082 >     60  8187245  8212307  7777247  6647705 >     89  8390758  9619271  9019454  7124407 > > So the wake-all-reader patch is good for this benchmark. The performance > was reduced a bit with the reader-spin-on-writer patch. It got even worse > with the writer-spin-on-reader patch. > > I looked at the perf output, rwsem contention accounted for less than > 1% of the total cpu cycles. So I believe the regression was caused by > the behavior change introduced by the two reader optimistic spinning > patches. These patch will make writer less preferred than before. I > think the performance of this microbenchmark may be more dependent on > writer performance. > > Looking at the lock event counts for K5: > >  rwsem_opt_fail=253647 >  rwsem_opt_nospin=8776 >  rwsem_opt_rlock=259941 >  rwsem_opt_wlock=2543 >  rwsem_rlock=237747 >  rwsem_rlock_fail=0 >  rwsem_rlock_fast=0 >  rwsem_rlock_handoff=0 >  rwsem_sleep_reader=237747 >  rwsem_sleep_writer=23098 >  rwsem_wake_reader=6033 >  rwsem_wake_writer=47032 >  rwsem_wlock=15890 >  rwsem_wlock_fail=10 >  rwsem_wlock_handoff=3991 > > For K4, it was > >  rwsem_opt_fail=479626 >  rwsem_opt_rlock=8877 >  rwsem_opt_wlock=114 >  rwsem_rlock=453874 >  rwsem_rlock_fail=0 >  rwsem_rlock_fast=1234 >  rwsem_rlock_handoff=0 >  rwsem_sleep_reader=453058 >  rwsem_sleep_writer=25836 >  rwsem_wake_reader=11054 >  rwsem_wake_writer=71568 >  rwsem_wlock=24515 >  rwsem_wlock_fail=3 >  rwsem_wlock_handoff=5245 > > It can be seen that a lot more readers got the lock via optimistic > spinning.  One possibility is that reader optimistic spinning causes > readers to spread out into more lock acquisition groups than without. The > K3 results show that grouping more readers into one lock acquisition > group help to improve performance for this microbenchmark. I will need > to run more tests to find out the root cause of this regression. It is > not an easy problem to solve. Just an update on my will-it-scale regression investigation. I have tried various ways to tune the rwsem code to get more performance out from this benchmark. I got some minor improvements but nothing major. So it looks like that there are some workloads that have performance hurted by reader optimistic spinning and this benchmark is one of them. Now I am testing an adaptive reader optimistic spinning disabling patch that shows great promise as I was able to bring back a major portion of the lost performance. I will try to make the patch more aggressive to see if it can bring most of the lost performance back. Cheers, Longman