lkml.org 
[lkml]   [2019]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [RFC PATCH v2 11/17] sched: Basic tracking of matching tasks
On Fri, May 3, 2019 at 8:06 AM Tim Chen <tim.c.chen@linux.intel.com> wrote:
>
> On 5/1/19 4:27 PM, Tim Chen wrote:
> > On 4/28/19 11:15 PM, Aaron Lu wrote:
> >> On Tue, Apr 23, 2019 at 04:18:16PM +0000, Vineeth Remanan Pillai wrote:
> >>> +/*
> >>> + * Find left-most (aka, highest priority) task matching @cookie.
> >>> + */
> >>> +struct task_struct *sched_core_find(struct rq *rq, unsigned long cookie)
> >>> +{
> >>> + struct rb_node *node = rq->core_tree.rb_node;
> >>> + struct task_struct *node_task, *match;
> >>> +
> >>> + /*
> >>> + * The idle task always matches any cookie!
> >>> + */
> >>> + match = idle_sched_class.pick_task(rq);
> >>> +
> >>> + while (node) {
> >>> + node_task = container_of(node, struct task_struct, core_node);
> >>> +
> >>> + if (node_task->core_cookie < cookie) {
> >>> + node = node->rb_left;
> >>
> >> Should go right here?
> >>
> >
> > I think Aaron is correct. We order the rb tree where tasks with smaller core cookies
> > go to the left part of the tree.
> >
> > In this case, the cookie we are looking for is larger than the current node's cookie.
> > It seems like we should move to the right to look for a node with matching cookie.
> >
> > At least making the following change still allow us to run the system stably for sysbench.
> > Need to gather more data to see how performance changes.
>
> Pawan ran an experiment setting up 2 VMs, with one VM doing a parallel kernel build and one VM doing sysbench,
> limiting both VMs to run on 16 cpu threads (8 physical cores), with 8 vcpu for each VM.
> Making the fix did improve kernel build time by 7%.

I'm gonna agree with the patch below, but just wonder if the testing
result is consistent,
as I didn't see any improvement in my testing environment.

IIUC, from the code behavior, especially for 2 VMs case(only 2
different cookies), the
per-rq rb tree unlikely has nodes with different cookies, that is, all
the nodes on this
tree should have the same cookie, so:
- if the parameter cookie is equal to the rb tree cookie, we meet a
match and go the
third branch
- else, no matter we go left or right, we can't find a match, and
we'll return idle thread
finally.

Please correct me if I was wrong.

Thanks,
-Aubrey
>
> Tim
>
>
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 25638a47c408..ed4cfa49e3f2 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -208,9 +208,9 @@ static struct task_struct *sched_core_find(struct rq *rq, unsigned long cookie)
> > while (node) {
> > node_task = container_of(node, struct task_struct, core_node);
> >
> > - if (node_task->core_cookie < cookie) {
> > + if (cookie < node_task->core_cookie) {
> > node = node->rb_left;
> > - } else if (node_task->core_cookie > cookie) {
> > + } else if (cookie > node_task->core_cookie) {
> > node = node->rb_right;
> > } else {
> > match = node_task;
> >
> >
>

\
 
 \ /
  Last update: 2019-05-08 17:50    [W:0.127 / U:54.608 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site