Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4423427pxu; Tue, 1 Dec 2020 04:47:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUMdIGYQ1yqxrb7mBTMA3zlys+IJSBGyy7sBqfynkhIH4InB98pBY9uJAdeW2Td9qgqjXm X-Received: by 2002:a17:907:2718:: with SMTP id w24mr2728496ejk.525.1606826869191; Tue, 01 Dec 2020 04:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606826869; cv=none; d=google.com; s=arc-20160816; b=x+YYqX17qe5qdxKMr8YSWGYkPZQtRvyzF+715k8jHc2fhplnoKRyBDNvRJyVjwH+yb Uad+xpfUWM8pOl89i4Q6HC9PDhIVEzWxYlqX00H/VcHpcfN7xaMTzxtqnJo8zUPn8Gx1 fG2idn6Zg1JbfndFyCp93Tz0Bx5+QdgtHkQhA2qocpKWAYGLZA4dUXkfBZ6k+S4iAkOd +XzPE2C50jGaROxC/cIXE808vsu3NscjMEusw2ECbxv5esSrNtkoXrThNHoc3SvvLo/0 eeVyAmNIYVpaR5eXfOqqKps/HeUzLHGUStuHCduElGkffB5B6bg2/62O1+tyzY7UTNtn n5Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7wUP00ZSTPQm1K94GxkbcIx65Jk+JKxFA87kex+sa6s=; b=S19Ggga3TKt82jlJlvDIol2i1F+eDHMgtDo86L5Bh+/tT68yMBOJsp8DUOVvEdbava GJ7o0dfPdJ1C313Ex0jp5eN+REtBJp9QUiT88mTuQyb5fz2d9wbKWl7gR+gBiC2cRVsZ 7F/M/F4qpZvqzha1q1xSCunOKaeNStXBZCOTGdB5VDD4qpQL8Xrkgdf2A3P+NnDva1ox 9W/PzAlf7/RBAXWvx51hjMaqYZUcIiLd8N6GAT9yzAI+VB506tfrBACqpAn3KjtVEUE3 +YCXj9wFXoqKMfupr46IAKgwEEiISwKJhTQQsHr6ZLdlKxjac/SFy2XmWSc8JOzD7MR9 ICVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si851869eju.318.2020.12.01.04.47.26; Tue, 01 Dec 2020 04:47:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731050AbgLAMm3 (ORCPT + 99 others); Tue, 1 Dec 2020 07:42:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:54614 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727055AbgLAMm3 (ORCPT ); Tue, 1 Dec 2020 07:42:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 81DBCACC4; Tue, 1 Dec 2020 12:41:47 +0000 (UTC) Date: Tue, 1 Dec 2020 12:41:44 +0000 From: Mel Gorman To: Yafang Shao Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, qianjun.kernel@gmail.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Subject: Re: [PATCH 3/6] sched: make struct sched_statistics independent of fair sched class Message-ID: <20201201124144.GT3306@suse.de> References: <20201201115416.26515-1-laoar.shao@gmail.com> <20201201115416.26515-4-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20201201115416.26515-4-laoar.shao@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 07:54:13PM +0800, Yafang Shao wrote: > If we want to use schedstats facility, we should move out of > struct sched_statistics from the struct sched_entity or add it into other > sctructs of sched entity as well. Obviously the latter one is bad because > that requires more spaces. So we should move it into a common struct which > can be used by all sched classes. > > The struct sched_statistics is the schedular statistics of a task_struct > or a task_group. So we can move it into struct task_struct and > struct task_group to achieve the goal. > > Below is the detailed explaination of the change in the structs. > > - Before this patch > > struct task_struct { |-> struct sched_entity { > ... | ... > struct sched_entity *se; ---| struct sched_statistics statistics; > struct sched_rt_entity *rt; ... > ... ... > }; }; > > struct task_group { |--> se[0]->statistics : schedstats of CPU0 > ... | > #ifdef CONFIG_FAIR_GROUP_SCHED | > struct sched_entity **se; --|--> se[1]->statistics : schedstats of CPU1 > | > #endif | > |--> se[N]->statistics : schedstats of CPUn > > #ifdef CONFIG_FAIR_GROUP_SCHED > struct sched_rt_entity **rt_se; (N/A) > #endif > ... > }; > > The '**se' in task_group is allocated in the fair sched class, which is > hard to be reused by other sched class. > > - After this patch > > struct task_struct { > ... > struct sched_statistics statistics; > ... > struct sched_entity *se; > struct sched_rt_entity *rt; > ... > }; > > struct task_group { |---> stats[0] : of CPU0 > ... | > struct sched_statistics **stats; --|---> stats[1] : of CPU1 > ... | > |---> stats[n] : of CPUn > #ifdef CONFIG_FAIR_GROUP_SCHED > struct sched_entity **se; > #endif > #ifdef CONFIG_RT_GROUP_SCHED > struct sched_rt_entity **rt_se; > #endif > ... > }; > > After the patch it is clearly that both of se or rt_se can easily get the > sched_statistics by a task_struct or a task_group. > > Signed-off-by: Yafang Shao I didn't see anything wrong as such, it's mostly a mechanical conversion. The one slight caveat is the potential change in cache location for the statistics but it's not necessarily negative. The stats potentially move to a different cache line but it's less obvious whether that even matters given the location is very similar. There is increased overhead now when schedstats are *enabled* because _schedstat_from_sched_entity() has to be called but it appears that it is protected by a schedstat_enabled() check. So ok, schedstats when enabled are now a bit more expensive but they were expensive in the first place so does it matter? I'd have been happied if there was a comparison with schedstats enabled just in case the overhead is too high but it could also do with a second set of eyeballs. It's somewhat tentative but Acked-by: Mel Gorman -- Mel Gorman SUSE Labs