Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2721843lqz; Wed, 3 Apr 2024 06:54:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViMca7GEX386ztT5+FUAXZikDWNOMjJMbnM3bqQc1Nt0UEi+/E2XhZg8ewxXxdTAOZ2n9nkFBLDEcNdVSQb+TJaTN/DANv3MiyUn2vVA== X-Google-Smtp-Source: AGHT+IGeHaLM8wfteocvqAK97kH7b2fqmyliNMiqXOFdRaCs9z6ucqm/BunmX4/EDvnDIRY1qkKQ X-Received: by 2002:a17:906:248d:b0:a4d:ffcb:1f4e with SMTP id e13-20020a170906248d00b00a4dffcb1f4emr1845449ejb.75.1712152471320; Wed, 03 Apr 2024 06:54:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712152471; cv=pass; d=google.com; s=arc-20160816; b=qk2u+IeKhXHNcZfMd+V4iD+BFjXWa5O4Or+mVlOrFF9HOpvyIkx/3+DTJ/F5Tk0+9Y eJfYUul3JdDyoVvnvxvnnmCJ9B137wiBs7eW5UfcapLlAvuqzSHANQc+Avz7HY+Lf3jW /hkyPVLpsO6LNS0FE2hfBI3SqcIay/2EO7TQUL7lF2KVPqY7ng/RTIuX6XkSLoGGqN9X UuGXPM6Tbd0L0befX6No/Sy3q22EMnG+kN+Umwr8VPupmFYXHz6LQT2xZcGNbS1UaJMD Wd9Ennk9ABsMuq0Psgnm+/Rd67928Qj5AtuzOO4sFcppB9zHiqNZtpzsVlPkPWDVLJJG Nlig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=EifQjE9G475mPBRIXKqbvKnaPLipvIcH7lDv2GyABro=; fh=MoE7IjcgY8LafDECau+JkQDNcrR2Cks8iPa9H2+CmsI=; b=0PS0f11O+3pCx/YC+XTqU4h1GoYeOzs8+OyHr0Eu0/efimbM//an78Scjo/GOzl+RZ /lWZYEZLhFtQEQnKGA13uV/6yRgIvqJ6kfflOH+YvS9m5CvA911sJNICBU923DzynJIy dM4mnmGE8lGwwKlJE6Fp17OK5SOeNSLTPauptPeDbjkwgfr/tBV8Pg+8CIldsTTSqTZN rt61B8oQcXaVzpiQhhXXCY59L6r7K+x7DMmxBfxJxfPK24VBtXMG+OwOtOLU5rH1en+R /pR8A4tluJRZRa7kaN27a+hZRDehP4V5trnXYxbAgy0OLQGC5kxfbxpxbV2WRoRDVhtb wscA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmfr1xwT; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-129890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129890-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y5-20020a170906070500b00a4e8d0bbc84si1658822ejb.909.2024.04.03.06.54.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 06:54:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmfr1xwT; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-129890-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129890-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DBC351F213BB for ; Wed, 3 Apr 2024 13:54:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A466214900F; Wed, 3 Apr 2024 13:54:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="wmfr1xwT" Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D3BE1487D8 for ; Wed, 3 Apr 2024 13:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712152453; cv=none; b=JjZcw7UtJouo6O+ZMs3rgFkieiYlgNBrMCVyNZkqn1/3N3mIHbh/9YKQXqvXo/5MP/aV15ylbxj5AWVEn9RgLesywGeXbI8YUC80fNEBKuLAW2FbcLo2KTymKOcJOezz2Rea06T74h56ZAt1eSaLGi0Xd/O3xK6DbYvHzq6iGbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712152453; c=relaxed/simple; bh=MfqtLRNa2fpBHZnFAnh4Yo9iQ9J9XzehWsBBWF+mzm0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=bO6PuzfVgwugq9ugbID9RFJQ/guAUOUGrw9oDQb0gdS/9lTR6SlNyBjaTOc3DLTzN+in/nyXNQfEKVhl4paj7Yh2UF+0xxeEZDc4An198eK6aDGkIygD60ApgKfFUJa5DVarzmybbWpHmLI+RyMkmquxrCC3doU69umpz26VzJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=wmfr1xwT; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-5e8470c1cb7so4118920a12.2 for ; Wed, 03 Apr 2024 06:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712152451; x=1712757251; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EifQjE9G475mPBRIXKqbvKnaPLipvIcH7lDv2GyABro=; b=wmfr1xwTmzCl3NCgw0oBNL8TF0sJFMVCl9Gdowx5oF+EHjNbu52r7vkVo+1kmeQ8vV t0N2LngBGsGUElDDSeX3SPGpTzUmfVX6qTSYXrInvhsOAr8KsMe1R9xPXXLppjZr/biX azlWO0NyxWawJ3uwlG0NQYXsv1tUpPXtmR+D/31tqnY+4lLda4xmZn6s3pmORPGJiaCt zGaE99Z4YTPrak5bdRxrVShBoDDh/6JYmN7D24tCYXzwKCNFbz7IvTDPWMY099hCcEjQ RIViNMae+E42OwZIEDRr9XdYuLshhqgs1IA6BKNbWdyuWshGgDwV2oqoS9mtvBcWlx9E Tgiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712152451; x=1712757251; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EifQjE9G475mPBRIXKqbvKnaPLipvIcH7lDv2GyABro=; b=QYmP7l4B8l49BAtfmK9agNLwma7riiiv0B+2qxq/opYcWzCNhLIXpB9od1OSoumW0K HCQ37BrW1G/Fxp5B0Cqd3D4FBzujjTKlhLHiruhH1UWGueeY2aj1jVxDIOHIUv1w7W+4 CIsSFtmylNPHZu+VgdCSBPk9vI6RBkXYyRcnvYrDu/Du1dJv8KJ0OMRKsRz5YfAZgDrW AQEoybUEOLzb/bWr0L+1YocSgPz9s57Oki6ZOkMPzZ2ubr009fIXBA44QH5nHfhnYDv8 LzCQO7vdqsevz1hdXIAD7zlmdVFAZhorz9hIJ6c0MK5ZfbZzUhAAVDGWlQcoofyZ6ysM JRHA== X-Forwarded-Encrypted: i=1; AJvYcCWf6rN7gKaAGe27G86BNz/mznuw2Qas2jjnEziBoSSYvXGIdq1I4Qzkq8q133WD/1+0jDou0P8Va2E4usz/QIUKps2TL27+ezdeyHf4 X-Gm-Message-State: AOJu0YyP6u1Ezcy3SN8brNm0RDye9dV4i3dVywQ2yadAr6x95F7JVMlY JDY5SJZgV8696AFCzSMPVEs124rCCQHlE4G5q+JsRjZd4TqpQQcPf62xEU20aL4oYCRrxnSeh0o WdO2wmNWBGKpD7+MOWk/uBV19Z4/jsyES2J+ghA== X-Received: by 2002:a17:90a:a084:b0:2a2:6a2:8bcd with SMTP id r4-20020a17090aa08400b002a206a28bcdmr12130670pjp.4.1712152451380; Wed, 03 Apr 2024 06:54:11 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240403005930.1587032-1-qyousef@layalina.io> <20240403094224.105fdef0@gandalf.local.home> In-Reply-To: <20240403094224.105fdef0@gandalf.local.home> From: Vincent Guittot Date: Wed, 3 Apr 2024 15:54:00 +0200 Message-ID: Subject: Re: [PATCH] sched/pi: Reweight fair_policy() tasks when inheriting prio To: Steven Rostedt Cc: Qais Yousef , Ingo Molnar , Peter Zijlstra , Juri Lelli , Daniel Bristot de Oliveira , Thomas Gleixner , "Paul E. McKenney" , Joel Fernandes , John Stultz , Dietmar Eggemann , linux-kernel@vger.kernel.org, Yabin Cui Content-Type: text/plain; charset="UTF-8" On Wed, 3 Apr 2024 at 15:40, Steven Rostedt wrote: > > On Wed, 3 Apr 2024 15:11:06 +0200 > Vincent Guittot wrote: > > > On Wed, 3 Apr 2024 at 02:59, Qais Yousef wrote: > > > > > > For fair tasks inheriting the priority (nice) without reweighting is > > > a NOP as the task's share won't change. > > > > AFAICT, there is no nice priority inheritance with rt_mutex; All nice > > tasks are sorted with the same "default prio" in the rb waiter tree. > > This means that the rt top waiter is not the cfs with highest prio but > > the 1st cfs waiting for the mutex. > > I think the issue here is that the running process doesn't update its > weight and if there are other tasks that are not contending on this mutex, > they can still starve the lock owner. But I think it's on purpose because we don't boost cfs tasks and we never boost them. That could be a good thing to do but I think that the current code has not been done for that and this might raise other problem. I don't think it's an oversight > > IIUC (it's been ages since I looked at the code), high nice values (low > priority) turn to at lease nice 0 when they are "boosted". It doesn't > improve their chances of getting the lock though. > > > > > > > > > This is visible when running with PTHREAD_PRIO_INHERIT where fair tasks > > > with low priority values are susceptible to starvation leading to PI > > > like impact on lock contention. > > > > > > The logic in rt_mutex will reset these low priority fair tasks into nice > > > 0, but without the additional reweight operation to actually update the > > > weights, it doesn't have the desired impact of boosting them to allow > > > them to run sooner/longer to release the lock. > > > > > > Apply the reweight for fair_policy() tasks to achieve the desired boost > > > for those low nice values tasks. Note that boost here means resetting > > > their nice to 0; as this is what the current logic does for fair tasks. > > > > But you can at the opposite decrease the cfs prio of a task > > and even worse with the comment : > > /* XXX used to be waiter->prio, not waiter->task->prio */ > > > > we use the prio of the top cfs waiter (ie the one waiting for the > > lock) not the default 0 so it can be anything in the range [-20:19] > > > > Then, a task with low prio (i.e. nice > 0) can get a prio boost even > > if this task and the waiter are low priority tasks > > > Yeah, I'm all confused to exactly how the inheritance works with > SCHED_OTHER. I know John Stultz worked on this for a bit recently. He's > Cc'ed. But may not be paying attention ;-) > > -- Steve