Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp809933lqs; Tue, 5 Mar 2024 18:30:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVtXJIjISaRDIOXpyGIWae6JeILAn7rtNlvjmduF+5i6U3R5PA+33/AlxaZsoXsBgaTHlDUvOixmiq7VvGjaBr+Buizy3ZoU9c1vTqC5A== X-Google-Smtp-Source: AGHT+IFvu+c/lm7oUap/NrX/Kyl4F2EH9EtzN90YI1gSCL19RFrXJZOYpdD8sKiyacVEeBWm3UTC X-Received: by 2002:a05:6358:430e:b0:17a:ec6c:4234 with SMTP id r14-20020a056358430e00b0017aec6c4234mr4192904rwc.10.1709692199813; Tue, 05 Mar 2024 18:29:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709692199; cv=pass; d=google.com; s=arc-20160816; b=EIjkOFPHDRhAQ4XHlZOhh02nbER1nukJ6pxjlfwWj/SORxz34l9O0JIOQDomDvjr4/ c126iHT0g0yalftEmhGm1ZX8baH6Y3/uw4gbT/as5kgBHwryChXgrYbiIfKLcHX71TUI KK6avioJHfrP6k+PfUEkjPtURRy1bxaRQ0wwo4j/wR0QRPVou/l4nOI7ZrZ/hJBVCt9N 0HXHyF1CjQoRJRgRX3VHjPcHfRcAP4bFNuHZlfeAoLDxOJndKDpnm+G3638S3nqYuz8T wS9H9oa8phV0mu854HWjJ64il9pilXdumDT9IOa0KfS4+nF7aS9SKLa4bFLRYwW5jUsH lUlg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7C9rxAZf2p6XR/2XiWXhnPifuebioXZkTUeVUjvyyeI=; fh=HGPOwMD1U+bU1zkI6pk9BDAYYJSoTCIazwWVkER0sVk=; b=IWxDgVzn8OtGrWbw+N5Fy5LNUGP7vDVLM84+coiQtXvTdWzf3WMVSL+UTO79EDCbXR 3DQrQIbTil38poNLWqz2cl85Fc0N3xCDkK7dLJILoC6MHTy4w0g5BH8e3RObLsrS3AGi v03sbt+WBtkxD90MVwg1NtRKMfgtIr/hlFZ2+R5IQETsFljgW+OjwFljuuzQ2AVySNec 18LcUTlefENIGR6zFD8dJ8+5JTQ/aPeC9XGU6uFLYspvFaq0TiyKKENmEBuN6eTUWmbF DypQu2Edj/rYb9EbT501pgLc0OtJz9zLZkb4qho1t8Od92jSOWQpwwWDF4V+YAG0vH50 iluA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FukrBhaU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-93238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m15-20020a63f60f000000b005dc892c862fsi10928968pgh.638.2024.03.05.18.29.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 18:29:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FukrBhaU; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-93238-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9A84AB26455 for ; Wed, 6 Mar 2024 02:21:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70C2BD53F; Wed, 6 Mar 2024 02:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="FukrBhaU" Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C6D22F32 for ; Wed, 6 Mar 2024 02:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709691706; cv=none; b=IMdcQ/NqP/yg1teU6IHxuAKol8vlCsgiIiazd4CUGargIq3qpXQbYo0DCo5Xv4c2XUyw606dx6WwhrfD9E8LtHxG7KTZe9F8TAihVbBG0Q+xIgLD2u2qj5tP4uVsqlV6p1ZczGLLRREvlJCRXsFVV0Zh1sXR9ykPt2UqUgVFy1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709691706; c=relaxed/simple; bh=llxPm/WzisI+fXOfjRbkdh3EW/AIJNXwoI7XOjyXYcc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZcnruGT7fFlBPRfEKt41jpBjQ6Qr82IiISJN2PV0p0XyBZSy6FDNGvBfPA7adRGB/A9HhzP3is7Icte/7/jq/yXSWl7bjTVjMdXyvtfCKQQjmrfrJbPycJaVA8jUa8HHdVyiG9iSTs7Zi0fXar52Noxx0Bou06b7sI+ucaH4eBk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=FukrBhaU; arc=none smtp.client-ip=115.124.30.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1709691701; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=7C9rxAZf2p6XR/2XiWXhnPifuebioXZkTUeVUjvyyeI=; b=FukrBhaUaG6JcR+IbuDIQSozVvzLeMces7Pi52l+eXPSyVBHxJ0sA4uyVu/xIna6BKvD7VZlumLYGIAk83nzPDHhIGiUwhhBRdZtwY4OKUncxNvamf7WyPJM3uCCw//euwZ6n5YxUNbpm9/m3dv4dXeMDaa9uxKvPhk8s6aHpf0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W1vhPKm_1709691700; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0W1vhPKm_1709691700) by smtp.aliyun-inc.com; Wed, 06 Mar 2024 10:21:41 +0800 From: Tianchen Ding To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Abel Wu Subject: [PATCH v2 2/2] sched/eevdf: Fix miscalculation in reweight_entity() when se is not curr Date: Wed, 6 Mar 2024 10:21:33 +0800 Message-Id: <20240306022133.81008-3-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240306022133.81008-1-dtcccc@linux.alibaba.com> References: <20240306022133.81008-1-dtcccc@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit reweight_eevdf() only keeps V unchanged inside itself. When se != cfs_rq->curr, it would be dequeued from rb tree first. So that V is changed and the result is wrong. Pass the original V to reweight_eevdf() to fix this issue. Fixes: eab03c23c2a1 ("sched/eevdf: Fix vruntime adjustment on reweight") Signed-off-by: Tianchen Ding Reviewed-by: Abel Wu --- kernel/sched/fair.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5551ce2af73e..091a1a750638 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3676,11 +3676,10 @@ static inline void dequeue_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) { } #endif -static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se, +static void reweight_eevdf(struct sched_entity *se, u64 avruntime, unsigned long weight) { unsigned long old_weight = se->load.weight; - u64 avruntime = avg_vruntime(cfs_rq); s64 vlag, vslice; /* @@ -3787,10 +3786,12 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, unsigned long weight) { bool curr = cfs_rq->curr == se; + u64 avruntime; if (se->on_rq) { /* commit outstanding execution time */ update_curr(cfs_rq); + avruntime = avg_vruntime(cfs_rq); if (!curr) __dequeue_entity(cfs_rq, se); update_load_sub(&cfs_rq->load, se->load.weight); @@ -3804,7 +3805,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, */ se->vlag = div_s64(se->vlag * se->load.weight, weight); } else { - reweight_eevdf(cfs_rq, se, weight); + reweight_eevdf(se, avruntime, weight); } update_load_set(&se->load, weight); -- 2.39.3