From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=RG8lfslG; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 2E3865A0620 for ; Wed, 06 Nov 2024 00:27:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730849254; bh=qrBCLDJWGqMjcjmT2DQsCdBCfyVSzCm6yzyexF+dJn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RG8lfslGxXgTduJnOu3nJ7JzdMLH97asIjxwN+vSgwihpU6sHizhYW2mEM1I1VbTO 5mrUDTPqCBcy6wWb3g8zkWmY2S5y8xwRUbLkCfQo/sGQVmfCRAidmQDcnwZFcMB/7j 10Hn1qWCpjBJZ85aCUtyRid4An1eSaygdMURRsML75hKVcBHDT+XNyjDA8+uclhANW SAsR3X0yVR4/25kWI9cMA06R9Zi7ivzcnrKRDKx469aZaTXGWW1F9hhZsJP6lzuSMX Ap232MyeMMG/jq9TDELjH5U7qEfGRCL9k20xSQoWVL12zqtPGnjtZSf27gdiGkrjYc ZsBw3h9vsN0yw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XjkyZ4WCFz4xGR; Wed, 6 Nov 2024 10:27:34 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 10/12] Makefile: Don't attempt to auto-detect stack size Date: Wed, 6 Nov 2024 10:25:26 +1100 Message-ID: <20241105232528.1408144-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105232528.1408144-1-david@gibson.dropbear.id.au> References: <20241105232528.1408144-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: HWOMRDFRTWW64QBCTANJFZXOOPPVSHFN X-Message-ID-Hash: HWOMRDFRTWW64QBCTANJFZXOOPPVSHFN X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We probe the available stack limit in the Makefile using rlimit, then use that to set the size of the stack when we clone() extra threads. But the rlimit at compile time need not be the same as the rlimit at runtime, so that's not particularly sensible. Ideally, we'd set the stack size based on an estimate of the actual maximum stack usage of all our clone()ed functions. We don't have that at the moment, but to keep things simple just set it to 1MiB - that's what the current probe will set things to on my default configuration Fedora 40, so it's likely to be fine in most cases. Signed-off-by: David Gibson --- Makefile | 6 ------ util.h | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 2a8540a..56bf2e8 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,6 @@ VERSION ?= $(shell git describe --tags HEAD 2>/dev/null || echo "unknown\ versio # the IPv6 socket API? (Linux does) DUAL_STACK_SOCKETS := 1 -RLIMIT_STACK_VAL := $(shell /bin/sh -c 'ulimit -s') -ifeq ($(RLIMIT_STACK_VAL),unlimited) -RLIMIT_STACK_VAL := 1024 -endif - TARGET ?= $(shell $(CC) -dumpmachine) # Get 'uname -m'-like architecture description for target TARGET_ARCH := $(shell echo $(TARGET) | cut -f1 -d- | tr [A-Z] [a-z]) @@ -36,7 +31,6 @@ FLAGS := -Wall -Wextra -Wno-format-zero-length FLAGS += -pedantic -std=c11 -D_XOPEN_SOURCE=700 -D_GNU_SOURCE FLAGS += $(FORTIFY_FLAG) -O2 -pie -fPIE FLAGS += -DPAGE_SIZE=$(shell getconf PAGE_SIZE) -FLAGS += -DRLIMIT_STACK_VAL=$(RLIMIT_STACK_VAL) FLAGS += -DVERSION=\"$(VERSION)\" FLAGS += -DDUAL_STACK_SOCKETS=$(DUAL_STACK_SOCKETS) diff --git a/util.h b/util.h index 3fc64cf..c341236 100644 --- a/util.h +++ b/util.h @@ -132,7 +132,7 @@ static inline uint32_t ntohl_unaligned(const void *p) return ntohl(val); } -#define NS_FN_STACK_SIZE (RLIMIT_STACK_VAL * 1024 / 8) +#define NS_FN_STACK_SIZE (1024 * 1024) /* 1MiB */ int do_clone(int (*fn)(void *), char *stack_area, size_t stack_size, int flags, void *arg); #define NS_CALL(fn, arg) \ -- 2.47.0