Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp47091rwn; Wed, 14 Sep 2022 15:44:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iaHUb9Z6Fvo/olRK9Re/DHqAlkqxj26Q11ct0jFACWxlHFw9s4VLd2utoSZOm2xRAUOEB X-Received: by 2002:a17:90b:314c:b0:202:e840:d5a4 with SMTP id ip12-20020a17090b314c00b00202e840d5a4mr7376604pjb.230.1663195498493; Wed, 14 Sep 2022 15:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663195498; cv=none; d=google.com; s=arc-20160816; b=BPf41rIvVoDYvHVFXM48LmIAtp3U6yZO8xrmOdfRuuH55NnYpY3WrqB5QwO6GTz2xq 7Y9rC3bouO6DAMF8T85S4ryCjYwFpTnS7+q8cufx+t+7U0Hp3m/P5CYQIaBdIkbwvkGj uubHNhGWQC79xgSJvikWL6NB3hao0R10M4hDY7yTc5wqI2bxtLlg19s7omGduK3pPbUT PXasPzcRgt7TUp3sqZSG30MahZSLdWcDa1DYk+mSlqAsaKT7y/+Kg8l8wafssoQq1hG1 09bjKq8n4U/pQOx7uG8qD9JJBbDPsHZG+pqWaRcbUfYZgY9tZvXh0tK/F3xklQqV7+5n V/UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=6JaDS/CJ9IG21HzjFofwbyaBlvEHavCgwqkIjw8crZA=; b=XqonJMjhFXWxKTE1XHqIU2wBiAGpJpWPslEWh/F8ydbHyMoQKfsSg3uWr4xbfOLJpN 66ndHy1R7TXhCIHi6CGtisTzA8N1MATxnxRtiOTsYZHC6ElN0ZklDtYPvdeNcnepiang 0Zd4gcerE+wGFABNe7DGgMLdY20Gcmldx4ABQfaE4oOR8VzpjrEIp6H7rKq84W8IXty0 mO994r6IWVnmFETFMy/Nwy+JuCGpVlfO9Uk/f4U4mhtbiRiI7AqSEF4BKW8pYSaRgB6I RWwESI/SVkxvWfu7BCQH6q07bYyKcCqOkg6PN9HHAs3pORXfOy3W/GLvG7O+Voa3weoJ I6bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KFD83YRG; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a65604a000000b004390b3a6bbesi10602018pgp.546.2022.09.14.15.44.46; Wed, 14 Sep 2022 15:44:58 -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=@intel.com header.s=Intel header.b=KFD83YRG; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbiINWZ3 (ORCPT + 99 others); Wed, 14 Sep 2022 18:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiINWZ2 (ORCPT ); Wed, 14 Sep 2022 18:25:28 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7422F383 for ; Wed, 14 Sep 2022 15:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663194327; x=1694730327; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZWoUPTKc7sh+5Vp757SvvaQZEfQpLpxlC+kz3jiUxxs=; b=KFD83YRGgqd/P9ZW5mEtod/Ioe8LM4CubQs73DgWmjsbYKm5qop3DKGI zuhwBkgfsgg2qFsBVQVPP7EAzdGjoQFsenbWfPGJzGbt+M8NIAkmy6bOn v1SCD3HGMA87u96E7DvuP/KtRGQ830VJ4jAFDNgs2pOCebtefQTw0ZULA R16HyxMKAArYGW02yDV8NuNCE6kK12yxqWXIL+Wx4bSBr8aVBskjBtBzo 9wIgIo19ZE8/y3mGWECKlyWJDTi7/bmDK/7c4DLyU7AISi+K7l7QVdfEx 96HZIyUoU7DvSFi/fJcAmaix+bPOk3ILx9GYGmDl4T0uNlRW+7kQOWGzU Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10470"; a="298552926" X-IronPort-AV: E=Sophos;i="5.93,316,1654585200"; d="scan'208";a="298552926" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 15:25:25 -0700 X-IronPort-AV: E=Sophos;i="5.93,316,1654585200"; d="scan'208";a="650240132" Received: from schen9-mobl.amr.corp.intel.com ([10.209.26.213]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 15:25:24 -0700 Message-ID: <199f559267169850f2bcbca9a5df89df30aa168e.camel@linux.intel.com> Subject: Re: [PATCH v5 2/5] sched/fair: Limited scan for idle cores when overloaded From: Tim Chen To: Abel Wu , Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , K Prateek Nayak , "Gautham R . Shenoy" , linux-kernel@vger.kernel.org, Mel Gorman Date: Wed, 14 Sep 2022 15:25:24 -0700 In-Reply-To: <20220909055304.25171-3-wuyun.abel@bytedance.com> References: <20220909055304.25171-1-wuyun.abel@bytedance.com> <20220909055304.25171-3-wuyun.abel@bytedance.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, 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 On Fri, 2022-09-09 at 13:53 +0800, Abel Wu wrote: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 5af9bf246274..7abe188a1533 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6437,26 +6437,42 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool > time = cpu_clock(this); > } > > - if (sched_feat(SIS_UTIL) && !has_idle_core) { > + if (sched_feat(SIS_UTIL)) { > sd_share = rcu_dereference(per_cpu(sd_llc_shared, target)); > if (sd_share) { > /* because !--nr is the condition to stop scan */ > nr = READ_ONCE(sd_share->nr_idle_scan) + 1; > - /* overloaded LLC is unlikely to have idle cpu/core */ > - if (nr == 1) > + > + /* > + * Overloaded LLC is unlikely to have idle cpus. > + * But if has_idle_core hint is true, a limited > + * speculative scan might help without incurring > + * much overhead. > + */ > + if (has_idle_core) > + nr = nr > 1 ? INT_MAX : 3; The choice of nr is a very abrupt function of utilization when has_idle_core==true, it is either feast or famine. Why is such choice better than a smoother reduction of nr vs utilization? I agree that we want to scan more aggressively than !has_idle_core, but it is not obvious why the above work better, versus something like nr = nr*2+1. Tim > + else if (nr == 1) > return -1; > } > } > > for_each_cpu_wrap(cpu, cpus, target + 1) { > + /* > + * This might get the has_idle_cores hint cleared for a > + * partial scan for idle cores but the hint is probably > + * wrong anyway. What more important is that not clearing > + * the hint may result in excessive partial scan for idle > + * cores introducing innegligible overhead. > + */ > + if (!--nr) > + break; > + > if (has_idle_core) { > i = select_idle_core(p, cpu, cpus, &idle_cpu); > if ((unsigned int)i < nr_cpumask_bits) > return i; > > } else { > - if (!--nr) > - return -1; > idle_cpu = __select_idle_cpu(cpu, p); > if ((unsigned int)idle_cpu < nr_cpumask_bits) > break;