From patchwork Sun Jun 16 01:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13699400 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 3B775C27C4F for ; Sun, 16 Jun 2024 01:36:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 752556B010D; Sat, 15 Jun 2024 21:36:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 701F16B010E; Sat, 15 Jun 2024 21:36:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2676B0111; Sat, 15 Jun 2024 21:36:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3BADB6B010D for ; Sat, 15 Jun 2024 21:36:04 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DCBC440E21 for ; Sun, 16 Jun 2024 01:36:03 +0000 (UTC) X-FDA: 82235035806.21.CF5BF5D Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by imf29.hostedemail.com (Postfix) with ESMTP id 34A4112000C for ; Sun, 16 Jun 2024 01:36:01 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Kc7CIsk6; spf=pass (imf29.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718501760; 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:references:dkim-signature; bh=Oq96Rf9+3SaAN8Q2fFpUtHn84wg3Cq2hV46UyTATzaQ=; b=wlg+vcPGq1djPLXRne95SP2US/XTXPe2zl4p9M8O+t2N8/HQucqXKjyy+oaTRe8CAGyylS gwCkH+9xiGyP34iKnbl1IG8bawBe12HyMhokx3bZQJR+tPU7iFMNRHyrBkS5gwkuv6KrqF G1guNw/vFzLthLyHMu394Py3ESf2Nvk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Kc7CIsk6; spf=pass (imf29.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.47 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718501760; a=rsa-sha256; cv=none; b=BIHY+zoC1yVISaQ29Zz+yCNX1QEtcTpe9Ud5YmJ33RchVD97RLNMj0c4BqqTFnQlB4lhdn VlWMBWZ9FNj1pxVbo1qIdHLzplhAlTkMVth6uV9WA/0xIRXfXnSRhNN8RnwNzOTuPD3xPG Fl5rjVHnTX4i7IdJTBXMawxtJFyOpGc= Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-57c83100bd6so4095180a12.3 for ; Sat, 15 Jun 2024 18:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718501760; x=1719106560; darn=kvack.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Oq96Rf9+3SaAN8Q2fFpUtHn84wg3Cq2hV46UyTATzaQ=; b=Kc7CIsk6wJxWLYdVria1ZXfbBqua08WYdjaKqVUJgPX8yllPH5bV3G3Db5Y6c0pA5F esLjJlsTWDOtBZ3sr58wLxJbOZP+lbWCY19sFiVeTwqt/9nfbiFYmUSvCq+4oSnMzQ5b bBS3ga1pRLR0r+SHLYxm9cQP70/MDMpyUswC4O3zLNwhiwUDm53vJmezrDAAYG3KMcMK CFXtQtrvRK8qJ8XThOGICk+QkyP467C2muK03m5F7GiIhmfv8OSocgz/wMp2OiwbvXIV Dn0E3BqwkufywuqqC5WRdnsbklZzyg7tY1w3WlhdwdCEK3irHXb/wUCm/OXIQLRBpAsp 6yzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718501760; x=1719106560; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Oq96Rf9+3SaAN8Q2fFpUtHn84wg3Cq2hV46UyTATzaQ=; b=LIaCEZsHt23CrGd72o4dxFC1DUjrckDW/t+TwONvRUyYIyFpQONGf+TQwc+GYXNF6N JuFceO8NqJ6nYVNdUiKeT5kkikFlbqsmXkKaf/IL2WC1EYqvdWtmdnLOk2PYsojKeKsd wNlsBD3yNDjz1VUZ7Rzslko04BunOwfy55BDY45BQeiaTVHVaF21reDUefQJm+x59ZLB wqPE7yZI+//+iwGVQZ47JLurFI+GLQY41jwGL87YgaPgEOhPjjuDS0uu52r8eIyiDXa+ h7TeBpwkLQKpwrS9wwioo8HBMAkDwwW4hcC6ivfw/WA36kHXSt3FIELwYfx1t7x9AW9H XLGA== X-Forwarded-Encrypted: i=1; AJvYcCUjucj3sjqS3nqixfLlxRClE2V2ZcgvNP0b/ZUdSYWxOCc/IcWny835b/7bPtx8BBBhekky7rEWThJep34Yw7woOAg= X-Gm-Message-State: AOJu0YyohEWWTBPPsgyAnrgas9Nkmf1s3ugxFGMSa1RXrdNrhkfuJKfb y3PLITNcjIih+y+C1QWgqUP6v+sOVZ1vALdS2lSfvrD4GbTwGk7N X-Google-Smtp-Source: AGHT+IH+6aWufJ6UlOo1msIz9ZpIvQp78Ti1Dc/pT5Fo42u/qllH30wvrpapVJvtDZMvAxFLSVrfLg== X-Received: by 2002:a50:a69b:0:b0:57c:acf4:c6c5 with SMTP id 4fb4d7f45d1cf-57cbd67f735mr3674394a12.24.1718501760278; Sat, 15 Jun 2024 18:36:00 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb7439606sm4388843a12.90.2024.06.15.18.35.59 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jun 2024 18:35:59 -0700 (PDT) From: Wei Yang To: agordeev@linux.ibm.com, gerald.schaefer@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com Cc: linux-s390@vger.kernel.org, linux-mm@kvack.org, Wei Yang , Mike Rapoport , David Hildenbrand Subject: [PATCH] s390/mm: get total ram pages from memblock Date: Sun, 16 Jun 2024 01:35:37 +0000 Message-Id: <20240616013537.20338-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 34A4112000C X-Stat-Signature: w4oqyt3ks9auo6kfuff53o8begm93mm9 X-HE-Tag: 1718501761-653568 X-HE-Meta: U2FsdGVkX1/ONd8fjULD1ZuKvTTr7615D+AslZKwWWyU26tT92BQIGENnx4pa8uWvUXBcJ66VUvF/H2jxRtvvfW9XBxuNIeMz/ayx3R1hQZwAb1i/jUPvN37G8p6msX/1JWIW25TUaR3Xav5oudG3a8jyz+oaI2bGX3iTwbPJMjDIW7NuYPx1TF5gcJk4KaDkBw0OWAhaAsWllRYjZ24s8XIyXX2/B7z0ziw/D6Vtvm6d5j7EukPFJ8QbenWbSn5kH+qBG1LLG4aEjHcQEY5wYAp5vSGCdNtA8TXneL2MKSdu9Bg9auDomH+0gf8RJnglblOvQC/0BemUO0/fsqFOkOsE4KPY2AzvXS1b34sDm5RhoZfGcVvsDBKVAOgDRBKr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YFsjlNTj66WxNrGr194Sw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000029, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On s390, zero page's size relies on total ram pages. 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. We can get the total usable pages from memblock directly. The size maybe not accurate due to the alignment, but enough for the calculation. Signed-off-by: Wei Yang CC: Mike Rapoport (IBM) CC: David Hildenbrand Reviewed-by: David Hildenbrand --- Not tested on a machine, hope it is fine. --- arch/s390/mm/init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index e769d2726f4e..d811ffa5e147 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -65,12 +65,13 @@ static void __init setup_zero_pages(void) unsigned int order; struct page *page; int i; + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size()); /* Latest machines require a mapping granularity of 512KB */ order = 7; /* Limit number of empty zero pages for small memory sizes */ - while (order > 2 && (totalram_pages() >> 10) < (1UL << order)) + while (order > 2 && (total_pages >> 10) < (1UL << order)) order--; empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);