Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3001764ybl; Fri, 20 Dec 2019 02:14:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwadm8yo2dBAZsVZKJTBbRqD6T9xUlJrJj4uODCXfMXEevncIpOnkY09VE+0N7G/cew7+vR X-Received: by 2002:a9d:2965:: with SMTP id d92mr13305328otb.175.1576836845756; Fri, 20 Dec 2019 02:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576836845; cv=none; d=google.com; s=arc-20160816; b=VFTJtwWAjp6CPVcfk4p1ruPzGYlb90d+bzCp+Zg8CMxjorhUKhAmKEywODlkeKYLeh QHxl+t+i1bFVkfRGSfocnM50wbyNQNEQnB0zf76wgOHWMRpou8IYGih1nTVtzHXwvXJV 8b5JeqydeO56S4n7Q04sZgCjEc86vcy690szVOB+4xCe0Xy42Y6C74ynTJhXXVoos2X9 40ef38uqNQRFFaWYr+VuZX/mgnZLuyMl0IDb08OSDBRiFsl73HYAyV1LTueQEWpckPzl sMLzjBb33u7vLoSJE2KPQdi7IZvGWh/SMC5ZYehRyBCAfhJ0+7HHPj/7VgadlgvJWoqR T7qw== 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:from:references:cc:to:subject:dkim-signature; bh=5M+97VbPVz5fx10oR8PMt5OPdUW758AjR3+Ji1vzz5M=; b=KHWIPKR+L35L9aUVRxBKGipkY2qv3J4R9pDAD78fxi4SOdBVO93bgE7ITl58p8Qzta i00XAe4euRU0xz4AZp+5oSek++UcgGzPEVXJgYphysO5r1/P0Ktv7Gckc9dyNn5v2Ccy XYF3TwLkCvGo4ir7oqIk+psrviiQ6b12uzK7XZz/n8SgOslmfg/04UM+kLVmxRSvnyAo 6KT3niq4bAAaMPAmvDjg21nRmn9iTyNv5VGBU+vEoqMvB9d8wBWSmq0vD1MlKIiLx1e9 hQs1d+KOwRka+qljrzyqkDj/qOx6hiMc1hzzQpNOLX1tJo1bbq+bcJfbUD+VCcSym8C2 OYoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="L1ZlN/vT"; 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 d20si4371089otq.157.2019.12.20.02.13.53; Fri, 20 Dec 2019 02:14:05 -0800 (PST) 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=pass header.i=@rasmusvillemoes.dk header.s=google header.b="L1ZlN/vT"; 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 S1727276AbfLTKMl (ORCPT + 99 others); Fri, 20 Dec 2019 05:12:41 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41091 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbfLTKMl (ORCPT ); Fri, 20 Dec 2019 05:12:41 -0500 Received: by mail-lj1-f193.google.com with SMTP id h23so9414378ljc.8 for ; Fri, 20 Dec 2019 02:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5M+97VbPVz5fx10oR8PMt5OPdUW758AjR3+Ji1vzz5M=; b=L1ZlN/vTOi3FuOhcVzlqz11rikUE109c0s2Si9hpwWNPLIKRQ/qB7kVRUO5Ak/dmSd bT5nZME+i87t5vsXEhQazURlMkxIXy/krhexuF1BqmfAPw7fMSe/hRk8wdqn430egyv8 aIhAE4cOu1xPOxmBuNxyA/rygFdbDQuEfno2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5M+97VbPVz5fx10oR8PMt5OPdUW758AjR3+Ji1vzz5M=; b=s1keIMQzPhEFyWk40prgXqN9fzD28PaEWhGsKd7vV0Jva51Jhdul1I1r2vPp66sYu7 jC1huKiUc3Q0IWGXcocCRE0367iziVivAsyWdaBctpvsjrg9vFMicpy1krrOgdZPZPHb 0SC76ucPhms+pfZDNLTH5SR3kW6QebhscxXo2OLo182kxStB1fgtWdTfCUgunR8Q4eR8 CSKdhpUrrWqdzXejmywWMCHpfXKRJ/IiIsCuyP8RcCvHrN0yV4CqpLhqYHoGnsqFBLgV dBXo45B31inHt/es/aYYQW2n5BAv5AlV2yqgLRXEF/EYifa7hO7PDUDtUINioXxeOPo8 Gurw== X-Gm-Message-State: APjAAAWMui2FWTKlmtfBVcNenF3GtaCquYLSB4v/+HcddIDNpdTgpQ99 3mcv/zknO6cOxTXHR6YB3MrUUg== X-Received: by 2002:a2e:5304:: with SMTP id h4mr9433917ljb.75.1576836759355; Fri, 20 Dec 2019 02:12:39 -0800 (PST) Received: from [172.16.11.28] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id i19sm3843910lfj.17.2019.12.20.02.12.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Dec 2019 02:12:38 -0800 (PST) Subject: Re: [RFC][PATCH 1/4] sched: Force the address order of each sched class descriptor To: Peter Zijlstra , Rasmus Villemoes Cc: Steven Rostedt , linux-kernel@vger.kernel.org, Kirill Tkhai , Kirill Tkhai , "mingo@redhat.com" , "juri.lelli@redhat.com" , "vincent.guittot@linaro.org" , "dietmar.eggemann@arm.com" , "bsegall@google.com" , "mgorman@suse.de" , Ingo Molnar , Andrew Morton References: <20191219214451.340746474@goodmis.org> <20191219214558.510271353@goodmis.org> <0a957e8d-7af8-613c-11ae-f51b9b241eb7@rasmusvillemoes.dk> <20191220100033.GE2844@hirez.programming.kicks-ass.net> From: Rasmus Villemoes Message-ID: <1ac359e8-fa7f-7ded-e2f2-9f7d0b23a4e1@rasmusvillemoes.dk> Date: Fri, 20 Dec 2019 11:12:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: <20191220100033.GE2844@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 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 20/12/2019 11.00, Peter Zijlstra wrote: > On Fri, Dec 20, 2019 at 09:52:37AM +0100, Rasmus Villemoes wrote: >> On 19/12/2019 22.44, Steven Rostedt wrote: >>> From: "Steven Rostedt (VMware)" >>> >>> In order to make a micro optimization in pick_next_task(), the order of the >>> sched class descriptor address must be in the same order as their priority >>> to each other. That is: >>> >>> &idle_sched_class < &fair_sched_class < &rt_sched_class < >>> &dl_sched_class < &stop_sched_class >>> >>> In order to guarantee this order of the sched class descriptors, add each >>> one into their own data section and force the order in the linker script. >> >> I think it would make the code simpler if one reverses these, see other >> reply. > > I started out agreeing, because of that mess around STOP_SCHED_CLASS and > that horrid BEFORE_CRUD thing. > > Then, when I fixed it all up, I saw what it did to Kyrill's patch (#4) > and that ends up looking like: > > - if (likely((prev->sched_class == &idle_sched_class || > - prev->sched_class == &fair_sched_class) && > + if (likely(prev->sched_class >= &fair_sched_class && > > And that's just weird. I kind of agree, but if one can come up with good enough macro names, I think all that comparison logic should be in helpers either way the array is laid out. Something like #define sched_class_lower_eq [something] /* perhaps comment on the array order */ sched_class_lower_eq(prev->sched_class, &fair_sched_class) > Then I had a better look and now... > >>> +/* >>> + * The order of the sched class addresses are important, as they are >>> + * used to determine the order of the priority of each sched class in >>> + * relation to each other. >>> + */ >>> +#define SCHED_DATA \ >>> + *(__idle_sched_class) \ >>> + *(__fair_sched_class) \ >>> + *(__rt_sched_class) \ >>> + *(__dl_sched_class) \ >>> + STOP_SCHED_CLASS > > I'm confused, why does that STOP_SCHED_CLASS need magic here at all? > Doesn't the linker deal with empty sections already by making them 0 > sized? Yes, but dropping the STOP_SCHED_CLASS define doesn't prevent one from needing some ifdeffery to define highest_sched_class if they are laid out in (higher sched class <-> higher address) order. Rasmus