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 C29CBC7619A for ; Wed, 22 Mar 2023 09:35:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230283AbjCVJfN (ORCPT ); Wed, 22 Mar 2023 05:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjCVJfL (ORCPT ); Wed, 22 Mar 2023 05:35:11 -0400 X-Greylist: delayed 368 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 22 Mar 2023 02:35:08 PDT Received: from outbound-smtp17.blacknight.com (outbound-smtp17.blacknight.com [46.22.139.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E8F5B5EB for ; Wed, 22 Mar 2023 02:35:06 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp17.blacknight.com (Postfix) with ESMTPS id D65281C3A54 for ; Wed, 22 Mar 2023 09:28:56 +0000 (GMT) Received: (qmail 16978 invoked from network); 22 Mar 2023 09:28:56 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.21.103]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 22 Mar 2023 09:28:56 -0000 Date: Wed, 22 Mar 2023 09:28:48 +0000 From: Mel Gorman To: Sebastian Andrzej Siewior Cc: Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Davidlohr Bueso , Linux-RT , LKML Subject: Re: [PATCH v6] locking/rwbase: Mitigate indefinite writer starvation. Message-ID: <20230322092848.hjlehutudsoz2hlz@techsingularity.net> References: <20230321161140.HMcQEhHb@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230321161140.HMcQEhHb@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 21, 2023 at 05:11:40PM +0100, Sebastian Andrzej Siewior wrote: > The rw_semaphore and rwlock_t locks are unfair to writers. Readers can > indefinitely acquire the lock unless the writer fully acquired the lock. > This can never happen if there is always a reader in the critical > section owning the lock. > > Mel Gorman reported that since LTP-20220121 the dio_truncate test case > went from having 1 reader to having 16 reader and the number of readers > is sufficient to prevent the down_write ever succeeding while readers > exist. Eventually the test is killed after 30 minutes as a failure. > > Mel proposed a timeout to limit how long a writer can be blocked until > the reader is forced into the slowpath. > Thomas argued that there is no added value by providing this timeout. > From PREEMPT_RT point of view, there are no critical rw_semaphore or > rwlock_t locks left where the reader must be prefer. > s/prefer/preferred/ > Mitigate indefinite writer starvation by forcing the READER into the > slowpath once the WRITER attempts to acquire the lock. > > Reported-by: Mel Gorman > Link: https://lore.kernel.org/877cwbq4cq.ffs@tglx > Signed-off-by: Sebastian Andrzej Siewior Acked-by: Mel Gorman Thanks Sebastian and Thomas! -- Mel Gorman SUSE Labs