mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xavier  <xavier_qy@163.com>
To: "Peter Zijlstra" <peterz@infradead.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org,  dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com,  mgorman@suse.de,
	vschneid@redhat.com, yu.c.chen@intel.com,
	 linux-kernel@vger.kernel.org
Subject: Re:Re: [PATCH v2] sched/eevdf: Reduce the computation frequency of avg_vruntime
Date: Fri, 11 Oct 2024 19:48:48 +0800 (CST)	[thread overview]
Message-ID: <4fb53053.b004.1927b68f2f8.Coremail.xavier_qy@163.com> (raw)
In-Reply-To: <20241011085201.GM17263@noisy.programming.kicks-ass.net>





At 2024-10-11 16:52:01, "Peter Zijlstra" <peterz@infradead.org> wrote:
>On Fri, Oct 11, 2024 at 02:24:49PM +0800, Xavier wrote:
>> The current code subtracts the value of curr from avg_vruntime and avg_load
>> during runtime. Then, every time avg_vruntime() is called, it adds the
>> value of curr to the avg_vruntime and avg_load. Afterward, it divides these
>> and adds min_vruntime to obtain the actual avg_vruntime.
>> 
>> Analysis of the code indicates that avg_vruntime only changes significantly
>> during update_curr(), update_min_vruntime(), and when tasks are enqueued or
>> dequeued. Therefore, it is sufficient to recalculate and store avg_vruntime
>> only in these specific scenarios. This optimization ensures that accessing
>> avg_vruntime() does not necessitate a recalculation each time, thereby
>> enhancing the efficiency of the code.
>> 
>> There is no need to subtract curr’s load from avg_load during runtime.
>> Instead, we only need to calculate the incremental change and update
>> avg_vruntime whenever curr’s time is updated.
>> 
>> To better represent their functions, rename the original avg_vruntime and
>> avg_load to tot_vruntime and tot_load, respectively, which more accurately
>> describes their roles in the computation.
>> 
>> Signed-off-by: Xavier <xavier_qy@163.com>
>

>This makes the code more complicated for no shown benefit.




Hi Peter,

Thank you for reviewing this patch. I would like to address your questions as follows:

Code Complexity vs. Understandability: I agree that this modification adds some
 complexity to the code, but the method of calculation is more straightforward.
 This patch maintains consistency in how avg_vruntime is added or subtracted
 relative to load. Specifically, the enqueue and dequeue operations of tasks directly
 impact the avg_vruntime of cfs_rq, which seems logical.

Efficiency Improvements: This approach minimizes unnecessary calculations,
 thereby enhancing execution efficiency. I understand that entity_eligible() and
 vruntime_eligible() are high-frequency operations. The existing code recalculates
 curr->vruntime added to cfs_rq->avg_vruntime for each eligibility check.
 If many tasks in the cfs_rq do not meet the conditions, it leads to multiple
 redundant calculations within pick_eevdf(). This patch resolves this issue by
 computing cfs_rq->tot_vruntime only when an update is necessary, allowing
 vruntime_eligible() to utilize the precomputed value directly.

Reducing avg_vruntime Calculations: This patch also reduces the frequency of
 avg_vruntime evaluations. The original code calls avg_vruntime() every time it's
 needed, despite many of those calls being redundant when curr->vruntime
 hasn't changed. This patch ensures that cfs_rq->avg_vruntime is updated only
 when curr->vruntime or cfs_rq->tot_vruntime changes, allowing subsequent
 calls to directly access the current value. This greatly decreases the frequency
 of avg_vruntime calculations.

I hope this explanation clarifies the benefits of the patch.
 I welcome any comments or suggestions. Thank you!

  reply	other threads:[~2024-10-11 11:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12  9:14 [PATCH v1] " Xavier
2024-09-26  6:03 ` Xavier
2024-10-11  6:11 ` [PATCH v2] " Xavier
2024-10-11  6:24 ` Xavier
2024-10-11  8:52   ` Peter Zijlstra
2024-10-11 11:48     ` Xavier [this message]
2024-10-17  4:47   ` kernel test robot
2024-10-18 14:52     ` [PATCH v3] sched/eevdf: Remove the consideration of the current task's time in vruntime_eligible() and avg_vruntime() Xavier
2024-10-25  7:13       ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4fb53053.b004.1927b68f2f8.Coremail.xavier_qy@163.com \
    --to=xavier_qy@163.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®