From patchwork Fri Feb 23 15:57:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 205482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp673847dyb; Fri, 23 Feb 2024 07:59:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVuelQsxok2YKHpnPLN00QKASNA1allOsof2qdkwxOl2qUlg/Zm0zZl1CXcBXZBvFBQlHMazse2YExr24TYTROnS3YBqg== X-Google-Smtp-Source: AGHT+IExwy4ZFKl4mWINZ2Tx4GJaGBo1lalzDx+K8IYUuaIojsAn7zBvmxlyT5GfIkDTbX8oSYYv X-Received: by 2002:a37:e202:0:b0:787:1635:1dd1 with SMTP id g2-20020a37e202000000b0078716351dd1mr215813qki.68.1708703983049; Fri, 23 Feb 2024 07:59:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708703983; cv=pass; d=google.com; s=arc-20160816; b=AAc0Heyl7ic/yAljvK2gm0b8gaUAxScRKHC++9QEVihFsDbIeOH6oK6hYhd7DU2J1c 0ktnKInyc5ypTm/WMmWebhJu/HmRxk3VdGug5p6pPhvf4UOHXeDyBktID5aGEpj2glw9 NRmobwa9ge5A9M5sOe1w8qfTT3NZIH57f8wPIxaxuNae/vpsRH3iKJRvWk0nZmwxbxzw ogme/ejgpxYn+WwYZr/MRV2gmpU1sRV8Zju8YQMullWE2ttpzQtNhicczmHA61SQ3lEx TCRp8DsK4/NxD/pS/iNS6TGsWAgNhh+kXeabhKA7kWVAfUypeE3vh5tlfHvJ3X5Lm2+p q1nQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a4BYLr0MWlji1r8Yd3MAsjyyUgmFtEg5Rxw6JJBPkks=; fh=ROTDl0s9ELwKo5cutDBzeKVm4oVxUeHhHeHvP/bi5yc=; b=WimSKXR2LEEId2puX9pz1teGW9jrZ3fxwjIQgt2n8wCEZTCJ9aPPWz1Hy6cLUR8D7G 8gyPy2G64U+ucxLMfAeQT/OLW1L4Qlpw4/skLLBJZ7u107dcKk2MSMee0aqtjvkVjoOg fjPqjp7hzgi1NjmOTWjcAurrJqmKo9sKZf4RToC50ymQL5n5hfVNw4rk+vbfnqp7DMCF hdWQ3N/4/NW7gEkyM4VccmxlAP3jqfgjvVD6R07AJODYAlF6k4wWK5q8STdKPyNxHWFs ZAGldaUFA7tRhdPrVVBCTQhNDzgcAiMF5efHYMQuUqKBoNsrHczXIQDfe1cyLeJZgXsm 8/yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=YXeyTTYw; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-78657-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78657-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dz6-20020a05620a2b8600b00787ba3f52e7si586099qkb.648.2024.02.23.07.59.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78657-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=YXeyTTYw; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-78657-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78657-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D24A01C25051 for ; Fri, 23 Feb 2024 15:59:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF3AD126F28; Fri, 23 Feb 2024 15:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="YXeyTTYw" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2958C84A29 for ; Fri, 23 Feb 2024 15:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708703899; cv=none; b=QSDTCf8wZ51I0jSL3SNlFraJZtq5s6egVvXSbx4GmkNVxn9k7MnCS6inNMZOTh/kih5bCrjm7gYG/+slVwDZsCj2DHQg/9au64BntFekCKrEx+Jv2mnu0yd6uk1ycrLWRJK/cThszNcMUCPXeTrz1tFecjks2fHPb/uMV5Zp9Co= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708703899; c=relaxed/simple; bh=verFB4RWW2WKHBdwnW5wGBh0OHUpCbgBY9nBGkAThvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T+/TSi/c8T0BLnowkF+03lsaDEVBRKmIDtYho0vstoibOSkFxuj/YSAV8Ad08jrO0YeW6k/+r89XpR0E1JT5Gdr6z/G6w5FuRtGQJ2g6WwRWx8spaIFLQ+O9cW2rHito+B/UgDkkNRXeCKLtebiYsyaFuJCcyo1gO/p7oFEoxUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=YXeyTTYw; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a3122b70439so82802966b.3 for ; Fri, 23 Feb 2024 07:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1708703896; x=1709308696; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a4BYLr0MWlji1r8Yd3MAsjyyUgmFtEg5Rxw6JJBPkks=; b=YXeyTTYwcoIAVJ/AeTKf+QibCFXJOubNU7kaqapP71SJhPdcorEKY1IFP0Ddu60xGo hLARODPjotg1kUiHZStUtlRRis+HWyJf5tURVyL1hiij6KoYzDLqLtuYN51k2aD7Fsju DPyVMFmIGcPv3Yns6nLp876sOIFaIPiOeUZ3pjMUhbiPXu9CXcfqDpuFBIYvmdp7G/7N hKsTUNO1Pd+/q+95NV3F9JNo4T4P7B2voPy4woGEzqJfWK37vFMmOMEMdxnMxduMzO4M 8uC68yqumtsB3nmEJq530KwSg80oecc9VmK0ByuegrZM8EHzQPGxwmFF1RoUjvqStonJ 1HNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708703896; x=1709308696; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a4BYLr0MWlji1r8Yd3MAsjyyUgmFtEg5Rxw6JJBPkks=; b=qafiseHB60G5Qz2c0C8Qp7Q4ECfABScNa5AENNunxfYPWjbZFuvoN4lLR8DRnCE5iT j4f87IWIbe5jGa3jHQXzeUaLoL8cDbThyphmJxkbdXWYPra8UtVJqtdtR8zFY/X3iWLZ gP5IlD0wjKT+AO7qHITTN/zK6xf0oSiYNAFLrWDSxa2MEktpgUlPDedMKsd3gADgi+Gd JC26wM2G2juRpuNk7yEnw1Y/6DLtm4YeX43pkUz6cOFArw953Ap+yB54UJTtHOn0EYvW VBODDxThJwAdZUqr9JVPW4gXa69mpPyJHQ74t9284lxnddnEWLpMH1Ym5+duZt2ZOPlJ uxEg== X-Gm-Message-State: AOJu0YzSMSMxeBX6KX25ZYxVr1XlKtMfNYp+iJexFPCPGIr85Gx8lUA6 bDLcVxoDvzCe04+N5KAfvjKevB0m4MlpQEG9zybQgtuGHBow353YOkOdPLkb7xk= X-Received: by 2002:a17:906:cec5:b0:a3f:6ff9:6280 with SMTP id si5-20020a170906cec500b00a3f6ff96280mr137907ejb.50.1708703896578; Fri, 23 Feb 2024 07:58:16 -0800 (PST) Received: from airbuntu.. (host109-154-46-208.range109-154.btcentralplus.com. [109.154.46.208]) by smtp.gmail.com with ESMTPSA id rg8-20020a1709076b8800b00a3e28471fa4sm6461293ejc.59.2024.02.23.07.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:58:16 -0800 (PST) From: Qais Yousef To: Jens Axboe , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sudeep Holla , Wei Wang , Jaegeuk Kim , Bart Van Assche , Christoph Hellwig , Qais Yousef Subject: [PATCH v2 1/2] sched: Add a new function to compare if two cpus have the same capacity Date: Fri, 23 Feb 2024 15:57:48 +0000 Message-Id: <20240223155749.2958009-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223155749.2958009-1-qyousef@layalina.io> References: <20240223155749.2958009-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791705987622676057 X-GMAIL-MSGID: 1791705987622676057 The new helper function is needed to help blk-mq check if it needs to dispatch the softirq on another CPU to match the performance level the IO requester is running at. This is important on HMP systems where not all CPUs have the same compute capacity. Signed-off-by: Qais Yousef Reviewed-by: Bart Van Assche --- include/linux/sched/topology.h | 6 ++++++ kernel/sched/core.c | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index a6e04b4a21d7..11e0e00e0bb9 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -176,6 +176,7 @@ extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], cpumask_var_t *alloc_sched_domains(unsigned int ndoms); void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms); +bool cpus_equal_capacity(int this_cpu, int that_cpu); bool cpus_share_cache(int this_cpu, int that_cpu); bool cpus_share_resources(int this_cpu, int that_cpu); @@ -226,6 +227,11 @@ partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], { } +static inline bool cpus_equal_capacity(int this_cpu, int that_cpu) +{ + return true; +} + static inline bool cpus_share_cache(int this_cpu, int that_cpu) { return true; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a76c7095f736..adbaabb23fa1 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3953,6 +3953,17 @@ void wake_up_if_idle(int cpu) } } +bool cpus_equal_capacity(int this_cpu, int that_cpu) +{ + if (!sched_asym_cpucap_active()) + return true; + + if (this_cpu == that_cpu) + return true; + + return arch_scale_cpu_capacity(this_cpu) == arch_scale_cpu_capacity(that_cpu); +} + bool cpus_share_cache(int this_cpu, int that_cpu) { if (this_cpu == that_cpu) From patchwork Fri Feb 23 15:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qais Yousef X-Patchwork-Id: 205483 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp673993dyb; Fri, 23 Feb 2024 08:00:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVKm8jWhkTEaOoqZo7yMIvXrP93rJ13UH/uopR0T3IaHeI6Z6mpp/3vUz2wju7jSFIpBufUvM4faG40cZUHn8nwsCMxiw== X-Google-Smtp-Source: AGHT+IHJr/RIztbK4EvQr1N5wX4hHFN8CkHD636zXrBATBTx9dp+c1DiiiOMIdFH0WEAGrRmqhAX X-Received: by 2002:ac2:5388:0:b0:512:e8eb:f978 with SMTP id g8-20020ac25388000000b00512e8ebf978mr132472lfh.4.1708704000005; Fri, 23 Feb 2024 08:00:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708703999; cv=pass; d=google.com; s=arc-20160816; b=Qk982hLIAUoglnEuZkxGB4s4u5EyqvxHZTOnIr7OQKI/oUT2zOqv5cQPVM5d8GNlnW ylE8puJo0iXeQyw9be0/77sngsGny2RNMO6ILEa3IcPCShIuZPhjEGdynGSZXDrdz9DJ jq4PRf0QL84vY+who2KW/D4F5qTkZXg4itB4Xias5zOGhA42HzDR2Rwy6oY5GFsHj8g+ HDkuu122Yw5qXQIW10HsAWaHOENE3H6l6B6nrNnclkdWjYSBSbCB8l0aTdxFgi7DsBtR Pimjd4F2t5gvl+LTwss6GYKfEiFpIideHR2vxb5u3c4XtYAGYV7GgNdytBanaXUegQTJ wMJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qXt+HI9wwNeUARCoHPWGtfsHeSRaQT3zlVaUv+U3mfk=; fh=ROTDl0s9ELwKo5cutDBzeKVm4oVxUeHhHeHvP/bi5yc=; b=KtszOtQCkWFJfB68sgv4t9v8ynrSQb172lFhbHg5F+BYV4eQ7SnCvi8Q8UE3csxvGY UJx/z5gq2FDSA4dvFZP2M5OGqjG5PO2/jONcLbQaLvlgdq0ThPtcwA/G9BKlT4wOe4TR rnGXAlOFZHjrGLU9bfjy94AtF1UeyOMkLcnPf2JVLJZyAx/wQnjKTM0Jl/TYAxzD6Tz1 zPPA6FtMh8hjscFn7K+uPjmXM382TOxIMT/zgTyC8DbyQEMgvUD2PsS0RHmMKFhnpxDb kXelkvHD9KyflCHrT2nrc+r7SgFbWBQR49DZ7lFv3vfMgya0RS83+gnKsfqqrvUz56zQ Xavg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=0Xtqqb8+; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-78659-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78659-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lg4-20020a170906f88400b00a3e40f8ea26si5388608ejb.18.2024.02.23.07.59.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78659-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=0Xtqqb8+; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-78659-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78659-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 70D5D1F265F5 for ; Fri, 23 Feb 2024 15:59:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DA701272CE; Fri, 23 Feb 2024 15:58:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="0Xtqqb8+" Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CF9D84A37 for ; Fri, 23 Feb 2024 15:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708703901; cv=none; b=jrTL9TrTlLafEQami8487i7VRFyhiwckYCUHBEEWW0dffgxoq6VKOi9lsTPLg0f+PyChBP8o9WGe7rMpKS1cpQapAUdpiHH7W5bBgJwWPzXcctTa9IRKOZ2GkcRUPn5wt1JH4ZwvIM4HxpNlet8xjqruQJ9mrAn6uo7DqeRhSB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708703901; c=relaxed/simple; bh=yubuTyPGf4bTd9nBZMSBW040fOuvUEmyH1Rqt46p1Gg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D6Yo03b7RUx67M8puvaCoVAXrfJQ2n/E9BPVU4NZpEg3xGkTxGh68d2Tnk1JyCIuwxoPRYloxsb/q6YbTl0mow6DzU4wqNu9xBWXORUuuMyZpfuOtJVR/bpJ9wxIE8PLcZ6vHsPvtrrI3uD7a5sV0yL9HZ8edExOw6xE0zC9txQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=0Xtqqb8+; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-564fd9eea75so716391a12.3 for ; Fri, 23 Feb 2024 07:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1708703898; x=1709308698; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qXt+HI9wwNeUARCoHPWGtfsHeSRaQT3zlVaUv+U3mfk=; b=0Xtqqb8+1zh8fzxoAxgMsPFrlvjISu+kE0AAhHVeLbU66BwuGySpbxEr9+LaNaaMJw TyShQQmia0rEE8Ig+wKKIuylGo0GJrxhrjuZXQ8vNfwgdR2OMYOUuLaymqHpxAXBk32i WxWcxxEZ7fmemoy+/3ODYupkX/ya09/lJYl8onuJdyQS+Kz25EruH2zG9c+Y8F1zWCUJ Qq6W/LTMC1ctjy6qDATiDVC7zTrv73PldMsuBg5s1w5+MSHZea1plIP6FwmVRtxupTPA /QAEReDjHuc/GUa6jDuavtWEzzMqUcSn+b6iZY4/+B2p1/pRpYCxUY08U+4AroBBYsZI v/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708703898; x=1709308698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qXt+HI9wwNeUARCoHPWGtfsHeSRaQT3zlVaUv+U3mfk=; b=fbtVhVvpoeK0yQcG/VRzDLoT+ierqGG5K2+wk+aZQNk6bezMZafFsNR2NLVV9sj3/v dMJ2EZB+IU+smmYJr3W7incgZvSmj7kVU4Bo6Mqaj64e/Cdg0O6C1gOo3B03DJRBbd6G G9K4Hxo/J8BGUBaELpqjCDyH5N65Nu6bBjIFGpPSJjEyVrYe9TFqAHcUN39agN8tdC1B wcxbHCdKM9d5Tz1BymwEgaAhCDJwVtyKOvUD+6/XL1ZYrIUyjzE9HlYt8cwyYw3sylbt xeRYwHyVLWDaedfEuFBpzlnq7FKEeKlAx5814IKPiZ/Kz04LbJ5Ej9wf9XSjRJfTgdri wAvA== X-Gm-Message-State: AOJu0YzYMTrQPJ6ExnE1grXyLNBXb1KJpkRqgpph5IHDqFwytCNJWeqK OMeJZpslJUFZPeynfjzRJKfuFlEfnaO5RdNRZj6eWzWa5oH32turpbx6SulNOw0= X-Received: by 2002:a17:906:3787:b0:a41:db75:7642 with SMTP id n7-20020a170906378700b00a41db757642mr70403ejc.37.1708703897542; Fri, 23 Feb 2024 07:58:17 -0800 (PST) Received: from airbuntu.. (host109-154-46-208.range109-154.btcentralplus.com. [109.154.46.208]) by smtp.gmail.com with ESMTPSA id rg8-20020a1709076b8800b00a3e28471fa4sm6461293ejc.59.2024.02.23.07.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 07:58:17 -0800 (PST) From: Qais Yousef To: Jens Axboe , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sudeep Holla , Wei Wang , Jaegeuk Kim , Bart Van Assche , Christoph Hellwig , Qais Yousef Subject: [PATCH v2 2/2] block/blk-mq: Don't complete locally if capacities are different Date: Fri, 23 Feb 2024 15:57:49 +0000 Message-Id: <20240223155749.2958009-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223155749.2958009-1-qyousef@layalina.io> References: <20240223155749.2958009-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791706005290209557 X-GMAIL-MSGID: 1791706005290209557 The logic in blk_mq_complete_need_ipi() assumes SMP systems where all CPUs have equal compute capacities and only LLC cache can make a different on perceived performance. But this assumption falls apart on HMP systems where LLC is shared, but the CPUs have different capacities. Staying local then can have a big performance impact if the IO request was done from a CPU with higher capacity but the interrupt is serviced on a lower capacity CPU. Use the new cpus_equal_capacity() function to check if we need to send an IPI. Without the patch I see the BLOCK softirq always running on little cores (where the hardirq is serviced). With it I can see it running on all cores. This was noticed after the topology change [1] where now on a big.LITTLE we truly get that the LLC is shared between all cores where as in the past it was being misrepresented for historical reasons. The logic exposed a missing dependency on capacities for such systems where there can be a big performance difference between the CPUs. This of course introduced a noticeable change in behavior depending on how the topology is presented. Leading to regressions in some workloads as the performance of the BLOCK softirq on littles can be noticeably worse on some platforms. Worth noting that we could have checked for capacities being greater than or equal instead for equality. This will lead to favouring higher performance always. But opted for equality instead to match the performance of the requester without making an assumption that can lead to power trade-offs which these systems tend to be sensitive about. If the requester would like to run faster, it's better to rely on the scheduler to give the IO requester via some facility to run on a faster core; and then if the interrupt triggered on a CPU with different capacity we'll make sure to match the performance the requester is supposed to run at. [1] https://lpc.events/event/16/contributions/1342/attachments/962/1883/LPC-2022-Android-MC-Phantom-Domains.pdf Signed-off-by: Qais Yousef Reviewed-by: Bart Van Assche --- block/blk-mq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 2dc01551e27c..ea69047e12f7 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1167,10 +1167,11 @@ static inline bool blk_mq_complete_need_ipi(struct request *rq) if (force_irqthreads()) return false; - /* same CPU or cache domain? Complete locally */ + /* same CPU or cache domain and capacity? Complete locally */ if (cpu == rq->mq_ctx->cpu || (!test_bit(QUEUE_FLAG_SAME_FORCE, &rq->q->queue_flags) && - cpus_share_cache(cpu, rq->mq_ctx->cpu))) + cpus_share_cache(cpu, rq->mq_ctx->cpu) && + cpus_equal_capacity(cpu, rq->mq_ctx->cpu))) return false; /* don't try to IPI to an offline CPU */