From owner-dev-commits-src-main@freebsd.org Tue Jun 15 00:23:37 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E45E65A68D; Tue, 15 Jun 2021 00:23:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G3pvY141mz3lVW; Tue, 15 Jun 2021 00:23:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DAC81E557; Tue, 15 Jun 2021 00:23:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15F0Nan2095272; Tue, 15 Jun 2021 00:23:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15F0NavY095271; Tue, 15 Jun 2021 00:23:36 GMT (envelope-from git) Date: Tue, 15 Jun 2021 00:23:36 GMT Message-Id: <202106150023.15F0NavY095271@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 5720b8de4832 - main - riscv: Add an hw.ncpu tunable to limit the number of cores MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5720b8de4832da70e76b9a72c679d0b168d7834e Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jun 2021 00:23:37 -0000 The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=5720b8de4832da70e76b9a72c679d0b168d7834e commit 5720b8de4832da70e76b9a72c679d0b168d7834e Author: Jessica Clarke AuthorDate: 2021-06-15 00:21:38 +0000 Commit: Jessica Clarke CommitDate: 2021-06-15 00:22:13 +0000 riscv: Add an hw.ncpu tunable to limit the number of cores Based on a similar change to arm64 in 01a8235ea61c. Reviewed by: mhorne MRC after: 1 week Differential Revision: https://reviews.freebsd.org/D30655 --- sys/riscv/riscv/mp_machdep.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index cdcc86e715dd..1dadf19ce51f 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -532,9 +532,9 @@ cpu_check_mmu(u_int id, phandle_t node, u_int addr_size, pcell_t *reg) void cpu_mp_setmaxid(void) { -#ifdef FDT int cores; +#ifdef FDT cores = ofw_cpu_early_foreach(cpu_check_mmu, true); if (cores > 0) { cores = MIN(cores, MAXCPU); @@ -543,12 +543,19 @@ cpu_mp_setmaxid(void) mp_ncpus = cores; mp_maxid = cores - 1; cpu_enum_method = CPUS_FDT; - return; - } + } else #endif + { + if (bootverbose) + printf("No CPU data, limiting to 1 core\n"); + mp_ncpus = 1; + mp_maxid = 0; + } - if (bootverbose) - printf("No CPU data, limiting to 1 core\n"); - mp_ncpus = 1; - mp_maxid = 0; + if (TUNABLE_INT_FETCH("hw.ncpu", &cores)) { + if (cores > 0 && cores < mp_ncpus) { + mp_ncpus = cores; + mp_maxid = cores - 1; + } + } }