Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2502748pxb; Fri, 29 Oct 2021 02:44:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOfyh4BoelK/jIOsDSXGpQT4BE059F65i9kQUJ2XX42mqJD3PACrSPai1Kt9P5KNg/uWEN X-Received: by 2002:a17:90b:1c0a:: with SMTP id oc10mr18707064pjb.67.1635500692775; Fri, 29 Oct 2021 02:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635500692; cv=none; d=google.com; s=arc-20160816; b=t74urgyjCvdXfHtH11LlzthWpwbNkeMIK1oi0qkHmjP55l8QTXD4GWYLa/ju11XYqp jl/+pgDzSgyK9rXtAC+7jDBu/Q64pW2R9mPT+Vjj8UixKVeE1UNk+Hw6HrfU6/3KX/Lz XqFvZ4zObzWy6nr+lmdhjVdGAHYqf7DKkraY2AzrVOAqxaMThD+K725yWLjnpNE4rpIn EJ95Z5wiGr8wHuVCG15HXqv9l2kqxYaHTda+xdd1uwq6+bcsTwx9uhodNDrBt4LLh27y rt8AmXN8k4/tZ2GkVlAIdxitXlmHrY+vnWfumQLUZbBkA5uFufF2+lX+eAbrVC03R+Nc ZeUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bUZwq/1zRVot/m4BkJ4rPIhNZn7JplNtfTPmyiUeHgQ=; b=T66wCfmX6q9+eYzq+2baVUCQvJSoiBQIzHgr7Mm/C3hMyE8LwOlmXMidW9LE4T6hCs /K/xURCLt017wCa4jQ/rzvRrtNQf+57vxZeaCCOdsxi3zSmhEEFoe61LRd8Ai8rMFdSh HQoZzwc5couQmZx4tnuZQwwguixSJwhTmRixkH7CnW2IP+MGLSBqwVvkdl4cUJbCjXAW n/4nbhs94IXuBKWeMCiYzZEJxqP8u6fKRc5RoFInrrEIhZMwPfk5Xe/O10gptw/jynDQ LjgsZDTt8vI8Xvyni8HgXmzMd9bVP/JMFdA2wf4vYN+XMmx5OxnoT3QM0XjaMnmfg5Ry 0Ukg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KVDohj5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si6965969pll.178.2021.10.29.02.44.39; Fri, 29 Oct 2021 02:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KVDohj5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231654AbhJ2JpH (ORCPT + 99 others); Fri, 29 Oct 2021 05:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbhJ2JpH (ORCPT ); Fri, 29 Oct 2021 05:45:07 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B24C061570; Fri, 29 Oct 2021 02:42:38 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id e2so15872841ljg.13; Fri, 29 Oct 2021 02:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bUZwq/1zRVot/m4BkJ4rPIhNZn7JplNtfTPmyiUeHgQ=; b=KVDohj5KYCE9Wg2bGbZ1h8TmmhsNRShxs2f2bC5lFyLFz6BnMzUIWoShB6Px+EncKo rwqw/eyvNbQba7I1pYOf5YWuBmzTspZ02sznpmscB2wSrfZm0miCj1aw28W1mjJnTC0r tXt5b7ikg7l0JmX7ZBL/hyRRF2H5dYu1kDkstoupFOA51OZMZYTfnz/sQWnBbBJLLsjP WQzwPD10LVXK2Nb8JLUjT+G0ZDrzP7/6rPv2mOWMy1vqAroh4dvWMFMe+wBhObpKTSf7 yZTn6xb7l/7hP6EuxME1A6kKrXYL1Na4SNSdVO+Q8WiamtlhKAKQdXmTBR/K8MagmuJZ O4yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bUZwq/1zRVot/m4BkJ4rPIhNZn7JplNtfTPmyiUeHgQ=; b=hbPgLkXoG/RXe7TVGxvYfp+2y62lNZasixK2K2Wdx446fg4m1D5Y0LfsxycY7xWeGK JVQTiUJ08D8QZtpYlikAatH14eEdzlw0apJWh1h9QEgQr1sUJ8QkoXvrMzHSfvXZu+sS qUtKid4xTLF/3cF0/bYBAgtx4nHHcc2X+ZdJOdA9Gs07V1884O2G3TzXpt6l8e0XRe6v ob3rzZyUxFcI8GQFMLX0VcEYoBuEXDI+dHviTwbEtXkYYf98HNlNDGJtZtf9Rn7eZ4qd ZK+VowwneZwH+XdXfux61KJ/i3M0SiDVnbqNRJ5mdQvqkiGi6YO4Uf29dPbFm+8+CwCJ 1Jmg== X-Gm-Message-State: AOAM533AgUjgKiL8J1O3S1yJJqg7zyUuWns+6Z7TP677hb6s2o8MM9eb rxDyB6cQOu9Ydf+06u5EfG5vg29Z/gHHW7QAcOt9HPX4FFA= X-Received: by 2002:a2e:361a:: with SMTP id d26mr11017101lja.104.1635500556936; Fri, 29 Oct 2021 02:42:36 -0700 (PDT) MIME-Version: 1.0 References: <20211027165800.md2gxbsku4avqjgt@linutronix.de> <20211028084654.bgtvnibvqnz2o5rh@linutronix.de> In-Reply-To: <20211028084654.bgtvnibvqnz2o5rh@linutronix.de> From: Ronny Meeus Date: Fri, 29 Oct 2021 11:42:25 +0200 Message-ID: Subject: Re: Unbounded priority inversion while assigning tasks into cgroups. To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Op do 28 okt. 2021 om 10:46 schreef Sebastian Andrzej Siewior : > > On 2021-10-27 22:54:33 [+0200], Ronny Meeus wrote: > > > From a looking at percpu_rw_semaphore implementation, no new readers are > > > allowed as long as there is a writer pending. The writer has > > > (unfortunately) to wait until all readers are out. But then I doubt that > > > this takes up to two minutes for all existing readers to leave the > > > critical section. > > > > > > > The readers can be running at low priority while there can be other threads > > with a medium priority will consume the complete cpu. So the low prio > > readers are just waiting to be scheduled and by that also block the high > > prio thread. > > Hmm. So you have say, 5 reads stuck in the RW semaphore while preempted > be medium tasks and high-prio writer is then stuck on semaphore, waiting > for the MED tasks to finish so the low-prio threads can leave the > criticial section? Correct. Note that 1 thread stuck in the read is already sufficient to get into this. Most of the heavy processing is done at medium priority and the background tasks are running at the low priority. Since the background tasks are implemented by scripts, a lot of accesses to the read part are done at low prio. > > Looking at v4.9.84, at least the RT implementation of rw_semaphore > > > allows new readers if a writer is pending. So this could be culprit as > > > you would have to wait until all reader are gone and the writer needs to > > > grab the lock before another reader shows up. But then this shouldn't be > > > the case for the generic implementation and new reader should wait until > > > the writer got its chance. > > > > > > > So what do you suggest for the v4.9 kernel as a solution? Move to the RT > > version of the rw_semaphore and hope for the best? > > I don't think it will help. Based on what you wrote above it appears > that the problem is that the readers are preempted and are not leaving > the critical section soon enough. > > How many CPUs do you have? Maybe using a rtmutex here and allowing only > one reader at a time isn't that bad in your case. With one CPU for > instance, there isn't much space for multiple readers I guess. > The current system has 1 CPU with 2 cores but we have also devices with 14 cores on which the impact will be bigger of course. Note that with the rtmutex solution all accesses (read + write) will be serialized. I wonder why other people do not see this issue since it is present in all kernel versions. And, especially in systems with strict deadlines, I consider this a serious issue. Ronny > Sebastian