Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6381691rwb; Wed, 18 Jan 2023 04:37:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXuw6ZK0uuo+WhiXCeMkk2ZsrEYbwj31Do7OlTMw63krcXmkp0mHB6YCWYKhqdPJnDEDSHr1 X-Received: by 2002:a05:6a20:2905:b0:b6:4fb2:9afa with SMTP id t5-20020a056a20290500b000b64fb29afamr25902349pzf.28.1674045437157; Wed, 18 Jan 2023 04:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674045437; cv=none; d=google.com; s=arc-20160816; b=0Il3TVGzfkXPWlneYAGBPT5OvFLKCpJf0Hil4KWcF0udcNSe/hnanyUDSfp8v5iTjq vjlPdv9RIUKnC9Pb31opuF7XXpkUZyUOk5euRT7jihaYUQWymwjR/OaWBPRcTJ++WFwd qX063drYUuP5jSXwHQHaF6nfn8749JlCpsevOY5FuaBoJ0WzkeCZkmUc3tN0oQ16yS0/ eOGEufA+csRatWA8lpocMvWOYFJo1vvkfsmVrBAvr6On3+yDdE009CDCwMDJ974raTmD 2iKDcOaCtdD4imjBX2hwioWhsYnQP9AWL/0U7eHpMGK1TSYPsKOUvHryGrSj0/Q/dpxh wkvg== 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:sender:dkim-signature; bh=FJaMI56CuLQSWiXvcFp/J8HGei2lr3N4VqMBnaci1Eg=; b=XLvTiNOnRIgZZKa4NrUTWAPK9PvWT9GZ9uzbm7iLqWHclstzeMdzevWvyXjssZT9tM YX7fTQKD+veA99N7kXD5GJfgsXmh4jOLPmIWmWVCGq6eVKHX9e6bFuJmnypR2APXhJ9z 8jrqmK9os5KQXcGfBBhqmD+f46BmCnknciTYxBnHqsPi/HBGfQYGHnkHlctV9QQkpy1S GIN8kT9T8mQnwiE/PwGaRfQ6pgpCHhvUQJk6FoIpnXIv9E+uweN3VwCioKeWab5Sd3xO Pm8bWOj58F76s3EtUOlWfAEYGXltGwN911tfTbew4da0V0RYSR9xnsFjJYDz17ObvfB+ d7Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=h1pBp+Re; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc18-20020a656d92000000b00478fc0cb33bsi36056283pgb.210.2023.01.18.04.37.11; Wed, 18 Jan 2023 04:37:17 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=h1pBp+Re; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbjARL2F (ORCPT + 45 others); Wed, 18 Jan 2023 06:28:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbjARL1l (ORCPT ); Wed, 18 Jan 2023 06:27:41 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 175FCBD145; Wed, 18 Jan 2023 02:45:53 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id mg12so9851399ejc.5; Wed, 18 Jan 2023 02:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=FJaMI56CuLQSWiXvcFp/J8HGei2lr3N4VqMBnaci1Eg=; b=h1pBp+ReYZJ1R2WXFgIEHoWl0UI1RZ8YxXFlZUuvlcn7bNNethjx3rZKL83ZRXIt1A 2tzcW98ytzjAjZUkpVYsIP9xVm481iP91GeIlzPkssYEKvxyKHfVbWP+rbxHABMVMFBx n8iGaTiyh7PIcCzRfnVRFPUwfI2NncWMoAQVUbvW2GdKdBajOtC8X/RluZu6lKj0Y2zp HUP8jb8ooNS8SAsclVxfsDLO2u4nyeIb89YrLKtNeS44tVrY/C+zF6tojUAcTVAHAWfj h0iK9568MFunp7NedC8boxuY+DHoWCOrrXv4HcysNklsV0uSAt3Zva3Hch3hioRBmwyF FoXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FJaMI56CuLQSWiXvcFp/J8HGei2lr3N4VqMBnaci1Eg=; b=3mTIfZqT/5FqnJ6Z1/UYhqvQbxXUMXWVz6WBrLK9IfXQOR96W9ucFU8e/0Pyvk9UfD YHOZ6f+WDjweHgxtsaOTjwuadGZtSSrQHHr9gzpNAYgX7Xv6GSI2Yx/B98iC93CL0M5R Zi6wWKpjBl2P/FiTfzxWRqyugP3wiF0AvUNleeCboHYdIWAp6c1EQW2qXcIh1qEdBI/4 NYrNBBLIr/F4rlSdrjocZTHT+fsOa15Nfj8zra9jRPF5fVsNZF3YK0sgoqX56ovzwjsB Ajl4bWJBPQ2RtxILiwNCkdUN6HGYJUTpQZdKUiKwz7xAC0J2XLXNedz0KXmnTtdss5Cd xloQ== X-Gm-Message-State: AFqh2kq6KcHOcSn1MKj7jtNjPbC41uLvaLEl4pQmmrMTVt049akTXzoE N2slDy1gNU9PYLi1+UZOB80= X-Received: by 2002:a17:906:fb0d:b0:856:6884:675f with SMTP id lz13-20020a170906fb0d00b008566884675fmr6467925ejb.52.1674038751892; Wed, 18 Jan 2023 02:45:51 -0800 (PST) Received: from gmail.com ([31.46.242.11]) by smtp.gmail.com with ESMTPSA id f1-20020a17090631c100b007aea1dc1840sm14429002ejf.111.2023.01.18.02.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 02:45:51 -0800 (PST) Sender: Ingo Molnar Date: Wed, 18 Jan 2023 11:45:45 +0100 From: Ingo Molnar To: Mel Gorman Cc: Sebastian Andrzej Siewior , Peter Zijlstra , Thomas Gleixner , Davidlohr Bueso , Linux-RT , LKML Subject: Re: [PATCH v2] locking/rwbase: Prevent indefinite writer starvation Message-ID: References: <20230117083817.togfwc5cy4g67e5r@techsingularity.net> <20230117165021.t5m7c2d6frbbfzig@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230117165021.t5m7c2d6frbbfzig@techsingularity.net> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 * Mel Gorman wrote: > > > dio_truncate is not a realtime application but indefinite writer > > > starvation > > > > If so then the PI boosting would not work if we would have it ;) > > > > True, but it's still undesirable for a basic functional test using normal > tasks with no prioritisation to stall forever. Agreed. > +/* > + * Allow reader bias with a pending writer for a minimum of 4ms or 1 tick. > + * This matches RWSEM_WAIT_TIMEOUT for the generic RWSEM implementation. > + * The granularity is not exact as the lowest bit in rwbase_rt->waiter_timeout > + * is used to detect recent DL / RT tasks taking a read lock. > + */ > +#define RWBASE_RT_WAIT_TIMEOUT DIV_ROUND_UP(HZ, 250) > + > +static void __sched update_dlrt_reader(struct rwbase_rt *rwb) > +{ > + /* No update required if DL / RT tasks already identified. */ > + if (rwb->waiter_timeout & 1) > + return; > + > + /* > + * Record a DL / RT task acquiring the lock for read. This may result > + * in indefinite writer starvation but DL / RT tasks should avoid such > + * behaviour. > + */ > + if (rt_task(current)) { > + struct rt_mutex_base *rtm = &rwb->rtmutex; > + unsigned long flags; > + > + raw_spin_lock_irqsave(&rtm->wait_lock, flags); > + rwb->waiter_timeout |= 1; > + raw_spin_unlock_irqrestore(&rtm->wait_lock, flags); > + } > +} So I'm not sure this should be dependent on the task being an RT task. Starvation scenarios are bad no matter what scheduling policy is used. Should be unconditional - and all workloads should live with the new behavior. Thanks, Ingo