Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FBE4C433F5 for ; Thu, 11 Nov 2021 19:37:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5899861252 for ; Thu, 11 Nov 2021 19:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234082AbhKKTjx (ORCPT ); Thu, 11 Nov 2021 14:39:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56510 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbhKKTjt (ORCPT ); Thu, 11 Nov 2021 14:39:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636659419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8L65s61VwL/LNFRDg02+DFLshHkF5TrWtlz0TeUmcmw=; b=EQfH43FIGWZHh9DcvKE0tXxQz5LqaLpWGhQw5B0liqQJlyFe3yHmNBiltoITK1QH13Gb4T usYfnLuFKXjq02It9EoXJb0dFbX+uS912qnC2xZp1/lq0G6jFJm8kas2d6qpNqdlxSrAMa sdr69/KEyKoJs2YByq1EF4LEUa9y6pI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327-sPKB2ka3NTeBGc5REmgnJQ-1; Thu, 11 Nov 2021 14:36:55 -0500 X-MC-Unique: sPKB2ka3NTeBGc5REmgnJQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D68EA19057A2; Thu, 11 Nov 2021 19:36:53 +0000 (UTC) Received: from [10.22.8.202] (unknown [10.22.8.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C4B34180; Thu, 11 Nov 2021 19:36:52 +0000 (UTC) Content-Type: multipart/mixed; boundary="------------fZIBEwIo5oImC01RwuDMTlRn" Message-ID: Date: Thu, 11 Nov 2021 14:36:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [BUG]locking/rwsem: only clean RWSEM_FLAG_HANDOFF when already set Content-Language: en-US To: Peter Zijlstra Cc: Hillf Danton , =?UTF-8?B?6ams5oyv5Y2O?= , mingo , will , "boqun.feng" , linux-kernel References: <4fafad133b074f279dbab1aa3642e23f@xiaomi.com> <20211107090131.1535-1-hdanton@sina.com> <13d683ed-793c-b502-44ff-f28114d9386b@redhat.com> <02e118c0-2116-b806-2b48-b9c91dc847dd@redhat.com> <20211110213854.GE174703@worktop.programming.kicks-ass.net> <61735528-141c-8d77-592d-b6b8fb75ebaa@redhat.com> From: Waiman Long In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------fZIBEwIo5oImC01RwuDMTlRn Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/11/21 14:20, Peter Zijlstra wrote: > On Thu, Nov 11, 2021 at 02:14:48PM -0500, Waiman Long wrote: >> As for the PHASE_CHANGE name, we have to be consistent in both rwsem and >> mutex. Maybe a follow up patch if you think we should change the >> terminology. > Well, that's exactly the point, they do radically different things. > Having the same name for two different things is confusing. > > Anyway, let me go read that patch you sent. My understanding of handoff is to disable optimistic spinning to let waiters in the wait queue have an opportunity to acquire the lock. There are difference in details on how to do that in mutex and rwsem, though. BTW, I have decided that we should further simply the trylock for loop in rwsem_down_write_slowpath() to make it easier to read. That is the only difference in the attached v2 patch compared with the previous one. Cheers, LongmaN --------------fZIBEwIo5oImC01RwuDMTlRn Content-Type: text/x-patch; charset=UTF-8; name="v2-0001-locking-rwsem-Make-handoff-bit-handling-more-cons.patch" Content-Disposition: attachment; filename*0="v2-0001-locking-rwsem-Make-handoff-bit-handling-more-cons.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSA5NTZmYjRiZjU0ZTYxNzM1YzBkZjFmZWRmOTdlNTlhMTk3MmVmYmNhIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBXYWltYW4gTG9uZyA8bG9uZ21hbkByZWRoYXQuY29t PgpEYXRlOiBUaHUsIDExIE5vdiAyMDIxIDE0OjI3OjM1IC0wNTAwClN1YmplY3Q6IFtQQVRD SCB2Ml0gbG9ja2luZy9yd3NlbTogTWFrZSBoYW5kb2ZmIGJpdCBoYW5kbGluZyBtb3JlIGNv bnNpc3RlbnQKClRoZXJlIGFyZSBzb21lIGluY29uc2lzdGVuY3kgaW4gdGhlIHdheSB0aGF0 IHRoZSBoYW5kb2ZmIGJpdCBpcyBiZWluZwpoYW5kbGVkIGluIHJlYWRlcnMgYW5kIHdyaXRl cnMuCgpGaXJzdGx5LCB3aGVuIGEgcXVldWUgaGVhZCB3cml0ZXIgc2V0IHRoZSBoYW5kb2Zm IGJpdCwgaXQgd2lsbCBjbGVhciBpdAp3aGVuIHRoZSB3cml0ZXIgaXMgYmVpbmcga2lsbGVk IG9yIGludGVycnVwdGVkIG9uIGl0cyB3YXkgb3V0IHdpdGhvdXQKYWNxdWlyaW5nIHRoZSBs b2NrLiBUaGF0IGlzIG5vdCB0aGUgY2FzZSBmb3IgYSBxdWV1ZSBoZWFkIHJlYWRlci4gVGhl CmhhbmRvZmYgYml0IHdpbGwgc2ltcGx5IGJlIGluaGVyaXRlZCBieSB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