Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1344809rwb; Mon, 7 Nov 2022 00:03:47 -0800 (PST) X-Google-Smtp-Source: AMsMyM5ZcfFKF/RdfaC8GRCVg5g5WRkSF+dq4w2MRm+AVVKKuXa+G5e354V0r5Cle/mlCn+h2cv7 X-Received: by 2002:a17:90b:2705:b0:20a:b25d:5d93 with SMTP id px5-20020a17090b270500b0020ab25d5d93mr67832913pjb.218.1667808227814; Mon, 07 Nov 2022 00:03:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667808227; cv=none; d=google.com; s=arc-20160816; b=Pnmp2d2YKy+WqRgNoIPeTD7yzPEg+JE8JJhx1GxL5MvWjyAORnIYQbmgD3zsvyStJK IhU+u4DfTdRlR/GTeYzZipVWqMJBFoWgMIQd3KcpQmeKlQThdKWnhN6nsCQ5x2gU8RsW uwKjeEBGwPmlz0sArxF+EdrPe7BY7HzaqMonZ2vMxwPK33YVIDro1HvLXgsKNgdqWMjR ya5JHVUF+Z97aWj2/iXJDVzkVHZ41aYUFr/z0sjK8kfoFDyDjJgyEu5OtLxmi3uq6Sqt 8TxycecUIcvOp0AlIBh/TOGUFDxxmXlRwcp/fbDk2QgiO3jjsuei20suaexm742lGKYC Ca2g== 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=wbw8UlZFhQEVv28M6pF5vKJuxWk/eE+BiE2ImvUMr70=; b=JwD8KSIgKwITEcS4nHU5MxNyORzp4SWHDwBlHIZMkZDVZEAJ82JEg0az2cv7izJ8pb T155c9wlSdtXy87p8hvKasKoAxkrcQ9dv/kyfMnerHSsZBT5uA76E1tvfk2nKEWSUfmR fcb1Jo/gP6GY3PcmiBptOJMz5mxDJzaqiIPYPNcMzQU4zxQIL6ByTeuOtEyHuVHUJ4l3 H2OHMIcAakXp0duaTOfz8zhM8a/O+qRQBoA3qk6STcvuHDK7XdrelFMautrg3dtPVBhD gKnrxvUfKnhplcNEhfvWawI21MQdUZCJnnJ8LMLWrrKEizBvxi1rO2qr2qaaIsXquvV9 ILNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZiSlZjGp; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a637a19000000b0046265702353si10256141pgc.203.2022.11.07.00.03.32; Mon, 07 Nov 2022 00:03:47 -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=@linaro.org header.s=google header.b=ZiSlZjGp; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbiKGIAa (ORCPT + 96 others); Mon, 7 Nov 2022 03:00:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbiKGIA1 (ORCPT ); Mon, 7 Nov 2022 03:00:27 -0500 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6422F13EB6 for ; Mon, 7 Nov 2022 00:00:26 -0800 (PST) Received: by mail-io1-xd29.google.com with SMTP id 11so8236945iou.0 for ; Mon, 07 Nov 2022 00:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=wbw8UlZFhQEVv28M6pF5vKJuxWk/eE+BiE2ImvUMr70=; b=ZiSlZjGp1IHwI4DBPdUNAPTypY58zT9rzzmGa03QZ4FoXl1HeH3HBfYuMb84vUZQc3 Rmx55oTFzOEHlqnzxd63jOcLDOgxyAaSugUX882ynWyKtEBOqJQXKywH4zlIhOKscpaw U49mpE2tG2bMvX/7KGEzIygbKmRcgZbO86S8uq+f3UyfYcePUQudIm8hOaR4HOahSKGP +oBNHekUpuEyTZIQePZpcClBDntMbJSREiuhCHSvvrIvy09BY0gCQ1UfQvqQuyndT3b3 ZOWgyTNj/Sa28Y0Hhwklg0bv70W+79QEcy7ZNy0qVVsZ8P0MgPCzInkfRWNqM5kCH2ut F/QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wbw8UlZFhQEVv28M6pF5vKJuxWk/eE+BiE2ImvUMr70=; b=tN3OVsT5qFK1PP5YlnP6wJ2O+fNr7QMCkxjcHW6zR7aDBNDmgHsydBLhLmlYWpp6Wo s+IYKz/tYoT9CYE+8RLkLP+1f1nWIGVWGMJ8bsMb1vr5LciJuQp0bUukRi04lvdSvZhO UGhv5xZsY0nIMKngkS67wiF3YPj4cGLYzE3nRr6r55ChpxdufgMGnOPVo2WLtmn1Lgxm tWrA8tYy0VPZ/CF7hh9zn0PI0uLVxg7mSreU/oE87TyQCxL6AJVjz52fSHo41f+RkEv4 wixWD/t7bM9dWiw57hQvbNOGo2Tr6YozIP+usdgv4malZE9N4nw3Kq6wTI/cT3OqCsAk aPCg== X-Gm-Message-State: ACrzQf22bWFkCrc9Ft6wQxVJ/bIY4lGSWBDXXFzVFT8CMA1htA9uBBWu QD3Mb1tH+N3JDVxcZFNsJrsS1jN7dAKr/7Mq02X7PA== X-Received: by 2002:a02:c006:0:b0:375:afec:565b with SMTP id y6-20020a02c006000000b00375afec565bmr7468891jai.135.1667808025546; Mon, 07 Nov 2022 00:00:25 -0800 (PST) MIME-Version: 1.0 References: <20221028093403.6673-1-vincent.guittot@linaro.org> <20221028093403.6673-2-vincent.guittot@linaro.org> In-Reply-To: From: Vincent Guittot Date: Mon, 7 Nov 2022 09:00:12 +0100 Message-ID: Subject: Re: [PATCH v7 1/9] sched/fair: fix unfairness at wakeup To: Chen Yu Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, parth@linux.ibm.com, qais.yousef@arm.com, chris.hyser@oracle.com, patrick.bellasi@matbug.net, David.Laight@aculab.com, pjt@google.com, pavel@ucw.cz, tj@kernel.org, qperret@google.com, tim.c.chen@linux.intel.com, joshdon@google.com, timj@gnu.org, kprateek.nayak@amd.com, youssefesmat@chromium.org, joel@joelfernandes.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On Sat, 5 Nov 2022 at 15:33, Chen Yu wrote: > > On 2022-10-28 at 11:33:55 +0200, Vincent Guittot wrote: > [snip] > > +static inline unsigned long get_latency_max(void) > > +{ > > + unsigned long thresh = get_sched_latency(false); > > + > > + thresh -= sysctl_sched_min_granularity; > > + > May I know why we substract sysctl_sched_min_granularity above? > I thought thresh -= 1 would be enough to let the waking task preempt > the current one, because: > When a long sleeping task is enqueued on this rq, its vruntime is set > to cfs_rq->min_vtime - latency, so > diff = curr->vtime - cfs_rq->min_vtime + latency, > since (curr->vtime - cfs_rq->min_vtime) >= 0, if we set the thresh to > (latency - 1), the diff is guaranteed to be bigger than thresh and > the waking task can preempt current task. If the waking task failed to preempt current it could to wait up to sysctl_sched_min_granularity before preempting it during next tick. Vincent > > thanks, > Chenyu > > + return thresh; > > +}