Message ID | 1708092603-14504-1-git-send-email-ssengar@linux.microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp549228dyb; Fri, 16 Feb 2024 06:28:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFfga9Ut9uutFJWlz+ECCVz8Vi04c7Fc00ZyrkKMBJDNSitGokHW+C+cksW+jefKTEEm6JvjAdhhkEXRqV+p0Agm/mQA== X-Google-Smtp-Source: AGHT+IE1H0gB3ii+wncGV3wTMXYHjf5lZ4lGkgwNStWo9xsR9qypaH2pN9/OP6aEu+5j+3S2Ct/H X-Received: by 2002:a17:902:da89:b0:1da:1fde:8411 with SMTP id j9-20020a170902da8900b001da1fde8411mr11960909plx.34.1708093714781; Fri, 16 Feb 2024 06:28:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708093714; cv=pass; d=google.com; s=arc-20160816; b=k4UN3vUXdzizr6nJIlOGrx4O+3AeSalIaPPgDT02GEMQvv7J9OM60JOaqTQnGMLanA QxUwckdzfWvqCusZxwaV0r6+p1ezZGPNyCx/EpT2wciQKpdDVCI/NbYXsjdzWpHUP6VX F1iiwarD6eL2xrVSYg9oc0FMPwKtosyZKCczjY2EMUla1YjG3nEm/JLbPsAnb2MJyZI2 brpYR3uMgv+tPHWED2MRmsrtaBk2Sefnkc3Cp79vaL1HPr54luo6wtPJGpRVqP7z4OHD 7hgzvdTaxod4kiLY4ECdsoAURsXP2bpPCLr0zOEnAwLELvEfo9tfowcMpThKYZhq3M6E GHvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=6rsdWrOQEu5DA9icbqeKHZVhT7pOiFjvnQjJDFTZo0Q=; fh=zO8DaL91w4oVkr7TTOSjG4wVES7bHsJ6WEQfQtyqnjo=; b=oS3o4uyByf+iJk/LPexCeDe21OV13VTysUMSfL62xr8FzW2ih+A3Gnd48y3riBudg5 CjjAYNInJ7Nv0DgkgpxSJ7I0K/iQHybn6p7FQhCux9f5AIn8azYuPmKbTNFLUSEUzMxg EtErxqMsnRrRT8k/0bJE4MnWfYzyCl7I6phkCNTcRQzEz1q8wpdf+0W3TcRpPKxtKjDy Z/C5MVM833S9V/SCKwjTu9thLftdhKNOTPqDXtwHm9PFjsBwqES0ER/0NAodi5n81m3m FkVBNz82Wc2IeS3CjpLs0pgSX8M4bJcB/mA7nuqhh1geM9ys4LbEgRnOkk9r1f8jbaAN lW8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=FOAOy004; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v18-20020a17090331d200b001d8ecf3d0fbsi3095458ple.511.2024.02.16.06.28.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 06:28:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=FOAOy004; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68712-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C788DB26F19 for <ouuuleilei@gmail.com>; Fri, 16 Feb 2024 14:10:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E91B12CDAB; Fri, 16 Feb 2024 14:10:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="FOAOy004" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7127012C804; Fri, 16 Feb 2024 14:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708092614; cv=none; b=nNukKsAAS6TGUCmBVy8iu/iJxCLeM+Yn7J92uinhKe+fCvepyLlR1efuYgHaXXbcAkApxIa6BYfbf21QGdgn+ljluM8TyhY57F3j21N+h7zzLk6qKrLriPDoi563hhOcjooddIjgNBFAMG9pZ0BDNfxZylT56eigBcjGR1rvTGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708092614; c=relaxed/simple; bh=AXKxcLqkqUbREUhKhjXJPqaX/qrI1VmYgEN0lW7ndqY=; h=From:To:Cc:Subject:Date:Message-Id; b=S1VVTua2myDUyxTE4ZC3RUQ5riR2H8ZdfPe9sZ3aSJQrpzY4Pp5pRo4l4BmJIgfeYbItZ4YiMfLXV42eYFZ1L47Dd5d+pyJFqJsCbWNQyV5+/7vFG9YtDK+OmYV3WP1Ao+U39w6bDki2QZz8FKDnLjPjG6ZdrtP63bfQi2aqync= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=FOAOy004; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 78FF6207FD20; Fri, 16 Feb 2024 06:10:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 78FF6207FD20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1708092607; bh=6rsdWrOQEu5DA9icbqeKHZVhT7pOiFjvnQjJDFTZo0Q=; h=From:To:Cc:Subject:Date:From; b=FOAOy004sRjynlkJXyFzMeBRzs8ykw3cFaOgzn/JpyDWVFtd7KK4Ah+Pp5d2Zt3yo 1MLKJ5lj6kKVIMQPVBkN0CqaGCSGxs6OfhUN0J516difF6/OXtPuhNysIzjSEtoo84 iUJb43BnlYXakK0KX2yNR6b34M/+oH3nBjaqyRuw= From: Saurabh Sengar <ssengar@linux.microsoft.com> To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Cc: ssengar@microsoft.com Subject: [PATCH] Drivers: hv: Kconfig: select CPUMASK_OFFSTACK for Hyper-V Date: Fri, 16 Feb 2024 06:10:03 -0800 Message-Id: <1708092603-14504-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791066074906486913 X-GMAIL-MSGID: 1791066074906486913 |
Series |
Drivers: hv: Kconfig: select CPUMASK_OFFSTACK for Hyper-V
|
|
Commit Message
Saurabh Singh Sengar
Feb. 16, 2024, 2:10 p.m. UTC
CPUMASK_OFFSTACK must be set to have NR_CPUS_RANGE_END value greater than
512, which eventually allows NR_CPUS > 512.
CPUMASK_OFFSTACK can also be enabled by setting MAXSMP=y, but that will
set NR_CPUS=8192. This is not accurate for Hyper-V, because maximum number
of vCPU supported by Hyper-V today is 2048. Thus, enabling MAXSMP increase
the vmlinux size unnecessary.
This option allows NR_CPUS=2048 which saves around 1MB of vmlinux size for
Hyper-V.
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
---
drivers/hv/Kconfig | 1 +
1 file changed, 1 insertion(+)
Comments
From: Saurabh Sengar <ssengar@linux.microsoft.com> Sent: Friday, February 16, 2024 6:10 AM > To: kys@microsoft.com; haiyangz@microsoft.com; wei.liu@kernel.org; > decui@microsoft.com; linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > Cc: ssengar@microsoft.com > Subject: [PATCH] Drivers: hv: Kconfig: select CPUMASK_OFFSTACK for Hyper-V > > CPUMASK_OFFSTACK must be set to have NR_CPUS_RANGE_END value greater than > 512, which eventually allows NR_CPUS > 512. > > CPUMASK_OFFSTACK can also be enabled by setting MAXSMP=y, but that will > set NR_CPUS=8192. This is not accurate for Hyper-V, because maximum number > of vCPU supported by Hyper-V today is 2048. Thus, enabling MAXSMP increase > the vmlinux size unnecessary. Note that these statements apply only to x86. arm64 doesn't have MAXSMP or NR_CPUS_RANGE_END. > > This option allows NR_CPUS=2048 which saves around 1MB of vmlinux size > for Hyper-V. > > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> > --- > drivers/hv/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig > index 0024210..bc3f496 100644 > --- a/drivers/hv/Kconfig > +++ b/drivers/hv/Kconfig > @@ -9,6 +9,7 @@ config HYPERV > select PARAVIRT > select X86_HV_CALLBACK_VECTOR if X86 > select OF_EARLY_FLATTREE if OF > + select CPUMASK_OFFSTACK > help > Select this option to run Linux as a Hyper-V client operating > system. > -- > 1.8.3.1 > I'm not sure that enabling CPUMASK_OFFSTACK for Hyper-V guests is the right thing to do, as there's additional runtime cost when CPUMASK_OFFSTACK is enabled. I agree that for the most general case, you want NR_CPUS to be 2048, which requires CPUMASK_OFFSTACK. But it would be legitimate to build a kernel with NR_CPUS set to something like 64 or 256 for a more limited Hyper-V guest use case, and to not want to incur the cost of CPUMASK_OFFSTACK. You could consider doing something like this: select CPUMASK_OFFSTACK if NR_CPUS > 512 But kernel builders always have the option of explicitly enabling CPUMASK_OFFSTACK. That's what I see in the distro vendor arm64 images in Azure, since there's currently nothing that automatically selects CPUMASK_OFFSTACK for arm64. So I'm wondering if selecting CPUMASK_OFFSTACK under HYPERV should be added at all. The two aren't really related. There are recent LKML threads on enabling CPUMASK_OFFSTACK for arm64 -- see links below for some useful discussion of the topic in general. Michael [1] https://lore.kernel.org/lkml/794a1211-630b-3ee5-55a3-c06f10df1490@linuxcom/ [2] https://lore.kernel.org/lkml/7ab6660e-e69f-a64b-0de3-b8dde14f79fa@linuxcom/ [3] https://lore.kernel.org/lkml/e0d41efb-a74e-6bb5-f325-63d42358c802@gentwo.org/
On Sat, Feb 17, 2024 at 04:46:04PM +0000, Michael Kelley wrote: > From: Saurabh Sengar <ssengar@linux.microsoft.com> Sent: Friday, February 16, 2024 6:10 AM > > To: kys@microsoft.com; haiyangz@microsoft.com; wei.liu@kernel.org; > > decui@microsoft.com; linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org > > Cc: ssengar@microsoft.com > > Subject: [PATCH] Drivers: hv: Kconfig: select CPUMASK_OFFSTACK for Hyper-V > > > > CPUMASK_OFFSTACK must be set to have NR_CPUS_RANGE_END value greater than > > 512, which eventually allows NR_CPUS > 512. > > > > CPUMASK_OFFSTACK can also be enabled by setting MAXSMP=y, but that will > > set NR_CPUS=8192. This is not accurate for Hyper-V, because maximum number > > of vCPU supported by Hyper-V today is 2048. Thus, enabling MAXSMP increase > > the vmlinux size unnecessary. > > Note that these statements apply only to x86. arm64 doesn't have MAXSMP > or NR_CPUS_RANGE_END. > > > > > This option allows NR_CPUS=2048 which saves around 1MB of vmlinux size > > for Hyper-V. > > > > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> > > --- > > drivers/hv/Kconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig > > index 0024210..bc3f496 100644 > > --- a/drivers/hv/Kconfig > > +++ b/drivers/hv/Kconfig > > @@ -9,6 +9,7 @@ config HYPERV > > select PARAVIRT > > select X86_HV_CALLBACK_VECTOR if X86 > > select OF_EARLY_FLATTREE if OF > > + select CPUMASK_OFFSTACK > > help > > Select this option to run Linux as a Hyper-V client operating > > system. > > -- > > 1.8.3.1 > > > > I'm not sure that enabling CPUMASK_OFFSTACK for Hyper-V > guests is the right thing to do, as there's additional runtime > cost when CPUMASK_OFFSTACK is enabled. I agree that for > the most general case, you want NR_CPUS to be 2048, which > requires CPUMASK_OFFSTACK. But it would be legitimate to > build a kernel with NR_CPUS set to something like 64 or 256 > for a more limited Hyper-V guest use case, and to not want to > incur the cost of CPUMASK_OFFSTACK. > > You could consider doing something like this: > > select CPUMASK_OFFSTACK if NR_CPUS > 512 Thanks for your review. This was my first thought as well, but for x86, NR_CPUS itself depends on CPUMASK_OFFSTACK and this creates some kind of circular dependency and doesn't work effectively. Here are few key points to note: 1. In ARM64 as well for enabling CPUMASK_OFFSTACK we need to enable DEBUG_PER_CPU_MAPS and that will have additional overhead. This dependency is for all the archs. There was an earlier attempt to decouple it: https://lore.kernel.org/lkml/20220412231508.32629-2-libo.chen@oracle.com/ 2. However, for ARM64, NR_CPUS doesn't have dependency on CPUMASK_OFFSTACK. In ARM64 NR_CPUS is quite independent from any policy, we can choose any value for NR_CPUS freely, things are simple. This problem specificaly to be solved for x86. 3. If we have to select more then 512 CPUs on x86, CPUMASK_OFFSTACK needto be enabled, so this additional runtime cost is unavoidable for NR_CPUS > 512. There is no way today to enable CPUMASK_OFFSTACK apart from enabling MAXSMP or DEBUG_PER_CPU_MAPS. Both of these options we don't want to use. I agree that we possibly don't want to enable this option for HyperV VMs where NR_CPUS < 512. I have two thoughts here: 1. Enable it only for VTL platforms, as current requirement for minimal kernel is only for VTL platforms only. 2. Fix this for all of x86. I couldn't find any reson why CPUMASK_OFFSTACK dependency is there on x86 for having more than 512 CPUs. What is special in x86 to have this restriction ? If there is no reason we should relax the restriction of CPUMASK_OFFSTACK for NR_CPUs similar to ARM and other archs. - Saurabh > > But kernel builders always have the option of explicitly > enabling CPUMASK_OFFSTACK. That's what I see in the distro > vendor arm64 images in Azure, since there's currently nothing > that automatically selects CPUMASK_OFFSTACK for arm64. > So I'm wondering if selecting CPUMASK_OFFSTACK under > HYPERV should be added at all. The two aren't really related. > > There are recent LKML threads on enabling CPUMASK_OFFSTACK > for arm64 -- see links below for some useful discussion of the > topic in general. > > Michael > > [1] https://lore.kernel.org/lkml/794a1211-630b-3ee5-55a3-c06f10df1490@linux.com/ > [2] https://lore.kernel.org/lkml/7ab6660e-e69f-a64b-0de3-b8dde14f79fa@linux.com/ > [3] https://lore.kernel.org/lkml/e0d41efb-a74e-6bb5-f325-63d42358c802@gentwo.org/
From: Saurabh Singh Sengar <ssengar@linux.microsoft.com> Sent: Saturday, February 17, 2024 11:17 PM > > > > > > diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig > > > index 0024210..bc3f496 100644 > > > --- a/drivers/hv/Kconfig > > > +++ b/drivers/hv/Kconfig > > > @@ -9,6 +9,7 @@ config HYPERV > > > select PARAVIRT > > > select X86_HV_CALLBACK_VECTOR if X86 > > > select OF_EARLY_FLATTREE if OF > > > + select CPUMASK_OFFSTACK > > > help > > > Select this option to run Linux as a Hyper-V client operating > > > system. > > > -- > > > 1.8.3.1 > > > > > > > I'm not sure that enabling CPUMASK_OFFSTACK for Hyper-V > > guests is the right thing to do, as there's additional runtime > > cost when CPUMASK_OFFSTACK is enabled. I agree that for > > the most general case, you want NR_CPUS to be 2048, which > > requires CPUMASK_OFFSTACK. But it would be legitimate to > > build a kernel with NR_CPUS set to something like 64 or 256 > > for a more limited Hyper-V guest use case, and to not want to > > incur the cost of CPUMASK_OFFSTACK. > > > > You could consider doing something like this: > > > > select CPUMASK_OFFSTACK if NR_CPUS > 512 > > Thanks for your review. > > This was my first thought as well, but for x86, NR_CPUS itself depends > on CPUMASK_OFFSTACK and this creates some kind of circular dependency > and doesn't work effectively. > > Here are few key points to note: > > 1. In ARM64 as well for enabling CPUMASK_OFFSTACK we need to enable > DEBUG_PER_CPU_MAPS and that will have additional overhead. > This dependency is for all the archs. There was an earlier attempt > to decouple it: https://lore.kernel.org/lkml/20220412231508.32629-1-libo.chen@oracle.com/ > > 2. However, for ARM64, NR_CPUS doesn't have dependency on CPUMASK_OFFSTACK. > In ARM64 NR_CPUS is quite independent from any policy, we can choose any > value for NR_CPUS freely, things are simple. This problem specificaly > to be solved for x86. > > 3. If we have to select more then 512 CPUs on x86, CPUMASK_OFFSTACK > needto be enabled, so this additional runtime cost is unavoidable > for NR_CPUS > 512. There is no way today to enable CPUMASK_OFFSTACK > apart from enabling MAXSMP or DEBUG_PER_CPU_MAPS. Both of these > options we don't want to use. > > I agree that we possibly don't want to enable this option for HyperV VMs > where NR_CPUS < 512. I have two thoughts here: > > 1. Enable it only for VTL platforms, as current requirement for minimal kernel > is only for VTL platforms only. > > 2. Fix this for all of x86. I couldn't find any reson why CPUMASK_OFFSTACK > dependency is there on x86 for having more than 512 CPUs. What is special > in x86 to have this restriction ? If there is no reason we should relax > the restriction of CPUMASK_OFFSTACK for NR_CPUs similar to ARM and other > archs. > You've done some deeper research than I did. :-( What a mess. ARM64 seems to have it right. On x86, the dependency between NR_CPUS and CPUMASK_OFFSTACK seems to flow the wrong direction. I would think you would select NR_CPUS first, and then if the number is large, select CPUMASK_OFFSTACK. And the display of CPUMASK_OFFSTACK in config tools should not be dependent on DEBUG_PER_CPU_MAPS. It should be easy to independently select CPUMASK_OFFSTACK (modulo architectures that don't support it). In the Libo Chen thread, I don't understand the reluctance to make CPUMASK_OFFSTACK independent of DEBUG_PER_CPU_MAPS. I don't have any great suggestions for the path forward. :-( Maybe revive the Libo Chen thread, with a better justification for removing the dependency between CPUMASK_OFFSTACK and DEBUG_PER_CPU_MAPS? Or at least clarify why the dependency should be kept? Michael
diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 0024210..bc3f496 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -9,6 +9,7 @@ config HYPERV select PARAVIRT select X86_HV_CALLBACK_VECTOR if X86 select OF_EARLY_FLATTREE if OF + select CPUMASK_OFFSTACK help Select this option to run Linux as a Hyper-V client operating system.