libspl: move physmem to sys/systm.h; initialise at libspl_init()

Sponsored-by: https://despairlabs.com/sponsor/
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Closes #17861
This commit is contained in:
Rob Norris 2025-10-24 23:19:53 +11:00 committed by Brian Behlendorf
parent d02ea5170a
commit 6cf6f091cf
5 changed files with 47 additions and 4 deletions

View File

@ -127,6 +127,10 @@ extern "C" {
#include <sys/kmem.h>
#include <sys/zfs_delay.h>
#include <sys/vnode.h>
#include <sys/random.h>
#include <sys/callb.h>
#include <sys/trace.h>
#include <sys/systm.h>
#include <sys/zfs_context_os.h>
@ -206,7 +210,6 @@ extern char *vn_dumpdir;
#define NN_DIVISOR_1000 (1U << 0)
#define NN_NUMBUF_SZ (6)
extern uint64_t physmem;
extern const char *random_path;
extern const char *urandom_path;

View File

@ -59,6 +59,7 @@ libspl_sys_HEADERS = \
%D%/sys/string.h \
%D%/sys/sunddi.h \
%D%/sys/systeminfo.h \
%D%/sys/systm.h \
%D%/sys/thread.h \
%D%/sys/taskq.h \
%D%/sys/time.h \

View File

@ -0,0 +1,34 @@
// SPDX-License-Identifier: CDDL-1.0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#ifndef _LIBSPL_SYS_SYSTM_H
#define _LIBSPL_SYS_SYSTM_H
extern uint64_t physmem;
#endif

View File

@ -20,14 +20,22 @@
* CDDL HEADER END
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2018 by Delphix. All rights reserved.
* Copyright (c) 2016 Actifio, Inc. All rights reserved.
* Copyright (c) 2025, Klara, Inc.
* Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
*/
#include <libspl.h>
#include <unistd.h>
uint64_t physmem;
void
libspl_init(void)
{
physmem = sysconf(_SC_PHYS_PAGES);
}
void

View File

@ -60,7 +60,6 @@
* Emulation of kernel services in userland.
*/
uint64_t physmem;
uint32_t hostid;
struct utsname hw_utsname;
@ -509,8 +508,6 @@ kernel_init(int mode)
umem_nofail_callback(umem_out_of_memory);
physmem = sysconf(_SC_PHYS_PAGES);
dprintf("physmem = %llu pages (%.2f GB)\n", (u_longlong_t)physmem,
(double)physmem * sysconf(_SC_PAGE_SIZE) / (1ULL << 30));