Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3313152yba; Sun, 28 Apr 2019 23:16:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDVYrk2GGE5edkd+7Cx75/8VgRO4BrQyZQFBHb37a9oGx0PNB0oeaP/hGCO6sD8wt9U4iK X-Received: by 2002:a17:902:a9c7:: with SMTP id b7mr59469095plr.145.1556518596357; Sun, 28 Apr 2019 23:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556518596; cv=none; d=google.com; s=arc-20160816; b=e9uofKxRdwc0iI02qNG2oCn12cHfezFhPJ6FwlFdsWAczSTPsg/d2m0h9zBqS3JDlm 2LpB6SN21/Y3C4I0HwGjeDCXO1ey/6DSPYcUco/Qka8LqJ3xR6L8qv9RevCPdfKLYKzP CvhsoBaZ1N6H2887gMIz2HwI5lwSTmkT03mFHkIcR5k1CkAImnQnqnj3lnA3AO3Yrreu XA9KSQJuJcF+GiLcUCQKUkTFcMibDZptj7yu0Bq2JLzULEl8RW8kacA5dWl2QMQvazRW 4HhG6/w8NHeg1BnbCDcrhupXs7ngPiYLp66TJm3Jo7e23yhDqDG2oQpI/AowuwPR+k/c xOMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qPrn/XjYJ7IHshtw5rEHSbh9p68CjWc5ktgZTqOEQhU=; b=MOuprxBEMVKKoadaDR14MVYm154c7BWhDXbp8G8WfTBrJssgxEAoI0aJ01C0a8TjTm ruia3YnCjoWggSyTy0eynlDkfoLEuVzNHtYu6pMr/rxQc93E4qhD4nYM88WaYGuYuNC5 6P3F68sPL2ovFqPUlCJP5nJ0sc9FR0d1uh3a78hUJNjb+solrSReECSelCN1Xt9SUZLI xNQOCH4X+lFlwQLlSJtlhoPUpbTgCHDm4Lr8Fnt4xFe1pHDNwUalUjOVtvO4LcxNLIid tTC1px2isWiOtDw71Vp7M2cGl3PEW4BLgn0l1h8dRuTebGr0HapKzLndkT7SvSuwvDte hgoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si29728305pgv.475.2019.04.28.23.16.21; Sun, 28 Apr 2019 23:16:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbfD2GP3 (ORCPT + 99 others); Mon, 29 Apr 2019 02:15:29 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:41417 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfD2GP3 (ORCPT ); Mon, 29 Apr 2019 02:15:29 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=aaron.lu@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0TQTvZNw_1556518518; Received: from aaronlu(mailfrom:aaron.lu@linux.alibaba.com fp:SMTPD_---0TQTvZNw_1556518518) by smtp.aliyun-inc.com(127.0.0.1); Mon, 29 Apr 2019 14:15:24 +0800 Date: Mon, 29 Apr 2019 14:15:18 +0800 From: Aaron Lu To: Vineeth Remanan Pillai Cc: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: Re: [RFC PATCH v2 11/17] sched: Basic tracking of matching tasks Message-ID: <20190429061516.GA9796@aaronlu> References: <2364f2b65bf50826d881c84d7634b6565dfee527.1556025155.git.vpillai@digitalocean.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2364f2b65bf50826d881c84d7634b6565dfee527.1556025155.git.vpillai@digitalocean.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > + } else if (node_task->core_cookie > cookie) { > + node = node->rb_right; And left here? > + } else { > + match = node_task; > + node = node->rb_left; > + } > + } > + > + return match; > +}