Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp210485rdf; Mon, 20 Nov 2023 23:40:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtA8gTQGzvlGGfNBY5nVYHUAgmhBChwVQLDCr+gfqmRtU9ZDHvfb6XKTYByAupHLzhK3MD X-Received: by 2002:a05:6808:38c7:b0:3af:d9ea:74b6 with SMTP id el7-20020a05680838c700b003afd9ea74b6mr5808595oib.43.1700552446477; Mon, 20 Nov 2023 23:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700552446; cv=none; d=google.com; s=arc-20160816; b=yanpDzfB315238xvKrfaPbhlGSz2GEtCME8bkqt4Yxp1Zp6uhAVzoToORX9fjC4mdd pnHz5zDo5xWKWpoM0qQs0doZ3JVTPA7s6r+13gYd6mhojzwY8ZwB9zPk/hboDd5vCSct G7eD87pRRduYXca2uiO7FubNpJd3ub40oEkdSE5k9n9xUukvXx7357JunceyX7jz3pWL p/32M1xwe/sUi9J1o22BZfoS8ePZ85wqJXI3X0w8ZOYtqPW4Q/u8P3NUMtXOs4TLyWdZ n4OA2K5AGfwKVKxHWXQPuTjvZsJIM92OTIy08fVGmWI2y1+ecWlqI0D6qCxsDA9QshVO 6xCQ== 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=2WaHbo5opQNO+MGUFx/OQLN8e/uAYLwUdV0Pq7O1x4E=; fh=0dOHTwLhZRcSeL1cn2LfAx4yZf5ptHxTdWpvFvnOHEs=; b=0JLVaf09DdAabFchkyLmkryXCCO0oh0WTbAoMzQlsWVVFaWhH+TlkGQCWKsbU3OsCk xdoMykpMLQr820hgxeYs77CUTW8pqgkzB//Alg1DQ0aAGxnW4FUKlUBlTwmk6WhXGftQ +MDvzcK9DM4UZyUi0NNXesX0bN1pg50ulKu+UpORb+5H/WwsgzZZ1u48/BFyTFgj94Tk 2ziGsFya+w0jYFeyyeVXdzcEVOQhIeGYKd4+Dmc8yYVhHqZqCwCSQ0pAtLOuB+f3HCmY V2iZDI4QKAcmKwSFZ+cn0vgRXAawHjCwDEoWuKPCg2atGqpJQV20nC0nrk06QPWAG3x6 SLdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Eg7ek/Hm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id p24-20020a63e658000000b005855f67e491si10042269pgj.696.2023.11.20.23.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 23:40:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Eg7ek/Hm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id A320A805AA0A; Mon, 20 Nov 2023 23:40:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229815AbjKUHkd (ORCPT + 99 others); Tue, 21 Nov 2023 02:40:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjKUHkb (ORCPT ); Tue, 21 Nov 2023 02:40:31 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D044C8 for ; Mon, 20 Nov 2023 23:40:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700552427; x=1732088427; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=qy5LvMXn9fulHhxgGbpRsXWBGv1kGPesnzfFG62n+wA=; b=Eg7ek/HmGcdGqBhTgzxU1+vRddlOkRs1CuUT5Kogro06N9JA6NxfIQRg y48hMLiO2k9pAdFTNgBCiU5OWc3tMx5rXejfHHvKKmOl+KKYHooFIyYJP FYR6Pg3Tqa+jOt5fsrMJaFSlP1HHhxwbN0G9W8UrTeMQsht0Vr1tNwczl xpf4lZcJ9AzwDeSF0Gd3HDyKCTIdJ6Qp4OUKiunCC7SqfGb6K1+1Jj9oy QRtNITH/gDnLfmtNTrBc9kpVWSOyn9DIju0ciufa/7TL+JfomeACWYCHS gduFI3Fih2GQvZ51yBsqKjuGTBSC4f5by8BY6LF9/e2+5Tp/yXf3OZv4L Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="376821651" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="376821651" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 23:40:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="884101975" X-IronPort-AV: E=Sophos;i="6.04,215,1695711600"; d="scan'208";a="884101975" Received: from chenyu-dev.sh.intel.com ([10.239.62.164]) by fmsmga002.fm.intel.com with ESMTP; 20 Nov 2023 23:40:22 -0800 From: Chen Yu To: Peter Zijlstra , Mathieu Desnoyers , Ingo Molnar , Vincent Guittot , Juri Lelli Cc: Tim Chen , Aaron Lu , Dietmar Eggemann , Steven Rostedt , Mel Gorman , K Prateek Nayak , "Gautham R . Shenoy" , Chen Yu , linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH v2 0/3] Introduce SIS_CACHE to choose previous CPU during task wakeup Date: Tue, 21 Nov 2023 15:39:14 +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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 20 Nov 2023 23:40:43 -0800 (PST) v1 -> v2: - Move the task sleep duration from sched_entity to task_struct. (Aaron Lu) - Refine the task sleep duration calculation based on task's previous running CPU. (Aaron Lu) - Limit the cache-hot idle CPU scan depth to reduce the time spend on searching, to fix the regression. (K Prateek Nayak) - Add test results of the real life workload per request from Ingo Daytrader on a power system. (Madadi Vineeth Reddy) OLTP workload on Xeon Sapphire Rapids. - Refined the commit log, added Reviewed-by tag to PATCH 1/3 (Mathieu Desnoyers). 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 the comments and tests! ---------------------------------------------------------------------- This series aims to continue the discussion of how to make the wakee to choose its previous CPU easier. 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 could benefit many workloads. Inspired by Mathieu's proposal to limit the task migration ratio[1], introduce the SIS_CACHE. It considers the sleep time of the task for better task placement. Based on the task's short sleeping history, tag p's previous CPU as cache-hot. Later when p is woken up, it can choose its previous CPU in select_idle_sibling(). When other task is woken up, skip this cache-hot idle CPU and try the next idle CPU when possible. The idea of SIS_CACHE is to optimize the idle CPU scan sequence. The extra scan time is minimized by restricting the scan depth of cache-hot CPUs to 50% of the scan depth of SIS_UTIL. This test is based on tip/sched/core, on top of Commit ada87d23b734 ("x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram") This patch set has shown 15% ~ 70% improvements for client/server workloads like netperf and tbench. It shows 0.7% improvement of OLTP with 0.2% run-to-run variation on Xeon 240 CPUs system. There is 2% improvement of another real life workload Daytrader per the test of Madadi on a power system with 96 CPUs. Prateek has helped check there is no obvious microbenchmark regression of the v2 on a 3rd Generation EPYC System with 128 CPUs. Link: https://lore.kernel.org/lkml/20230905171105.1005672-2-mathieu.desnoyers@efficios.com/ #1 Chen Yu (3): sched/fair: Record the task sleeping time as the cache hot duration sched/fair: Calculate the cache-hot time of the idle CPU sched/fair: skip the cache hot CPU in select_idle_cpu() include/linux/sched.h | 4 ++ kernel/sched/fair.c | 88 +++++++++++++++++++++++++++++++++++++++-- kernel/sched/features.h | 1 + kernel/sched/sched.h | 1 + 4 files changed, 91 insertions(+), 3 deletions(-) -- 2.25.1