From patchwork Wed Jul 3 00:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13720516 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0428DC30658 for ; Wed, 3 Jul 2024 00:52:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 863856B008C; Tue, 2 Jul 2024 20:52:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8130A6B0092; Tue, 2 Jul 2024 20:52:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B4726B0093; Tue, 2 Jul 2024 20:52:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4D9566B008C for ; Tue, 2 Jul 2024 20:52:11 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F2817140645 for ; Wed, 3 Jul 2024 00:52:10 +0000 (UTC) X-FDA: 82296614820.27.6720529 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by imf20.hostedemail.com (Postfix) with ESMTP id 441291C0015 for ; Wed, 3 Jul 2024 00:52:09 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=gfVq2MFg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.180 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719967910; a=rsa-sha256; cv=none; b=p6jI7GQwWGwipwZL8lgsBsUhBmnCK7yoz1tfdsY4EjHBRlhqSmZzkDNOcwZ45Aylqq8mVd v0zpM1vYDO9szCiE+JFeDtHmBYG2TH1F9jNAFCxCPK/K9p+BlmlCu2y5Km2wRliWWSvVog bKeWoEZTDPodSaPGbiyeb6BX6BtniD0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=gfVq2MFg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.180 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719967910; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=hlxAVPd+z/4aF6F4fWIjQzN+IGGbLzBgd/ODx938I10=; b=OfVhMN9POgwnrZYA+Cj6UXeZ2a2jPyFRTb2QkSDctv/G+4elBx1WajmiqA5BPPoLUjg3gX CJQ87cvTS8kyx8iRKuLn0lMIIZ6dKwP76t3V8MSGLBBFr8QG9Tj73JQ4y/A5HAsGOShpRl zrjQ7rPAtNy0/CoZVX2F6n4frP97c2Y= Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2ee75ffce77so17128241fa.3 for ; Tue, 02 Jul 2024 17:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719967928; x=1720572728; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=hlxAVPd+z/4aF6F4fWIjQzN+IGGbLzBgd/ODx938I10=; b=gfVq2MFgNdwJMWhWfcEnXGFg3epeIbpPXoqKXjZYuava8fcoz+9qO3Up1KQ/P6r9QQ 6E2LI9nWL2pPfIyfN41Gg9ArqI0wcBCWjIu64t9jL3QZq0PUI1epirjE7sbDHJwbN2sd ALfii9DB7XuJrPDodlXq0HZCDb2msm/yoRkGN7+YEEUGAc+Fu3Af4lbvZ5AF1IV/6+vu HUSByn0sWX5wrlT/WSPgX7kYrTUjRJptryHMdLOSMxj26+4bnFEorMDTotfn8W1H/8S8 j2g6PXI01/14eM9rokY1wf6vnysWTu11xc6F6JK916H5MaAuyi4Jx4Cb6Jyn5EfVQoa7 oJoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719967928; x=1720572728; h=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=hlxAVPd+z/4aF6F4fWIjQzN+IGGbLzBgd/ODx938I10=; b=LwAeCpmLkgBXcISZ9Zozd7kuam+l/uMbSmHsnE02gn8+Wbvc8X4YuBJp6vB3+OZy4l y4f/dysjbkaUV5zyUDTMTtZE7lWiHPjHFrUgut5tt7pWLJjfG1pxRJyQRzpbZisl6LT0 5IrLNwNNDzb+TCQBBZGZaX2Gdhl8Btc+zyRHSOTV4RnPw0Hdm0rWjseRXOaO9bsLHIOz VEI9JsnHwkSHdyn63qZmsrIoaDAsr0jluAldHeqMEOpupN3YV7NjGiREp4fsSecUfCfE WiaT0s/xyWi5jYYl9hdt8sDx8AB5n9Dwect7BssxYABEWBDLYRQpof+3dLdzwDXsZn80 dFBw== X-Gm-Message-State: AOJu0Yzygc2HrmetIielHk4c8pnA4ntz+NWJ4Dj443Y4j3dOid3AE57h 6AO1TLlJ6apI21rK48RHnykUgLnomGHnaexg3N3c3aGPIH5M+Nzd X-Google-Smtp-Source: AGHT+IFunxU3aCA2igMV0VDSihUIRl9wR+hXTq/LJHY8uSNSWMts/3OWUtAEdbp1a66ut6KDvzvC+A== X-Received: by 2002:a05:6512:b15:b0:52c:8b69:e039 with SMTP id 2adb3069b0e04-52e8264b68cmr9439738e87.4.1719967927546; Tue, 02 Jul 2024 17:52:07 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a779bcb94a4sm36144666b.117.2024.07.02.17.52.06 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 17:52:06 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org, brauner@kernel.org, oleg@redhat.com, mjguzik@gmail.com, tandersen@netflix.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@redhat.com, Wei Yang Subject: [PATCH v3 2/3] kernel/fork.c: get totalram_pages from memblock to calculate max_threads Date: Wed, 3 Jul 2024 00:51:50 +0000 Message-Id: <20240703005151.28712-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240703005151.28712-1-richard.weiyang@gmail.com> References: <20240703005151.28712-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 441291C0015 X-Stat-Signature: dfxunoafgygujcih3bycs1y1uqar6yea X-Rspam-User: X-HE-Tag: 1719967929-501758 X-HE-Meta: U2FsdGVkX1/YziaPvuIQnvJF7q6F3qaqcb/wfmPzbYbDyvtTpFUr8DWP20XTSA/ppPmIV7y0WMjckpWXRSQFdu2kt2JWBB6CwJGqbNcXEbCWLGT+RlEZTNtFTHhX/8j5Q/mRKLoB/F7Gx3Me5miJmiLUfqKudu1FyySZsNBXmOYG+86m7ZLNF/tNHtPSNnme+HFbtzzdZ4/PgM0Uw2X9/CrdrzI5/pZb/UvuCLARZEsicnv7EkmXQ0Q6tOrbmmD2EncQBLFkxcU1iV/nnG+9sjraVKk9g+2TrO5tMnuHCANxvaCamOATtuFy9IiB0u4rC3/N5cu4Y+Mmb+7QL/aQnqMOYiuygj7InBrslDjEbTS8Clw2MCNjvP20fYNEQYIDC7JtESfdBIulXrqPBZCwfohXFumsUsh06ksVsXlvQrpw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fn2h0dS8t8AQehwEzSkNZXROKLUjEqSYhqcLrLchUA X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since we plan to move the accounting into __free_pages_core(), totalram_pages may not represent the total usable pages on system at this point when defer_init is enabled. Instead we can get the total estimated pages from memblock directly. Signed-off-by: Wei Yang CC: Mike Rapoport (IBM) CC: David Hildenbrand CC: Oleg Nesterov --- kernel/fork.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index 99076dbe27d8..e80e889543f3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -999,7 +1000,7 @@ void __init __weak arch_task_cache_init(void) { } static void set_max_threads(unsigned int max_threads_suggested) { u64 threads; - unsigned long nr_pages = totalram_pages(); + unsigned long nr_pages = memblock_estimated_nr_pages(); /* * The number of threads shall be limited such that the thread