Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2944878rwb; Fri, 20 Jan 2023 09:11:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvtUsi1LWLbB70pb8fhKSS7vuJRz3++PQ58FEcEUEe8jb6PETNrb7UAsf8+uGtrmruzUpk X-Received: by 2002:a17:902:e887:b0:193:e89:f5ff with SMTP id w7-20020a170902e88700b001930e89f5ffmr48959847plg.28.1674234699050; Fri, 20 Jan 2023 09:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674234699; cv=none; d=google.com; s=arc-20160816; b=CpVGCLEnzBDpFE/WfKeINfQNvfhdGedfgSLZ8IFG6VGjgrzIBOeIAua0Na98olzOe/ bgehGZlFDXk9IhzFFPpgNoz/Ni1Z41ZIY2ZH9jczJQ/ryj9R/ei5DEDmOAtbex9sI1rZ lI8TPRD/tHQKejD8g02VAdXErKYtaGHhz1e923J8AjUeUXq/1i9LFUM4m670+mXOF3vC Kf7IHlankHtCdCS04+cPX1iiXqS9jNKza6DNoCvUkj5Ni3FtAXFk9KDEsxv5OScw4+Iu k7jpFs8VuWo7GguVClF8ZY6hXXH6R+21hWZeegUKul2ichK4hYO8i1TbHhWF7XLrRnQC /GEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=YLRoVkXLJvVtaddOs4J3QE3hsO3euyWw9wk/7D9L8S8=; b=To+vCsztBP1UvlVpZPpnzpJBzCWE88ErJh/0r74dTzBmvVNIQhypt9UmRrkw0R6zgJ uJCPDy+IZaaWiKozjeM5RtfwMxijmgz7qCpCyvdnwSSjUKuwhEX9OGfKLvpO22NN90q8 xaHilgHyYqjbR22DHNgRVyB1rfqHYniZ/jv2Mrd/Iyd0Av/ip6+sbzeIYhhM3b89ttJy CEkoPGRjtWhiaplFgyq6U6t67Nopv18nq5YioIaXve29qgN6uNVYprR6dGJ+ssMqmvoW nYMbU2z3l1x427I/0TTF03PqD8VeXR4JRPFZF5nmoSu7mIx2NoNr7YZiKV1NGfkUwlT2 e6ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170902e5c200b0018948b0082fsi23724125plf.244.2023.01.20.09.11.30; Fri, 20 Jan 2023 09:11:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbjATQ62 convert rfc822-to-8bit (ORCPT + 50 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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)