From patchwork Tue Jul 9 02:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13727182 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 310CBC3DA45 for ; Tue, 9 Jul 2024 02:36:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B94F66B0099; Mon, 8 Jul 2024 22:36:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1D986B009B; Mon, 8 Jul 2024 22:36:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9709A6B009C; Mon, 8 Jul 2024 22:36:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 739FF6B0099 for ; Mon, 8 Jul 2024 22:36:27 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E70A61216BD for ; Tue, 9 Jul 2024 02:36:26 +0000 (UTC) X-FDA: 82318650372.12.3A1A41F Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf03.hostedemail.com (Postfix) with ESMTP id 377F220009 for ; Tue, 9 Jul 2024 02:36:24 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SojOmlYl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.48 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=1720492551; 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=d/wAyZTOVWvFtpD3rAecyL5NKhlbJZDYmglLcjhS/4M=; b=nGgjW3KcVg/A5iUHMi3vnF4Ih5RQVao8701hCkBQByNOp6Ea+KeZutyNPN7lilWJRHj23L cH/XTbjBAqEWCSM0hzTTFn4vxYz0bfca6xmnMf0rc5xuORX5BICDLQo+261ltPkXMevMEi 1yBH9k2el7SHQAOQAB2t0kusNWFUzr8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720492551; a=rsa-sha256; cv=none; b=IjYHywWWSD6Rr9cACK7Y6DjwOOQu+z7UNGgUn77JX7axQ+dq1qbCGfoz7pHQbGHeaYI+ws eTSqowdyhhKesi5oz4Gmb7aCeKKgFfoSfLNTOsXs6TmmE54CPVk/g7367SgfYC1GTYTKP0 JEDfmhsxEf6/gYubign8yUt+wYRdMBo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SojOmlYl; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-58b447c519eso5580425a12.3 for ; Mon, 08 Jul 2024 19:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720492584; x=1721097384; 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=d/wAyZTOVWvFtpD3rAecyL5NKhlbJZDYmglLcjhS/4M=; b=SojOmlYlYXenVXOgpjUOx63L4A46FfxH+xrV7LZojrk0viOoMuNx8n9u9o2KBVbQ1M nXu2GYiAbtcOqHZUdpeIks/ZVXWh9F7GmIvuOWMy0sSbZxTvPrvAl9c19oreTQofGrVZ I/CNWrqYc0kXkicO3cPjQXQna6s1l0RtbkK2RXUq4IdqP1eNg0qY+ra8XXtp2bO8Jg1j 4PyoTTfX9fzpHYLQnw3TM2eM0VNy6L0NOT0b420eZl+4V2eil2mKyWnwayos4Mnf1RJH +4nNa1zQw/p5/cY3FMW8q89fpM6i148DuNkpA0NksEQBDEyZokNsEeWRUVkTg1KQ+qsa BPpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720492584; x=1721097384; 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=d/wAyZTOVWvFtpD3rAecyL5NKhlbJZDYmglLcjhS/4M=; b=W8T4UHpFOFCzXRPBXYHVMNWlnqTxqgLA0ij6elx65SQKpWcQtqNSrBWr/t3QPNPrZO YD7BYeRAbHaK1LFL//9OieVEiRVhFwic0i+FVMHtViVjRhGkxxXSPMsoMBcr4GostZOn St8Ph01jWu678zEXO0x+c+A5vdWNsPNHOxG6jRUXWnm/ELTU86RVuJm5ftdWfQbt1nDz wpW3jfTYL8oxBvgat+eWdz02MvX5zNi5J/9xTdbJuBCK03cPXhS+8nM2LIHzzC3Rv4OP stF3iy7WFxiWw3g01UGnMP65Pd4WHH4nr2okWSzi1cYU3+0Xo2mchtEV081ljAGKsJsZ JiWQ== X-Gm-Message-State: AOJu0YwedZBdMWPUPKYNhvWBn/PlqmCN5JyUe8NpFJNtrPYzOXQsr+UT uve3u3iUgVCwt3+RxUdxB8UcYQW0+snYBo82y7CT0VLifjv1aRpY X-Google-Smtp-Source: AGHT+IG0bFuBDe46akiyEVESqjZ03+fBK7ogEUSgXPWIa2oJals8wXjwQoZDybeIteOOj7JIhyhzvQ== X-Received: by 2002:a17:907:3f19:b0:a77:c548:6456 with SMTP id a640c23a62f3a-a780b88608amr89849466b.59.1720492583774; Mon, 08 Jul 2024 19:36:23 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a72fd39sm39561366b.91.2024.07.08.19.36.22 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2024 19:36:22 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org, brauner@kernel.org, oleg@redhat.com, tandersen@netflix.com, mjguzik@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang , David Hildenbrand Subject: [PATCH v5 2/3] kernel/fork.c: get totalram_pages from memblock to calculate max_threads Date: Tue, 9 Jul 2024 02:36:08 +0000 Message-Id: <20240709023609.21332-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240709023609.21332-1-richard.weiyang@gmail.com> References: <20240709023609.21332-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 377F220009 X-Stat-Signature: t6eopg5j73989fxks33a9cuobrwyut8h X-Rspam-User: X-HE-Tag: 1720492584-889162 X-HE-Meta: U2FsdGVkX1+KDEaT4gbhPkywXMdtHmCn8FkGTblH/7GA+WlbHGf/xDcqjwFSdHPFBA0O1Pd2dFtdFMFX85H6wlf46XlForU9ZhbEXHuH+KnhcAr5TOe/+bzL9bmE9qDzLIaXEC/1TGAkrzr7eYRaMBh+mGHEpGxpOwGww28G/d5+kEEmVeciUbOwVQBxcJ0aljGUWOy2bokT4OQoyluH7Kpo6Gvc9RJ9/D7Ir7mv3lr+UJUH8s7U0EB0ipi5WoImX7onfNoTkf3dmZuGo/ZkOPnqv6DgqZxyrlSr4/sSEogLA1rKvJe8voXOD5Q2JxwKNrCEvaX2WEescz6IdKnyhW2OI1iy71DQKXcAxG/tCodGSiOTf8ZrhrPemybQln2uPxWzj9zHNZbxNzSzvVfUb+R9X9Izz/8f3ftOqrUxt/lCJgf8KWVSAMhgrACE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R7NOzd8Zn1W2Y7DPxkG43kOtz 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 Acked-by: Mike Rapoport --- kernel/fork.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index 279efadabbf2..d6c2a4ccd532 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_free_pages(); /* * The number of threads shall be limited such that the thread