Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2626647rdb; Tue, 12 Sep 2023 07:34:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGj74vDpBjRi58Xz+R65IuZb4vSB4hXWHB+SsAme/Pfc4QEx8TryYbWK11xaDoAtAUCT6kS X-Received: by 2002:a05:6870:d60f:b0:1b0:2f63:4ff6 with SMTP id a15-20020a056870d60f00b001b02f634ff6mr15715257oaq.1.1694529297082; Tue, 12 Sep 2023 07:34:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694529297; cv=pass; d=google.com; s=arc-20160816; b=AKjwEGWNpDHC4petk3SfNpKB53aYR0+xmjHHHhzmydupS3aE2kzUaoOZj6JbnmK7Y2 8K5QbPWfZXQZPZsV1nHXRPjN94qDj0tvDvw0aBp6p4Lm6a5rOWM/oVM4w4YfCA7y8CCc i5rCTMN3gQ4bt/2C3TPDO5FuBRdt+5gxq8WQHh6XrQhKU7XRkwX9ckl8sElLBc4NdsNg /0CDCXfG4Y/8hJ4kw8gNmvaMGQ9otn3v+ev38ELnWLLGYssCh2uiwEVa3QKGpxl0vfjH LjE/oougZdpVa2UceSOv/GDJzrdWmI1DxP2SsgAyUnW60eFK2joNHfVgybJz7lzyC7yC OXag== 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=hDX0EkvdohX8eBsvKm2QiQU7TSdJTQRKei8+kwPGRO4=; fh=7TmCBLaX/TCVz++vuZUfyIofbYH5gAq9GecKbfmoxHk=; b=elvWouwhwI0Rr9+RHf/F2JhVK69i2FrknNaPBG0nU0gMaXMdvVWBtqKPsDt5SMq85H X6nnYpmZlqv+1T0xZH3Pex5YV0bvqqYWFZSwr1z0r/gk21J/wPag/KWm/r7bymvcmhkl xjScVTllvS5O6hWO+xW3g5vHO6Jr8eEh4OcRJg7suqwSX0gl7ncBbfQGoA+gnbiIKcEa sjYYfx6E4uB90p3wrEB8G6Lk62MZjDkvqQgP4/SZTjqTT0znfI6Dgud8DAaFQaaUW+Xd 2akcM9SocyiQWJzk4KiwttwjkwmwVoit1gKRMiPuM75bQ5+iFrXHklEdBRHvBTyEAlGj h6DA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=aCFXfTnF; 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 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i6-20020a639d06000000b00565eb0b379fsi1991042pgd.436.2023.09.12.07.34.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:34:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=aCFXfTnF; 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 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 48AF88220127; Tue, 12 Sep 2023 07:27:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233444AbjILO1M (ORCPT + 99 others); Tue, 12 Sep 2023 10:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235934AbjILO1J (ORCPT ); Tue, 12 Sep 2023 10:27:09 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E53210D9 for ; Tue, 12 Sep 2023 07:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VKisALyqVtizQ+78b0riLTelD9ptYXBobGGdftJNdGEEpHalte7ovAhFPqwYfNacPHaVBRMIlwhckab9KUJQts/c5+HkWfgDnJrqB4CQs76LxR9bw2A7q8KMb908j5qAG4Ds3zLcQ54GUYOacQjozMKCw2jJG8wg3bcPECXxnYK5WEs4aPc9741MGb1JwSNKUReuUZUO9r3odEtpQevsUGLKUUPjSKRFqEp0jKhM0uPpOcqSxs/yTYO2e92lNOKsqbCwrzM7WnM1EOVkpPsvTS97QMSY+i76uIYTM3y6TNfqANCFT8kIP/ss87l2XHTODoHXWJ3taWLqHY8plMzr8w== 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=hDX0EkvdohX8eBsvKm2QiQU7TSdJTQRKei8+kwPGRO4=; b=A3gA1BBf3Gox018+LPRo24oL5lZaNM1VwmmSZ+rYKcuyd1OK6zRn2Qiy7j2D6uHzdzpM8GDF+XWlk4IiL8TJLU0IhoJglDpsqfVdRwnTMRJfCcLnohZPzEB8qPo5fyLsakEcChopUlpVFd/g5PZygjHcPwgv+mPoMMhkBnHNb6gcmnQ/uEQZWh1HIkoyVHbjfD37GdWKgaDyBm3bNvHwPXGQkwpK1HkL84/+J1WawuqvQ62nW4RbzXfR4ay2zROFVYnnACXx9Vx/tKgnmBBuD2JuBeyXpvHbuya+bvngADhjcubxJQiVVQIJpuo4gq5usWUCoCW/bMK4oRizMffLsA== 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=hDX0EkvdohX8eBsvKm2QiQU7TSdJTQRKei8+kwPGRO4=; b=aCFXfTnFtIJ1gcgeihAL0xn9rzz6Ob164SaqoDFyUDLYSZGW0S3W/caBrkCrBpAQ3kETJnrdzDdq6Rjt/ZdgnrUkjeDZtcqIwvRjDjeA7ep22/cWd18F9tc3j/qPfSB4Tf9O9jGz0VFA1/u6hC9fLBJ05itVavbwEZ3snaXdr+4= 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 SJ1PR12MB6266.namprd12.prod.outlook.com (2603:10b6:a03:457::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.35; Tue, 12 Sep 2023 14:26:56 +0000 Received: from MW2PR12MB2379.namprd12.prod.outlook.com ([fe80::319e:591f:38a0:6bbb]) by MW2PR12MB2379.namprd12.prod.outlook.com ([fe80::319e:591f:38a0:6bbb%6]) with mapi id 15.20.6768.036; Tue, 12 Sep 2023 14:26:54 +0000 Message-ID: <229069c1-3d61-53bb-fff7-691942c48d21@amd.com> Date: Tue, 12 Sep 2023 19:56:37 +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 2/2] sched/fair: skip the cache hot CPU in select_idle_cpu() Content-Language: en-US To: Chen Yu Cc: Tim Chen , Aaron Lu , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Gautham R . Shenoy" , linux-kernel@vger.kernel.org, Peter Zijlstra , Mathieu Desnoyers , Ingo Molnar , Vincent Guittot , Juri Lelli References: <31c910c2-717d-b86c-4e08-5c94383682e8@amd.com> <5b35ae2b-a401-2489-4b3a-a03e8284d138@amd.com> From: K Prateek Nayak In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MAXP287CA0001.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:49::13) To MW2PR12MB2379.namprd12.prod.outlook.com (2603:10b6:907:9::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW2PR12MB2379:EE_|SJ1PR12MB6266:EE_ X-MS-Office365-Filtering-Correlation-Id: eb5ae4ea-b93b-4633-c4d3-08dbb39c4fec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yeo5Ba6IIQkBGUAZI45LX70ezw87RjnaqIILlq794AW2F3HASCyd8R6bSvITv/SCMpK0Fr6rczhZxYLEnuUo/bCQbaIwC1HL7IDPVECbh2NqJa0XiESInLw1bkCBQQzjvhHJSnJrTelxMwfBpP8aipFAjUelEToqXXL+IjBKi0ZDUp4tRpaNtcth+1zdSfRhFEqxt5UBs6gMln9F4T67/wR2VtI3hrNxps1r4GV9UOOFPDes+oFzHCKHKymdFnBdC3QKjQHeIw2yKiHS69d7ep+mVIiC9niYf6FCzmf8lpMOplfmIe3VxNHb5A19DZXX7I5l7TJm1ddJB8TbrhgxnDRGdxZK+Wt+AU3BHjDaWNkb8JkzAjqkNKBolVWTJTR57Z6AxeoQ1uLMvBEnloDF0cXWETcSTaYa5rSwGSf8ePUj0Y8OkBZBRD3Cjr0b2XhemLkF4q5d/jS0p1LBYIFVsCnFlZGuQT1GEsfIohekvF+BUElg0s6RxIc/CbXjPNvi/YD5d/NDWNagBlGHHq3qzNybfD2HMitRMatD4/Gat5NOLPsg+4xGjuk1Gf0Cyxm5NUUhckjxvWWx5TCm5wYhODcY5Nkgo+W+rAuJ2LyDIyUJoxk93SGjsS71ZD54XAmHZ2lfIFnd5/IScqk2R0HZpA== 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:(13230031)(396003)(136003)(376002)(346002)(366004)(39860400002)(1800799009)(451199024)(186009)(41300700001)(31686004)(6506007)(53546011)(6486002)(6666004)(38100700002)(36756003)(86362001)(31696002)(2616005)(6512007)(2906002)(83380400001)(26005)(4326008)(7416002)(8936002)(316002)(5660300002)(478600001)(8676002)(66556008)(6916009)(66946007)(54906003)(66476007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N20vQ0NFVHBPS2EzejVvWGRONllhdGY4c2F6cFAvVStlVUo5WHN6WGoybVVJ?= =?utf-8?B?THlyMktjdEFUNGE2alNPMjNhMHVaWFEvKzdwOVVZZHc1MkRqOENaUVhrUHlH?= =?utf-8?B?dGtVa2tLeE5ENVRUMkU1NnJXUnVxZnBGYk9jVEpGMmFNSXRGVlNoR3hSa01P?= =?utf-8?B?bzNMWG5YSjZUck4wb2E2RjRaRnkyVFZ5bzJ4YXBxQzBFSnJtZTNUMitpSEE5?= =?utf-8?B?NUgwbGs5YnpjdG9obm5na1ArVGNMbzVCeXVWNzZ2c2tNaW8vekhXTW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VFCbFV2MUtvYlh1aW1kR00rb2JlS2p3Vm1pYXlnNkNFd2VJ?= =?utf-8?Q?pSgPNuE7yoh1/z+ub2zqJuV8B?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb5ae4ea-b93b-4633-c4d3-08dbb39c4fec X-MS-Exchange-CrossTenant-AuthSource: MW2PR12MB2379.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2023 14:26:54.2255 (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: 8UK20Ga+4U2MY3/90vBsNnMqKU1/wKN74Zfu4uNhf2bdOHWMvlLgDnVdLxONuQBi2AfdzCBIMSzrYqVsXdSoyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6266 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 07:27:11 -0700 (PDT) Hello Chenyu, On 9/12/2023 6:02 PM, Chen Yu wrote: > [..snip..] > >>> If I understand correctly, WF_SYNC is to let the wakee to woken up >>> on the waker's CPU, rather than the wakee's previous CPU, because >>> the waker goes to sleep after wakeup. SIS_CACHE mainly cares about >>> wakee's previous CPU. We can only restrict that other wakee does not >>> occupy the previous CPU, but do not enhance the possibility that >>> wake_affine_idle() chooses the previous CPU. >> >> Correct me if I'm wrong here, >> >> Say a short sleeper, is always woken up using WF_SYNC flag. When the >> task is dequeued, we mark the previous CPU where it ran as "cache-hot" >> and restrict any wakeup happening until the "cache_hot_timeout" is >> crossed. Let us assume a perfect world where the task wakes up before >> the "cache_hot_timeout" expires. Logically this CPU was reserved all >> this while for the short sleeper but since the wakeup bears WF_SYNC >> flag, the whole reservation is ignored and waker's LLC is explored. >> > > Ah, I see your point. Do you mean, because the waker has a WF_SYNC, wake_affine_idle() > forces the short sleeping wakee to be woken up on waker's CPU rather the > wakee's previous CPU, but wakee's previous has been marked as cache hot > for nothing? Precisely :) > >> Should the timeout be cleared if the wakeup decides to not target the >> previous CPU? (The default "sysctl_sched_migration_cost" is probably >> small enough to curb any side effect that could possibly show here but >> if a genuine use-case warrants setting "sysctl_sched_migration_cost" to >> a larger value, the wakeup path might be affected where lot of idle >> targets are overlooked since the CPUs are marked cache-hot forr longer >> duration) >> >> Let me know what you think. >> > > This makes sense. In theory the above logic can be added in > select_idle_sibling(), if target CPU is chosen rather than > the previous CPU, the previous CPU's cache hot flag should be > cleared. > > But this might bring overhead. Because we need to grab the rq > lock and write to other CPU's rq, which could be costly. It > seems to be a trade-off of current implementation. I agree, it will not be pretty. Maybe the other way is to have a history of the type of wakeup the task experiences (similar to wakee_flips but for sync and non-syn wakeups) and only reserve the CPU if the task wakes up more via non-sync wakeups? Thinking out loud here. > On the other > hand, if the user sets the sysctl_sched_migration_cost to a quite > large value: > 1. Without SIS_CACHE, there is no task migration. But that is in the load balancing path. I think the wakeup path will still migrate the task. But I believe there might be very few cases where all CPUs are marked cache-hot and the SIS_UTIL will not bail out straight away as a result of high utilization. Probably a rare scenario. > 2. With SIS_CACHE enabled, all idle CPUs are cache hot and be skipped > in select_idle_cpu(), the wakee will be woken up locally. > It seems to be of the same effect, so there is no much impact > to wakeup behavior I suppose. > > [..snip..] > -- Thanks and Regards, Prateek