Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp437426lqp; Mon, 10 Jun 2024 08:30:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEhbw9Mww1owBXLvLj1GNa5lSQJUtq+f/Y4tyerE4RySdvPe/K6c3trVKJIX+s7AxE2n5GenYH3Oy6wzo0J7Fm+YCtCYuS8C3GpZuClg== X-Google-Smtp-Source: AGHT+IFBk9HRRUq9bXZ0Hww1HWrcp3Nuty0sSjSe1CJUZb8ml4cZK/00vReR+Hg2J8zRhrO7R1qe X-Received: by 2002:a05:6122:c9:b0:4e4:ea87:ec72 with SMTP id 71dfb90a1353d-4eb562bbb38mr7750455e0c.11.1718033444521; Mon, 10 Jun 2024 08:30:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718033444; cv=pass; d=google.com; s=arc-20160816; b=TIRRmBQ2+6mBv/mKJhUPQlIivDJx7mv363mS/1se7sjd4eM99TdB2YkaE/Jpnwckg/ 37rdgh88H0BpgLHibmwUrwJnLnaajKz+fUnnANL+kyxcdRVsSJen/eGbU1i7OsTzhPQ5 Y6q9obNHm7gHr6BfYp9oPzmklzc4fCunO05QIfvav9Hu44dE8nFEWKwwHJhLHy1nV5hc p5TdDesvD0KPVbFSpEDW0GFNKESoD9lT3Q3BxLxnaSXl9XePjNX5n+8RzmHAefIl7SAE h3CeCHgT+pvIHrLlPPhFXs/Jdn0tYvM4m7WMlbgGR6Jelo+5M9p8eHuVxPOc6W5oz/vX h2XQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ZPiDzQFEU1Es65ZY8cB0HXKp0zeH1meATut6NiOHY4M=; fh=tdY3RD71eVGyFr36motyabqJnjpt1q4YaYGxGQOLstc=; b=pzG/gls8LTGK0G64w07ROpxJO5KOsIt38DPsZnBwnl9MhmkYLLBZfn/xpevAWheVzQ 1NexPQW4FbTqVerDL0Gg8Ajpu9Ggw3OMOoie6hCJfjqlDRfo7YEKUATBzoK4AzFX35HP O+9OCbrVoqkmUzhpp8F+iV5jxkF1vNDRYtTQYRkbmRZ1Qgc+n9/YeO7f5bVmqWSDzwl8 OfpXtRh8iKms8bdxkUXnUSaaSzaYC2FpGO5z5qYWxZ1THGmwPYt2F42+CwzFZnK+Edng xLpKE6mNyfoXyGVd0eB86vNwaVo5I31RlVuL6Vh6iwiCO9sDE9WlH9r0viCYycaMfRht Dd9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ada2fe7eead31-48c1a1eaff1si2218371137.348.2024.06.10.08.30.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:30:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208488-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208488-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3DF6F1C219F2 for ; Mon, 10 Jun 2024 15:30:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A4A81422A2; Mon, 10 Jun 2024 15:29:15 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D415913DB9B for ; Mon, 10 Jun 2024 15:29:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718033354; cv=none; b=dnrrW629j+SeJA77XXZwbjqfYaVz3UEZp+hOkOP1PvEMzvxa+IfiGAdPpiPYUwmmWsPINMuHtgNuMCONYCBAIr6WodbDO6wYJLqAPxUI7wXxuUTKfbTbNIr6vmJX1BLwKohSgKOfUGk+BeaUq2F151FQ9714Zhf3yW91Hf2iTbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718033354; c=relaxed/simple; bh=Rk/pTVr4dMrIIDGaZ5dSZUdETiX8CTSW7Y1NoRKt3SQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=XvI5dFxxU2Kb7gDWjgExcvGHXGUkLrnmyxp37Is0yvv7faWnempGRCOqRxiW7i1mUHp+KwFmxEvepqsU2OqmYlINau2OiGboEGt8xUo7hfrNPOb3B/yCVk0lS9eKmTxnv8Pm3INn30ZdyQ8qg+sMqfJY8vVGsgLWfd0zMUmgzpY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FE1411FB; Mon, 10 Jun 2024 08:29:36 -0700 (PDT) Received: from [10.57.88.147] (unknown [10.57.88.147]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D28D23F64C; Mon, 10 Jun 2024 08:29:09 -0700 (PDT) Message-ID: Date: Mon, 10 Jun 2024 16:29:08 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v3 2/6] sched/uclamp: Track a new util_avg_bias signal From: Hongyan Xia To: Dietmar Eggemann , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , pierre.gondois@arm.com, linux-kernel@vger.kernel.org References: <2e43dc6b376ea6d785976a398b5d9ffe823cf35d.1715082714.git.hongyan.xia2@arm.com> <1b36141c-1ad7-4c34-b293-92003f473465@arm.com> Content-Language: en-US In-Reply-To: <1b36141c-1ad7-4c34-b293-92003f473465@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 28/05/2024 12:09, Hongyan Xia wrote: > On 26/05/2024 23:52, Dietmar Eggemann wrote: >[...] >>> +    old = READ_ONCE(p->se.avg.util_avg_bias); >>> +    new = (int)clamp(util, uclamp_min, uclamp_max) - (int)util; >>> + >>> +    WRITE_ONCE(p->se.avg.util_avg_bias, new); >>> +    if (!p->se.on_rq) >>> +        return; >>> +    WRITE_ONCE(avg->util_avg_bias, READ_ONCE(avg->util_avg_bias) + >>> new - old); >>> +} >>> +#else /* !CONFIG_UCLAMP_TASK */ >>> +static void update_util_bias(struct sched_avg *avg, struct >>> task_struct *p) >>> +{ >>> +} >>> +#endif >>> + >>>   /* >>>    * sched_entity: >>>    * >>> @@ -296,6 +330,8 @@ int __update_load_avg_blocked_se(u64 now, struct >>> sched_entity *se) >>>   { >>>       if (___update_load_sum(now, &se->avg, 0, 0, 0)) { >>>           ___update_load_avg(&se->avg, se_weight(se)); >>> +        if (entity_is_task(se)) >>> +            update_util_bias(NULL, task_of(se)); >> >> IMHO, >> >> update_util_bias(struct sched_avg *avg, struct sched_entity *se) >> >>      if (!entity_is_task(se)) >>          return; >> >>      ... >> >> would be easier to read. > > Yeah, that would work, and might be a good way to prepare for group > clamping if it ever becomes a thing. > Sadly it's not as easy as I hoped. The problem is that we need to fetch task uclamp values here so we need to get p anyway. Also, even if one day we implement group uclamp, we need to fetch the cfs_rq this se is on instead of the whole rq, so the function signature needs to change anyway. Keeping it the current way might be the better thing to do here. > [...]