From patchwork Wed Sep 28 22:32:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993200 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 3A774C6FA82 for ; Wed, 28 Sep 2022 22:33:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E7976B0074; Wed, 28 Sep 2022 18:33:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 898076B0075; Wed, 28 Sep 2022 18:33:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70F596B0078; Wed, 28 Sep 2022 18:33:48 -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 626446B0074 for ; Wed, 28 Sep 2022 18:33:48 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 36E3D1C6AB0 for ; Wed, 28 Sep 2022 22:33:48 +0000 (UTC) X-FDA: 79962947736.19.01C7309 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf05.hostedemail.com (Postfix) with ESMTP id DEC48100008 for ; Wed, 28 Sep 2022 22:33:47 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id r20so8849421qtn.12 for ; Wed, 28 Sep 2022 15:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hB/8CHaP3epa66ZDI7eIxcYHinx9lai7E+SzdR8JK34=; b=WAksJPCtovML0PXfuV6MvtFhaquK0tq65BQzPSMUX0EZb3CqP+duiDKDvHl3Sit7m7 7aOY0PEle5W8Mi2h7QigBTY8Lg9rVOpp48AzS1DIJ4l7/+09QqhqnWAx1czOCbInzF8d x0YJ/P2gInkW3C6VhvjtTXDTumcsev/S/pTT+ignxMH0mOrEue1fBAf5GE5WDzaQFzF0 RdlNkUbc/JOrJS4Z1j8l16rMuCAMgQ8Ox/Jf5BztPHKu7DNY6R4apLKF8tfNNMjx27+d 3I23mrMNzl+yyZHs1Odm+efLgckSB2i6WXUlZx+oBQ50hBKajiK77oTPrOY+jVboWfch SIFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hB/8CHaP3epa66ZDI7eIxcYHinx9lai7E+SzdR8JK34=; b=FQ94sjOLw+CxFUGcAOMOslZcxZcIRNeJt6px5eRca8v1lzuyAg4lcajt1MzaHdgpM2 0Un3syuOA8/U2jsWt8DBJiueuMC62o9EkriuoYrztdVpWwnG/yY+Sy6AzTtixKTzqPPB rLKnLBkLDW39w7b/J1Zbdcx82RGNo67raq+W6+lprbJ9LM2htc8cZS/aRxvf1G13ePnc IS3Jzf+M7iLIIm0jpY7cqDtSTTA0/k7BXLfIc6dRBfJ/BuJv7voXPrM+hps13/VPPKrK qefGYxhOVc6pj9bbtKqE5HSbwY1xW14XfzvRxTRxZepGjNkPx/nQ2Qt3mL9JN6nprSxb acAw== X-Gm-Message-State: ACrzQf2DfSmnCKc1zPNZHIvI0kR1191RG1wC88wiPWIAQaFmoAFF03rv Ty5WjtDHAcMEeWl47UMQQB0= X-Google-Smtp-Source: AMsMyM5iPvaKGQ+lU/wA15lUDKduPyVp0Psny3VAxI8TVl+GMPXgPk02cHgarNIBuaXdamZhkM7iCg== X-Received: by 2002:ac8:7f93:0:b0:35b:bbdd:5699 with SMTP id z19-20020ac87f93000000b0035bbbdd5699mr78529qtj.46.1664404427112; Wed, 28 Sep 2022 15:33:47 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:33:46 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 1/9] lib/show_mem.c: display MovableOnly Date: Wed, 28 Sep 2022 15:32:53 -0700 Message-Id: <20220928223301.375229-2-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WAksJPCt; spf=pass (imf05.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404427; a=rsa-sha256; cv=none; b=7eZgoUGcM/7ydk9MDf7aV5KLk65eMvyvQ+w+e66qEDZJ06gaDXUTeEJi2sNlQyWMJw7J9f dMSuJDy1hZi4HJbODITAK46FG5cnxhGIUKtXABO8E1UPiOyPP8QhpxO8mPaAaHRdPqdXoZ PFQXN/TwMDBXv4shb99kLt6rrqfe9YY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404427; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hB/8CHaP3epa66ZDI7eIxcYHinx9lai7E+SzdR8JK34=; b=7aRNMevb/cx3cIcXKTQC7VAGYYDAKLE5l51LP5KW3E8WXOBvVJ+d3m7vLa/j+p5WTQ5beb sHbi9WnILFjCtTxSRi0AJnqI36aKWrg7zSirFnjKTAMogLuq/Thy2gOaM4Kb2HKDJe9InS lMlTAPhzkD8fWxNZycRtL45XxKaSlVo= Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=WAksJPCt; spf=pass (imf05.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Stat-Signature: zziubn7g711kyceduw6n81bi3jt4nxa4 X-Rspamd-Queue-Id: DEC48100008 X-Rspamd-Server: rspam05 X-HE-Tag: 1664404427-463110 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: The comment for commit c78e93630d15 ("mm: do not walk all of system memory during show_mem") indicates it "also corrects the reporting of HighMem as HighMem/MovableOnly as ZONE_MOVABLE has similar problems to HighMem with respect to lowmem/highmem exhaustion." Presuming the similar problems are with regard to the general exclusion of kernel allocations from either zone, I believe it makes sense to include all ZONE_MOVABLE memory even on systems without HighMem. To the extent that this was the intent of the original commit I have included a "Fixes" tag, but it seems unnecessary to submit to linux-stable. Fixes: c78e93630d15 ("mm: do not walk all of system memory during show_mem") Signed-off-by: Doug Berger --- lib/show_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/show_mem.c b/lib/show_mem.c index 1c26c14ffbb9..337c870a5e59 100644 --- a/lib/show_mem.c +++ b/lib/show_mem.c @@ -27,7 +27,7 @@ void show_mem(unsigned int filter, nodemask_t *nodemask) total += zone->present_pages; reserved += zone->present_pages - zone_managed_pages(zone); - if (is_highmem_idx(zoneid)) + if (zoneid == ZONE_MOVABLE || is_highmem_idx(zoneid)) highmem += zone->present_pages; } } From patchwork Wed Sep 28 22:32:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993201 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 3158EC04A95 for ; Wed, 28 Sep 2022 22:33:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C68356B0078; Wed, 28 Sep 2022 18:33:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C18486B007B; Wed, 28 Sep 2022 18:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A925D6B007D; Wed, 28 Sep 2022 18:33:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9A8866B0078 for ; Wed, 28 Sep 2022 18:33:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5CDE71207D7 for ; Wed, 28 Sep 2022 22:33:51 +0000 (UTC) X-FDA: 79962947862.22.162ACF1 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf13.hostedemail.com (Postfix) with ESMTP id B65F720022 for ; Wed, 28 Sep 2022 22:33:50 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id c11so8864412qtw.8 for ; Wed, 28 Sep 2022 15:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6/+RylwAUS1L6kGkdbzNevLkV7SCUovxqo9fjOaS6JU=; b=kC/0LNb9bktbL+TEwR3l+o6fUDutxrrSeCaNe1//+eoGCAW+xNZO4DlmQHy9VcTyfS NwAIyqoskQm/m5kv6XZ4r7B1ACZBqZis8V/cQNWWyzM9pA3Is409pWX7+mJZ+/N2vvBI YozbOIh7aY5FgIxfp56OJu1Gme5MA8TIs7VrQ4zlIKfuDoRx/M7tAtjTXSP7dzFQ50dF x6WJ/l4IoBT3rvV++v7Beym46s0QSrWDIFgJllEiXfwCqYwnQOCcV3XO4+cbD8UDzrDC Fgpv0bDTnfoI7cOl7Bdut11t3RGz5K9z2orfa9hNqZxWTfMH5f4yEJcCefUWQ9e0L4rd pWOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6/+RylwAUS1L6kGkdbzNevLkV7SCUovxqo9fjOaS6JU=; b=ZiCy5+/n3aJP/c6U8tkjutdQhsydtjfpDRPFdV03Ad6GULU+v2raYV4LIPK5B79FEv YQ0FAun7LCHAy3dovvMmErEtuQf+VSIhBN/hK48YfyjO52nKxWCNOn8dRS1Qdl4WTg9+ LGEizKU1OCI4EeZymucED4p9vlodPWMH0b2y5grD8F9rcSjP3R30tNOSqHC16zhE8K4O TopIrkYBzW73y6xY0LYLoLp3iv9jhLy6peXztMdFDg+mXheo/+hq2vf4/DStZXEa2x83 8x4ams3vag7brJHL5GBVc3e4srONoRUjC0mX9rywHbo9E4KXzHAY7m2Bu/b7dgGuKAHT 9uJA== X-Gm-Message-State: ACrzQf1JVXoEagrvv6s4R+SC7HbL+yIEQelAXBVNf4BJrn+PPjRtzNu8 SerK/FeyRlm6ZGDLd8FIu7w= X-Google-Smtp-Source: AMsMyM6j7B74qZOjrMnDAmps4FdyuXPteigyZvK3BDi31VGk6vlpVOIX8YjcSQSYPDGzBZGstAm8RA== X-Received: by 2002:a05:622a:138f:b0:35b:bb7b:743c with SMTP id o15-20020a05622a138f00b0035bbb7b743cmr33120qtk.361.1664404429867; Wed, 28 Sep 2022 15:33:49 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:33:49 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 2/9] mm/vmstat: show start_pfn when zone spans pages Date: Wed, 28 Sep 2022 15:32:54 -0700 Message-Id: <20220928223301.375229-3-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="kC/0LNb9"; spf=pass (imf13.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404430; a=rsa-sha256; cv=none; b=Qr6SYd9mi2F1zkDMsjcsu9NTEg0iVUKSh2Mx7je/ocE/wObNnhe+7ADitgoIXVuzoWpb7g R2gvzDn+k5kswvBeU5C2Su2H70Dx6MQu/CjfcN31TcRWUdtVY0kziwRWaGOew/urknhGqA ItDLiqFmS5ax+3gzIw1N6G5vhOur9sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404430; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6/+RylwAUS1L6kGkdbzNevLkV7SCUovxqo9fjOaS6JU=; b=HAid4nLV4ct+mp9KZMLkaBgeoX1B6wf0FmPk5yIfPnf6IQbYym5FsV1s4MXW4R69pTC2T5 LmoqiRxoo1I1TIETfFLJNAXg40oa6UE/0IkMdt4NcFQ0ZJJsM9PY3j+KhMfOoyApI9Rysz pDu1a9DJgCPKcJH6mL8UvpLkqsUwEG0= Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="kC/0LNb9"; spf=pass (imf13.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 3x15uizxapt8tufejc18z3a6n7b5dork X-Rspamd-Queue-Id: B65F720022 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1664404430-204338 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: A zone that overlaps with another zone may span a range of pages that are not present. In this case, displaying the start_pfn of the zone allows the zone page range to be identified. Signed-off-by: Doug Berger --- mm/vmstat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 90af9a8572f5..e2f19f2b7615 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1717,6 +1717,11 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat, /* If unpopulated, no other information is useful */ if (!populated_zone(zone)) { + /* Show start_pfn for empty overlapped zones */ + if (zone->spanned_pages) + seq_printf(m, + "\n start_pfn: %lu", + zone->zone_start_pfn); seq_putc(m, '\n'); return; } From patchwork Wed Sep 28 22:32:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993202 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 95E43C6FA86 for ; Wed, 28 Sep 2022 22:33:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05A1A6B007B; Wed, 28 Sep 2022 18:33:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0317D6B007D; Wed, 28 Sep 2022 18:33:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC6ED6B007E; Wed, 28 Sep 2022 18:33:53 -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 CF0886B007B for ; Wed, 28 Sep 2022 18:33:53 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A4C2912071B for ; Wed, 28 Sep 2022 22:33:53 +0000 (UTC) X-FDA: 79962947946.16.9BE0573 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf29.hostedemail.com (Postfix) with ESMTP id 4EC1512000F for ; Wed, 28 Sep 2022 22:33:53 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id s18so8872995qtx.6 for ; Wed, 28 Sep 2022 15:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cdp6gKq67l8BHxfvYyqMmk5Gv7X6BRjPu/o7++6IXk0=; b=URRpeJBFdppH8e/fE8Zn7u382jDrgAPrKGhvy+7Q9UV2n6l9mlnKvfUaPasfPDJqgk CD+pbglEc1OI5Fj/Ci2WqTozLVEtwoShQNGOrjiQFjdUvELjoZQctEpQ0qJlyiY1tPms mCJNKHtApeVTyeFWznRhP/VEmF+PEBVfL0Wj6h7o2eqTX4N+Rwbn+bTA29OKo7/TjhZr oFtvm1ZfUUbyXsguDLLXRWV61hzGuJRFQ3SHrca2K/fo6GpbBESMus7lg6s82a/2Xses 6HTILxedb1ZkW+eSgwHqH81i1xdlpXFU+5urGqxgxYDlYtqfNTdk8gQDSt36m8RjOxql PFVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cdp6gKq67l8BHxfvYyqMmk5Gv7X6BRjPu/o7++6IXk0=; b=Tr97VZ56OluMRMZ1cgrJ9eGtVXOfT5XsmuJsEwThyKGU/yP5WaRaJ87mQSwhCaBCGt 9dUkbOK1bsvK1rE6/60rH0Da9cXZ67d2oRYtMNDCwwjoqG/LgZA5raz8wGzLwkEaHaTu ++vHGJv+nbEoN6a5Tv+5lJ8Drg41KsGCHp6MbuKWY3edzRJgOxLudnv+AZnQpr6TWowj uJXI1tq+7Pzv1xarAZRiyS7ndMu6WM+3e2uzpP/sRZwc9aEjOOWd4SFtQRQBmO48gyfe 87brpsq5neLVxEbGxEGJdj68JKYl2CYf4eWJB3ck1am1iF+0FaSrKVWR9qtMuteqXfDD sSfA== X-Gm-Message-State: ACrzQf2osSuGqTfex1OJfwZ1rewVFW71IkjGuQgJ1dwLoRDVlkLuQ2An rjexRQJK4rV2U/785LlUVqE= X-Google-Smtp-Source: AMsMyM5HlDloR0Q6E7bhHNQx3py83nBExasTaOUqKPuAI2ERKE88ypL9nf6ynZrpI0Y72+pqvQzwZg== X-Received: by 2002:a05:622a:190b:b0:35b:b5a2:eceb with SMTP id w11-20020a05622a190b00b0035bb5a2ecebmr25196qtc.529.1664404432585; Wed, 28 Sep 2022 15:33:52 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:33:52 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 3/9] mm/page_alloc: calculate node_spanned_pages from pfns Date: Wed, 28 Sep 2022 15:32:55 -0700 Message-Id: <20220928223301.375229-4-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=URRpeJBF; spf=pass (imf29.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404433; a=rsa-sha256; cv=none; b=q3nJX5dJBAINkZLnitnZ9DHgDk4Bancr5kdh7IJsstfyZsCUUZVkAsdvEdp6cwh3QXeFF3 4dKfcoRcS35YagPqxLpQA2fF/a6H1R0M7699dh6lAUGFz8GpSQhJKj4/y5OC7oLZpdgJUu MfzOHtOgvSYOoXQHb49TXh7ox2K/XKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404433; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cdp6gKq67l8BHxfvYyqMmk5Gv7X6BRjPu/o7++6IXk0=; b=K0FE4wKzkKIuwFs/t34pqMpluLLc01Zb4TnKYQ4zEshXwrtkPjwDSQ8lUaa93RFOkTPv5P aoklTU9ish0xaKVhPWfWqcpImwPF2sPZLb8MCYRaLNbYOm2Cz5IENoprQYJeMaVt+SzAQe tnBv1S/6aJWor9KZNmiaK+dw032SHJs= X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=URRpeJBF; spf=pass (imf29.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.179 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam10 X-Stat-Signature: iyi479nr9tm5nqdrtzuyos6q8fmwuiyk X-Rspamd-Queue-Id: 4EC1512000F X-HE-Tag: 1664404433-280376 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: Since the start and end pfns of the node are passed as arguments to calculate_node_totalpages() they might as well be used to specify the node_spanned_pages value for the node rather than accumulating the spans of member zones. This prevents the need for additional adjustments if zones are allowed to overlap. Signed-off-by: Doug Berger --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e5486d47406e..3412d644c230 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7452,7 +7452,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, unsigned long node_start_pfn, unsigned long node_end_pfn) { - unsigned long realtotalpages = 0, totalpages = 0; + unsigned long realtotalpages = 0; enum zone_type i; for (i = 0; i < MAX_NR_ZONES; i++) { @@ -7483,11 +7483,10 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, zone->present_early_pages = real_size; #endif - totalpages += size; realtotalpages += real_size; } - pgdat->node_spanned_pages = totalpages; + pgdat->node_spanned_pages = node_end_pfn - node_start_pfn; pgdat->node_present_pages = realtotalpages; pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); } From patchwork Wed Sep 28 22:32:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993203 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 5861DC6FA82 for ; Wed, 28 Sep 2022 22:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8D436B007D; Wed, 28 Sep 2022 18:33:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3B656B007E; Wed, 28 Sep 2022 18:33:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB5356B0080; Wed, 28 Sep 2022 18:33:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BB2726B007D for ; Wed, 28 Sep 2022 18:33:56 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B532120A8B for ; Wed, 28 Sep 2022 22:33:56 +0000 (UTC) X-FDA: 79962948072.05.503EB65 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf19.hostedemail.com (Postfix) with ESMTP id 09FBD1A000D for ; Wed, 28 Sep 2022 22:33:55 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id p3so3502481qvz.6 for ; Wed, 28 Sep 2022 15:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Y1gY+TTTvQU628l9QGecp/PtNkThqCYkuVMTpcWzNvU=; b=BqYh+xbtP+MiEfognlviz93t2UYTYbdkBqOta6P6qz05hPu2VXyNpJC6ZPNULV48aV R7ix3iOWaCRHG86HGLxJOkOqX/k5tkF1yhFvp7trfzvr0tkFqw6il3mSg1zFJq9cGzrl o6my3cBgPsq0pFc3Ib7FFLp9Ce+8nvoZVzr+yWG/M+XojQe2YfkMiMH2x48UuO+Jq0kf LySWCGNlbEk6r/C2v8x/crAodPNpp4U5MuIaDgbMfYbRraHdNmJMNeg3sA9TnaNV5H6B 3+tTIPJ7STDIM6FZsrlOKaKFPsGy72ghWhyrMA3E0+WLnlE1E5MXJip0lp+GLAdIqCIm yCkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Y1gY+TTTvQU628l9QGecp/PtNkThqCYkuVMTpcWzNvU=; b=xTfzu461KNqV7SKCkFkDq9xg4FTP/qxHEGcoD1S0c36eiZvzWBlqS3aAkll9Jj9Gg6 Dgvd7lCDTP7zHWHjwYKfZxM7qFDaVrpLobZY6WGkdUQvjGG2HH14Dut/+40jijYvWe34 DOapKXGRUmas+UY8pjq1IXsK+FzLW9qJTk4wJrwgdDrhr2LczXYdt/wN8VLYGukCCBzi a1rpznLygvlOM7acHc4hXFGHthJiQ18HCSchAoC3FaAc0U0chCYDDxfIZtGrWTdJmPVt g6PmItb8dcvKDCNe0zHzcZ9vf7zIoZGiulrARyJ2bcgpgTkItbEAiMXdha0G5+qiWcoX ARRg== X-Gm-Message-State: ACrzQf1h4iG2S03kfuK9vhsua1b9aFNx1x81oUAfhkNa7v5HusGvjEZe Ppcha4A6NkPddvgl9XpU9xo= X-Google-Smtp-Source: AMsMyM7sRRj9qRUG7RZy9MMEt2bnHdiX8XuLyY5K1L0DMOgv9jkZopsYpvfjf6WZb2+cG3qtbuVi9w== X-Received: by 2002:a0c:9a4c:0:b0:4a4:3ad8:3c28 with SMTP id q12-20020a0c9a4c000000b004a43ad83c28mr205895qvd.124.1664404435298; Wed, 28 Sep 2022 15:33:55 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:33:54 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 4/9] mm/page_alloc.c: allow oversized movablecore Date: Wed, 28 Sep 2022 15:32:56 -0700 Message-Id: <20220928223301.375229-5-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404436; a=rsa-sha256; cv=none; b=uiqeY6I5+PXEc5fq0slVoTnFWGnLxyqnX/+cJX6QdPCEn8TkgSDPdTnUW3ESZtGqm2T1+O AIYZwWfE6GjlKqyzRolTJtiNLwbIV45x6BvF+xaqNDB693kRIoAmFRnmSXNnIRFovUd2kb 9Xu9JYK49qHNEAWLntUMbbBo17MCu4Y= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BqYh+xbt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404436; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Y1gY+TTTvQU628l9QGecp/PtNkThqCYkuVMTpcWzNvU=; b=bpquwiOHrTNb1V0u0Ck4gXWLR5gK/dcRlTh95wNd/d9B2vdLrHi/d8WjmsXBjW/oxaapSB SVpMNhdOJdwNRKmYsar1s4+nlCQqhhmKhGpwubQ53/YlYC0gVih9OnZfYzODwrmEkVYmqu whd0RrckoYWxROTmH/p+1OgbNrlSEOM= X-Stat-Signature: 9i4cgdjic471apgksayqpsa9uxa3j4nk X-Rspamd-Queue-Id: 09FBD1A000D Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=BqYh+xbt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1664404435-360908 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: Now that the error in computation of corepages has been corrected by commit 9fd745d450e7 ("mm: fix overflow in find_zone_movable_pfns_for_nodes()"), oversized specifications of movablecore will result in a zero value for required_kernelcore if it is not also specified. It is unintuitive for such a request to lead to no ZONE_MOVABLE memory when the kernel parameters are clearly requesting some. The current behavior when requesting an oversized kernelcore is to classify all of the pages in movable_zone as kernelcore. The new behavior when requesting an oversized movablecore (when not also specifying kernelcore) is to similarly classify all of the pages in movable_zone as movablecore. Signed-off-by: Doug Berger --- mm/page_alloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3412d644c230..81f97c5ed080 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8041,13 +8041,13 @@ static void __init find_zone_movable_pfns_for_nodes(void) corepages = totalpages - required_movablecore; required_kernelcore = max(required_kernelcore, corepages); + } else if (!required_kernelcore) { + /* If kernelcore was not specified, there is no ZONE_MOVABLE */ + goto out; } - /* - * If kernelcore was not specified or kernelcore size is larger - * than totalpages, there is no ZONE_MOVABLE. - */ - if (!required_kernelcore || required_kernelcore >= totalpages) + /* If kernelcore size exceeds totalpages, there is no ZONE_MOVABLE */ + if (required_kernelcore >= totalpages) goto out; /* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */ From patchwork Wed Sep 28 22:32:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993204 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 1DA0BC04A95 for ; Wed, 28 Sep 2022 22:34:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A94096B0080; Wed, 28 Sep 2022 18:33:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A43FD6B0081; Wed, 28 Sep 2022 18:33:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E4656B0082; Wed, 28 Sep 2022 18:33:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7C5C46B0080 for ; Wed, 28 Sep 2022 18:33:59 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 48FCA1204E8 for ; Wed, 28 Sep 2022 22:33:59 +0000 (UTC) X-FDA: 79962948198.27.B4FDA27 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by imf06.hostedemail.com (Postfix) with ESMTP id DB70F180007 for ; Wed, 28 Sep 2022 22:33:58 +0000 (UTC) Received: by mail-qv1-f49.google.com with SMTP id m18so3309278qvo.12 for ; Wed, 28 Sep 2022 15:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=lhtWJhsd4j1WsvrD24jP2B8/duCGXddB3TQ2GRCgsxg=; b=K4Q7s1SxcUiklLSpEe6hESiZP1eOwlpB06nDUMzWfLR+0hfwHBSsDc9vw59nU6aEJj fuU58WUvQGm9lOcNc70XihFXQHcDbjXpCyfRDy2Yj10m+KOk1le/1KJ5jGnO2/drUJNV 6/w5oHj4j7ksI1PvbfmNogyb+2VAXBylqvHHytrxEPT6B9tqreUV6nx7JxfuMcSx1mg9 udUN//BAAEMQCXBmrh/9DmVfqDgnInPV/jLTGI6qM30DD1crAkg5uZsVTBCOviHGTcAp iByb2ebeoASWVGlb1e4wklMEohoA3Kf3sXcc76Vlm2ERoj9cZ8IF+PZ5jHcsAhAgaAvh BJ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=lhtWJhsd4j1WsvrD24jP2B8/duCGXddB3TQ2GRCgsxg=; b=QR6CyfBFs9tlEwl+v5wbzlt573bK84pyRc7Rajd+GFojbSkJjCKsAN4ZpIL3cF8tg2 19cVc3ycPA3wXGKAb03qKNcp17cwKhudLyRF69E6/LovO/WC611pQPOgHJo3Jfchk1j6 srJsPkW7SezKwCDu2lCvL1LSOGIWBj6jsJfBgi0RqnYSHQqr3AIciKPSIXGmw49q1Nmy WlyMe5OMEcAlW3yuvw7KSrzYjekmAPN94ALGFqZGQ+qQUGPOU7Vlli5uIgHAUUiUQFmg Rp+fo9mAFlz4sMEqqrZzCMEhrjlxuCfnwSRzFwWKd0Uu6XP+EJBYDzfEwOG13odBAXGO NyJw== X-Gm-Message-State: ACrzQf1+l73n0a5wOxo9d3kUoJTYummHzDvUM9utKQMeCkj8uJPHbvWX KYP2aaGEs+jMNBDye3XvzgI= X-Google-Smtp-Source: AMsMyM6hndsIdtDYd0/y5nc1hr5JoFumCrEoRQfIpyGeSDegaAZLd45AZZ0iEbDObJ88KUO8KKuesA== X-Received: by 2002:a0c:b295:0:b0:496:b91a:f5f4 with SMTP id r21-20020a0cb295000000b00496b91af5f4mr234203qve.20.1664404438041; Wed, 28 Sep 2022 15:33:58 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:33:57 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 5/9] mm/page_alloc: introduce init_reserved_pageblock() Date: Wed, 28 Sep 2022 15:32:57 -0700 Message-Id: <20220928223301.375229-6-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404438; a=rsa-sha256; cv=none; b=C65LCkf5ViG4wvvF++s0ULuS83vtef+mbqKLDfpJYlwC5vEOlajRzbtW6xgMoLoKc1Cjxq DMWPGMMFL6IXNvHgqrXQfT3UGyrKh3WQEeYugmg4DQ7RtXa8nNYX4AogIQhrleXJbP+KCS ewhl8XqJAm2z8ABVPcvWF9As2mCHxvI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=K4Q7s1Sx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.49 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404438; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lhtWJhsd4j1WsvrD24jP2B8/duCGXddB3TQ2GRCgsxg=; b=MPcdwsOPHtPs/HDXzMydnIS4i0RAcXTyKmdoR1d2N0dNlKfgexsX+mpl2V8i1AuhZXQhya fZCZfLcVqbf/eYs+AZyt9DkFzb1GIEpC0iJh0Fad6gLVt/rCYDpTOg/j/HnSCe/92eKD07 EipYRa9UxuKtb1S567FMyqef5oVJAdw= X-Rspamd-Queue-Id: DB70F180007 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=K4Q7s1Sx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.49 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: enfgd8u5xrppw9hn3ds9rfqdbu9a5cs1 X-HE-Tag: 1664404438-825342 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: Most of the implementation of init_cma_reserved_pageblock() is common to the initialization of any reserved pageblock for use by the page allocator. This commit breaks that functionality out into the new common function init_reserved_pageblock() for use by code other than CMA. The CMA specific code is relocated from page_alloc to the point where init_cma_reserved_pageblock() was invoked and the new function is used there instead. The error path is also updated to use the function to operate on pageblocks rather than pages. Signed-off-by: Doug Berger --- include/linux/gfp.h | 5 +---- mm/cma.c | 15 +++++++++++---- mm/page_alloc.c | 8 ++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index f314be58fa77..71ed687be406 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -367,9 +367,6 @@ extern struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask, #endif void free_contig_range(unsigned long pfn, unsigned long nr_pages); -#ifdef CONFIG_CMA -/* CMA stuff */ -extern void init_cma_reserved_pageblock(struct page *page); -#endif +extern void init_reserved_pageblock(struct page *page); #endif /* __LINUX_GFP_H */ diff --git a/mm/cma.c b/mm/cma.c index 4a978e09547a..6208a3e1cd9d 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "cma.h" @@ -116,8 +117,13 @@ static void __init cma_activate_area(struct cma *cma) } for (pfn = base_pfn; pfn < base_pfn + cma->count; - pfn += pageblock_nr_pages) - init_cma_reserved_pageblock(pfn_to_page(pfn)); + pfn += pageblock_nr_pages) { + struct page *page = pfn_to_page(pfn); + + set_pageblock_migratetype(page, MIGRATE_CMA); + init_reserved_pageblock(page); + page_zone(page)->cma_pages += pageblock_nr_pages; + } spin_lock_init(&cma->lock); @@ -133,8 +139,9 @@ static void __init cma_activate_area(struct cma *cma) out_error: /* Expose all pages to the buddy, they are useless for CMA. */ if (!cma->reserve_pages_on_error) { - for (pfn = base_pfn; pfn < base_pfn + cma->count; pfn++) - free_reserved_page(pfn_to_page(pfn)); + for (pfn = base_pfn; pfn < base_pfn + cma->count; + pfn += pageblock_nr_pages) + init_reserved_pageblock(pfn_to_page(pfn)); } totalcma_pages -= cma->count; cma->count = 0; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 81f97c5ed080..6d4470b0daba 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2302,9 +2302,8 @@ void __init page_alloc_init_late(void) set_zone_contiguous(zone); } -#ifdef CONFIG_CMA -/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ -void __init init_cma_reserved_pageblock(struct page *page) +/* Free whole pageblock */ +void __init init_reserved_pageblock(struct page *page) { unsigned i = pageblock_nr_pages; struct page *p = page; @@ -2314,14 +2313,11 @@ void __init init_cma_reserved_pageblock(struct page *page) set_page_count(p, 0); } while (++p, --i); - set_pageblock_migratetype(page, MIGRATE_CMA); set_page_refcounted(page); __free_pages(page, pageblock_order); adjust_managed_page_count(page, pageblock_nr_pages); - page_zone(page)->cma_pages += pageblock_nr_pages; } -#endif /* * The order of subdivision here is critical for the IO subsystem. From patchwork Wed Sep 28 22:32:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993205 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 CF2F4C04A95 for ; Wed, 28 Sep 2022 22:34:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EA736B0081; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 699EA6B0082; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ECD16B0083; Wed, 28 Sep 2022 18:34:02 -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 40BB56B0081 for ; Wed, 28 Sep 2022 18:34:02 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EA75F40F47 for ; Wed, 28 Sep 2022 22:34:01 +0000 (UTC) X-FDA: 79962948282.04.4444AF2 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 8BF8040009 for ; Wed, 28 Sep 2022 22:34:01 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id gb14so251616qtb.3 for ; Wed, 28 Sep 2022 15:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=XG34Y6tDaJWwx6DqjTOFzsu9FQfdW30BYf0FXo1qOyK2ddb1gPjKGPuXlnXn7WJbbp 3at5ITh2zqc5ND+psxUlpktCRqb1IAzsURp8laAwU3meMWmslVlJ04PurbIm8TjZW067 nvbJ2vgFDTno5HMU+Gfi0PWAZYLTaVzf8H1Dyc6ZNAhhNr+6tXQhmbbkKh+4XQNl5zF1 K+hxIbMy/hJCcqrK4JjzhlxcdtKPFgihmjVSBLcdQYwclydS6XWbaKLgt1yT+hrAmziP mvTMSR2mIOdkNftizVll21ORt676/ts4LNcVaPrB5p5YHLQb1rddtODGPalGlxkiWHGt FAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=5XlRjAwQml5hy9JnwpQMcjyvM/xRWvf7/+uKGNV2EvFQAWjpmMn4/eThEpOr1Scw6O 5wGbmT8AU6lCOcDvFvTyfzwMxy96UFZc3YwFGQztssskmmAyLgMcQD+qvdgC+ksiS7Wb /XwGVXGx5dyODa0sRpwHdGu75IqgeC7if3BX6ivJKb226UwB7Fqogt4F1nUYqMnk91zV 6i2k3V0wujNCt62sDrbIM8bVWJK19PhQVSKFKEIZtJG2jqSQrBe49U7sK9olKA/Ugki8 O0wnxHqwAczarvHB2tWr05A2Jvxx0f/ZS5PMFiEyYNqZwKKTCp0Mv+1nHIZcaaFKUflE ErRg== X-Gm-Message-State: ACrzQf3Rz7y2+XhqwBnK9LShg9ukHh8YMTMsV2G5+33yO9o60aZWdSOV Huu4S22fxk8ZwhNmB12rcvg= X-Google-Smtp-Source: AMsMyM5hls3k73DLDHwmozK6Fn+6fum9LVyQsQgOKR/Uau82IHif8GbeTAVnzUtgkLXNeRQjKZrgzg== X-Received: by 2002:ac8:584c:0:b0:35c:ceee:197a with SMTP id h12-20020ac8584c000000b0035cceee197amr50280qth.662.1664404440788; Wed, 28 Sep 2022 15:34:00 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:00 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 6/9] memblock: introduce MEMBLOCK_MOVABLE flag Date: Wed, 28 Sep 2022 15:32:58 -0700 Message-Id: <20220928223301.375229-7-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404441; a=rsa-sha256; cv=none; b=FXl6lawteknIyXvtYfmFv7S9t6vZnkIy13cwhGvT2GdLnpQeog1bzz45pu/VjYdtVGTFo2 pyBUwqkoxnjhkmaA4tEE7KLtFXxXYRO3LZdLBqyoXu/zgBC6M4XbCj6mRYH09Ye4kfp33Y Qhw+H2ZYE8bPo0wcMU+bEkFdUY2Euos= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XG34Y6tD; spf=pass (imf12.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=opendmb@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=1664404441; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5WWAAzNcGRX09yf3QcgLeiV4ytIgw0QIAz2zMov/ZDY=; b=0Tuc8L97xvfHYlHOlrOjCe5DfwImxYtHvZsdLl0PJAdW/F2RgQzwPfPc+lUlHkQiexMG0Q rFDrpq0c/QGNilZ87gCaJRWungg6hlUpP6wSfseX+koYD3Zmi83ijaXcUGND92BJ3xZAc2 BdNpqaKMXQs/emU9LozMlNFOaSbaKco= X-Stat-Signature: 5y9o6qngb4uda1nx5gqz1nusf71kfu9f X-Rspamd-Queue-Id: 8BF8040009 X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=XG34Y6tD; spf=pass (imf12.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam01 X-HE-Tag: 1664404441-470294 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: The MEMBLOCK_MOVABLE flag is introduced to designate a memblock as only supporting movable allocations by the page allocator. Signed-off-by: Doug Berger --- include/linux/memblock.h | 8 ++++++++ mm/memblock.c | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 50ad19662a32..8eb3ca32dfa7 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -47,6 +47,7 @@ enum memblock_flags { MEMBLOCK_MIRROR = 0x2, /* mirrored region */ MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ MEMBLOCK_DRIVER_MANAGED = 0x8, /* always detected via a driver */ + MEMBLOCK_MOVABLE = 0x10, /* designated movable block */ }; /** @@ -125,6 +126,8 @@ int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); +int memblock_mark_movable(phys_addr_t base, phys_addr_t size); +int memblock_clear_movable(phys_addr_t base, phys_addr_t size); void memblock_free_all(void); void memblock_free(void *ptr, size_t size); @@ -265,6 +268,11 @@ static inline bool memblock_is_driver_managed(struct memblock_region *m) return m->flags & MEMBLOCK_DRIVER_MANAGED; } +static inline bool memblock_is_movable(struct memblock_region *m) +{ + return m->flags & MEMBLOCK_MOVABLE; +} + int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, unsigned long *end_pfn); void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, diff --git a/mm/memblock.c b/mm/memblock.c index b5d3026979fc..5d6a210d98ec 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -979,6 +979,30 @@ int __init_memblock memblock_clear_nomap(phys_addr_t base, phys_addr_t size) return memblock_setclr_flag(base, size, 0, MEMBLOCK_NOMAP); } +/** + * memblock_mark_movable - Mark designated movable block with MEMBLOCK_MOVABLE. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_mark_movable(phys_addr_t base, phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 1, MEMBLOCK_MOVABLE); +} + +/** + * memblock_clear_movable - Clear flag MEMBLOCK_MOVABLE for a specified region. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_clear_movable(phys_addr_t base, phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 0, MEMBLOCK_MOVABLE); +} + static bool should_skip_region(struct memblock_type *type, struct memblock_region *m, int nid, int flags) From patchwork Wed Sep 28 22:32:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993206 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 E4432C04A95 for ; Wed, 28 Sep 2022 22:34:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FCBB6B0082; Wed, 28 Sep 2022 18:34:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AB686B0083; Wed, 28 Sep 2022 18:34:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D7F46B0085; Wed, 28 Sep 2022 18:34:05 -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 4C5846B0082 for ; Wed, 28 Sep 2022 18:34:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0950C8106C for ; Wed, 28 Sep 2022 22:34:05 +0000 (UTC) X-FDA: 79962948450.09.3B30E45 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by imf11.hostedemail.com (Postfix) with ESMTP id 906EB4000F for ; Wed, 28 Sep 2022 22:34:04 +0000 (UTC) Received: by mail-qt1-f174.google.com with SMTP id w2so8855461qtv.9 for ; Wed, 28 Sep 2022 15:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=DEXyAVVZTwjXHLz6TLbcaFBwG1eIHET55TmuRMjtAC8=; b=mvoi09XGyZecBM4bUAQhNKHLRNMAyjZJsvIEtBFhl7CXvFbJQphsG5lNcE/3eysAFk VKG/T0mz3affytowEU/UjtHjYhPkHvVj0Ai+/tnp6AzL+u41WXFqCtnfd7YCm3i0Af7z dei199HOvzGCsOGRNVMy3UY3PaG1EO77MtGg7AdyhyxFmT6UvboWu+pp5fIyO/aiL3oG BLf963tZWwtxHm837fxn0XLrI5bpyjmbVUjlGQV+p11qUHjDRsHJW6IOIJ2FkU3H3wRa elmtE8tr24QaF94RaAPb2ahqb0KQN+6m61Z6yRcXYTLeb54tH6tuMmFj9Tdb4+l7s9gp L39A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=DEXyAVVZTwjXHLz6TLbcaFBwG1eIHET55TmuRMjtAC8=; b=b9Qh+WN7mDxpauklH4JY0nIIMSRKDcvqLl8FNoJEYMJIKq6j+ltXA1ZTNF+1xWj9vW +Sl29D15MH5elIWmvjgxCvEPsmt0NDpYvsz8HMXJMGZZEVNN+8VgQHbf0DyKhneWFj2Q Y6mXdLj90Ogr8KQ/KlEdB/rP+E9GVsxPOIC+xz9cFw+BSHf6zrklwhlHNu4OMCtZWajr qybH45+wdd/5fZ0n/vwQcCZvyAuD2C0MQGonz/Oif+bJPhurgZ6uMbhypiLhvifwgWk0 MEjsxWZRq0V7+WxvrNgXSBVkvNU1ewytnvRHxuQU8drFaIVyJC0HyZ70LYDC5cJu6urj rm0Q== X-Gm-Message-State: ACrzQf191t7aPOJDCP5Y5anzjPPPZBV50UbRI1MeSjY8jgzmiR+Jv2nH KipnoLPoJmCAcnPgVeyICAY= X-Google-Smtp-Source: AMsMyM4zK5Ad43j5BEB/FAjyYbGE4juEGhx6jkVPsOw3+Vy3Yucdoes2I5POjKQyImNAwv8ia7KmKg== X-Received: by 2002:ac8:5750:0:b0:35c:cb1b:2639 with SMTP id 16-20020ac85750000000b0035ccb1b2639mr41854qtx.183.1664404443601; Wed, 28 Sep 2022 15:34:03 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:03 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 7/9] mm/dmb: Introduce Designated Movable Blocks Date: Wed, 28 Sep 2022 15:32:59 -0700 Message-Id: <20220928223301.375229-8-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404444; a=rsa-sha256; cv=none; b=SzFcuvxV+nRv6WzBzB4OWdwqlfkj9YnbyLLS5i5bN+cAd95IJr/XPP4QLYgxampSSt+wPH XUO4RCDNJeOwDcN1s4eozKa22hnJDX2TO/Nrhm1Soa4I176J008ZbgTpzVgxN5fMvyHP0J obVHT9xxZxiqou9jQLvgWt8G3wKGXmM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mvoi09XG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.174 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404444; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DEXyAVVZTwjXHLz6TLbcaFBwG1eIHET55TmuRMjtAC8=; b=AjE5c9k7izmwtnDrSBKyDcib3tib7aple6AYQusSmXu42YHvDFwO+umELVeomPZFjGWNfX g3qi/xjVYNsQ5nyBrsfzdOx1/xrt4cDrt41H9ED+XtvPKgnoqfqANvl/toWEDbOP5+VIdk zE1C3wvCsu2KodUWrCg9pTvGQOfBpkQ= X-Rspamd-Queue-Id: 906EB4000F X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mvoi09XG; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.174 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: sx1d71ut3mi4iu3e93rqf8f8oyctjhk5 X-HE-Tag: 1664404444-382992 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: Designated Movable Blocks are blocks of memory that are composed of one or more adjacent memblocks that have the MEMBLOCK_MOVABLE designation. These blocks must be reserved before receiving that designation and will be located in the ZONE_MOVABLE zone rather than any other zone that may span them. Signed-off-by: Doug Berger --- include/linux/dmb.h | 29 +++++++++++++++ mm/Kconfig | 12 ++++++ mm/Makefile | 1 + mm/dmb.c | 91 +++++++++++++++++++++++++++++++++++++++++++++ mm/memblock.c | 6 ++- mm/page_alloc.c | 84 ++++++++++++++++++++++++++++++++++------- 6 files changed, 209 insertions(+), 14 deletions(-) create mode 100644 include/linux/dmb.h create mode 100644 mm/dmb.c diff --git a/include/linux/dmb.h b/include/linux/dmb.h new file mode 100644 index 000000000000..fa2976c0fa21 --- /dev/null +++ b/include/linux/dmb.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DMB_H__ +#define __DMB_H__ + +#include + +/* + * the buddy -- especially pageblock merging and alloc_contig_range() + * -- can deal with only some pageblocks of a higher-order page being + * MIGRATE_MOVABLE, we can use pageblock_nr_pages. + */ +#define DMB_MIN_ALIGNMENT_PAGES pageblock_nr_pages +#define DMB_MIN_ALIGNMENT_BYTES (PAGE_SIZE * DMB_MIN_ALIGNMENT_PAGES) + +enum { + DMB_DISJOINT = 0, + DMB_INTERSECTS, + DMB_MIXED, +}; + +struct dmb; + +extern int dmb_intersects(unsigned long spfn, unsigned long epfn); + +extern int dmb_reserve(phys_addr_t base, phys_addr_t size, + struct dmb **res_dmb); +extern void dmb_init_region(struct memblock_region *region); + +#endif diff --git a/mm/Kconfig b/mm/Kconfig index 0331f1461f81..7739edde5d4d 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -868,6 +868,18 @@ config CMA_AREAS If unsure, leave the default value "7" in UMA and "19" in NUMA. +config DMB_COUNT + int "Maximum count of Designated Movable Blocks" + default 19 if NUMA + default 7 + help + Designated Movable Blocks are blocks of memory that can be used + by the page allocator exclusively for movable pages. They are + managed in ZONE_MOVABLE but may overlap with other zones. This + parameter sets the maximum number of DMBs in the system. + + If unsure, leave the default value "7" in UMA and "19" in NUMA. + config MEM_SOFT_DIRTY bool "Track memory changes" depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS diff --git a/mm/Makefile b/mm/Makefile index 9a564f836403..d0b469a494f2 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -67,6 +67,7 @@ obj-y += page-alloc.o obj-y += init-mm.o obj-y += memblock.o obj-y += $(memory-hotplug-y) +obj-y += dmb.o ifdef CONFIG_MMU obj-$(CONFIG_ADVISE_SYSCALLS) += madvise.o diff --git a/mm/dmb.c b/mm/dmb.c new file mode 100644 index 000000000000..f6c4e2662e0f --- /dev/null +++ b/mm/dmb.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Designated Movable Block + */ + +#define pr_fmt(fmt) "dmb: " fmt + +#include + +struct dmb { + unsigned long start_pfn; + unsigned long end_pfn; +}; + +static struct dmb dmb_areas[CONFIG_DMB_COUNT]; +static unsigned int dmb_area_count; + +int dmb_intersects(unsigned long spfn, unsigned long epfn) +{ + int i; + struct dmb *dmb; + + if (spfn >= epfn) + return DMB_DISJOINT; + + for (i = 0; i < dmb_area_count; i++) { + dmb = &dmb_areas[i]; + if (spfn >= dmb->end_pfn) + continue; + if (epfn <= dmb->start_pfn) + return DMB_DISJOINT; + if (spfn >= dmb->start_pfn && epfn <= dmb->end_pfn) + return DMB_INTERSECTS; + else + return DMB_MIXED; + } + + return DMB_DISJOINT; +} +EXPORT_SYMBOL(dmb_intersects); + +int __init dmb_reserve(phys_addr_t base, phys_addr_t size, + struct dmb **res_dmb) +{ + struct dmb *dmb; + + /* Sanity checks */ + if (!size || !memblock_is_region_reserved(base, size)) + return -EINVAL; + + /* ensure minimal alignment required by mm core */ + if (!IS_ALIGNED(base | size, DMB_MIN_ALIGNMENT_BYTES)) + return -EINVAL; + + if (dmb_area_count == ARRAY_SIZE(dmb_areas)) { + pr_warn("Not enough slots for DMB reserved regions!\n"); + return -ENOSPC; + } + + /* + * Each reserved area must be initialised later, when more kernel + * subsystems (like slab allocator) are available. + */ + dmb = &dmb_areas[dmb_area_count++]; + + dmb->start_pfn = PFN_DOWN(base); + dmb->end_pfn = PFN_DOWN(base + size); + if (res_dmb) + *res_dmb = dmb; + + memblock_mark_movable(base, size); + return 0; +} + +void __init dmb_init_region(struct memblock_region *region) +{ + unsigned long pfn; + int i; + + for (pfn = memblock_region_memory_base_pfn(region); + pfn < memblock_region_memory_end_pfn(region); + pfn += pageblock_nr_pages) { + struct page *page = pfn_to_page(pfn); + + for (i = 0; i < pageblock_nr_pages; i++) + set_page_zone(page + i, ZONE_MOVABLE); + + /* free reserved pageblocks to page allocator */ + init_reserved_pageblock(page); + } +} diff --git a/mm/memblock.c b/mm/memblock.c index 5d6a210d98ec..9eb91acdeb75 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -2090,13 +2091,16 @@ static void __init memmap_init_reserved_pages(void) for_each_reserved_mem_range(i, &start, &end) reserve_bootmem_region(start, end); - /* and also treat struct pages for the NOMAP regions as PageReserved */ for_each_mem_region(region) { + /* treat struct pages for the NOMAP regions as PageReserved */ if (memblock_is_nomap(region)) { start = region->base; end = start + region->size; reserve_bootmem_region(start, end); } + /* move Designated Movable Block pages to ZONE_MOVABLE */ + if (memblock_is_movable(region)) + dmb_init_region(region); } } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6d4470b0daba..cd31f26b0d21 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -433,6 +434,7 @@ static unsigned long required_kernelcore __initdata; static unsigned long required_kernelcore_percent __initdata; static unsigned long required_movablecore __initdata; static unsigned long required_movablecore_percent __initdata; +static unsigned long min_dmb_pfn[MAX_NUMNODES] __initdata; static unsigned long zone_movable_pfn[MAX_NUMNODES] __initdata; bool mirrored_kernelcore __initdata_memblock; @@ -2165,7 +2167,7 @@ static int __init deferred_init_memmap(void *data) } zone_empty: /* Sanity check that the next zone really is unpopulated */ - WARN_ON(++zid < MAX_NR_ZONES && populated_zone(++zone)); + WARN_ON(++zid < ZONE_MOVABLE && populated_zone(++zone)); pr_info("node %d deferred pages initialised in %ums\n", pgdat->node_id, jiffies_to_msecs(jiffies - start)); @@ -6899,6 +6901,10 @@ static void __init memmap_init_zone_range(struct zone *zone, unsigned long zone_end_pfn = zone_start_pfn + zone->spanned_pages; int nid = zone_to_nid(zone), zone_id = zone_idx(zone); + /* Skip overlap of ZONE_MOVABLE */ + if (zone_id == ZONE_MOVABLE && zone_start_pfn < *hole_pfn) + zone_start_pfn = *hole_pfn; + start_pfn = clamp(start_pfn, zone_start_pfn, zone_end_pfn); end_pfn = clamp(end_pfn, zone_start_pfn, zone_end_pfn); @@ -7348,6 +7354,9 @@ static unsigned long __init zone_spanned_pages_in_node(int nid, node_start_pfn, node_end_pfn, zone_start_pfn, zone_end_pfn); + if (zone_type == ZONE_MOVABLE && min_dmb_pfn[nid]) + *zone_start_pfn = min(*zone_start_pfn, min_dmb_pfn[nid]); + /* Check that this node has pages within the zone's required range */ if (*zone_end_pfn < node_start_pfn || *zone_start_pfn > node_end_pfn) return 0; @@ -7416,12 +7425,17 @@ static unsigned long __init zone_absent_pages_in_node(int nid, &zone_start_pfn, &zone_end_pfn); nr_absent = __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn); + if (zone_type == ZONE_MOVABLE && min_dmb_pfn[nid]) { + zone_start_pfn = min(zone_start_pfn, min_dmb_pfn[nid]); + nr_absent += zone_movable_pfn[nid] - zone_start_pfn; + } + /* * ZONE_MOVABLE handling. - * Treat pages to be ZONE_MOVABLE in ZONE_NORMAL as absent pages + * Treat pages to be ZONE_MOVABLE in other zones as absent pages * and vice versa. */ - if (mirrored_kernelcore && zone_movable_pfn[nid]) { + if (zone_movable_pfn[nid]) { unsigned long start_pfn, end_pfn; struct memblock_region *r; @@ -7431,6 +7445,21 @@ static unsigned long __init zone_absent_pages_in_node(int nid, end_pfn = clamp(memblock_region_memory_end_pfn(r), zone_start_pfn, zone_end_pfn); + if (memblock_is_movable(r)) { + if (zone_type != ZONE_MOVABLE) { + nr_absent += end_pfn - start_pfn; + continue; + } + + end_pfn = min(end_pfn, zone_movable_pfn[nid]); + if (start_pfn < zone_movable_pfn[nid]) + nr_absent -= end_pfn - start_pfn; + continue; + } + + if (!mirrored_kernelcore) + continue; + if (zone_type == ZONE_MOVABLE && memblock_is_mirror(r)) nr_absent += end_pfn - start_pfn; @@ -7450,6 +7479,15 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, { unsigned long realtotalpages = 0; enum zone_type i; + int nid = pgdat->node_id; + + /* + * If Designated Movable Blocks are defined on this node, ensure that + * zone_movable_pfn is also defined for this node. + */ + if (min_dmb_pfn[nid] && !zone_movable_pfn[nid]) + zone_movable_pfn[nid] = min(node_end_pfn, + arch_zone_highest_possible_pfn[movable_zone]); for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *zone = pgdat->node_zones + i; @@ -7457,12 +7495,12 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, unsigned long spanned, absent; unsigned long size, real_size; - spanned = zone_spanned_pages_in_node(pgdat->node_id, i, + spanned = zone_spanned_pages_in_node(nid, i, node_start_pfn, node_end_pfn, &zone_start_pfn, &zone_end_pfn); - absent = zone_absent_pages_in_node(pgdat->node_id, i, + absent = zone_absent_pages_in_node(nid, i, node_start_pfn, node_end_pfn); @@ -7922,15 +7960,23 @@ unsigned long __init find_min_pfn_with_active_regions(void) static unsigned long __init early_calculate_totalpages(void) { unsigned long totalpages = 0; - unsigned long start_pfn, end_pfn; - int i, nid; + struct memblock_region *r; - for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { - unsigned long pages = end_pfn - start_pfn; + for_each_mem_region(r) { + unsigned long start_pfn, end_pfn, pages; + int nid; - totalpages += pages; - if (pages) + nid = memblock_get_region_node(r); + start_pfn = memblock_region_memory_base_pfn(r); + end_pfn = memblock_region_memory_end_pfn(r); + + pages = end_pfn - start_pfn; + if (pages) { + totalpages += pages; node_set_state(nid, N_MEMORY); + if (memblock_is_movable(r) && !min_dmb_pfn[nid]) + min_dmb_pfn[nid] = start_pfn; + } } return totalpages; } @@ -7943,7 +7989,7 @@ static unsigned long __init early_calculate_totalpages(void) */ static void __init find_zone_movable_pfns_for_nodes(void) { - int i, nid; + int nid; unsigned long usable_startpfn; unsigned long kernelcore_node, kernelcore_remaining; /* save the state before borrow the nodemask */ @@ -8071,13 +8117,24 @@ static void __init find_zone_movable_pfns_for_nodes(void) kernelcore_remaining = kernelcore_node; /* Go through each range of PFNs within this node */ - for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { + for_each_mem_region(r) { unsigned long size_pages; + if (memblock_get_region_node(r) != nid) + continue; + + start_pfn = memblock_region_memory_base_pfn(r); + end_pfn = memblock_region_memory_end_pfn(r); start_pfn = max(start_pfn, zone_movable_pfn[nid]); if (start_pfn >= end_pfn) continue; + /* Skip over Designated Movable Blocks */ + if (memblock_is_movable(r)) { + zone_movable_pfn[nid] = end_pfn; + continue; + } + /* Account for what is only usable for kernelcore */ if (start_pfn < usable_startpfn) { unsigned long kernel_pages; @@ -8226,6 +8283,7 @@ void __init free_area_init(unsigned long *max_zone_pfn) } /* Find the PFNs that ZONE_MOVABLE begins at in each node */ + memset(min_dmb_pfn, 0, sizeof(min_dmb_pfn)); memset(zone_movable_pfn, 0, sizeof(zone_movable_pfn)); find_zone_movable_pfns_for_nodes(); From patchwork Wed Sep 28 22:33:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993207 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 9130EC32771 for ; Wed, 28 Sep 2022 22:34:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27D546B0083; Wed, 28 Sep 2022 18:34:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22D956B0085; Wed, 28 Sep 2022 18:34:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A6F06B0087; Wed, 28 Sep 2022 18:34:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F141F6B0083 for ; Wed, 28 Sep 2022 18:34:07 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C94D840F54 for ; Wed, 28 Sep 2022 22:34:07 +0000 (UTC) X-FDA: 79962948534.27.D8BCCA9 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf17.hostedemail.com (Postfix) with ESMTP id 3FADB4000E for ; Wed, 28 Sep 2022 22:34:07 +0000 (UTC) Received: by mail-qv1-f41.google.com with SMTP id ml1so9061757qvb.1 for ; Wed, 28 Sep 2022 15:34:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=hndRuqLYmpsdza/I5YqR10YZRjB6Gw7lqCVZwv7bT84=; b=W5KTlkD6VDvTed2L2KfHwXo9j86RBLv0DNqupCjdd7UJXUFKgQ6ICn1v22QPaFF653 UUH7LRcXhW62qq39IHwi34e5XSq8nSnOM5SAyWJvUpLscbaqAkYsuFZsSYCAiBqDk+WE 12K8uhBSmyEFWms9uxioDGzI3h9oFNasFPBomC7bWYUMDQ+i5OMAZnByjvqWrIn0HhIf KJhuzCmgX/7mBYgrmftfQadDSto2kyNLE2imb9nYnmLFfllPp4mAvrPZGMDuVzxUOjDG 9lGghwppmTYcB6NOl9/Hb1f4XFaxXyms0ePckizh45ccJw6S8t2QhVjg7VgrvpJxSSdo T/Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=hndRuqLYmpsdza/I5YqR10YZRjB6Gw7lqCVZwv7bT84=; b=svnfyc/42SDMXIXCV08L5sNwSqiEl/cPmWnL86La0XOZuP7Pz4WBIodg4U5rxk5GEg fM+D0MK+AINufeAZN9w+UUn2sWSsS7wx6bera2nZ8FRrpFyPQe5+lzvq/vZj09y8dvP9 WBYOQ7SOjqmlKr9AYP2vE2fM4nl86KxMqHfn+XibouGuzvVyOw25nVFtwAT5IkiwSgrc 0S4EfkNeVmoeBTe5pl1Tj6cGuy1GVm7q42kue6mP2Lp95B8xBw50tnWEmocMXyi57a4S 1pufjhaRPe7CGpLufeVhV5MBLQ989YqBy+wufMB8WwH9QcRrVaknnzP4fpb23xpeXkCQ PK6g== X-Gm-Message-State: ACrzQf3qJoRzcxF5DlJFfDdp1XzXfsATC4VPwG3bkkfEDj6vsbl//Hs9 tMIL1eekZWTSfljsNIZ+A6o= X-Google-Smtp-Source: AMsMyM6Ccu/5uERbT7jxjfR+0FE1IFewQaesnxuWr2WVMdlCZf4bfvdaCH8iSFcEiEy/T6yQAHFDhA== X-Received: by 2002:ad4:4ea7:0:b0:4ad:656a:260c with SMTP id ed7-20020ad44ea7000000b004ad656a260cmr268848qvb.51.1664404446501; Wed, 28 Sep 2022 15:34:06 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:05 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 8/9] mm/page_alloc: make alloc_contig_pages DMB aware Date: Wed, 28 Sep 2022 15:33:00 -0700 Message-Id: <20220928223301.375229-9-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404447; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hndRuqLYmpsdza/I5YqR10YZRjB6Gw7lqCVZwv7bT84=; b=t22K2ngKuegFEoitTJItI92k4bwV5I8k5MFFZTfPv845rdE6d2BuisnzQS3CEd5lEqgsl/ lrHBmpaBrouhxwyMmkgNT6bzKFkpZpCl0fD4l48khs5qWcUUMCVkfd9t+RArMxKq14ctnx 3qeWNlf1kWbVfvIHm9L8zg4Nl01KYQE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=W5KTlkD6; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404447; a=rsa-sha256; cv=none; b=nw9iop4sAFciCoocymE6+nhI7GpnsSYWZLkYt3OtRqp4H51PwNhUZTTsYrWbMEDwpmYMlp W4CFejYuHP4VEAXbNBPtY74RssxOdSDEVLtJZ1ijqFlzt+9p0C0DVhe4mM/ALgNLKPb2+6 +gbROY5b6Q9j9+LVDrJ0xBGVPTueFVw= X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3FADB4000E Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=W5KTlkD6; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.41 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: 14r5jgs6jc38i97knur4xbt7h9pxcjuz X-HE-Tag: 1664404447-139921 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: Designated Movable Blocks are skipped when attempting to allocate contiguous pages. Doing per page validation across all spanned pages within a zone can be extra inefficient when Designated Movable Blocks create large overlaps between zones. Use dmb_intersects() within pfn_range_valid_contig as an early check to signal the range is not valid. The zone_movable_pfn array which represents the start of non- overlapped ZONE_MOVABLE on the node is now preserved to be used at runtime to skip over any DMB-only portion of the zone. Signed-off-by: Doug Berger --- mm/page_alloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cd31f26b0d21..c07111a897c0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -435,7 +435,7 @@ static unsigned long required_kernelcore_percent __initdata; static unsigned long required_movablecore __initdata; static unsigned long required_movablecore_percent __initdata; static unsigned long min_dmb_pfn[MAX_NUMNODES] __initdata; -static unsigned long zone_movable_pfn[MAX_NUMNODES] __initdata; +static unsigned long zone_movable_pfn[MAX_NUMNODES]; bool mirrored_kernelcore __initdata_memblock; /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */ @@ -9369,6 +9369,9 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn, unsigned long i, end_pfn = start_pfn + nr_pages; struct page *page; + if (dmb_intersects(start_pfn, end_pfn)) + return false; + for (i = start_pfn; i < end_pfn; i++) { page = pfn_to_online_page(i); if (!page) @@ -9425,7 +9428,10 @@ struct page *alloc_contig_pages(unsigned long nr_pages, gfp_t gfp_mask, gfp_zone(gfp_mask), nodemask) { spin_lock_irqsave(&zone->lock, flags); - pfn = ALIGN(zone->zone_start_pfn, nr_pages); + if (zone_idx(zone) == ZONE_MOVABLE && zone_movable_pfn[nid]) + pfn = ALIGN(zone_movable_pfn[nid], nr_pages); + else + pfn = ALIGN(zone->zone_start_pfn, nr_pages); while (zone_spans_last_pfn(zone, pfn, nr_pages)) { if (pfn_range_valid_contig(zone, pfn, nr_pages)) { /* From patchwork Wed Sep 28 22:33:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12993208 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 239F4C32771 for ; Wed, 28 Sep 2022 22:34:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08C86B0072; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9106B0087; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9329A6B0088; Wed, 28 Sep 2022 18:34:10 -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 82AE06B0072 for ; Wed, 28 Sep 2022 18:34:10 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5EF2540F55 for ; Wed, 28 Sep 2022 22:34:10 +0000 (UTC) X-FDA: 79962948660.25.A253A0C Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf06.hostedemail.com (Postfix) with ESMTP id 1720E180005 for ; Wed, 28 Sep 2022 22:34:09 +0000 (UTC) Received: by mail-qv1-f53.google.com with SMTP id w9so3199538qvn.11 for ; Wed, 28 Sep 2022 15:34:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=kc8MnC2tZjfyT1OHr7oem13ar6CbGvXTPlsJPg4ls4ohROc83adATaBlEJCZezeH1C vsZ5oUUA+B9L0g+Bkk39PLzeubyp2DyfVoJoZ9Zuq2Qsb8+StameSMoVBPuMt3bVCnRL coy4RGa8VfE6Rbw622dqywhJ4WJzOSAvVN20qhVzwAACdHRDu9rFPEkPLP2ljJiJY43l IqGSh57dsBe0H2HHsWh1998DsIFN/Qm+GtfjxXU8olPYvmv6jkBMS834HsYzg10Atmro bL25Bin46Q5OK+V8UdIyXx7CaaLqS7R6BnZCiF4UnAN1AD9nXKL/uUXTGBwtWYMMWzbv oyAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=sBu0bxY4N6GVontXd4dyqoF8oa/BunFZoe3KZSbTKiadT9D1NKBv+s+nG8ySQ/fA3Z QBKo09jyElF9AQyLEgFy5RvILemZmYDsQRRE+gSPAuf9TsQZShrPVmsb3G8hrSO688H4 KF7MExX3RaBmvSJemlFdrSxkuA5V9APx08L09/RSz3IgmOTwaNy+0y+XD8EDDeVipYee JmHHbO+Yw5Ltk5KxdBiLjcxD9EEtjRnlxVbk6TCYLMrxAOQwl/j0yNB9ADBQWY/AYU4j I9xgTNx7j2AkxIGW+CVLmRqr8Hrajg1vD6SEwYoFIHsdz5OMH95odq6xl174vikgz/5+ kIFQ== X-Gm-Message-State: ACrzQf0ElPP1p1uVtzKpnAH0if099dZ9suZ+Pwbfs+sdOeq9P5cwTp4T xsdVti1mT38ZE8ckBjlrI+w= X-Google-Smtp-Source: AMsMyM6VoQtRRInmPkH9hx0tn+zQ9wF1eVVy8Cf8ySuI7caOUVeCsNTyQ/vn10yr9RGUky2CsTBgnQ== X-Received: by 2002:a05:6214:2301:b0:498:9f6f:28d with SMTP id gc1-20020a056214230100b004989f6f028dmr277150qvb.5.1664404449183; Wed, 28 Sep 2022 15:34:09 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j188-20020a37b9c5000000b006bb83c2be40sm3963481qkf.59.2022.09.28.15.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 15:34:08 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Michal Hocko , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v2 9/9] mm/page_alloc: allow base for movablecore Date: Wed, 28 Sep 2022 15:33:01 -0700 Message-Id: <20220928223301.375229-10-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220928223301.375229-1-opendmb@gmail.com> References: <20220928223301.375229-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664404450; a=rsa-sha256; cv=none; b=AS01FdYl5eAYTWPDuT8mNd60TnNg6qR/xOCDMWn1um8MLNkRCsciMp0zZ0nVwsiCBrDrcO wuhaKz1kA8mPJaIUy5HVw7v1BsTM2Ux5updkunOnHC7AQEBkKYMVsyPYKjsCoHCpAcZrQG vyB+ObGrzHGJggrYiiRfpFBCziKfQpg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kc8MnC2t; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=opendmb@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664404450; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tjj6ATF6Canh9drI6EDoMALKIa5USqpwu3Z1hroTt1E=; b=fj96iXFe/XrVwngRP56SO8+AvK+Mix6ZyC1zYi/4RlOBxxPZpDnggptPyi4R60CM0t0qLr EnKfSP52iIZsV2qe5aBqPEzzQ/N8zZtdJGJqCB4ET7claR7qMGoDTTNakZeNAK5DICFJxd xlOkMRfNMNaVALGTs+rIb3N/uGwls0c= X-Rspamd-Queue-Id: 1720E180005 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kc8MnC2t; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.53 as permitted sender) smtp.mailfrom=opendmb@gmail.com X-Rspamd-Server: rspam03 X-Stat-Signature: 36trkegw19nfeu6hp89i3cgq8yb5p1ex X-HE-Tag: 1664404449-556763 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: A Designated Movable Block can be created by including the base address of the block when specifying a movablecore range on the kernel command line. Signed-off-by: Doug Berger --- .../admin-guide/kernel-parameters.txt | 14 ++++++- mm/page_alloc.c | 38 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 426fa892d311..8141fac7c7cb 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3312,7 +3312,7 @@ reporting absolute coordinates, such as tablets movablecore= [KNL,X86,IA-64,PPC] - Format: nn[KMGTPE] | nn% + Format: nn[KMGTPE] | nn[KMGTPE]@ss[KMGTPE] | nn% This parameter is the complement to kernelcore=, it specifies the amount of memory used for migratable allocations. If both kernelcore and movablecore is @@ -3322,6 +3322,18 @@ that the amount of memory usable for all allocations is not too small. + If @ss[KMGTPE] is included, memory within the region + from ss to ss+nn will be designated as a movable block + and included in ZONE_MOVABLE. Designated Movable Blocks + must be aligned to pageblock_order. Designated Movable + Blocks take priority over values of kernelcore= and are + considered part of any memory specified by more general + movablecore= values. + Multiple Designated Movable Blocks may be specified, + comma delimited. + Example: + movablecore=100M@2G,100M@3G,1G@1024G + movable_node [KNL] Boot-time switch to make hotplugable memory NUMA nodes to be movable. This means that the memory of such nodes will be usable only for movable diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c07111a897c0..a151752c4266 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8370,9 +8370,9 @@ void __init free_area_init(unsigned long *max_zone_pfn) } static int __init cmdline_parse_core(char *p, unsigned long *core, - unsigned long *percent) + unsigned long *percent, bool movable) { - unsigned long long coremem; + unsigned long long coremem, address; char *endptr; if (!p) @@ -8387,6 +8387,17 @@ static int __init cmdline_parse_core(char *p, unsigned long *core, *percent = coremem; } else { coremem = memparse(p, &p); + if (movable && *p == '@') { + address = memparse(++p, &p); + if (*p != '\0' || + !memblock_is_region_memory(address, coremem) || + memblock_is_region_reserved(address, coremem)) + return -EINVAL; + memblock_reserve(address, coremem); + return dmb_reserve(address, coremem, NULL); + } else if (*p != '\0') { + return -EINVAL; + } /* Paranoid check that UL is enough for the coremem value */ WARN_ON((coremem >> PAGE_SHIFT) > ULONG_MAX); @@ -8409,17 +8420,32 @@ static int __init cmdline_parse_kernelcore(char *p) } return cmdline_parse_core(p, &required_kernelcore, - &required_kernelcore_percent); + &required_kernelcore_percent, false); } /* * movablecore=size sets the amount of memory for use for allocations that - * can be reclaimed or migrated. + * can be reclaimed or migrated. movablecore=size@base defines a Designated + * Movable Block. */ static int __init cmdline_parse_movablecore(char *p) { - return cmdline_parse_core(p, &required_movablecore, - &required_movablecore_percent); + int ret = -EINVAL; + + while (p) { + char *k = strchr(p, ','); + + if (k) + *k++ = 0; + + ret = cmdline_parse_core(p, &required_movablecore, + &required_movablecore_percent, true); + if (ret) + break; + p = k; + } + + return ret; } early_param("kernelcore", cmdline_parse_kernelcore);