Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp956934pxk; Thu, 17 Sep 2020 23:04:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/cKzlSwBahDBSCHMWbUZlXUTG5QJ0D0FXh4atvYYFfYT2BnasSoJNEhmQNmyYD3Z72Fjs X-Received: by 2002:a17:906:faec:: with SMTP id lu44mr33796556ejb.527.1600409062194; Thu, 17 Sep 2020 23:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600409062; cv=none; d=google.com; s=arc-20160816; b=bwBTtfH28pMJwdNerRNdekL64zp8mrFvq0MFk3P+3+dD81iCa6eBx3b/bCoKY0Akv9 nKj2EgGGWaSz8v+3fLbpU0Mq6m0qYySwZSwbGh0h26h+xF/0nuTE7AzHYx5kGGl+9CKI UZYVODxSuzJThlteTCMmgYVFxGqx7+tYsDhVHUabt+CYZkiajOEWuoImwisH4JJl4nqo qXFFD/IgeGgk4mjViIdjhPj1cpIiDqjKvQx7LghuEIMvS2OrfaDu1LehYrtuzNcdQr6/ iHS99xyfafbTlsHEg1kz+ySExCt2tw0GPpa3/sbww9A4In7XlKDZ7jcesyWfL4cyd8+w CfSg== 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=7GjiLePj2d/62yENu9Rruo7vO63aApraxg0iEhjHAYE=; b=MUQahQsHDIW7z4/LZrNEHah1ETkFNn3jg/R5MCENWIztADDoaQrdaYzCeGq9OJW7Kx f0QuI+MbjiQB3Yx2pMYgujsibE7K5GZ/CLHCW+O94wYrxuJlhNBYMtC1dgUDRU0n0fQP sCckNLCNeC6q6fEzrZ8An7jZE8CDbYdKNp0dqu9qdsdaXk5NlqZ47B26UTjAmuOV3j9n DjnO/6dAgYnzU0T2W8TXFku5wVVtUnykpb3HZv2kiejz7tQaRJvfPAkf4aOSPdmQby3n Du48tWFomZYa115NG4cLmeUEeQ5wiggVviNgVHSTaMp3DC5itBe8U5dfmaUc+V7mC4p6 04jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZB3D+Qt+; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si1903898ejn.597.2020.09.17.23.03.58; Thu, 17 Sep 2020 23:04:22 -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=@redhat.com header.s=mimecast20190719 header.b=ZB3D+Qt+; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726354AbgIRGAg (ORCPT + 99 others); Fri, 18 Sep 2020 02:00:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32979 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgIRGAf (ORCPT ); Fri, 18 Sep 2020 02:00:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600408833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7GjiLePj2d/62yENu9Rruo7vO63aApraxg0iEhjHAYE=; b=ZB3D+Qt+Wf5vONbhbTIr/Z+//lfCYlUfQpCwFbA3SDlQEk6d68EKkHwXJR8vuLOCbsuQTj jKGYRS3XitpymKv/taJ8t2Q8sMcoDVXmJ7X/8y3LKsEpviJmweq/eJbtg8rJNyfcRcgeCP +3LDgw4T0RkACOUL+r3r6Uj2NMUNFhc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-BGvCzAg6NbyIYQ0BWeSdIA-1; Fri, 18 Sep 2020 02:00:31 -0400 X-MC-Unique: BGvCzAg6NbyIYQ0BWeSdIA-1 Received: by mail-wr1-f71.google.com with SMTP id f18so1717057wrv.19 for ; Thu, 17 Sep 2020 23:00:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7GjiLePj2d/62yENu9Rruo7vO63aApraxg0iEhjHAYE=; b=FJQyh0MolUaxRV0t8mkFeXCmoem1slD2zLx0n7sZ23tl1MIwnyZQl7PJXsCFyyN+qQ uvsLV4TG0RwUxPxYKrrMRQyRqoiel3MNzkhRXmZyk5ByA/Mn08K/mhw85Rw5JnYn1Zlc mlC6U9AXronrT5UyPPskj5OIvnu4gDeSM3h4PLs/PeZ3TtKyPT+usqzBitoiLIHdYImx KKl2JN60WZsb8de1FJZbfRrdqvDFya5MiPOiPedE/of9iyNF87sVNL23NDvj8SeB/Y/c 1y/WzEDtxO8bnNOTAfr7zsRm69+G1q8lifkTmivUiRECIJLFOEpC4YnlkMhos4G0iq5w pE9g== X-Gm-Message-State: AOAM532jCCjhTKzJPOMcAC+BQrT//tEAQ28qwXY/+pILnwkcj//qiZuZ BjOH+kBkTmza9VDne/XFL/On6N3ksKyXj8aFUpeqpzXGqYem2AUsThPphgvb637H4u8OXAnfpps v96iX5kVZgp7+4/Fklhn4jlLk X-Received: by 2002:adf:e80b:: with SMTP id o11mr34185436wrm.118.1600408829955; Thu, 17 Sep 2020 23:00:29 -0700 (PDT) X-Received: by 2002:adf:e80b:: with SMTP id o11mr34185414wrm.118.1600408829691; Thu, 17 Sep 2020 23:00:29 -0700 (PDT) Received: from localhost.localdomain ([151.29.184.101]) by smtp.gmail.com with ESMTPSA id a5sm3175493wrp.37.2020.09.17.23.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 23:00:28 -0700 (PDT) Date: Fri, 18 Sep 2020 08:00:26 +0200 From: Juri Lelli To: Daniel Bristot de Oliveira Cc: Ingo Molnar , Peter Zijlstra , Mark Simmons , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/deadline: Unthrottle PI boosted threads while enqueuing Message-ID: <20200918060026.GC261845@localhost.localdomain> References: <5076e003450835ec74e6fa5917d02c4fa41687e6.1600170294.git.bristot@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5076e003450835ec74e6fa5917d02c4fa41687e6.1600170294.git.bristot@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On 16/09/20 09:06, Daniel Bristot de Oliveira wrote: > stress-ng has a test (stress-ng --cyclic) that creates a set of threads > under SCHED_DEADLINE with the following parameters: > > dl_runtime = 10000 (10 us) > dl_deadline = 100000 (100 us) > dl_period = 100000 (100 us) > > These parameters are very aggressive. When using a system without HRTICK > set, these threads can easily execute longer than the dl_runtime because > the throttling happens with 1/HZ resolution. > > During the main part of the test, the system works just fine because > the workload does not try to run over the 10 us. The problem happens at > the end of the test, on the exit() path. During exit(), the threads need > to do some cleanups that require real-time mutex locks, mainly those > related to memory management, resulting in this scenario: > > Note: locks are rt_mutexes... > ------------------------------------------------------------------------ > TASK A: TASK B: TASK C: > activation > activation > activation > > lock(a): OK! lock(b): OK! > > lock(a) > -> block (task A owns it) > -> self notice/set throttled > +--< -> arm replenished timer > | switch-out > | lock(b) > | -> B prio> > | -> boost TASK B > | unlock(a) switch-out > | -> handle lock a to B > | -> wakeup(B) > | -> B is throttled: > | -> do not enqueue > | switch-out > | > | > +---------------------> replenishment timer > -> TASK B is boosted: > -> do not enqueue > ------------------------------------------------------------------------ > > BOOM: TASK B is runnable but !enqueued, holding TASK C: the system > crashes with hung task C. > > This problem is avoided by removing the throttle state from the boosted > thread while boosting it (by TASK A in the example above), allowing it to > be queued and run boosted. > > The next replenishment will take care of the runtime overrun, pushing > the deadline further away. See the "while (dl_se->runtime <= 0)" on > replenish_dl_entity() for more information. > > Signed-off-by: Daniel Bristot de Oliveira > Reported-by: Mark Simmons > Reviewed-by: Juri Lelli > Tested-by: Mark Simmons > Cc: Ingo Molnar > Cc: Peter Zijlstra > Cc: Juri Lelli > Cc: Vincent Guittot > Cc: Dietmar Eggemann > Cc: Steven Rostedt > Cc: Ben Segall > Cc: Mel Gorman > Cc: Daniel Bristot de Oliveira > Cc: linux-kernel@vger.kernel.org > > --- Thanks for this fix. Acked-by: Juri Lelli Best, Juri