Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp1805675qtg; Wed, 22 Mar 2023 02:37:30 -0700 (PDT) X-Google-Smtp-Source: AK7set/0ca2+BeZ9nX+oAgrka1czKPppPWoQSPF9SOfyaYl4JJFmd7BEg6jGA2uXoEvGxxE8CwpB X-Received: by 2002:a17:90b:1d0e:b0:237:9a13:5841 with SMTP id on14-20020a17090b1d0e00b002379a135841mr3358174pjb.3.1679477849812; Wed, 22 Mar 2023 02:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679477849; cv=none; d=google.com; s=arc-20160816; b=p9v0A8p0iq9vY637BCqUmiI+tXxnHqAjn3qQ1bg5N7IduSNpboewSv/Ydu9oJ74SmG Jz8EnPw2K94syeu1JmcN9HYgwyLr4itE7Wn86xCLAAxnhLArry+5WG7OX4b6bdoM0KFb +QqYv7R3GiJD/fH90P30euwmBkaBuy2d/JSVAIcw5ow5i1n4Tt1X6JuwYNKdN0cO2fqM KH/770dzGoXmC/i3xs50gho3iFyOpBpQzxOpLRxUIqnlYZiMVGYLkTrFV+ZpsSt5graq sw8X+riVNUOO6Kk+MiJw1CIv9zYBdv7mi/G4FBEHYPKt6E4wI1MmGxeDdq4BURRqJqfi Rkfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=xNcpBzzKyItoDg22H46xDXW9oiMy+tXV2/+WhaLeJtg=; b=FRSKZJxbWZENQTyopZbW/LTPkFDpi+fb0XDhN4Ik2ucIjNRxAdF1ODYw0TJCHUp2AR pMXgX62Ad/LgyCLLWhOW48MrwrLsSXg/PBgVUXk2R9062yV0QVctBHklWfG8vPgHPwwz KVK/kSoPSyEnkR4jxDukGBXWE0snl1r1Qwus/hxNto1cbJLyASeZIMuHhtmoJFpE3O+9 sAy+aMs+RVpbCmbhODqBMsKs0iV8XzH832FP81HAgXK7WbHf6S/LnxOdCMxdU48Ny9wF EVttuzyUoJQ197G9ri+USuZKUKRU8ER6ocJXmHlpXPO6kTkfhopTOCZ/F2nYvyb8/Mqt ln/Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a63834a000000b0050f975790e1si628665pge.168.2023.03.22.02.37.18; Wed, 22 Mar 2023 02:37:29 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjCVJfM (ORCPT + 99 others); Wed, 22 Mar 2023 05:35:12 -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> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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