Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1598671lqg; Sun, 3 Mar 2024 19:01:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYjaDGaZEnB7q0d9C1fVC0tR2ejbNYMtOD/XDbv0J6ISNwlUB48IxQ2UTejz2/mio/i3E+VpJDimw3AQdm0Ak2Yj+7mcsHpj7VNNWl7A== X-Google-Smtp-Source: AGHT+IF6v0dr14+HK0rya2uA6/Gx8erzZxXH9TzheB1KWiZwtTasJEPlYxl8xMqkcrlNEMx7xm22 X-Received: by 2002:a9d:67d5:0:b0:6e4:de56:7710 with SMTP id c21-20020a9d67d5000000b006e4de567710mr3935878otn.6.1709521263995; Sun, 03 Mar 2024 19:01:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709521263; cv=pass; d=google.com; s=arc-20160816; b=T+IjwixLRo0GPS/iCa7WBAdLRywTFWgai82iLmxLkgZBbxBO7jfZtEc678NLNeNmZF +gs+XC4Sxn+N3UIi/eRBf5250PFMzMujPRkY5wP7J9rKVwS1X3NO9xPasjMUODX35y4i wfHlfMIqO9uQQVy0oqbpAV2Gd4Fd4NAY79lOp63xF7ou06c8Trm9wSrH5MOfC3/2V2p3 8mkvRoJRS0Y0Na3mFX+IPxo511qq1NYxpphRlCYBLeuJ7FDJB0X1hi9XHEt/EewfHpTb SjRW6fOsKicwuAbkTnlGP/W5VNJ/RGUaz453hTnjBqmEfI2sm8aRE0oBt+79n4lBlLlY X/Eg== 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=OAEj4XYKb6Z7iXVcveEaFUEGuCaJ8azk2/tiA7nFnrA=; fh=HGPOwMD1U+bU1zkI6pk9BDAYYJSoTCIazwWVkER0sVk=; b=QQ8TcleWCI3um/vblZtn5MTz0b2kiVH3e5Km4ACG/qigxjUg65vd/7GCG4F0/v19ea lgtsB0bQtEYawGQ7nFhrxo/V7UKs5xQG61Xt/QhRE3owDVP/6PdUcjTfTURBQ6B+9FCu 9MzN31fGSsyzbxe1bOGfSpc4jb7EWnjCunlF0cxsLZzqhTBY9bdxmbcOTdwLXo4VpO9l Gaebr0ZrUvWabX8DrdoOT7m4Cw4oiylRCAO85Vu2ahze09Jn+pWT8Xf8+pHdyIRj9hZo 0awMWG5ym4d72wXjWjX70ZJg58TnhxGQ7PSZcstK+kmXPF8ZQ6C3pxPI6Nx2QgrzM25w YEhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=Myqptbhw; 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-89994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89994-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 sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i38-20020a632226000000b005dc84ba3c3asi7565092pgi.287.2024.03.03.19.01.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Mar 2024 19:01:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=Myqptbhw; 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-89994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89994-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 81531281430 for ; Mon, 4 Mar 2024 03:01:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B888733F7; Mon, 4 Mar 2024 03:00:57 +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="Myqptbhw" 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 0AB2617C9 for ; Mon, 4 Mar 2024 03:00:53 +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=1709521256; cv=none; b=pcXpAbRqi5D2IMk2zZaGBqRoldlQS6vTCh8rvosHOkz+54cv2EG+ZHMaR7a0ArtDsAEhuke2J1ai7oWXyQmscpySYttyXLef3jyYiGZCN+N5qd06HMFK3C8+mAxPkbvwZtJnQieKq9LkD3VTxSQclyACwoh38Ii/H6n86ruq0wg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709521256; c=relaxed/simple; bh=nw9L+W2RdaeA/JiFU5L3vP+VcASNnK3QbAN7wrUFDFQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e96P08fQlqNRrAr9zjl9l1jBaLpHKFHRme0dmhjFt+yFHOakS5X1dnB/oy3jPFRhOzY2V7KTL5ylRxZLXuS8oGSG7A/FF6OON+ohZ2qQVFSB3SqqfB7VzNw2o5jwA3cF5hvauhr5aeKGcXTWzcFeGxhc2gb2BBCSOtz9cO86Mp0= 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=Myqptbhw; 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=1709521251; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=OAEj4XYKb6Z7iXVcveEaFUEGuCaJ8azk2/tiA7nFnrA=; b=MyqptbhwDSgqNFwQg+dfz2ORR+xFL8mW4MSbmcPLxGILWPfp38hCZEkkVjOf0c4ECOQYbr9awrQiQNUYM7nz4s82gHNdmKOjzNDPd3Aqqqiqq9WrOKOutK+XjlNIkasaain0TgkMXudi3fFGwaZnfsl/ZlbruKmjlvROTSGur88= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=dtcccc@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W1i0XYp_1709521250; Received: from localhost.localdomain(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0W1i0XYp_1709521250) by smtp.aliyun-inc.com; Mon, 04 Mar 2024 11:00:50 +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 2/2] sched/eevdf: Fix miscalculation in reweight_entity() when se is not curr Date: Mon, 4 Mar 2024 11:00:42 +0800 Message-Id: <20240304030042.2690-3-dtcccc@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240304030042.2690-1-dtcccc@linux.alibaba.com> References: <20240304030042.2690-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 --- 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