Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2146272pxu; Sun, 13 Dec 2020 15:29:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNUNRyrIWt9tFTWxWutgOThI9BJB8ZMRuvzof9KhS9rfIdcx3L9+mPjKSKmnZ6zS18Dgyr X-Received: by 2002:a17:906:bc9b:: with SMTP id lv27mr19912661ejb.505.1607902186366; Sun, 13 Dec 2020 15:29:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607902186; cv=none; d=google.com; s=arc-20160816; b=D7JJLqvE1/wnqdVC/Ia3a45QusXxBFu234SioqvD04ry2LSffS3JWDmIn82mJQtHe4 HJ8+cyIImHhzz00YwtWJkMZYk3PniyhT5m0KcSmh6JekS4PowJlnhtttWYHlgNGhpV8D aY12MT/tv/n9eQW0o5ueIH31S4Ks9Al8u5/2+a2DGfsGU3UJf6kRfqDL4d4PQcQrVOl5 zEr3AhwEhfjPN3a22F/ZIbUTJuxK//CZ3Awu5QJmS/iZL3dv2fIv2O9UAWpxYvzj2840 OeXYxhe+MB0RTQLhT0avaPwMHWkRL0CURkj1DQwHZBGtpqBuj7XCZ0fVd9KKEhKRQl8z sjYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l7ZKpJQnWVoGVG6S+pc/QYKZRm9QmpPrRjGbTbsRPyw=; b=vf2IjcOZtcRx5EyRdCDVCfclIRXfI2kiRKbjQxCmUKJrAlDqZzYE3AtAnhMD2e7+i3 Rk8oi1W350DQej/dG4SYVOTHUdMSglXC5ydrHqbfw9JYiQ1mJM3ZvboWn+p/2zFm6nIz FZd3Khkj5OgJEeGH53ZDdurT1bnvIseUTRMCXIn1++nXgBrh0uKJcTrUQ+QeG+UR3YnV 2HpcYJu4270FmPoXhbfWn/il7zPJb9QgmjOmi7WqPv9DBOPLw9D5dGszjJIvJYebN0sj F6DgxZXW+bcGTMogX6p5+oJBxilSy1b7szKPauLYJQTLb87CW4Db1D88Smonfnv8gLz/ 87qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nMJuCeab; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb13si8541149ejc.320.2020.12.13.15.29.23; Sun, 13 Dec 2020 15:29:46 -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; dkim=pass header.i=@linaro.org header.s=google header.b=nMJuCeab; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438556AbgLLKEO (ORCPT + 99 others); Sat, 12 Dec 2020 05:04:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438544AbgLLKDU (ORCPT ); Sat, 12 Dec 2020 05:03:20 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0225C0613CF for ; Sat, 12 Dec 2020 02:02:38 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id l11so17807089lfg.0 for ; Sat, 12 Dec 2020 02:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l7ZKpJQnWVoGVG6S+pc/QYKZRm9QmpPrRjGbTbsRPyw=; b=nMJuCeabxBC1WMnQHVVvn3pDb+Fgb/CLowajiM9lPWjO+z0Tyuo9ejIItA1T8ahLg0 QSGzrPBkrNJA/85ZvLFdANo1s8IPvo8lX1Eyzz1eu1+oxqCWBRmU3mVgcOU+F4Bz/ZzG b4hd2Ge/4dCnqioBxNcnXICIoYvtj2snMDc+QookxQwyI/6N+h7IPradDxiDkGfuihUP 8ZlcaG3WR+whRVSw5grgTdDb8ySKq0BPqL+DlvL0MYCiH4ZtXkKf3t1A8Qg1sUGzDlNX HlVls3GYQiIUCzt5ddguvyt8NubHPIfSeS777+dNO9paIbeRJ+lb9EflBxBn63eCciW1 /Jsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l7ZKpJQnWVoGVG6S+pc/QYKZRm9QmpPrRjGbTbsRPyw=; b=gcLZkQD6as8mPUxk3yKigbEpu1AyauaHGd6L/vMbY4dHvz6V5qZv203S2q2fvgYG4f iaWqtLW5i4P1Bnu9VTqe7Ecm7TvVJ+2JA+kynPRjTTNdQMS7uudZpoxDYBfWQ7EJht8v K3SRD+MwIaHFXSbcVRtgoksdhhzqHd0bjAEVkEmQjFDJ9rrCiq/DTA5qpLY2APin9owm +34QvzjxWi/rgiXHMSvEHEnKEhntnTYj8/Bi/sntKsn+Gzwkp2oauJBHEaJUJtpcrEhk K4Ah5091WmJeMS3TtcWOt+u8P7AhPD0IlUlw9Lhejvdq26gYoJRHyD2VA6fcU2j6EqIn g2rA== X-Gm-Message-State: AOAM530omzWHMtvgUUGDAwh4MFrUT2SEQl7y2EyHtlaZXviudnikZJQs XJua7z54cmgEGC73EbkONHdbTP/H8NeKrPn3nQhaXw== X-Received: by 2002:a2e:9913:: with SMTP id v19mr6538610lji.209.1607767357032; Sat, 12 Dec 2020 02:02:37 -0800 (PST) MIME-Version: 1.0 References: <20201208153501.1467-1-mgorman@techsingularity.net> <20201209143748.GP3371@techsingularity.net> <20201210110424.GR3371@techsingularity.net> <20201211102357.GW3371@techsingularity.net> In-Reply-To: <20201211102357.GW3371@techsingularity.net> From: Vincent Guittot Date: Sat, 12 Dec 2020 11:02:24 +0100 Message-ID: Subject: Re: [PATCH 0/4] Reduce scanning of runqueues in select_idle_sibling To: Mel Gorman Cc: Peter Ziljstra , Ingo Molnar , LKML , Aubrey Li , Barry Song , Juri Lelli , Valentin Schneider , Linux-ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Dec 2020 at 11:23, Mel Gorman wrote: > > On Fri, Dec 11, 2020 at 10:51:17AM +0100, Vincent Guittot wrote: > > On Thu, 10 Dec 2020 at 12:04, Mel Gorman wrote: > > > > > > On Thu, Dec 10, 2020 at 10:38:37AM +0100, Vincent Guittot wrote: > > > > > while testing your patchset and Aubrey one on top of tip, I'm facing > > > > > some perf regression on my arm64 numa system on hackbench and reaim. > > > > > The regression seems to comes from your patchset but i don't know > > > > > which patch in particular yet > > > > > > > > > > hackbench -l 256000 -g 1 > > > > > > > > > > v5.10-rc7 + tip/sched/core 13,255(+/- 3.22%) > > > > > with your patchset 15.368(+/- 2.74) -15.9% > > > > > > > > > > I'm also seeing perf regression on reaim but this one needs more > > > > > investigation before confirming > > > > > > > > > > TBH, I was not expecting regressions. I'm running more test to find > > > > > which patch is the culprit > > > > > > > > The regression comes from patch 3: sched/fair: Do not replace > > > > recent_used_cpu with the new target > > > > > > > > > > That's not entirely surprising. The intent of the patch is to increase the > > > hit rate of p->recent_used_cpu but it's not a guaranteed win due to two > > > corner cases. If multiple tasks have the same p->recent_used_cpu, they can > > > race to use that CPU and stack as a result instead of searching the domain. > > > If SMT is enabled then p->recent_used_cpu can point to an idle CPU that has > > > a busy sibling which the search would have avoided in select_idle_core(). > > > > > > I think you are using processes and sockets for hackbench but as you'll > > > see later, hackbench can be used both to show losses and gains. > > > > I run more hackbench tests with pipe and socket and both show > > regression with patch 3 whereas this is significant improvement with > > other patches and Aubrey's one > > > > Is SMT enabled on your test machine? If not, then patch 4 should make no yes I have SMT on my system : 2 nodes x 28 cores x 4 SMT > difference but if SMT is enabled, I wonder how this untested version of > patch 3 behaves for you. The main difference is that the recent used cpu > is used as a search target so that it would still check if it's an idle > core and if not, fall through so it's used as an idle CPU after checking > it's allowed by p->cpus_ptr. > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 5c41875aec23..63980bcf6e70 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6275,21 +6275,14 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) > return prev; > } > > - /* Check a recently used CPU as a potential idle candidate: */ > + /* Check a recently used CPU as a search target: */ > recent_used_cpu = p->recent_used_cpu; > + p->recent_used_cpu = prev; > if (recent_used_cpu != prev && > recent_used_cpu != target && > cpus_share_cache(recent_used_cpu, target) && > - (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) && > - cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) && > - asym_fits_capacity(task_util, recent_used_cpu)) { > - /* > - * Replace recent_used_cpu with prev as it is a potential > - * candidate for the next wake: > - */ > - p->recent_used_cpu = prev; > - return recent_used_cpu; > - } > + (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu))) > + target = recent_used_cpu; > > /* > * For asymmetric CPU capacity systems, our domain of interest is > @@ -6768,9 +6761,6 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int wake_flags) > } else if (wake_flags & WF_TTWU) { /* XXX always ? */ > /* Fast path */ > new_cpu = select_idle_sibling(p, prev_cpu, new_cpu); > - > - if (want_affine) > - current->recent_used_cpu = cpu; > } > rcu_read_unlock(); > > > -- > Mel Gorman > SUSE Labs