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 32C0FC6FA8E for ; Thu, 2 Mar 2023 22:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbjCBWlp convert rfc822-to-8bit (ORCPT ); Thu, 2 Mar 2023 17:41:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjCBWln (ORCPT ); Thu, 2 Mar 2023 17:41:43 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04DCD4DE0C for ; Thu, 2 Mar 2023 14:41:41 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-264-PvAjbCtRPHihBSSlL2U9CA-1; Thu, 02 Mar 2023 22:41:38 +0000 X-MC-Unique: PvAjbCtRPHihBSSlL2U9CA-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.47; Thu, 2 Mar 2023 22:41:36 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.047; Thu, 2 Mar 2023 22:41:36 +0000 From: David Laight To: 'Steven Rostedt' , John Stultz CC: LKML , Wei Wang , "Midas Chien" , Kees Cook , "Anton Vorontsov" , "Guilherme G. Piccoli" , Tony Luck , "kernel-team@android.com" , Thomas Gleixner , "Peter Zijlstra" , Sebastian Andrzej Siewior Subject: RE: [PATCH] pstore: Revert pmsg_lock back to a normal mutex Thread-Topic: [PATCH] pstore: Revert pmsg_lock back to a normal mutex Thread-Index: AQHZTUSK7fWJqBV/U0q1fZmOSFQwN67oEXJw Date: Thu, 2 Mar 2023 22:41:36 +0000 Message-ID: References: <20230302062741.483079-1-jstultz@google.com> <20230302082414.77613351@gandalf.local.home> <20230302152103.2618f1b7@gandalf.local.home> In-Reply-To: <20230302152103.2618f1b7@gandalf.local.home> 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: Steven Rostedt > Sent: 02 March 2023 20:21 ... > There's no harm in spinning, as the task can still be preempted, and > there's no issue of priority inversion, because the spinners will not be on > the same CPU as the owner and the top waiter, if they only spin if those > two tasks are also running on a CPU. ISTM that a spinlock should spin - even on an RT kernel. If it might spin for longer than it takes to do a process switch it shouldn't be a spinlock at all. (I bet there are quite a few that do spin for ages...) Adaptive spinning for a sleep lock (as an optimisation) is entirely different. I changed some very old driver code that used sema4 (which always sleep) to mutex (which quite often spin) and got a massive performance gain. I've also had terrible problems trying to get a multithreaded user program to work well [1]. Because you don't have spinlocks (userpace can always be preempted) you can't bound the time mutex are held for. So any vaguely 'hot' lock (maybe just used to remove an item from a list) can get interrupted by a hardware interrupt. The only way to make it work is to use atomic operations instead of mutex. I can't help feeing that the RT kernel suffers from the same problems if the system is under any kind of load. You might get slightly better RT response, but the overall amount of 'work' a system can actually do will be lower. [1] Test was 36 threads on a 40 cpu system that need to spend about 90% of the time processing RTP (UDP) audio. This also involves 500k ethernet packets/sec (tx and rx). It is all possible, but there were a lot of pitfalls. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)