Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1726224rdh; Tue, 26 Sep 2023 01:19:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7Ol6zmuqUFMUhhA7OMnzCzafqoCYKt4V4g3p0uboCkHNPhm67VKlNv3yE0RPAqUuMT137 X-Received: by 2002:a05:6358:e49c:b0:143:9b25:c029 with SMTP id by28-20020a056358e49c00b001439b25c029mr14322700rwb.2.1695716395321; Tue, 26 Sep 2023 01:19:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695716395; cv=none; d=google.com; s=arc-20160816; b=fQDm1Wc1+nAvxZ/dj8/rPJOLEEYgBq7bUQKvwXczw91RBpOhKefGiA6qE62ydYDinH 7BKVwtUFLfgg/u2IDRD9zFFA3e2h/eKdlPm278WE/ROwRlZ/TU8Dpb+zeU0kTwo6NP+X otyjgGU5ePJaCgoGRFnakAGN8EN5WYbmWsSSDrwFCRhJyARE8l4zF7zhJ30Q+C1cKvmX lSGShxc/SfkYvX/nSNtm+ocxPny5u9ASMSoheLSj6C5e6h0T2tXsa6Cc9hKXy4g6gRPt vIpd/RCYHSa9vmz6X3lg1FuKDs01xJ/fwyMwuzhja8z53RvEva9pAkcR6fno5WSd/nlD XWnQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=sVKJWDlRXphNgqmykXPwc5CThiakbdhMYnD2mqMZB4I=; fh=k2Da3tdGwoTTGVnisHT5n9jOa+bFowxZWJ3Ziql+GyA=; b=G/RxPHMH6Csw3icAMPkxrUmi+Lp7x6doLBzOEW+lUnG0MlDZu0EKw/pxyhQtbHtzud UlwoM1Nxlw2FnDM2w45JR03hIY/hbzkZ26dSDfFHx8Sa2wLx+SAMlGhMD2za8tZQK4g0 mg3AM2Yq8H5LCS/Pj3W9OMVh2vt/jyzMaPVZRm92bgFIk0UOVb6R0ls37eI8ZqwsuQY8 jpatN50EkMuw/s3Snw8i2wieZqBhEv1FTxwCZ0H9UIhnDyOzOGYjBIXpHB4DtmkZqE32 rG/rle/qUf6MuJMbshMbiDqQPEooXHpx3v+5qZD+KSM+NEvCYRDQIP/Tf5m/eJ9VLDgE AqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="a/W2+Ajd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id e10-20020a056a001a8a00b00690bc2ac50asi12741690pfv.246.2023.09.26.01.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 01:19:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="a/W2+Ajd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3A2D98089853; Mon, 25 Sep 2023 22:11:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbjIZFLI (ORCPT + 99 others); Tue, 26 Sep 2023 01:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231549AbjIZFLH (ORCPT ); Tue, 26 Sep 2023 01:11:07 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C806B0 for ; Mon, 25 Sep 2023 22:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695705060; x=1727241060; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=IURD6yOAQKSnGHG4SzFBtCW0lCI8dfJfDlDAE12p3e0=; b=a/W2+AjdHdZBv2CAB8QeLbkWHTSdgmCnyIiJ6pUCh9AQw2hEAc7lXoB6 dgI/ECMWtql37uhGmqLihOw5/d31N216qdZ7d9Bzmcnco07PQyDQ+aJy4 313NGjcEttW47tjd9Wpiq2kOHQ2BrR8ltt7n87o+AoTDDr5v2y2UHOIND JafA0zFjFN0IUOlXV+R3tW0BylIU4YE3ecdzGFzY3ZBDkDF2hn7DL72N4 88tTew5xKJchkF136vibJC8cvwfq1ViOAE1QTH46TtkvKpVuOcw3cBDZE wVg+Xi9IjpI9O3Nt2GdWigWL+rka+F0T2ZZAP+hXLeCEWCVy6XcUcOANm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="380351347" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="380351347" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 22:10:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="742222883" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="742222883" Received: from chenyu-dev.sh.intel.com ([10.239.62.164]) by orsmga007.jf.intel.com with ESMTP; 25 Sep 2023 22:10:53 -0700 From: Chen Yu To: Peter Zijlstra , Mathieu Desnoyers , Ingo Molnar , Vincent Guittot , Juri Lelli Cc: Tim Chen , Aaron Lu , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , K Prateek Nayak , "Gautham R . Shenoy" , linux-kernel@vger.kernel.org, Chen Yu , Chen Yu Subject: [PATCH 0/2] Introduce SIS_CACHE to choose previous CPU during task wakeup Date: Tue, 26 Sep 2023 13:10:21 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 22:11:44 -0700 (PDT) RFC -> v1: - drop RFC - Only record the short sleeping time for each task, to better honor the burst sleeping tasks. (Mathieu Desnoyers) - Keep the forward movement monotonic for runqueue's cache-hot timeout value. (Mathieu Desnoyers, Aaron Lu) - Introduce a new helper function cache_hot_cpu() that considers rq->cache_hot_timeout. (Aaron Lu) - Add analysis of why inhibiting task migration could bring better throughput for some benchmarks. (Gautham R. Shenoy) - Choose the first cache-hot CPU, if all idle CPUs are cache-hot in select_idle_cpu(). To avoid possible task stacking on the waker's CPU. (K Prateek Nayak) Thanks for your comments and review! ---------------------------------------------------------------------- When task p is woken up, the scheduler leverages select_idle_sibling() to find an idle CPU for it. p's previous CPU is usually a preference because it can improve cache locality. However in many cases, the previous CPU has already been taken by other wakees, thus p has to find another idle CPU. Inhibit the task migration while keeping the work conservation of scheduler could benefit many workloads. Inspired by Mathieu's proposal to limit the task migration ratio[1], this patch considers the task average sleep duration. If the task is a short sleeping one, then tag its previous CPU as cache hot for a short while. During this reservation period, other wakees are not allowed to pick this idle CPU until a timeout. Later if the task is woken up again, it can find its previous CPU still idle, and choose it in select_idle_sibling(). This test is based on tip/sched/core, on top of Commit afc1996859a2 ("sched/fair: Ratelimit update to tg->load_avg") patch afc1996859a2 has significantly reduced the cost of task migration, the SIS_CACHE further reduces that cost. SIS_CACHE shows noticeable throughput improvement of netperf/tbench around 100% load. [patch 1/2] records the task's average short sleeping time in its per sched_entity structure. [patch 2/2] introduces the SIS_CACHE to skip the cache-hot idle CPU during wakeup. Link: https://lore.kernel.org/lkml/20230905171105.1005672-2-mathieu.desnoyers@efficios.com/ #1 Chen Yu (2): sched/fair: Record the short sleeping time of a task sched/fair: skip the cache hot CPU in select_idle_cpu() include/linux/sched.h | 3 ++ kernel/sched/fair.c | 86 +++++++++++++++++++++++++++++++++++++++-- kernel/sched/features.h | 1 + kernel/sched/sched.h | 1 + 4 files changed, 87 insertions(+), 4 deletions(-) -- 2.25.1