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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C772CC27C7C for ; Fri, 20 Jan 2023 16:58:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbjATQ62 convert rfc822-to-8bit (ORCPT ); Fri, 20 Jan 2023 11:58:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjATQ61 (ORCPT ); Fri, 20 Jan 2023 11:58:27 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45ADF61B3 for ; Fri, 20 Jan 2023 08:58:26 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-141-EJZeUxsUNoylJYguLyIYjA-1; Fri, 20 Jan 2023 16:58:23 +0000 X-MC-Unique: EJZeUxsUNoylJYguLyIYjA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 20 Jan 2023 16:58:20 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Fri, 20 Jan 2023 16:58:20 +0000 From: David Laight To: 'Peter Zijlstra' , Hernan Ponce de Leon CC: "mingo@redhat.com" , "will@kernel.org" , "longman@redhat.com" , "boqun.feng@gmail.com" , "akpm@osdl.org" , "arjan@linux.intel.com" , "tglx@linutronix.de" , "joel@joelfernandes.org" , "paulmck@kernel.org" , "stern@rowland.harvard.edu" , "diogo.behrens@huawei.com" , "jonas.oberhauser@huawei.com" , "linux-kernel@vger.kernel.org" , "Hernan Ponce de Leon" , "stable@vger.kernel.org" Subject: RE: [PATCH] Fix data race in mark_rt_mutex_waiters Thread-Topic: [PATCH] Fix data race in mark_rt_mutex_waiters Thread-Index: AQHZLOuXmFFanV4GpkyO0ZW7VUnI7K6nhS4Q Date: Fri, 20 Jan 2023 16:58:20 +0000 Message-ID: References: <20230120135525.25561-1-hernan.poncedeleon@huaweicloud.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra > Sent: 20 January 2023 16:23 ... > > do { > > - owner = *p; > > + owner = READ_ONCE(*p); > > } while (cmpxchg_relaxed(p, owner, > > owner | RT_MUTEX_HAS_WAITERS) != owner); > > > > Can't we replace the whole of that function with: > > set_bit(0, (unsigned long *)&lock->owner); > > ? If you need the cast then probably not... There really ought to be a compile-time test (somehow) that set_bit() is only used on large bit arrays. OTOH atomic_or32/64() and atomic_and32/64() might use usable in many places. On x86 I doubt it makes much difference whether you use 'bis' or 'lock or'. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)