Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2140814pxb; Sat, 27 Feb 2021 11:58:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWYxLnw8PFSe4XwF6WqIc2Da2Rkp3d3+l5An3ra3eHAUIVvWEWXNFKEDa7CgjKA7x3l3M6 X-Received: by 2002:a05:6402:430c:: with SMTP id m12mr9488479edc.299.1614455896508; Sat, 27 Feb 2021 11:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614455896; cv=none; d=google.com; s=arc-20160816; b=BVSmicMsYk7CkB+cQubsohwUYQ3SCoi4Wc+vWwPMhedlSxvptI3BRwSx7ckBiQhaqn nvWF6//2JkLzSValbV11L9OYNvCVz2vNH7m49BOt0Og9OOh+JKtZp613rshMNSEup9p/ P0ngr8ocmjBIqyyUW+1HyvOTFqUx9eTnaEzRdTu4xE8P4vil2CAY1TEcWi2Fm45iRTav vgY2KoujqeiYzgAXJL8T5WxZ8hlrmPXATeafptIhVTSzn/4ikyGqK3DJ2mwmac8rdBBO /NBHpMvjlEE2TNjivbr7Iz7R4pP8dWpIzgffl7ODP+4luO5RliaDIUEchKQu4BSyc8cz LRww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=N2qyNgpT+13fb1tviarHVbligwuuz/UgtLuhaZGN5Fg=; b=RGhJbyrxxMLShdH0cytPNtOufdX1fDqz4kRB1RHTXuWBkQrT6dypygSj/RwfYzHRcb Me6XiqMtc+N8I9JtPnfJRiP5XksykuLg9uJ0lFF13n7lIR/43va1klPbP5g58ILl73j3 9X4fX27moolaOlbRD4l5fN3YVM2+jwHdxHIKedMr171Ij05jyjzgSW8jP/8yiph9kcSr z4KOFs/DMKwNaqv4rvdYvJX6PiGS4LTMShSnihYh/mHKZ6Bde+A62ca7yhVTgy+twoiy UMZSSviEcbgWA3XagXP/JjDwGL9okqAy4a7fh90+B1a3PeKSMbzKWaV/IpwXS/IAJ3aL E9Xg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si8031631ejf.641.2021.02.27.11.57.54; Sat, 27 Feb 2021 11:58:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230082AbhB0T5G (ORCPT + 99 others); Sat, 27 Feb 2021 14:57:06 -0500 Received: from shelob.surriel.com ([96.67.55.147]:40756 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbhB0T5C (ORCPT ); Sat, 27 Feb 2021 14:57:02 -0500 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lG5hA-0003pP-16; Sat, 27 Feb 2021 14:56:08 -0500 Message-ID: Subject: Re: [PATCH] sched/fair: Prefer idle CPU to cache affinity From: Rik van Riel To: Srikar Dronamraju , Ingo Molnar , Peter Zijlstra Cc: LKML , Mel Gorman , Thomas Gleixner , Valentin Schneider , Vincent Guittot , Dietmar Eggemann , Michael Ellerman , Michael Neuling , Gautham R Shenoy , Parth Shah Date: Sat, 27 Feb 2021 14:56:07 -0500 In-Reply-To: <20210226164029.122432-1-srikar@linux.vnet.ibm.com> References: <20210226164029.122432-1-srikar@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-p2iMuyud8R1l++kK4rlj" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-p2iMuyud8R1l++kK4rlj Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2021-02-26 at 22:10 +0530, Srikar Dronamraju wrote: > Current order of preference to pick a LLC while waking a wake-affine > task: > 1. Between the waker CPU and previous CPU, prefer the LLC of the CPU > that is idle. >=20 > 2. Between the waker CPU and previous CPU, prefer the LLC of the CPU > that is less lightly loaded. >=20 > In the current situation where waker and previous CPUs are busy, but > only one of its LLC has an idle CPU, Scheduler may end up picking a > LLC > with no idle CPUs. To mitigate this, add a new step between 1 and 2 > where Scheduler compares idle CPUs in waker and previous LLCs and > picks > the appropriate one. I like that idea a lot. That could also solve some of the issues sometimes observed on multi-node x86 systems, and probably on the newer AMD chips with several LLCs on chip. > + if (sched_feat(WA_WAKER) && tnr_busy < tllc_size) > + return this_cpu; I wonder if we need to use a slightly lower threshold on very large LLCs, both to account for the fact that the select_idle_cpu code may not find the single idle CPU among a dozen busy ones, or because on a system with hyperthreading we may often be better off picking another LLC for HT contention issues? Maybe we could use "tnr_busy * 4 < tllc_size * 3" or something like that? That way we will only try to find the last 5 idle CPUs in a 22 CPU LLC if the other LLC also has fewer than 6 idle cores. That might increase our chances of finding an idle CPU with SIS_PROP enabled, and might allow WA_WAKER to be true by default. > + /* For better wakeup latency, prefer idler LLC to cache > affinity */ > + diff =3D tnr_busy * pllc_size - sync - pnr_busy * tllc_size; > + if (!diff) > + return nr_cpumask_bits; > + if (diff < 0) > + return this_cpu; > + > + return prev_cpu; > +} --=20 All Rights Reversed. --=-p2iMuyud8R1l++kK4rlj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAmA6o9cACgkQznnekoTE 3oOwmQf5AcNEkODl1mcUA9dumuWDRBi4LvyhOEXhI2llLN9yZMzvNW9n/2rLLEX3 freYfyTjKB4reIXFydXQiHFOetlsudfgxszGYVroyXVse8IG0p+qxlVzc1Z/s8aO PFKu+wG9kShkA7LX4OaWFPCsnse3/eO3IEfPIbWyaMn8/+karmKBdtgqCCdEpAt8 rG5HWI5ta5dfpOvuFBJReBe+0vYLhCXvClMJeL4Hg+8eSlHuL6OOtGQ+NX7gD6Ma 500P1NrpsfY0QMSALfjaqr0fdw2aIexVk8nt3Pf/oMzwwdk9AEkq59ln7xzALriq Fez+fUFI5PlCkUyGow2YU9B1Cukeaw== =PQF9 -----END PGP SIGNATURE----- --=-p2iMuyud8R1l++kK4rlj--