Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4163400ybh; Tue, 6 Aug 2019 07:18:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqILWbqTuLc1S5GXXZv0URrKjM6KIARih/7VZIZHFSoynPdQ6CKvHQwn6NtFarrKwjcAEF X-Received: by 2002:a63:101b:: with SMTP id f27mr3119592pgl.291.1565101105078; Tue, 06 Aug 2019 07:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565101105; cv=none; d=google.com; s=arc-20160816; b=Nih2L9jKp7rS6xc5OCfqOjGKr0Zi/CwyEhezuD3dSRlt1tc9SzzP4vRTD/nMtpbzCS wXX/vNq/oxAI8xuOZkrJVGdFMcE24G6nNP+qBIaiy/5X5QrBUwuxigy5+IlRQeiDrWvF mqT0wIk17lrBod2V/bFd/4yCbET3V3JEYwRD98y//Kn5TbuY+8pG0Y0L3SJ7QTGaIz/8 JXpSRKN9N0S/mB4Y5Bfvfh7agxcWj3vw947GYozYwHIx3pKx8hOsVKxrN+A8GvrP27jv QZReJ/A0Y8ND2yFwt5DUG6YnpFyIFBGazsaB2NqUufE2P1NBdkxqDaY47LI9NiHW7gno Zecw== 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:dkim-signature; bh=hrnXr7yGnyArLiHfQ0lWFY8+UrvOf+p4SAkiuT8O4f8=; b=qdMlzLeGmw/yKxFCvK2/F0ck+7zG+QWzmXokNDBfMzNWHDa9Evudjjql0rNPwPufeg bCW26qSJORZEFbbnlOXR6uNGFH3MDtYdx4gmO/n+kv/P6Pim6smXhokX4sYVH85fS4rn /1CJEFw8o7dn41/rqAcMWULZMFJxr0weNFIyGrEL5kZB99v7KrV2HP0Tnwjj+RadYjb8 BIzcBV35HCJyvgTilzQdYr+cfD5h+ab+gvpZzCxLirGcLom2C9e2nfZr6/xj8dmAwxbM 5rkdur6bb4K/moSgLqavwI5zsIQoWuMswjxodehYNrKzZu9ApJMcAdjv5Pqc40ZJqOnj ZxWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=G+X2quMB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si48104229pfg.49.2019.08.06.07.18.09; Tue, 06 Aug 2019 07:18:25 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=G+X2quMB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732127AbfHFORa (ORCPT + 99 others); Tue, 6 Aug 2019 10:17:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55464 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728558AbfHFORa (ORCPT ); Tue, 6 Aug 2019 10:17:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=hrnXr7yGnyArLiHfQ0lWFY8+UrvOf+p4SAkiuT8O4f8=; b=G+X2quMB8Z2eErXJFz4pRAT1y lM/5+AV4U5RAUlKVfPe7vxvFDZbgGyc7DnMqdugkQZKK6H+9/Hq7pFAq8FWVgIeOvkmjQ7zMrsZHW 4MMV8Qb05NYgYWBBHRW3q8EKNRw8Kw9zva1N7DSdFN+r+50u5ittTCpfPduyTrjtjrtHn244DLLIP SFhn60qZinbI+wSPKDtaSFcXB/Of9BU2UGoDyCv4m9PQ05sYxoqeS24oE86XPpl4ritIfhJUCdogg KBFZ9ghwSHOenD9sdO2D+pk4Fj3jyKlNIQ4I8h79Z5hCXKa9rMJfb+O1CRFWmg62oOnnXG+CfvySo 9rcZ7qkPQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hv0HC-00084U-E0; Tue, 06 Aug 2019 14:17:22 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A9D49307145; Tue, 6 Aug 2019 16:16:54 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 11467201B4BAA; Tue, 6 Aug 2019 16:17:20 +0200 (CEST) Date: Tue, 6 Aug 2019 16:17:20 +0200 From: Peter Zijlstra To: Aaron Lu Cc: Aubrey Li , Julien Desfossez , Subhra Mazumdar , Vineeth Remanan Pillai , Nishanth Aravamudan , Tim Chen , Ingo Molnar , Thomas Gleixner , Paul Turner , Linus Torvalds , Linux List Kernel Mailing , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Kees Cook , Greg Kerr , Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: Re: [PATCH 2/3] core vruntime comparison Message-ID: <20190806141720.GS2332@hirez.programming.kicks-ass.net> References: <20190606152637.GA5703@sinkpad> <20190612163345.GB26997@sinkpad> <635c01b0-d8f3-561b-5396-10c75ed03712@oracle.com> <20190613032246.GA17752@sinkpad> <20190619183302.GA6775@sinkpad> <20190718100714.GA469@aaronlu> <20190725143003.GA992@aaronlu> <20190725143248.GC992@aaronlu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190725143248.GC992@aaronlu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 25, 2019 at 10:32:49PM +0800, Aaron Lu wrote: > +bool cfs_prio_less(struct task_struct *a, struct task_struct *b) > +{ > + struct sched_entity *sea = &a->se; > + struct sched_entity *seb = &b->se; > + bool samecpu = task_cpu(a) == task_cpu(b); > + struct task_struct *p; > + s64 delta; > + > + if (samecpu) { > + /* vruntime is per cfs_rq */ > + while (!is_same_group(sea, seb)) { > + int sea_depth = sea->depth; > + int seb_depth = seb->depth; > + > + if (sea_depth >= seb_depth) > + sea = parent_entity(sea); > + if (sea_depth <= seb_depth) > + seb = parent_entity(seb); > + } > + > + delta = (s64)(sea->vruntime - seb->vruntime); > + goto out; > + } > + > + /* crosscpu: compare root level se's vruntime to decide priority */ > + while (sea->parent) > + sea = sea->parent; > + while (seb->parent) > + seb = seb->parent; > + delta = (s64)(sea->vruntime - seb->vruntime); > + > +out: > + p = delta > 0 ? b : a; > + trace_printk("picked %s/%d %s: %Ld %Ld %Ld\n", p->comm, p->pid, > + samecpu ? "samecpu" : "crosscpu", > + sea->vruntime, seb->vruntime, delta); > + > + return delta > 0; > } Heh.. I suppose the good news is that Rik is trying very hard to kill the nested runqueues, which would make this _much_ easier again.