X-Received: by 2002:a17:90b:ed4:b0:1bc:5dee:f350 with SMTP id gz20-20020a17090b0ed400b001bc5deef350mr6552045pjb.234.1645574827268; Tue, 22 Feb 2022 16:07:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1645574827; cv=pass; d=google.com; s=arc-20160816; b=ceyV2zI5QIROYdg2dGK3EX+bJxhxJ+vuAGpaH0b/ApaUBPxofvlky4DuKy+ZCQ90IU DN2vecG+ZECpJ1fVAJhk14yzyYEI1K3A5XispIVlqFxK2yn7cxF1p48QlyxpPXGaUHRo cQpPMUjiXnKM88NYCrFV0a82uE0y+MVvM8/uYuxQ7Y5QZ33l8+L0YIEd/ahrIosoG0Ks dABgInsCLOPqbVf3ZfJSBhIJCeJAVS1thjvpDrv6TFohAxIgUvTK216LfX985QSxNYdg nCWVuTApe0FU4o3gSGyw3YkFaho8iP4m1G1pas9fTS1MsXJqlzC90ChU0dZaopHkC18r 0GEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=mUrD48/lKf99g7pxXn2ANNtaUcqrgcLYXES05dtmjUg=; b=TgqcCl3g4lqVCPBmouID7DlHIJx4r4Mh2wH9tXN7PfFJqgHWE1Y2wjlzthZ0iosJJ+ t/7B+UZonm6J5xuKmgSVblgW6jswn5QpbwBViA1McRz1twR+rZxoLqqGE35PofHiNaBW sChstukIVMIv08WoYcTiYPl5bQM/CUhaSWKZX0l0hn3srvKjZnOyW3TyZvHU68iJkSR9 auIC1QATCHnKTmDJuTq6tGwXVUbPbV0CePv4wcVZ1fI3r4Gl7JZidZOIrn11b86cciQP 0a6XjMm6jvkCQ3cTxao6cuqzXy2/Dl+oQIvaM9yOT66fpRRD/QrvJZWHKjSijRNsHvrr Xrpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=p2lxVNLG; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3si4707901plx.205.2022.02.22.16.06.48; Tue, 22 Feb 2022 16:07:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=p2lxVNLG; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234220AbiBVQeL (ORCPT + 99 others); Tue, 22 Feb 2022 11:34:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234088AbiBVQdC (ORCPT ); Tue, 22 Feb 2022 11:33:02 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2061.outbound.protection.outlook.com [40.107.223.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE8C78067 for ; Tue, 22 Feb 2022 08:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fUNxUjlfgozREInkhROu+Q0KtQ1g3/tlDbdm1Uh/bnAEDdCTXP+AC6ywYDBAe7UwE3OjNWQPGnNbZGIb4MALafKw91hl0Kbdw9tg9EXKlJmYlV1dbVSrnGM4XTdSduEHiseX86gTfXgmYu0QEq0JQMGX5nkDdW9SV1gF8H0KTGzVKKo3PHBac3s4U8roNhlRWb+yor3yN5e1HguIOISeozKGt/NswokNsCXRdhSlLSvJSL8+91HxRvNpzJkJtFe48qpO6BiPk/U753g2V9knm3M0b6+bfKo/lhgvmjhcKuR7DAkCEL5v8zHfanhaF640meGJKtRid4nEMNxlNvWGIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mUrD48/lKf99g7pxXn2ANNtaUcqrgcLYXES05dtmjUg=; b=CluUeqSSnpWra59DXFSo12pw2myReklj8uPbnP3tqVsAY1Ka1SL+9kQSIf/bk9JVAtkZqUkkVpIJixWaJDdPS8gES5TtH81riHyJlzHYY+QqEH/sz9FcTj/3pDzHNETPnUg+P3dPFbBXHAMpAgNwhm2G5nMfZNPp0PnRbdMEb0dj+tzoQF524eQXYc7rAYLmrinrxIaqO7togjTtWsRUHhZt0coIjQ1q6vZX8ZQJKyxTg+zj0DiPI1bB6gPGDojTiIDnKs5a28Io8MGwTzT+j/jwpsw4qzLgUX1I/fXPdRRAgmaqX0YW8+FJvku6lqKYeo6mc+lZkHuVtBeey7/RCA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mUrD48/lKf99g7pxXn2ANNtaUcqrgcLYXES05dtmjUg=; b=p2lxVNLGNyLsfKi95L2kudOu7X77jQ5X8UuF4FlG/wj88ZKu47DJJm28SilhVRO6TUBNuAyqBvam0/LGRUb6wgmpTWJPvEpGANJaNRFvETRf8BPuaT0AWUoYlh223slermLCQUTxpGoIkJfpz8MiYYA88WfmrRZsAjc7wdtYBQo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) by BN7PR12MB2690.namprd12.prod.outlook.com (2603:10b6:408:32::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Tue, 22 Feb 2022 16:32:35 +0000 Received: from BL1PR12MB5874.namprd12.prod.outlook.com ([fe80::8d44:d69b:b031:1d50]) by BL1PR12MB5874.namprd12.prod.outlook.com ([fe80::8d44:d69b:b031:1d50%4]) with mapi id 15.20.4995.027; Tue, 22 Feb 2022 16:32:34 +0000 Message-ID: <6b4d8615-4c60-3d89-5210-b495344cabd4@amd.com> Date: Tue, 22 Feb 2022 10:32:32 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] kernel/sched: Update schedstats when migrating threads Content-Language: en-US To: peterz@infradead.org, juri.lelli@redhat.com Cc: 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 References: <20220126152222.5429-1-carlos.bilbao@amd.com> From: Carlos Bilbao In-Reply-To: <20220126152222.5429-1-carlos.bilbao@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MN2PR12CA0004.namprd12.prod.outlook.com (2603:10b6:208:a8::17) To BL1PR12MB5874.namprd12.prod.outlook.com (2603:10b6:208:396::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 601e52e4-8abe-4d37-cd46-08d9f620ee49 X-MS-TrafficTypeDiagnostic: BN7PR12MB2690:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CBnI4kK/13Cl76qITBysSbaHN2tYqEBaiRHt2a9+eUfJSajBNaiavtq3ncPJ4g5WnEybRbTvFhrnuj6BBVOnPXBNotc0DW4nFOWDn99jYByyvs7M2YDRW/TQ3LIKYY1bD0nnqVi0nDmvxY4boYpZ7T/v2keam0fjo0FYvokUAxuaei/SyWTewvFdc+ps0wWaP4HcWl3ua8EEL1vGPmqyv1aHCHhT22ZN6hd5AFEpD4XyqTWZDBRe7gIe7cFntAbsyRIftsAxWhFHHjECcFzp3apBxC9jY5oGnA28AhOA7Z7fu4uUEGpJUHY2w83EKDKSgh2QkCGDsjPnBNVzObbWirREWR+BRaibLA1i68BtnHmJtFUnTiIvgf6fBJO0x9v58yo/npn+ZkuGIRo+D0gbh15wKhXOYl2hCL70erxIyXvCYFdQrsMPRJH29b5+Yb4Cf1JeluEzdk2P2cQbIIyRTEnHDUB72wtVRBI4S6bzfvtVLcfdEs5d/RhAWtp+L5P3CtqO2RcwsCilD10uQu6WHdGy0N0m19pyONK27eCQPiiF20ma90uCYh3Y9YhFOJMO6oI/xzj+AM39WrTEdW2HXqvQujiKAMG6yFCzoQgDafYqa5DJVkoi87Uq31+SPZvZAe+B6kvr/Eb+vKnFmUYKFjLpjr09pmmaAE9vl2pSCbZByA5rjHnRFio4MylTynce4kq3KwFwTDY3F1J+KSOdr7u0x2DW8MgEC/SMClwf3WU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5874.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66946007)(83380400001)(508600001)(4326008)(53546011)(8676002)(66556008)(6486002)(66476007)(31686004)(36756003)(6506007)(7416002)(26005)(8936002)(86362001)(44832011)(316002)(31696002)(38100700002)(6512007)(2906002)(5660300002)(2616005)(186003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RU5lYkpabXlFWlF2Q0srMVE4TVc5eHJrcWZQdUlVT0xha01vS3R1eStqYWF5?= =?utf-8?B?cmNJRUE5OHBSNDFyN3Vua1BUUDNFMFpYVkpFd0dDMFc5ZlpQaVEzVXFJYWQz?= =?utf-8?B?N01NcDZlcE1xZkxqSEcveGxsaDZqYjVOays5dGQ3OWJkVFN1M2hYQm5Za1ZS?= =?utf-8?B?MThaWVVtdTJTOFRpcXYyQjlYTktUUElqaUt6RzNtdlNBRXh2WkVzMnVwMVZk?= =?utf-8?B?ZVZCbmc3MFE1UnJqOVB6M3VZVW1mMzFOajc4UmxUWnI0dlAvYnRvUXZONDVW?= =?utf-8?B?NGdCQUx1UEVadXEyQ0JMaFd1L1FMbC9WeHVrRGJ1dlF1Q2I0Z0ZVWENFL1p6?= =?utf-8?B?ZFBUNXZvakp2VzdQbHRzUXZzeXNvRlQzR1RrVzdmdUYzSDl4cVpEc2VLVlY4?= =?utf-8?B?Y0dERlZrdEo0OUNmTFg0a2d3NFFKVjVoM256QkpsOE1uVWpCK01HbGdWcjZL?= =?utf-8?B?VW8rclZYRlZiVFJBK0p1OWNJRTg0cmtvcGxKR3piMm5Vb1JRRXkvTVMzS3Zy?= =?utf-8?B?U2lNVDc2a1gySXlsQ1p1aGxGVUJpSFV3aGtReFlvSTNISzBWM2pyZU80bDdI?= =?utf-8?B?bmZuSGpwRlJwWFNickJGalE0QmlQamFMT05BeXdhcGtzMmx4b3FvcDY5cG84?= =?utf-8?B?RGx1a0VsR1pjOGV0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W?= =?utf-8?B?aUl1NDlNeDlscHlpOUlVYUg0UlF0UnFTRXh5R1k0dEkwUDEwWkdvMUpqUmtm?= =?utf-8?B?SUJJMVk1RnBvbStVV2Y1cE42VjY5ZGNTNEN0VGR3SGdQMFhxZGI2Nk5XMSty?= =?utf-8?B?TStYczZlUDErblByd3cwK2dOWlJMd0JibytId01Za1pTMGRXK00wYzd6RHNQ?= =?utf-8?B?a3c0WGpqcGJTNXFsTGtTaUlkdjQ0UDNVU3JFaGljZDVCRmZGOU1NU21WWlk4?= =?utf-8?B?Z25aQ0hEUDVRWnZKNFBIRHFnbXJKZloyMTlnZHZLd1B3V09mSStoRjFhdTBq?= =?utf-8?B?dzdYTmE0KzZ2QXlkVzRwbzFHYlN0MUs0RCszUStOUERFZGlDcmM1SHBlc05F?= =?utf-8?B?RWJ5eU1WZXQzaWsyY2EveDVjU2ZnVjk4WnlkSUJzTlY0QytlWTZSZUt0S3pN?= =?utf-8?B?ZkN6T01EcElQcmxoVVdYZFpZc2U1Ti9saVJHZmpzaGhGd3VnbTNNSlB3dnZC?= =?utf-8?B?R3d1aFRITzVlOWtHdDhKbzhiQnpWTndET3NsTmpLRitxZXVRSFlUbDl5Zytn?= =?utf-8?B?T2I5N2JNT2h1Y080ams0UTRkSS92aUpwY1oxUFc2WUllTFhpak0vZHVrdE52?= =?utf-8?Q?7GtWm6yfeUgnrPHWkEmcGf4=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 601e52e4-8abe-4d37-cd46-08d9f620ee49 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5874.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2022 16:32:34.7617 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h1lKFaJxguEIbxOEB09dxfVkWmaXHuOg5WV8pGysmiP1yNKOSFbA03CkPKyJng1CQZvhXAnT0CpRWk6GnPOw3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR12MB2690 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Hi, On 1/26/2022 9:22 AM, 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. > > 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); I would love to hear some thoughts on this. Thanks, Carlos