Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4102858yba; Tue, 9 Apr 2019 11:10:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRq4XEVYYZk1z8QMRWl1EKlhCi6QxWFms8P7o47kH+tf19Mv6CY2sEDlkpugnpa49+6Krt X-Received: by 2002:a63:6842:: with SMTP id d63mr35011215pgc.49.1554833441243; Tue, 09 Apr 2019 11:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554833441; cv=none; d=google.com; s=arc-20160816; b=SXhmB1xfcT5CsxEzB2iUAL0UY5IhCIc4xyt1FwEAynXEsFrNCkAnIydYOuAKisNkHk I80fnN33WCZZNmycXZTgkQQ6lFcwhbTJCuFJLoOU4/mN4yCLdN9Vb/0/zH44nTS8Ek+o WQYGUP87DPhRlDKK4FSuLF+HLZMWey7cD2IsW7hMduaW8INrLEVvxGhUuOR/5LW1fgxb 1WOWIo+U83GtyAzS37rxzIpEMBVT17jvAIaNXN6a+m2Uk1hfDW4fWUdWhTD9LV1+90Uz 7rIXjgsHGtESoXKgH6H9UjMDQkgCgusTSNgoWKb+6dGLPxVSyrUHS4w5un5YPQKwVzSG h5+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=1W1slNZtmicBFUdr9i6FdUpidw8lx88nfJcAAANS1/U=; b=l+0y0U8vc/XgEJjXRoFCsYGpfvV+YzKLk2rK/f79weHzbeIk6sJ9gGCATDNHOFbYsT J/zsGAD2d/cSxRDniRQQdsEmpfnp9QbMq8pv++LkZbNlWmbcTmgBNuXSYdXKjYNGso6n ntKF7ZYnBHu8jKLnh8XsO7+p6S7yfpuLxBLXGIffbhETV29hVv8Q9XuGOgfLfFvTvFNq e6gxhymhcbWfNHGD6hvr8oEw/rWJFtpUFZSdvHHKpWpmwmkcOKEit0JC5+2i5l/DZXHj zCAHdh0J+oseET0M6sJFFTAzPpah662XQSTqeNKHDHc1o9fA+U66YAd7MkziMNYS6jg/ KJMA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si29999700pgg.1.2019.04.09.11.10.23; Tue, 09 Apr 2019 11:10:41 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726554AbfDISJr (ORCPT + 99 others); Tue, 9 Apr 2019 14:09:47 -0400 Received: from mga02.intel.com ([134.134.136.20]:43844 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbfDISJr (ORCPT ); Tue, 9 Apr 2019 14:09:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2019 11:09:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,330,1549958400"; d="scan'208";a="159653643" Received: from schen9-desk.jf.intel.com (HELO [10.54.74.162]) ([10.54.74.162]) by fmsmga002.fm.intel.com with ESMTP; 09 Apr 2019 11:09:45 -0700 Subject: Re: [RFC][PATCH 13/16] sched: Add core wide task selection and scheduling. To: Aaron Lu , Peter Zijlstra Cc: 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, Aubrey Li , Julien Desfossez References: <20190218165620.383905466@infradead.org> <20190218173514.667598558@infradead.org> <20190402064612.GA46500@aaronlu> <20190402082812.GJ12232@hirez.programming.kicks-ass.net> <20190405145530.GA453@aaronlu> From: Tim Chen Openpgp: preference=signencrypt Autocrypt: addr=tim.c.chen@linux.intel.com; prefer-encrypt=mutual; keydata= mQINBE6ONugBEAC1c8laQ2QrezbYFetwrzD0v8rOqanj5X1jkySQr3hm/rqVcDJudcfdSMv0 BNCCjt2dofFxVfRL0G8eQR4qoSgzDGDzoFva3NjTJ/34TlK9MMouLY7X5x3sXdZtrV4zhKGv 3Rt2osfARdH3QDoTUHujhQxlcPk7cwjTXe4o3aHIFbcIBUmxhqPaz3AMfdCqbhd7uWe9MAZX 7M9vk6PboyO4PgZRAs5lWRoD4ZfROtSViX49KEkO7BDClacVsODITpiaWtZVDxkYUX/D9OxG AkxmqrCxZxxZHDQos1SnS08aKD0QITm/LWQtwx1y0P4GGMXRlIAQE4rK69BDvzSaLB45ppOw AO7kw8aR3eu/sW8p016dx34bUFFTwbILJFvazpvRImdjmZGcTcvRd8QgmhNV5INyGwtfA8sn L4V13aZNZA9eWd+iuB8qZfoFiyAeHNWzLX/Moi8hB7LxFuEGnvbxYByRS83jsxjH2Bd49bTi XOsAY/YyGj6gl8KkjSbKOkj0IRy28nLisFdGBvgeQrvaLaA06VexptmrLjp1Qtyesw6zIJeP oHUImJltjPjFvyfkuIPfVIB87kukpB78bhSRA5mC365LsLRl+nrX7SauEo8b7MX0qbW9pg0f wsiyCCK0ioTTm4IWL2wiDB7PeiJSsViBORNKoxA093B42BWFJQARAQABtDRUaW0gQ2hlbiAo d29yayByZWxhdGVkKSA8dGltLmMuY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9ZLGoaRwRmCnzblJG0pRzNaC/F+0hNf63F1iSXzIlncHZ3By15bnt5QDk l50q2K/r651xphs7CGEdKi1nU0YJVbQxJQ== Message-ID: <460ce6fb-6a40-4a72-47e8-cf9c7c409bef@linux.intel.com> Date: Tue, 9 Apr 2019 11:09:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: <20190405145530.GA453@aaronlu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/5/19 7:55 AM, Aaron Lu wrote: > On Tue, Apr 02, 2019 at 10:28:12AM +0200, Peter Zijlstra wrote: >> Another approach would be something like the below: >> >> >> --- a/kernel/sched/core.c >> +++ b/kernel/sched/core.c >> @@ -87,7 +87,7 @@ static inline int __task_prio(struct tas >> */ >> >> /* real prio, less is less */ >> -static inline bool __prio_less(struct task_struct *a, struct task_struct *b, bool runtime) >> +static inline bool __prio_less(struct task_struct *a, struct task_struct *b, u64 vruntime) >> { >> int pa = __task_prio(a), pb = __task_prio(b); >> >> @@ -104,21 +104,25 @@ static inline bool __prio_less(struct ta >> if (pa == -1) /* dl_prio() doesn't work because of stop_class above */ >> return !dl_time_before(a->dl.deadline, b->dl.deadline); >> >> - if (pa == MAX_RT_PRIO + MAX_NICE && runtime) /* fair */ >> - return !((s64)(a->se.vruntime - b->se.vruntime) < 0); >> + if (pa == MAX_RT_PRIO + MAX_NICE) /* fair */ >> + return !((s64)(a->se.vruntime - vruntime) < 0); > ~~~ > I think <= should be used here, so that two tasks with the same vruntime > will return false. Or we could bounce two tasks having different tags > with one set to max in the first round and the other set to max in the > next round. CPU would stuck in __schedule() with irq disabled. > >> >> return false; >> } >> >> static inline bool cpu_prio_less(struct task_struct *a, struct task_struct *b) >> { >> - return __prio_less(a, b, true); >> + return __prio_less(a, b, b->se.vruntime); >> } >> >> static inline bool core_prio_less(struct task_struct *a, struct task_struct *b) >> { >> - /* cannot compare vruntime across CPUs */ >> - return __prio_less(a, b, false); >> + u64 vruntime = b->se.vruntime; >> + >> + vruntime -= task_rq(b)->cfs.min_vruntime; >> + vruntime += task_rq(a)->cfs.min_vruntime > > After some testing, I figured task_cfs_rq() should be used instead of > task_rq(:-) > > With the two changes(and some other minor ones that still need more time > to sort out), I'm now able to start doing 2 full CPU kbuilds in 2 tagged > cgroups. Previouslly, the system would hang pretty soon after I started > kbuild in any tagged cgroup(presumbly, CPUs stucked in __schedule() with > irqs disabled). > > And there is no warning appeared due to two tasks having different tags > get scheduled on the same CPU. > > Thanks, > Aaron > Peter, Now that we have accumulated quite a number of different fixes to your orginal posted patches. Would you like to post a v2 of the core scheduler with the fixes? Thanks. Tim