Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3351818yba; Mon, 29 Apr 2019 00:14:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqytXqmoWQn29NaDR+yA3tRCRy8TBj2ecPHVAobN5yEoiB8PlTqpVRCpbprCtr9pH+yj6Rbd X-Received: by 2002:a63:8f49:: with SMTP id r9mr50717661pgn.306.1556522065832; Mon, 29 Apr 2019 00:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556522065; cv=none; d=google.com; s=arc-20160816; b=TLi6+K7RogxbPRUkkRGkynCkMK9Ds+4sGM0x9r/3YuGcY6Lv+4RzvJWYYopNl5yTI4 DcDV+hQyYwWw+chrUjsgiB5uoR9eymeA4EX+ZivxC/izoNOko4tGvBxB9201Ak0Vq+AA glLJMBWH67fSXDhkk3YmWBYPDjc/Hq1mNK/MKN2F9wY22oKzgTk9nA8hwXr7XEU4tQQx 6pzI+7a+917HHMwFnJb+wdTCildNpfnmcjbzkE41ihnvdSoqlLaMpbtsS+iGjs/GalzU QfiWqwyn3TCkkFztwZqALqE27UQLrJwq4yZ4aLIRtPsrCTnCynvx+VwR93fgzEEhT/Mu a5eQ== 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=w083MlWv0afS1zc/pjFBXHO7Q1dlc5WGRCrCRbl1I+M=; b=lEX6EW0Lp62Vf1rq+y0r7oQMwpI8gaAKhaBBFieaM0k+E69XK0xk88xU0osS7r6EwK TwTjldaZcOd2fkQLNVs0bOvyQ9jM6daCxkSqg+iQ8I70bi01p9PQPSvK3L7wQpU3dvHv CG3JkNtTM7K62OppT3L/p5abEN90pKe0XHFsoQR5AY8u4h9EMLQmi3/SFDzFGOMRzU9X D0rN37F4ltmeG3cKv9ohUIx49ag7rdoIa/pMyldPGWIiYan5u5xb2XnTDxAl+vJJ66ir hUuwPA0ugZGfSVxnN+DEqpg9QNooqzyNUxZqu+j5u1aMYJd+er/goM7USMXzjBXHzOFe ae4A== 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 s194si11269606pfs.37.2019.04.29.00.14.10; Mon, 29 Apr 2019 00:14: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; 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 S1727416AbfD2HNN (ORCPT + 99 others); Mon, 29 Apr 2019 03:13:13 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:52017 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfD2HNM (ORCPT ); Mon, 29 Apr 2019 03:13:12 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=aaron.lu@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0TQUwxLd_1556521981; Received: from aaronlu(mailfrom:aaron.lu@linux.alibaba.com fp:SMTPD_---0TQUwxLd_1556521981) by smtp.aliyun-inc.com(127.0.0.1); Mon, 29 Apr 2019 15:13:08 +0800 Date: Mon, 29 Apr 2019 15:13:01 +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 13/17] sched: Add core wide task selection and scheduling. Message-ID: <20190429071259.GA15100@aaronlu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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:18PM +0000, Vineeth Remanan Pillai wrote: > +// XXX fairness/fwd progress conditions > +static struct task_struct * > +pick_task(struct rq *rq, const struct sched_class *class, struct task_struct *max) > +{ > + struct task_struct *class_pick, *cookie_pick; > + unsigned long cookie = 0UL; > + > + /* > + * We must not rely on rq->core->core_cookie here, because we fail to reset > + * rq->core->core_cookie on new picks, such that we can detect if we need > + * to do single vs multi rq task selection. > + */ > + > + if (max && max->core_cookie) { > + WARN_ON_ONCE(rq->core->core_cookie != max->core_cookie); > + cookie = max->core_cookie; > + } > + > + class_pick = class->pick_task(rq); > + if (!cookie) > + return class_pick; > + > + cookie_pick = sched_core_find(rq, cookie); > + if (!class_pick) > + return cookie_pick; > + > + /* > + * If class > max && class > cookie, it is the highest priority task on > + * the core (so far) and it must be selected, otherwise we must go with > + * the cookie pick in order to satisfy the constraint. > + */ > + if (cpu_prio_less(cookie_pick, class_pick) && core_prio_less(max, class_pick)) It apapears to me the cpu_prio_less(cookie_pick, class_pick) isn't needed. If cookie_pick is idle task, then cpu_prio_less(cookie_pick, class_pick) is always true; If cookie_pick is not idle task and has the same sched class as class_pick, then class_pick is the best candidate to run accoring to their sched class. In this case, cpu_prio_less(cookie_pick, class_pick) shouldn't return false or it feels like a bug; If cookie_pick is not idle task and has a different sched class as class_pick: - if cookie_pick's sched class has higher priority than class_pick's sched class, then cookie_pick should have been selected in previous sched class iteration; and since its cookie matches with max, everything should have been finished already; - if cookie_pick's sched class has lower priority than class_pick's sched class, then cpu_prio_less(cookie_pick, class_pick) will still returns true. So looks like cpu_prio_less(cookie_pick, class_pick) should always return true and thus not needed. > + return class_pick; > + > + return cookie_pick; > +}