Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4378329pxb; Tue, 2 Mar 2021 13:42:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPPFiy6ozCYGpNm/pAD+bp/2AJNmjDnPpGUurf6DhLIuHGiqq8irCrbO53BzEUg8CNcNyT X-Received: by 2002:a17:906:7c43:: with SMTP id g3mr22666051ejp.210.1614721356722; Tue, 02 Mar 2021 13:42:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614721356; cv=none; d=google.com; s=arc-20160816; b=rTLspp+3kRCCHZ5GiyM7o3ZiKbkq5L3YxLvAFzzqf70+xRAPfNNzT7kfV/PG5yrLZW GF8fDWcHh7I5N40W/xVgfeG4pMeLY3WNSOG52o/A1aF108rUM8THd5AC9plM6d4kjEKR P9A5T1yr6HLpv0n/z0+iV0t23HC0LJbOS0lS1bAUvs0o/8mhQEt5hlkYDuxlaLG18E2G Flko5wOkhob5Vq2SLeqW+GDfxddxEKCIME/I+VFH3sZTgDYUS58lQNJDVLJOBEjRXh2z weTGuvp9GwSc17yAHfl/v8CC2mPRvqA/2BLG6OVuWWikzNXWcQTgleZbhzRdty305yjh zXQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=RnkqKw7K20MtuChf63otEzPNbikS7ixvr2ZNwPhiGjs=; b=JOzNlekVy/y2D1LX0pJH5T/kpiKhHarP+wscyslzgtT17tnAldTEpvI0hh3Hx0iZ8Z ztFE0nIxxhD/PiVkNO6z+z3c5WhSO3R/mS32hWDEcV7LRXBmj6yiHtZNNTxk+X/4SiqZ MM6l56QxpP6XPRVumhHMVSAlTZ1bEsUNVPVnAzil7HRlA7vS5cd+joVznXskw4ICDjmT C3ejlWK1WU+yZbkGVzzQROODNPdKbOnADkbJhcZn2nQOAmZMxvo8WMkya5EcGW20CHVH 3k7t+ugyCWV08PrEkJiGsMDNjtgWoH2MN291lcsCaV3Fuf49+hg32+pBLnSXmL1wVXvf wttg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si9307388ejh.211.2021.03.02.13.42.12; Tue, 02 Mar 2021 13:42:36 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378980AbhCBKFR (ORCPT + 99 others); Tue, 2 Mar 2021 05:05:17 -0500 Received: from foss.arm.com ([217.140.110.172]:47644 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1577798AbhCBJyF (ORCPT ); Tue, 2 Mar 2021 04:54:05 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3430EED1; Tue, 2 Mar 2021 01:53:18 -0800 (PST) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A3EF3F70D; Tue, 2 Mar 2021 01:53:15 -0800 (PST) Subject: Re: [PATCH] sched/fair: Prefer idle CPU to cache affinity To: Srikar Dronamraju , Ingo Molnar , Peter Zijlstra Cc: LKML , Mel Gorman , Rik van Riel , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Michael Ellerman , Michael Neuling , Gautham R Shenoy , Parth Shah References: <20210226164029.122432-1-srikar@linux.vnet.ibm.com> From: Dietmar Eggemann Message-ID: <19bfd781-05f7-b220-d8a2-fde8ea2d9959@arm.com> Date: Tue, 2 Mar 2021 10:53:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210226164029.122432-1-srikar@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/02/2021 17:40, Srikar Dronamraju wrote: [...] > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 8a8bd7b13634..d49bfcdc4a19 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -5869,6 +5869,36 @@ wake_affine_weight(struct sched_domain *sd, struct task_struct *p, > return this_eff_load < prev_eff_load ? this_cpu : nr_cpumask_bits; > } > > +static int prefer_idler_llc(int this_cpu, int prev_cpu, int sync) > +{ > + struct sched_domain_shared *tsds, *psds; > + int pnr_busy, pllc_size, tnr_busy, tllc_size, diff; > + > + tsds = rcu_dereference(per_cpu(sd_llc_shared, this_cpu)); > + tnr_busy = atomic_read(&tsds->nr_busy_cpus); > + tllc_size = per_cpu(sd_llc_size, this_cpu); > + > + psds = rcu_dereference(per_cpu(sd_llc_shared, prev_cpu)); > + pnr_busy = atomic_read(&psds->nr_busy_cpus); > + pllc_size = per_cpu(sd_llc_size, prev_cpu); > + > + /* No need to compare, if both LLCs are fully loaded */ > + if (pnr_busy == pllc_size && tnr_busy == pllc_size) ^ shouldn't this be tllc_size ? > + return nr_cpumask_bits; > + > + if (sched_feat(WA_WAKER) && tnr_busy < tllc_size) > + return this_cpu; > + > + /* For better wakeup latency, prefer idler LLC to cache affinity */ > + diff = tnr_busy * pllc_size - sync - pnr_busy * tllc_size; > + if (!diff) > + return nr_cpumask_bits; > + if (diff < 0) > + return this_cpu; > + > + return prev_cpu; > +} > +