Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp769204rwd; Thu, 18 May 2023 03:49:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7iWx8WxIlP3ZgEfylStVitisQ/76oAzVJugORRy2UOGQx24OqtwB5gpz0QQ51jHZbfP+BG X-Received: by 2002:a17:90a:1181:b0:24e:4a1a:3994 with SMTP id e1-20020a17090a118100b0024e4a1a3994mr2131506pja.3.1684406966299; Thu, 18 May 2023 03:49:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684406966; cv=pass; d=google.com; s=arc-20160816; b=S1IpKOMWt+1wrQN9v34BFIfDjOa3d+sllMA2XCpOxW2/nOwTpieKsajKdX22+AAjYg kwgfYr/XjinsWO65VdgQZr2/Eko+Kpp550KMXmmuwZ4TeaTdFU4B3F97UJseI3MXYhBw BvNuRp7GWMCRVy2WJEF6wi2wt75LzEHsmW1mWzD6vNyVoYoIIyNeDHzg90Srp+gu6Rsd vIj84TmD4TRJGCRgsJR2Mx0vGirYsYpImbW9FZtkdvLIdOk0pPwLuzGPcrStMzDeVHwt XLiE/zsRevkqzp7bJv7wpwpsqLuk1pMVZhorGXSnZ0LD0QkyVbNKSfQUHDMNVGywMoWd AX0w== 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=pj4mhm+sLh5/Bkv/I99j82b7n05wyxqtTvzWWJDBvgA=; b=I2IgaWIwkejzEhdXxtr20jTeW/bkHgZT9D13yLvDLUxHtZVXcJeSvTRsZSVs/DgfgO 02Flemzd/Z1uY2BUMQz8SfhrFM6ROe+j62xDOAbci/+7+eU3fHKY21gLIvgNIAHepdwd QdKFDh13IIEW67c+4nfhbcZKalev5CPrE9NP1ic8pf6/gAEG3cCVapItWruhrKJGY7bi PSW9jb31jCQcQyN8wrfEYFIjoxNbUKiU2KmYNzq3EhyidtODPIidZ7JifAv4/RMEhR9c kE89fhLm5upbu06j8t55n8cUz8YFRC0AVPjcvV8LuU3eTaYl8QUmf9ITELv2LZQje1Nq +iGg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rJ51ZirR; 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 c8-20020a17090a558800b00250a6b87c76si1396604pji.142.2023.05.18.03.49.14; Thu, 18 May 2023 03:49:26 -0700 (PDT) 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=rJ51ZirR; 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 S230091AbjERK0r (ORCPT + 99 others); Thu, 18 May 2023 06:26:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbjERK0g (ORCPT ); Thu, 18 May 2023 06:26:36 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD0711FCF for ; Thu, 18 May 2023 03:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jlk9psHiNgIaHZS1jOW1m2fb7Jc0/Ihxt3+uQxctIXj85Pa7FfTyWVHa0tviu7kGYdCNy3Hb6LlV+RZLOLj92NqIG0dZGr6ihYpM6OBDhIWX8H/7GIi5yllzet0XHEWpVQPMTwSaJL7g2KM6gV9ZvBn0tZgMMuunDsXqbVoj0HcI1JYoMpwWjeyPr+f8UqiLauDdYtpdFkNsZo5hfcoDoxPIHwmxodaZmmcIqVquXT34bSPsLCXWIFvqOjs6fKPMcwzV0vjUiShQIZqUPAwolmap0MIbsSj6G90wXbDbElU5y15qXDXT10wZR1abHeBcJQjSX5grLcMSHkIC3Goxig== 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=pj4mhm+sLh5/Bkv/I99j82b7n05wyxqtTvzWWJDBvgA=; b=b7D4KNgpebVqT0R8Zs5DNJ0a94AMJWT056eBe0DG7OuTXxJOvJ8ttcG65RtCQREsGwTjqoMZymbvDZk8cOayaHf7pe22rdkCF/yFl6KJ0jgHmo735ycwKzMXcmu5IDme5CN7jfm+1bpTAypGJh6hxFP1KKpTCzv0YQDPAQVoFlb6iSqCtcfFec01ALJMKwiUnZKTJ8n0cBJXrpz042vh54CZ+QnQwd1Fft3fdID8thgqPcWggsA3PMaDq3HyuZP1nHAN3A71fpDxmBW7st0lyJ5F0aJpwTZ+Jbf9VuL7mK5isSnp4UE/ovdJXDonx16vHv9PoQMHmxG4QUb2n+0h8Q== 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=pj4mhm+sLh5/Bkv/I99j82b7n05wyxqtTvzWWJDBvgA=; b=rJ51ZirRGiem87c1U/JXSQglhED1rNaf9mvzbMYIoZJywY6aZ/H66mOk6MGEWacfQlVhQfV6pXtaYl5KM7PdQ71d06XsHndUpcPykCbE93DfWK9P1NZJvqp+GpQWQXh+dYtnSa9S50GR+c/mMKgX9Y5NdA9fH95/w4BK6OMbok0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from MW2PR12MB2379.namprd12.prod.outlook.com (2603:10b6:907:9::24) by SA0PR12MB4559.namprd12.prod.outlook.com (2603:10b6:806:9e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Thu, 18 May 2023 10:26:25 +0000 Received: from MW2PR12MB2379.namprd12.prod.outlook.com ([fe80::b197:512:a4ca:6e9c]) by MW2PR12MB2379.namprd12.prod.outlook.com ([fe80::b197:512:a4ca:6e9c%4]) with mapi id 15.20.6387.033; Thu, 18 May 2023 10:26:25 +0000 Message-ID: <12061140-4f09-b83f-843c-2fb8ff9f6e81@amd.com> Date: Thu, 18 May 2023 15:56:12 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [RFC PATCH] sched/fair: Introduce SIS_PAIR to wakeup task on local idle core first Content-Language: en-US To: Chen Yu Cc: Mike Galbraith , Peter Zijlstra , Vincent Guittot , Ingo Molnar , Juri Lelli , Mel Gorman , Tim Chen , Dietmar Eggemann , Steven Rostedt , Abel Wu , Yicong Yang , "Gautham R . Shenoy" , Len Brown , Chen Yu , Arjan Van De Ven , Aaron Lu , Barry Song , linux-kernel@vger.kernel.org References: <20230516011159.4552-1-yu.c.chen@intel.com> <19664c68f77f5b23a86e5636a17ad2cbfa073f78.camel@gmx.de> <795a6d9475ecb444d219a9d36dc93b48a69e960e.camel@gmx.de> <0ac968e3-cd80-6339-970d-37005876b145@amd.com> From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0042.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:98::7) To MW2PR12MB2379.namprd12.prod.outlook.com (2603:10b6:907:9::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2PR12MB2379:EE_|SA0PR12MB4559:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f911a65-0b9d-4fb4-e9d8-08db578a5520 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cw1J1JZlZ+5ZHQJtoIH7keduaW7omPhK0LUVmBIA4PGWQK2l/hFW31rCpw4A966lfAQy5kmoWH9z/cmRFTYuWI0E8kr3uYUEzlsNxyB97WMfnmDT7LI7N+LD6z8Q2ARPpuinSe35iqbJrVq2KPJM9EClevkQul7p67NXkArUWjXXm6O7/ubVNJ0m9R2F9Wbvo6vMU3ZUKTPKALpzS5E3IQIV2qhLRYFhDOcIVkeARQUIlJf8+cn4UPMdn6Q/Q9pFBGNJh0SCUjIg5oVGRvTGWSHl1JZASZ1dRTIyaXwpLk67f0+rFCfnJgMdZ5GCCbQ0mP5UEMdGR4cTlOb3vwRLuMFXnxH0iewnx0IxmUBmoeDl47QJF4P8N1AfDzv7l38dwUR2JXRWM4Z/Av5YrnyU7QEcWFaSTUGvsPXAkGtpz6Ihu6W5iVOwk4/8sY+nGHcQspZx5lBeLk6K31h3VWFSyLDvqWArpnUiLMEnJyanK5QEEYr/niXC7UlneRkBgXtEUe8hKgzldyak5ItMPmmYk6GGouvcdP3tVNX5MDzBJ7lxxS5S2FGpDRRC05pfXKGINpAhavJ0Ge6YOEsoV2etpfHzkSCOjcbCms3HeIApzfYE4NGfkMltjY/PpY0XqcETCE34Ozwr9TkH2I9YE0h58Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW2PR12MB2379.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(136003)(39860400002)(366004)(346002)(451199021)(83380400001)(186003)(6486002)(2616005)(54906003)(478600001)(6666004)(6512007)(6506007)(53546011)(26005)(8936002)(36756003)(5660300002)(8676002)(7416002)(41300700001)(6916009)(38100700002)(66556008)(66476007)(4326008)(66946007)(2906002)(316002)(31696002)(31686004)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TDh3Ly9TRHFGSWI0aUJUTisrajJsd2w2cDllb0xkdGZ5MEM2enlmbmVJSXFq?= =?utf-8?B?UGZOSXVSU0JlSkJTN05LQ3FQRndrZHFXM2poSW1BVHVNQlRsaTF0L1FVaXk0?= =?utf-8?B?R09oK1F6UkZVV0hYTXZ0L2pCQUFwVUNHNFI0bko4L0Fjd3FOcjRkcDhPSkpJ?= =?utf-8?B?WEl0MVExZEN0ZXl0bWlHTFJ6R0xJa0FnL01Zc3JyLzNzbXpNOThZSGR3U05t?= =?utf-8?B?SjRudURPcnhKWStmQ0g2YUpoS1FtQjJZM3IvbEJTVU5NVnN4V290K2tteDFu?= =?utf-8?B?MzBzcjh6UmZjR2VYWG5IZm1CeDZ5c1MyUmNFUHBmM2xzUkVEdjJGZUkyNVA2?= =?utf-8?B?S29lMXlpSHdOWkMvQUgwdTNreHQzZHpranNobE9Rcm5LMnlGeGRzSnFhUitr?= =?utf-8?B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W2PR12MB2379.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 10:26:25.2769 (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: esYdwK7sbE1Tb/ApqWw67w5K/tODowfNRDKttOUNZZNgmbihZ8iyAG08XsYwpg04xEBVeaCymwoP/5SoSNwUuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4559 X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, 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 Hello Chenyu, On 5/18/2023 9:47 AM, Chen Yu wrote: > Hi Prateek, > On 2023-05-18 at 09:00:38 +0530, K Prateek Nayak wrote: >> [..snip..] >>> + /* >>> + * If the waker and the wakee are good friends to each other, >>> + * putting them within the same SMT domain could reduce C2C >>> + * overhead. But this only applies when there is no idle core >>> + * available. SMT idle sibling should be prefered to wakee's >>> + * previous CPU, because the latter could still have the risk of C2C >>> + * overhead. >>> + * >>> + */ >>> + if (sched_feat(SIS_PAIR) && sched_smt_active() && !has_idle_core && >> >> "has_idle_core" is not populated at this point and will always be false >> from the initialization. Should there be a: >> >> has_idle_core = test_idle_cores(? /* Which CPU? */); > Yes you are right, I have 2 patches, the first one is to check has_idle_core > in the beginning but I forgot to send it out but only the second one. >> if (sched_feat(SIS_PAIR) ...) { >> ... >> } >> has_idle_core = false; >> >> ?: "has_idle_core" is currently used in select_idle_sibling() from the >> perspective of the target MC. Does switching target to current core >> (which may not be on the same MC) if target MC does not have an idle core >> make sense in all scenarios? > Right, we should check whether target equals to current CPU. Since I tested > with 1 socket online, this issue did not expose Ah! I see. Yup a single socket (with one MC) will not run into any issues with the current implementation. >> >>> + current->last_wakee == p && p->last_wakee == current) { >>> + i = select_idle_smt(p, smp_processor_id()); >> >> Also wondering if asym_fits_cpu() check is needed in some way here. >> Consider a case where waker is on a weaker capacity CPU but wakee >> previously ran on a stronger capacity CPU. It might be worthwhile >> to wake the wakee on previous CPU if the current CPU does not fit >> the task's utilization and move the pair to the CPU with larger >> capacity during the next wakeup. wake_affine_weight() would select >> a target based on load and capacity consideration but here we >> switch the wakeup target to a thread on the current core. >> >> Wondering if the capacity details already considered in the path? >> > Good point, I guess what you mean is that, target could be other CPU rather than > the current one, there should be a check if the target equals to current CPU. Yup. That should handle the asymmetric capacity condition too but wondering if it makes the case too narrow to see the same benefit. Can you perhaps try "cpus_share_cache(target, smp_processor_id())" instead of a "target == smp_processor_id()"? Since we use similar logic to test if p->recent_used_cpu is a good target or not? This will be equivalent to your current implementation for a single socket with one LLC and as for dual socket or multiple LLC case, we can be sure "has_idle_core" is indicates the status of MC which is shared by both target and current cpu. > Let me refine the patch and have a test. > I'll hold off queuing a full test run until then. > thanks, > Chenyu > > [..snip..] -- Thanks and Regards, Prateek