Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp344417rdb; Tue, 31 Oct 2023 09:02:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOi5d9O1utwz0UF+uDrtkB+eYElZanFkCFUFh1TfYSF6wOsMTndG2lLJh4Xr6vt67J7+/6 X-Received: by 2002:a17:902:f213:b0:1c3:4b24:d89d with SMTP id m19-20020a170902f21300b001c34b24d89dmr11630545plc.40.1698768139968; Tue, 31 Oct 2023 09:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698768139; cv=none; d=google.com; s=arc-20160816; b=Q7Yat6OTL7J+d5jQP1E5TILkwMxHdzV4UtfSoUqKxA60JE0BD3giiPunFxILPqMfjf 7HuMHyPaC75RA9eGvGbIjF7gvtA+A0vfp5uBdlWZF0pXwsyWwqK7EPluLRHbMTwyWyAw nvg3IXSzfKu4xTnu/lJY9YlPXK1arnSnJzfuJ8IGkELOb0XCdMd7N36AMdJlL0MNATeO mWZhFsdQRxdkhqOTwsK3dlClmA6RyP5t8au8uGEEtQLrpvnOZUyGZHSj9K7OgHHUxzRw YdMiYP5CTAMJ+rtDU5DNoXlLVbeMWZm/2+aZhD0O4howXXuegv2VstL7ySYhwTRpOR9Z FV0w== 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:dkim-signature; bh=AxFRKm6HPoBH+ZXu12vS/5bpNGLAyx3w22Bu1ude2cM=; fh=B1ywLUHfvEz7XQ+vVHzRC9XEGJIeSiFVfFWIoHyQ/+E=; b=QBgZIPtMH/Y/DoSwRVAoP5eBKbmMGSqr07TudhyNEzy45Nq6yTx38I6Z6bRKBwUVDI OoDawvrb7RlgZSdlGjFTDftECPFwtfBIeyDBXkqeiLZBU2IaZK84cu/BS3aXWPAwozP2 prhFPSWM0HRBIWzQYfDr1jOe48aAxaTVszyS5rK32mI+bbmG8Gwoc7ZLRly0O9pVLpqI uq4k2OmOdSGmX3+Pg7XnGOGyeWzMjlSUmynpwv072PP9JgWglz5yNGTFBd65p8m+NkPj zzYKyOpeefg/q5+7bl1G0Wgci3Y5jqn8z73vQe9B4hznSte14S3c4evwVTlGcCcDIs4p 0vYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vubEH9ft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s9-20020a170902ea0900b001c9b2013393si1202255plg.230.2023.10.31.09.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 09:02:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vubEH9ft; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2673D801D14B; Tue, 31 Oct 2023 09:02:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344881AbjJaQCB (ORCPT + 99 others); Tue, 31 Oct 2023 12:02:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344803AbjJaQCA (ORCPT ); Tue, 31 Oct 2023 12:02:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BF37F4; Tue, 31 Oct 2023 09:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=AxFRKm6HPoBH+ZXu12vS/5bpNGLAyx3w22Bu1ude2cM=; b=vubEH9ftjuQuNiRkV31eAfjf0l X/7OHqN7Bw114j76oJUn1aJeLGkfxeFJ6HvMxt14meYZthI/pJtLEKt/MqaUYsD/rCw4hrtDfKEy/ MpmtouENeJQCjIzT3HpNc9XtUy26QJV0aSbfsdajmhwEymTlRm1uXEq2wWsKZPK7hd9yJj679h+BY U5t1scmWDaJ0jFV/o7I1ozZMubGV4HWwYTVKTSEj5Pk3mp9CZH2gUmFPCSZSXzBCoHCKhEpgv2nDe +yvxkjP/jBBlhME3dlKfUexxMm9yztZPXwdW4NGdfr82pVIZyvPeTKKlLw2vqQnaXrAwnUWE4KK8T O2jFPoLg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qxrBA-00B05n-JP; Tue, 31 Oct 2023 16:01:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 3F576300473; Tue, 31 Oct 2023 17:01:20 +0100 (CET) Date: Tue, 31 Oct 2023 17:01:20 +0100 From: Peter Zijlstra To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Daniel Bristot de Oliveira , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Steven Rostedt , Vincent Guittot , Thomas Gleixner , Sebastian Andrzej Siewior , Tomas Glozar Subject: Re: [PATCH] sched/fair: Make the BW replenish timer expire in hardirq context for PREEMPT_RT Message-ID: <20231031160120.GE15024@noisy.programming.kicks-ass.net> References: <20231030145104.4107573-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231030145104.4107573-1-vschneid@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 09:02:02 -0700 (PDT) On Mon, Oct 30, 2023 at 03:51:04PM +0100, Valentin Schneider wrote: > Consider the following scenario under PREEMPT_RT: > o A CFS task p0 gets throttled while holding read_lock(&lock) > o A task p1 blocks on write_lock(&lock), making further readers enter the > slowpath > o A ktimers or ksoftirqd task blocks on read_lock(&lock) > > If the cfs_bandwidth.period_timer to replenish p0's runtime is enqueued on > the same CPU as one where ktimers/ksoftirqd is blocked on read_lock(&lock), > this creates a circular dependency. > > This has been observed to happen with: > o fs/eventpoll.c::ep->lock > o net/netlink/af_netlink.c::nl_table_lock (after hand-fixing the above) > but can trigger with any rwlock that can be acquired in both process and > softirq contexts. > > The linux-rt tree has had > 1ea50f9636f0 ("softirq: Use a dedicated thread for timer wakeups.") > which helped this scenario for non-rwlock locks by ensuring the throttled > task would get PI'd to FIFO1 (ktimers' default priority). Unfortunately, > rwlocks cannot sanely do PI as they allow multiple readers. > > Make the period_timer expire in hardirq context under PREEMPT_RT. The > callback for this timer can end up doing a lot of work, but this is > mitigated somewhat when using nohz_full / CPU isolation: the timers *are* > pinned, but on the CPUs the taskgroups are created on, which is usually > going to be HK CPUs. Moo... so I think 'people' have been pushing towards changing the bandwidth thing to only throttle on the return-to-user path. This solves the kernel side of the lock holder 'preemption' issue. I'm thinking working on that is saner than adding this O(n) cgroup loop to hard-irq context. Hmm?