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_HELO_NONE,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 02577C28CC5 for ; Wed, 5 Jun 2019 18:13:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DABD520866 for ; Wed, 5 Jun 2019 18:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbfFESNt (ORCPT ); Wed, 5 Jun 2019 14:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46030 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbfFESNs (ORCPT ); Wed, 5 Jun 2019 14:13:48 -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 0807330C1205; Wed, 5 Jun 2019 18:13:33 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-85.bos.redhat.com [10.18.17.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ACEF2B3CC; Wed, 5 Jun 2019 18:13:28 +0000 (UTC) Subject: Re: [PATCH v8 15/19] locking/rwsem: Adaptive disabling of reader optimistic spinning From: Waiman Long To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org, x86@kernel.org, Davidlohr Bueso , Linus Torvalds , Tim Chen , huang ying References: <20190520205918.22251-1-longman@redhat.com> <20190520205918.22251-16-longman@redhat.com> <20190604092008.GJ3402@hirez.programming.kicks-ass.net> <8e7d19ea-f2e6-f441-6ab9-cbff6d96589c@redhat.com> <20190604173853.GG3419@hirez.programming.kicks-ass.net> <20190604181426.GH3419@hirez.programming.kicks-ass.net> Organization: Red Hat Message-ID: <46e44f43-87fd-251b-3b83-89a8bb3b407f@redhat.com> Date: Wed, 5 Jun 2019 14:13:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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.46]); Wed, 05 Jun 2019 18:13:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/4/19 2:21 PM, Waiman Long wrote: > On 6/4/19 2:14 PM, Peter Zijlstra wrote: >>> I worked on this owner merging patch mainly to alleviate the need to use >>> cmpxchg for reader lock. cmpxchg_double() is certainly one possible >>> solution though it won't work on older CPUs. We can have a config option >>> to use cmpxchg_double as it may increase the size of other structures >>> that embedded rwsem and impose additional alignment constraint. >> cmpxchg8b was introduced with the Pentium (for PAE IIRC, it enabled >> atomic 64bit PTEs, but Linux never used it for that) and every Intel/AMD >> thereafter has had it. AFAIK there's no x86_64 chip without cmpxchg16b. > Thank for the clarification. I actually didn't check when cmpxch8b was > introduced. I know it is a bit slower than regular cmpxchg. So we may > still need to do some performance analysis to see how it compares with > my current approach. Using cmpxchg_double is actually more risky than I thought. I have been trying to try to use cmpxchg_double for down_write, but I kept getting kernel panics because the rwsem wasn't 16b-aligned. As rwsem is embedded in quite a large number of structures, they all have to align properly to make that work or the kernel will panic. That does seem too risky to me. So I am dropping the idea of trying to use it. Cheers, Longman