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 0E59FC433EF for ; Thu, 11 Nov 2021 19:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3D9B61264 for ; Thu, 11 Nov 2021 19:15:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbhKKTRs (ORCPT ); Thu, 11 Nov 2021 14:17:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31874 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbhKKTRp (ORCPT ); Thu, 11 Nov 2021 14:17:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636658095; 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=YzeRgKH/Qgg99kDPJcaXcwiXQdHDpVrdLYGz7V0Y8Po=; b=JpORbFP6NJkVSO2ih1SiDXb1CcYjHPsolU/AT7/dUyAskS49I+Z9LTGGLBIls7V4eSa0Ze BDx3ywWzMbAVllHqEFbVSsoTQok4ReStMncB+vrr0FCUV2lG3fwRS/h/0Hi8yl69gsFP4o 14uhymfwLE7VqsQtVvHCrkwTtLE6pMM= 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-573-tSrVbfwRPVCprjcbI1lstw-1; Thu, 11 Nov 2021 14:14:51 -0500 X-MC-Unique: tSrVbfwRPVCprjcbI1lstw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EE398799E0; Thu, 11 Nov 2021 19:14:50 +0000 (UTC) Received: from [10.22.8.202] (unknown [10.22.8.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06B17101E59D; Thu, 11 Nov 2021 19:14:48 +0000 (UTC) Content-Type: multipart/mixed; boundary="------------CJNXWTbrrTYQhJTYYpn3lgEa" Message-ID: <61735528-141c-8d77-592d-b6b8fb75ebaa@redhat.com> Date: Thu, 11 Nov 2021 14:14:48 -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> From: Waiman Long In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------CJNXWTbrrTYQhJTYYpn3lgEa Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/11/21 10:08, Peter Zijlstra wrote: > On Wed, Nov 10, 2021 at 10:38:55PM +0100, Peter Zijlstra wrote: >> >> The comment above RWSEM_WRITER_LOCKED seems wrong/out-dated in that >> there's a 4th place that modifies the HANDOFF bit namely >> rwsem_down_read_slowpath() in the out_nolock: case. >> >> Now the thing I'm most worried about is that rwsem_down_write_slowpath() >> modifies the HANDOFF bit depending on wstate, and wstate itself it not >> determined under the same ->wait_lock section, so there could be a race >> there. >> >> Another thing is that once wstate==HANDOFF, we rely on spin_on_owner() >> to return OWNER_NULL such that it goes to trylock_again, however if it >> returns anything else then we're at signal_pending_state() and the >> observed race can happen. >> >> Now, spin_on_owner() *can* in fact return something else, consider >> need_resched() being set for instance. >> >> Combined I think the observed race is valid. >> >> Now before we go make things more complicated, I think we should see if >> we can make things simpler. Also I think perhaps the HANDOFF name here >> is a misnomer. >> >> I agree that using _andnot() will fix this issue; I also agree with >> folding it with the existing _andnot() already there. But let me stare a >> little more at this code, something isn't making sense... > I think I want to see WRITER_HANDOFF go away. And preferably all of > wstate. > > Something like the *completely* untested below, might set fire to your > pet, eat your granny, etc.. > > Also, perhaps s/HANDOFF/PHASE_CHANGE/ ? > > Waiman, did I overlook something fundamental here? The handoff bit is also set when the current writer is a RT task. You miss that in your patch. The attached patch is my version of your change. What do you think about that? 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. Cheers, Longman --------------CJNXWTbrrTYQhJTYYpn3lgEa Content-Type: text/x-patch; charset=UTF-8; name="0001-locking-rwsem-Make-handoff-bit-handling-more-consist.patch" Content-Disposition: attachment; filename*0="0001-locking-rwsem-Make-handoff-bit-handling-more-consist.pa"; filename*1="tch" Content-Transfer-Encoding: base64 RnJvbSAxYzc2YTljMWI5ZDE2ZDBjZWIwN2Y2NDM4MDMwMzUxNzdiNDA0MmE1IE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBXYWltYW4gTG9uZyA8bG9uZ21hbkByZWRoYXQuY29t PgpEYXRlOiBUaHUsIDExIE5vdiAyMDIxIDEzOjQ5OjM1IC0wNTAwClN1YmplY3Q6IFtQQVRD SF0gbG9ja2luZy9yd3NlbTogTWFrZSBoYW5kb2ZmIGJpdCBoYW5kbGluZyBtb3JlIGNvbnNp c3RlbnQKClRoZXJlIGFyZSBzb21lIGluY29uc2lzdGVuY3kgaW4gd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