X-Received: by 2002:a17:90b:4c8e:b0:1b9:f99f:1218 with SMTP id my14-20020a17090b4c8e00b001b9f99f1218mr12121269pjb.75.1645665717959; Wed, 23 Feb 2022 17:21:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645665717; cv=none; d=google.com; s=arc-20160816; b=qeg7Nrhzn9W8g6/oRSwiJsD7oq/n5EnZXsBqWCqLtQRigUD/PwOeyT8fXS2bHO7BWp zdPSux1UxLAaVyaSmsQzLlP6PtLmqI5rMDXN1IGsWA14IVq+ADV2Yb1smDyVhiGtGLZu Rhca9/583T/jJW0sxHXp7xR6tluC62ryT5Xk4+A1urLIzIKavc6w9pxAFZ02PFsFNdnf CfBPNax6CFCI3ptoYeJ6aqeXsOSrr0uDYhYvcJZx1bUNThTouCsxbKBww2AKdmdME2k9 6P8sBxbK7Y75Q8QIYZR75vr7vZUFO+rN01C82PEnF4kQ+dEnociC0vDySGoJE8GjzGSF DxLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6dI8rlxnvMgk/CFWZ7aIu/AOOPTmafd9dUBuyUNg4Oc=; b=HLeMSxDMOokHlaQiPh8H5Hy/uwZrSHtxWYqQRHNOMiWXVNxiYLeTsm51IwCzzg3Qqf LM5ZI75u5aPZkbC5A0onPH/ACo1tarHwiWlyxu92S8gMF6Xesbzlhytrjb+ANblvxOiQ FeAuhGcDOGtYUpdsNoae4LJRPU/5UygzwWwVLomUaafPQjIaPHBHk2WZCZAX1M9P2NiM 4wdnkrGixInqk+llK6mqTaG0O6g/JrvRWJgEwbeNtavSJ0lQvLsBbDvERgE1ktWBhk38 F58mWHL+g+RAwVGt7gED4pUXg3L7c5nVHSA/7/Kussj2K+8DaZX+frJnfm60pP/XOlde Os7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="XuPw/GXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mh8si1141786pjb.38.2022.02.23.17.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 17:21:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="XuPw/GXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3BBBD1A58D1; Wed, 23 Feb 2022 17:05:51 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237532AbiBWKUK (ORCPT + 99 others); Wed, 23 Feb 2022 05:20:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234973AbiBWKUJ (ORCPT ); Wed, 23 Feb 2022 05:20:09 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1FD48BE32 for ; Wed, 23 Feb 2022 02:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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; bh=6dI8rlxnvMgk/CFWZ7aIu/AOOPTmafd9dUBuyUNg4Oc=; b=XuPw/GXs8D8h1ys61CHxVZ2YpD lqIDjNOD1VfzUWUujSiEvHpT6ZVs8XQ/iXFIzK7+L3I4EHZT4a5Jp02Dk/QQ0GDouPV4GXcOdF0ZH E6X0BH5mhFhiBF54GSx/m2qFjtHxH4ho1g/2F6VLgsptGlKyRTdmhskr3C4TzMjhp+VKMAld86KCr B09Jc4w3nJvQzLpVrsv/JI15KzYQeLl+ROk/elVoNfLuzw44GINaWaOEO3/URTlijCpDSgl2w5/19 vPn0HYI9o6iLy+8cmdLi9S4jyMLSlAhN2XPEjiNa93jkjepkRIsXxni2nIJ9w2XYW7idKOQTQQ+Zt CFl6pT6Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nMok5-00CEGq-P4; Wed, 23 Feb 2022 10:19:29 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id BA3B7300454; Wed, 23 Feb 2022 11:19:27 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A3BA6203DC967; Wed, 23 Feb 2022 11:19:27 +0100 (CET) Date: Wed, 23 Feb 2022 11:19:27 +0100 From: Peter Zijlstra To: Carlos Bilbao Cc: juri.lelli@redhat.com, vincent.guittot@linaro.org, mingo@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/sched: Update schedstats when migrating threads Message-ID: References: <20220126152222.5429-1-carlos.bilbao@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220126152222.5429-1-carlos.bilbao@amd.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 26, 2022 at 09:22:23AM -0600, Carlos Bilbao wrote: > The kernel manages per-task scheduler statistics or schedstats. Such > counters should be reinitialized when the thread is migrated to a > different core rq, except for the values recording number of migrations. I'm confused, why should we reset schedstats on migrate? I'm thinking this breaks per-task, since tasks tend to bounce around quite a lot. > Signed-off-by: Carlos Bilbao > --- > kernel/sched/core.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index fe53e510e711..d64c2a290176 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -8757,6 +8757,7 @@ bool sched_smp_initialized __read_mostly; > int migrate_task_to(struct task_struct *p, int target_cpu) > { > struct migration_arg arg = { p, target_cpu }; > + uint64_t forced_migrations, migrations_cold; > int curr_cpu = task_cpu(p); > > if (curr_cpu == target_cpu) > @@ -8765,7 +8766,14 @@ int migrate_task_to(struct task_struct *p, int target_cpu) > if (!cpumask_test_cpu(target_cpu, p->cpus_ptr)) > return -EINVAL; > > - /* TODO: This is not properly updating schedstats */ > + if (schedstat_enabled()) { > + forced_migrations = schedstat_val(p->stats.nr_forced_migrations); > + migrations_cold = schedstat_val(p->stats.nr_migrations_cold); > + memset(&p->stats, 0, sizeof(p->stats)); > + schedstat_set(p->stats.nr_forced_migrations, forced_migrations); > + schedstat_set(p->stats.nr_migrations_cold, migrations_cold); > + schedstat_inc(p->stats.nr_migrations_cold); > + } > > trace_sched_move_numa(p, curr_cpu, target_cpu); > return stop_one_cpu(curr_cpu, migration_cpu_stop, &arg); > -- > 2.27.0 >