From patchwork Sat Mar 11 00:38:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170538 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 0CB94C6FD1F for ; Sat, 11 Mar 2023 00:39:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 879708E0002; Fri, 10 Mar 2023 19:39:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 828AB6B0074; Fri, 10 Mar 2023 19:39:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CA048E0002; Fri, 10 Mar 2023 19:39:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5B68D6B0072 for ; Fri, 10 Mar 2023 19:39:50 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2F28E403BE for ; Sat, 11 Mar 2023 00:39:50 +0000 (UTC) X-FDA: 80554759740.23.EA47C4F Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by imf23.hostedemail.com (Postfix) with ESMTP id 5875A14000E for ; Sat, 11 Mar 2023 00:39:48 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Nf4Q5bno; spf=pass (imf23.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.177 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=1678495188; 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=rkrJtBKgdz9IacsmBdIB0+uEq5L3ahKPJNy4SS1btTU=; b=tDZP3q5bOKZlvvUXzPZbP+35YtLTf73Z5GtvUZu3muug0faMr+77ehezLVY51Cq/gdPGEA hd4HTYdg/8Q2nq00JFCLiJ0dr2+YL+IK3WxB3fRCEUXxqFsJFmkO4CAS9iIdHnl6K6Abs1 KqUcHYhv2J11uRdIz98k3Ik3ruCNRLg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Nf4Q5bno; spf=pass (imf23.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.177 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=1678495188; a=rsa-sha256; cv=none; b=xS+YhGgc9FqhVNjUnHglbQUgkTadZ2w1VBqmXpbKyl2WgxeHiBFZKIcrcysVc/K6sHr1Ma r15nTe/ZeF6WZ3qeKRDfClQDKFF2pb20ENcHQ7D773cpERZmhc2OREm+O9lMFEe6lYQNDy DjqEKADAqCfAOdfiyMdTjF2Cl+cX1uQ= Received: by mail-qt1-f177.google.com with SMTP id d7so7672658qtr.12 for ; Fri, 10 Mar 2023 16:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rkrJtBKgdz9IacsmBdIB0+uEq5L3ahKPJNy4SS1btTU=; b=Nf4Q5bnoJ84mo6BVRKtM3OfYWI13uwKOw3uMc7wGcqg/YFrF0EDMb2Tc70a6r1fzZc Vir55wXtNRFzDTHoKksEBE1mT4Whc3rUCB6/a0qYsGVSTiZtZ1TEhI9YVuoSUTQOWpIZ wkyLW5TGMgj2c/+6vz/qhI3xMN7MdJyqYQkUUjkArXHvmslWI6L/Xb589+yt2NqJ62aO kbpLaP4c6yERZu1yQsMLtGpH/zEzYZeuNWWDxxsC3FvHSaQbKpvi5zFCrlyV+6tabjRH vcZbcVon48Fjz/56NthcczU09cWdHbhFtoufMuJ6CShKWnTHB9IBjP7QRZcPwiJtc50q dKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495187; 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:message-id:reply-to; bh=rkrJtBKgdz9IacsmBdIB0+uEq5L3ahKPJNy4SS1btTU=; b=YHwrmDRsQceGjdQdG6U9iT4vy3cNwDTLi5yi13BAizxhr42X0deI4DdZQbnSVTxYV6 ki92mZnrfcpzRZq2kJcRzIX2Res++t0bJjtUvn+ZOvoKqMY+vLCPKY0tTILSSug2Ak+P tA46RqhK1MXLIuk792sME3j8rOarbpM9Bq+x/VJN7ty8qU7oX0dhEH/xe4apdmtA+ckF ZdMfqFuDSq0GaAg3/b0ZgcOTE3oyaW8HPp5gDYuNlruBx9xzZK+OJB93iq4WFtrmph4O K971rDqdbhVqZwDizKuzKTrxy9AcWCM4XePbLZOlsGAJSdD3YdwJJCVMd9l39yZFL1lz gNlg== X-Gm-Message-State: AO0yUKVDvcX6vYXz4ALql0L+R4B0BbW7NZSKeKOsgIPvS/k10wDAjXMu P3NGQsQBu966WvWlNs4tsXs= X-Google-Smtp-Source: AK7set/Bpp6yGdrFeMDx50dFU90Wr4xltqSMpKJQRscRiht85efTCEQ33g7uJ6Dpxtrzuwm9BJqBkA== X-Received: by 2002:a05:622a:244:b0:3bd:1bbc:8d8e with SMTP id c4-20020a05622a024400b003bd1bbc8d8emr10459853qtx.0.1678495187484; Fri, 10 Mar 2023 16:39:47 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:39:47 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 1/9] lib/show_mem.c: display MovableOnly Date: Fri, 10 Mar 2023 16:38:47 -0800 Message-Id: <20230311003855.645684-2-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5875A14000E X-Stat-Signature: n11x1n6z57xbsocahhp9wmp5d656wyzn X-Rspam-User: X-HE-Tag: 1678495188-285413 X-HE-Meta: U2FsdGVkX19hvb7e7xVq3mTjH57vciaULlFn4XPa/VPh6zsxQStHY9A/ZoiqwpvBIqsR2hLdaXveyAH0E3a7LwwIVrZbv4QmQ1fAc1QNB0Oc/2spu2a1IrcmcgFLTm6tB7058w9xKbAGGBEo2ZR6dWTKsBZVbzL+GAwqqf5HqOrhiUqd3KdfVKjeoxpSwdUTwWI1beZFQjIn6utK4+S+rADfo0+K05FwUqRwAtMZ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te9wZwnWJ3OJf7f/l7j6HpCfwyhq8dRSkpBDpQUeT4pZVnhqaYbEpxX1QmFM6dOHq+TSDFUyHwL/16x+pFrnuVZSE0gWaTI63QBQiK0z7DAo/XeIcMp+uDpehpkjFE91yPZ1dcO12FhdhJZY/jni2Z2DJ4EaNbGNXDWfHZdE1/Wzy+UgHR4BWOifeHYbSPIExOMzGtqah4xZM7/uITJKIbkCTwp01zOu9hFNE4+KpPEsjVdQE4yfGIycWn26i6K7RbknZAt88/3KBpHZI= 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 0d7585cde2a6..6a632b0c35c5 100644 --- a/lib/show_mem.c +++ b/lib/show_mem.c @@ -27,7 +27,7 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx) 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 Sat Mar 11 00:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170539 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 94B69C6FA99 for ; Sat, 11 Mar 2023 00:39:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EA0E8E0003; Fri, 10 Mar 2023 19:39:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0846B0074; Fri, 10 Mar 2023 19:39:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 088C18E0003; Fri, 10 Mar 2023 19:39:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E9D4D6B0072 for ; Fri, 10 Mar 2023 19:39:53 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C11D2AAE4E for ; Sat, 11 Mar 2023 00:39:53 +0000 (UTC) X-FDA: 80554759866.21.632F2D3 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by imf30.hostedemail.com (Postfix) with ESMTP id CDE7380008 for ; Sat, 11 Mar 2023 00:39:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H0fDFIKr; spf=pass (imf30.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.174 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=1678495191; 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=21XWFqZKFhrw7IqRe7YpT4TCzw//2tpfFn1az0nze7A=; b=qpTQf4w72MfiKt05nGwZ9WGiaGDEDBOGsbRN+Tkh/sb1rr5ez1nHyJow66E7R9Qv1bYWRp qN7zDM9/cAn96tA7r2yWMcxu3mK5fuuintKYx2a4Kp+B3/aMjs3qrbVG0nyiCyw1FRQ8q2 wHY0kk4OUPPwSUJOeo0sg7kf/h6PbXY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=H0fDFIKr; spf=pass (imf30.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.174 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=1678495191; a=rsa-sha256; cv=none; b=4DHudC/yw7r3/schEtUo02jZqoNu27rW+iZaHk+2lHrhShB55aunafSYoZQURaNOQZzgJN Jx2q8EY8tKhjG7qgBJ1vStn9wSLvfebPbXO4Esfbne/W/4bWCOUdJSwVLFhmDARf3HgStO PKUcmral2wcnEtroGrRA0B5DAaAcZFQ= Received: by mail-qt1-f174.google.com with SMTP id cf14so7703709qtb.10 for ; Fri, 10 Mar 2023 16:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=21XWFqZKFhrw7IqRe7YpT4TCzw//2tpfFn1az0nze7A=; b=H0fDFIKrE+i4ootQK/33BZNQZIOFe5T2gXr49E41EzK7+v+nPMZu5ce7GQgvufox1r xofMSL1BtQS45kz/SyzPCOerPL6qsYRi0a6twooP6fAdZu2ZRX08kGWmrLZ7Z0zZSTZP q+UEKBCQTwBEJR6r7gXIwUeRd0wTaMWuxQ3AU3IKjs4i6DE3h4QiwCXwnyrg4hJfR9Fa OqS3WXoZcjVB0XhOmr7mqX1611c4J16sjcN1h+t7gR00matvjm9r+0NLXtlYAE//yMF/ M0fUUbTDdeXlerycqwdx/xfIlphKCqHxxm1rGe7SLvvTxgx6cxy15SvFrAbj2TA/Q5VH y60A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495191; 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:message-id:reply-to; bh=21XWFqZKFhrw7IqRe7YpT4TCzw//2tpfFn1az0nze7A=; b=RM249FxqSoBGgV89524FYIO7FdIErhtAaqrvn/CY3PoiSUdWvm3dcGxhpiJ/dd/G1s 0PfGOKQpx0/Ux91UIfJCIKFXbDpcFMMBg44KgwfHUZjVdDq6yttJ5LGUwjCs57iLEKRY oAv8g8hsvVX6q7uFxuEsYKHmfmimE/PeZatz6j4EpF+Q371SWtocC3+5BTma206K33to Q1YK52Dk46etVSjntcaPiWDBF6wUsxnbFDgUlebLemRx2d5+ovr4oKo6deOqi4wq7oqu ZhaKnex9mnjC8wiE2W1yQ+fcNuDL+JhS31nbiRKBtDVVhshVTpswRqUui6NuwaxIZaAY /2ZQ== X-Gm-Message-State: AO0yUKVqAOaSZohfU2mJhg8a8snm+iJ7kuVkrcBbO1v++/2+1RFiYXPY ALMvUWzwSeA5L6hcAvnAfeY= X-Google-Smtp-Source: AK7set+uqKakBULmDoJ5Xr6lerX7tivt8yOC0pEZoZHG6hVLZ77mTu5fc8Qx1J0t8jZ7dQbCVw6tHQ== X-Received: by 2002:ac8:5ad5:0:b0:3bf:a3fc:c70a with SMTP id d21-20020ac85ad5000000b003bfa3fcc70amr46750078qtd.28.1678495191044; Fri, 10 Mar 2023 16:39:51 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:39:50 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 2/9] mm/page_alloc: calculate node_spanned_pages from pfns Date: Fri, 10 Mar 2023 16:38:48 -0800 Message-Id: <20230311003855.645684-3-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CDE7380008 X-Stat-Signature: nr9847dpjo4dfw34dok45tbwq75jihzq X-Rspam-User: X-HE-Tag: 1678495191-651878 X-HE-Meta: U2FsdGVkX18PuSPNZ0AieqeTmXmKIXhqoause/MVovlJH/WFSvsbiuQsoL6soU3gFazrWpPc9e1g/dwK03lqacKpgXbAtvybt9QL7gSZ40YqIgP9/U273nWDyh8PiQWI9rhnkWwubQDVTiBBGn2KUO5X88YO64JlVrxongEKdu2wbDCeuwgAWIwNxdDxKYWovvJzTMN77qyvtIqnkwO1olz71tnms+boSNzPbmQBBh/y4n/PjKYCTp989VQgGxV1zWHgk7mPWn0pGgXdAqVArb1NJQc0YQmrAZnDEFL2Ta7etF3cbDURlCRVBM8MeQfIpG5q2ta41EL5j3aRd2MI4VurgtR3upSqecNBoc5+dctpOfSSZHyWAmNRFKkLJ0ka/4SJUr4VoYL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LG0tKEQZmpEXD3MVRNdYpfOoMRcryJVO2HuC4V0ZSAwm/mzWKcxHAARiFcX8vjPgK0gtgs7FQZs69s6H9tcsBjVXeE5MA6kJmXrKthHVk/FEJhuvtJSQPZxg65pIqUe+b0NH6wkcEBKOLec= 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. The realtotalpages name is reverted to just totalpages to reduce the burden of supporting multiple realities. Signed-off-by: Doug Berger --- mm/page_alloc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ac1fc986af44..b1952f86ab6d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7586,7 +7586,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 totalpages = 0; enum zone_type i; for (i = 0; i < MAX_NR_ZONES; i++) { @@ -7617,13 +7617,12 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, zone->present_early_pages = real_size; #endif - totalpages += size; - realtotalpages += real_size; + totalpages += real_size; } - pgdat->node_spanned_pages = totalpages; - pgdat->node_present_pages = realtotalpages; - pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); + pgdat->node_spanned_pages = node_end_pfn - node_start_pfn; + pgdat->node_present_pages = totalpages; + pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, totalpages); } #ifndef CONFIG_SPARSEMEM From patchwork Sat Mar 11 00:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170540 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 D22AAC6FD19 for ; Sat, 11 Mar 2023 00:39:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E10E8E0005; Fri, 10 Mar 2023 19:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B9066B0074; Fri, 10 Mar 2023 19:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F6F8E0005; Fri, 10 Mar 2023 19:39:57 -0500 (EST) 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 3739F6B0072 for ; Fri, 10 Mar 2023 19:39:57 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2029CC01D4 for ; Sat, 11 Mar 2023 00:39:57 +0000 (UTC) X-FDA: 80554760034.27.92C2D9E Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by imf08.hostedemail.com (Postfix) with ESMTP id 59D3E160007 for ; Sat, 11 Mar 2023 00:39:55 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ACBZmz9T; spf=pass (imf08.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.181 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=1678495195; 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=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=4bzhVfYSjc+FLdR3krYFS5WtFq2XTYo22nNRV/7Vb+S8f82I0kRguwL1LNGo1ds0L63hY6 qeVVNGnqz4/szgOD6T8kN49whB00lygdvFt9S/hdUa93CYLAWCS1+Jrm5DxspLiUJUVov2 NRPH57B3MITCCe6buVctbvTmG2drEuk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ACBZmz9T; spf=pass (imf08.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.181 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=1678495195; a=rsa-sha256; cv=none; b=sQzYC6GcKmNSq7kEO3wtrW30BnnWkw/gnf7iQfPnHBjeeq3JdrcH214PzH/B5kDAlpYmL5 WeY5wqU7N3Rkkgt6urrVa++z5VDmMfgHWfK2GAWbqZnaXNg+sWpuxrSK/qsqSq3p32XCSX pzGk+psiypJZMwjhUOpA9/nXjX2F6ec= Received: by mail-qt1-f181.google.com with SMTP id c19so7679548qtn.13 for ; Fri, 10 Mar 2023 16:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=ACBZmz9T+fOJ/er2MQetIFMNgeRLKnusO2uR98YFrcykpO+2zcEzh45d0mpQn8L8jZ cdR/zhSiqUdc+7AlJATmoMf24jV3C/a2RsALpIVpVApX7OZzvi2A5rlaFFLOoM+4a+Iu cmlDmVB6VWydoOGSTEEfkLhgMkdb8XzoDjcQk2fg+HQnJYwd+s4LvbFXcehweSegHqMN qGoJLqVGKKRZcSfMSqbYZaOJYXZtrhVIS58QLZE1cpB/NF+nc7muaTC4uG6RsPAN/amf FfNftp8lhVc0lAl1X0hPzYaMUxdq1qzm2P450TpVFNj2Fc9ZAuorzU1Nl1iW7OagYS9k XYQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495194; 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:message-id:reply-to; bh=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=Uzg2cMjzeapOW+Flp3SyjarX+61D/XQoRSF+aEmy8hLuhlP3Ig5GnSVTNHmqENY/Eq LbYt43LFpY4tHiT5sduk7kNTAFfZjtR4jrcZL23CGJTF3tweUbtv5jg3tnGUfdm1ekrv 4Pj5IuBH/te1N/EIsJcsEaBHeyEv/IKJroJH+N9uGRNvJ858WOoCElzBAixG+tGUm/HE 2NK1dnu8vjEeRFo+ux9cHVpDF2keUFQNzwVNDVHby8V/nXOscYD0u30o1eIvLFfehuFE DxuUip+YtcNscqeHCxFiCx2gvCBN+oqNpBVSamtORDRm62tLg9WegXgKc0exCWgP/S9L 8iUg== X-Gm-Message-State: AO0yUKW7uQByuF5/+5Ws8L9L/Z3IP++rAj1F5mOOBODun73H5Ymxaz1G eo8u57cmgFjnAgX6f/dUkMg= X-Google-Smtp-Source: AK7set+MmuySHwc8FcDbJGZpaVLU4HCrie7tiN1VA0TeZDeCtzqts9IA4rg4ydaSqQ297OiyWnJ7pQ== X-Received: by 2002:ac8:5a88:0:b0:3bf:d8ec:a9fc with SMTP id c8-20020ac85a88000000b003bfd8eca9fcmr11747709qtc.52.1678495194581; Fri, 10 Mar 2023 16:39:54 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:39:54 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 3/9] mm/page_alloc: prevent creation of empty zones Date: Fri, 10 Mar 2023 16:38:49 -0800 Message-Id: <20230311003855.645684-4-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 59D3E160007 X-Rspam-User: X-Stat-Signature: pza8ewwihht3xrpafa4acfax4kqn7esy X-HE-Tag: 1678495195-452734 X-HE-Meta: U2FsdGVkX18ovq1sMhluDGNPVibbh3kd9MwO3YuMr6A1cZk4/ZPeWtPkxR1RA0mBekVgO2AzF8aHipqcqmARQIK0jUEn38UHTH77CDa0NLay+dCK9IHGyiuB4BzTTf3JPG0OEVDIQyluOoLD5f2kvG6xoP5IGK+ZmRPLcxfuVTnS9wW6nwRm5t0MvZjfgoeqnOjcUg/88uDUDmmxGXe56WNjlRF1Lz3diHHuNgZ+oM1CiZM3HKyw1HzcKgEiDS2dpbgHkWYtlp8+XjhY/r8ZEOyp2/nYa8ZrWPVeSWeZ0l7fOJsstxfnz3KqBuckTmxjgmgnFPV2GcnsqIwV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3dgn5bF5ZFxD8pfVjjU9o2x6qllb9v9R/JMhaHVBNWDv0dHFpDko2Eea0iAx6rkQCyRCo6aRqZM3JXQ1rue9b121nx81rDmExLdpphN1eXzKg3HRG48FsACUw1R5cajzT0rBIMpMltYY5vbZXsNiLxEdigu+XFadB1e2hAnIGmVBQ/w/Uo= 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: If none of the pages a zone spans are present then its start pfn and span should be zeroed to prevent initialization. This prevents the creation of an empty zone if all of its pages are moved to a zone that would overlap it. The real_size name is reverted to just size to reduce the burden of supporting multiple realities. Signed-off-by: Doug Berger --- mm/page_alloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b1952f86ab6d..827b4bfef625 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7592,8 +7592,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *zone = pgdat->node_zones + i; unsigned long zone_start_pfn, zone_end_pfn; - unsigned long spanned, absent; - unsigned long size, real_size; + unsigned long spanned, absent, size; spanned = zone_spanned_pages_in_node(pgdat->node_id, i, node_start_pfn, @@ -7604,20 +7603,21 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, node_start_pfn, node_end_pfn); - size = spanned; - real_size = size - absent; + size = spanned - absent; - if (size) + if (size) { zone->zone_start_pfn = zone_start_pfn; - else + } else { + spanned = 0; zone->zone_start_pfn = 0; - zone->spanned_pages = size; - zone->present_pages = real_size; + } + zone->spanned_pages = spanned; + zone->present_pages = size; #if defined(CONFIG_MEMORY_HOTPLUG) - zone->present_early_pages = real_size; + zone->present_early_pages = size; #endif - totalpages += real_size; + totalpages += size; } pgdat->node_spanned_pages = node_end_pfn - node_start_pfn; From patchwork Sat Mar 11 00:38:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170541 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 DD78DC6FA99 for ; Sat, 11 Mar 2023 00:40:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45B138E0006; Fri, 10 Mar 2023 19:40:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E2B98E0007; Fri, 10 Mar 2023 19:40:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25CFB8E0006; Fri, 10 Mar 2023 19:40:01 -0500 (EST) 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 13C886B0072 for ; Fri, 10 Mar 2023 19:40:01 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DC06F1C5E7D for ; Sat, 11 Mar 2023 00:40:00 +0000 (UTC) X-FDA: 80554760160.07.7C6BF86 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf17.hostedemail.com (Postfix) with ESMTP id F177040005 for ; Sat, 11 Mar 2023 00:39:58 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=VF08Okgd; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.51 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=1678495199; 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=YS/BwpEuHX62q7q4jA6kz2JjH38ryXLVzKB9Q24XSVc=; b=GR+7t/+l/ZlyaqtBDKYMJd7VtqMdQMXcAsc3hUwRPZf5Ua5LEZ/gkbl0irLVDUMdU3KHcM GsyD3Yb5NuakK9Kopr10mzh48GDSl7uRsGm1l5/SUyXmzY7JLBw1NUFRuat+jbg06N9f3W /08Hj03VcRAkaNJusM1xYjGpQkjhrmE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=VF08Okgd; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.51 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=1678495199; a=rsa-sha256; cv=none; b=zlaOa6RqAe6y17zcpXknj9VF8BmEzBZp+FcdUZUZ42Ji8/hPu0FQJNGX+Mf0FEhySMB8Um YdnTvPO4MNTUbsvsyqWjgdoB2BWx2xu+wMevGDuBw4HdAjCmDrOK310gCR6eRUJaRKs0I3 BENytmHgqVaygZnIqLhh/uTpRyNSMBI= Received: by mail-qv1-f51.google.com with SMTP id ne1so4751583qvb.9 for ; Fri, 10 Mar 2023 16:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YS/BwpEuHX62q7q4jA6kz2JjH38ryXLVzKB9Q24XSVc=; b=VF08OkgdvcCe08OFIcKq9AjNHxoLhzwun0cGIC1Dw+CHTXLxKUFwhYo6TUZdd/cWK3 9WanLdPXxSvDlWj9fqkxau3KxElLZQ+s/76QZ3bxEmG1O+nywfnvT/hiRGlxMPH/ohYJ FAs5zCI3FPjJgsi5FN6DhqLP9JB7Lpvd8rZj/E499x6+NukAtPbth8cSZITIIevW4iJI mpXPc4PbQsDfArMwZv6d+gaXpvtIkJexpGmEU7Bh54jzSPLoRC8gA+96ufZ6AQFCWzAo aZF9vOT02zcYSfbZLxIu9rZCY/Z3v8Xnipykl3H10Lw3vvS3h3NOz85H7iNEhWMQD/d4 eWTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495198; 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:message-id:reply-to; bh=YS/BwpEuHX62q7q4jA6kz2JjH38ryXLVzKB9Q24XSVc=; b=vtaqAgPC8bfVRzb+HJa2wsKMqdpn/SnRAInVUNKssWgkzMiOjdxt+jpZ1z0K4CIumw nudbo+IMqqCPuHyCKkRy3ZVojvXWpY97v5SjE4tC1RnjTZlobDsGo/qXwyJ/zW1tZfjl KYSLVJFqsuiLNXTZC098FdHcHljtheyrQzJSH42TorB8T2Yk3oV4pSlJfcYsqpk1adtJ VdULlNdgZoyl2W45mrZ5e0Bn1fnN/uXUftvHn6x68V0xEshoCuh3CvedGZspPizABMY4 +cufjObT7DFCwLCc+Jo3x/8VJTnwVv22kUvz+FdHPIRHJPbiWFjiuG27PNtN24aZiszL aplg== X-Gm-Message-State: AO0yUKW4U00BkekISHUM/84+zF7t5kqXyqvSGoHR8bS6rUfPkLDpdXG+ AAwqjvTP3/GHzw2aAyXbtqI= X-Google-Smtp-Source: AK7set/7lbmUehkOoWsoZelfJbwaie1c7mWXavPmCpQDq6lJJf0+Kbe53vrmeRB0vmNfXKniiuy2zg== X-Received: by 2002:ad4:5aee:0:b0:57e:56f5:5410 with SMTP id c14-20020ad45aee000000b0057e56f55410mr1647846qvh.39.1678495198141; Fri, 10 Mar 2023 16:39:58 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:39:57 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 4/9] mm/page_alloc.c: allow oversized movablecore Date: Fri, 10 Mar 2023 16:38:50 -0800 Message-Id: <20230311003855.645684-5-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: F177040005 X-Rspam-User: X-Stat-Signature: 5has61qa6acb97xit8xqfhzizekh3y7m X-HE-Tag: 1678495198-392013 X-HE-Meta: U2FsdGVkX1+COCSeAOlvXvShyixY0U3pE171p0Ba0D7+fd/wlKww0XrYWGeU+fvqVNKhFzrc9GHMSfvKG+ZQBTHF0jj7MoPdFs14ZVtdOSFmRavcnvsosE2bTRX71u7XlvHmQkWNgyBGPWoDAnUMlhsc8jbAsSoS0mL0XjDl0V5dH6HfvNVBrWMhDsUsnrOnUtRNMOXsKHW3jtFU6eMiiaBCfWm1BgPt/wd7zqtqmSPkLLPLltuTO7fyFHCjpNsIsa41V6qFpUZN/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H9dPEWwy5SgsEiuR+8FGF7CO3OH/PcWhF8r16U0jwbaeRXqC5rNuSHS5iNB1y7KrqJfpF+jp2PGZpHj2nnhhgmZ1JVuKCniI5PK8Bnxytxc63mIv9R9NifJGfGXvpG/tyOWG7HLsBQjEcJmIvrG3Wy+QLRUErVcfIM71Rd3FsfKGvmHahSNRXraDn4pug+85xy5lG6HbuxeNj3viORaUONlGGbFALs71hur3hyMQsX1QEDQ= 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 827b4bfef625..e574c6a79e2f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8166,13 +8166,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 Sat Mar 11 00:38:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170542 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 21E17C6FD19 for ; Sat, 11 Mar 2023 00:40:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B13916B0072; Fri, 10 Mar 2023 19:40:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC1218E0008; Fri, 10 Mar 2023 19:40:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ECE48E0007; Fri, 10 Mar 2023 19:40:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7F5D36B0072 for ; Fri, 10 Mar 2023 19:40:04 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 57594A0185 for ; Sat, 11 Mar 2023 00:40:04 +0000 (UTC) X-FDA: 80554760328.16.BE5DC97 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf26.hostedemail.com (Postfix) with ESMTP id 8C9B0140003 for ; Sat, 11 Mar 2023 00:40:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QuGf7CPV; spf=pass (imf26.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.42 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=1678495202; 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=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=3Rf40WrtY7eB9XMp/xVmlp1It8xT0ScKauK7MSrUO1uPtluZeDWq9KA+u+xLzyMDtAwxZa ePJLx89Md6y2+37TfmYy6USrOI7MNJmgVgg4PyfRxlFOCPu8osZEPnxh+vT2xxxMgAWhzk vB7WRL1eLq4w/zy7ZbzxHh70NYJNASI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QuGf7CPV; spf=pass (imf26.hostedemail.com: domain of opendmb@gmail.com designates 209.85.219.42 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=1678495202; a=rsa-sha256; cv=none; b=0Z+hxwJLj+YavsgHdX2n8qoKJSqxiw3Pm6rEn8mUIfh8cmo4wQMh+xG5NDOFQAVvNCGbKF Ke32TENWimAZFbRdguyLaXE3B6y+o6c94VJgB+p0DR425mpqx80TiKNW/ZCxbaczUFWDzv d+b08GL8Tlq+x4qK67AjjugMzysAM3o= Received: by mail-qv1-f42.google.com with SMTP id jl13so832581qvb.10 for ; Fri, 10 Mar 2023 16:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=QuGf7CPVoKCsHOOIjm2NK5cjpLghKA1j7kJ/1K741bb8Tjt2zne1lcBoQKG5RZFaLH d+9iDxF3djo9jXBNdij0VGTP6ZY1SP8dGV2Shkve2mUoxGpnaN76uokoWkwI7LKRvxaz KF+uFAAEj6TJzhXi7bf5vxZsTi5W+CbUoaBE2wno33o87jXYbrldRxk4635GHPh9JKm9 VfG5OUzjlwFRg/KWjFtjZSd0w2xGePXLgufWztrOsXM8yCuJbytBX4lGLAtjafBKNG5q fVvaqQHAnJwIYiTQug11IA0ltwfKKzu0TeoRULLmWlo061rrvJL/iDxv+7SOUACOFXta PEiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495202; 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:message-id:reply-to; bh=i8Ej0xERH/saZ/pDi1cj12vURZcx4JMPO5LgIvCru00=; b=U7tdylpEl2RbFxDRIu+VH69kwjdQg0knh1XqtUZjiV/B0+kNEk7hPcp2bvF+P5cgul 6XLAqntDfdv2nlXmtUvsCzDifxWUmKIDlZhxa0zjf7wiqJ8U97xu0NlpX88R/jr9r9m1 F0RDx+Z1vNLBQkHTzMqwLG1tjVfyQjD434YYgrjJmTh6zucPO2XBmEeaf6izXZ6+mBZK /KbRT4XwXY9HpbHKljwzaDKnUMEIeqOnQv7xDK1Ax0RB4HnyfXLNQ1mvGdj+HXubcqVJ jP3v5j8qAFPMdp6TALD9kLXpXKc7Q8L6RAuGDcc4wVzLNlGzuMxb82po5UQy0LBdFKw9 ywxQ== X-Gm-Message-State: AO0yUKW58KtKGryvH0CFVEkdoXPrQ1azweQUJxml7hh4aQil52OqLgN+ gUkcqBpyRkif4MjccH03nYA= X-Google-Smtp-Source: AK7set/lVXoZ5W4bIAwoTLxlwAsTqWdy1gsFvdTIDfjsCCmW6gc1QRgTGtZT2GQJIiWjAJ6Nsll19w== X-Received: by 2002:a05:6214:124b:b0:5a1:d44:79a7 with SMTP id r11-20020a056214124b00b005a10d4479a7mr1926784qvv.20.1678495201744; Fri, 10 Mar 2023 16:40:01 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:01 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 5/9] mm/page_alloc: introduce init_reserved_pageblock() Date: Fri, 10 Mar 2023 16:38:51 -0800 Message-Id: <20230311003855.645684-6-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: mqctfnxnads5z77h97hrr9geky4gbch1 X-Rspamd-Queue-Id: 8C9B0140003 X-HE-Tag: 1678495202-305602 X-HE-Meta: U2FsdGVkX1/Gr2RbzfPyH6g4WgeB7jbZeTHvOhug/7aoctxcMo5FVXDMJtZrGYRGIkFowrEke2voberCMl06p0k1qSX1tXGKVmx6K6LA1jheO0EtxbmbOdiOCTSl/FFD6poLpplG8aS3zzV6iKbMQWNCKWxsrSqfpbh5S6LlDQZAuCxeyDY/CLM1Hu7amIfEiEGbFM9Xo0nnfvenXFx3uLIjx2jTVx8FmCELrg0+xpugvwkw3zxh1yBZlJfyMT60hryuFP5qcViG//TgO9XEcwxDeywXL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IqUFJZ0ids14tl7CeBUy1nKr4Bk+Cv5hZTM0v7+M20qNqwdT0qCC9t7nzkfC9aXW5mGfM7RT9U2VSN5WwdUlUIjsvji1vWNW6hnxodbBKTt6NzxLSKlkczfgVEOfTcjcmb8Wh+3XGwGTaEvDJEH2C0PzYbujqvz98aeKP8lmq+koDmdOxiWW/0SrYQSo4aqc1/qm+zalw1htpOPX5oDyS1a968ScCpeTadMVm6rjTuMgHteTqkugGrPUYfd977xo8= 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 65a78773dcca..a7892b3c436b 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -361,9 +361,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 a7263aa02c92..cc462df68781 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 e574c6a79e2f..da1af678995b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2308,9 +2308,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; @@ -2320,14 +2319,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 Sat Mar 11 00:38:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170543 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 AB12BC6FD1F for ; Sat, 11 Mar 2023 00:40:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A8258E0007; Fri, 10 Mar 2023 19:40:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4586F6B0075; Fri, 10 Mar 2023 19:40:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 320628E0007; Fri, 10 Mar 2023 19:40:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 232196B0074 for ; Fri, 10 Mar 2023 19:40:08 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EF9B5803AC for ; Sat, 11 Mar 2023 00:40:07 +0000 (UTC) X-FDA: 80554760454.27.6C81A6C Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by imf20.hostedemail.com (Postfix) with ESMTP id 285911C0003 for ; Sat, 11 Mar 2023 00:40:05 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gYseOYKW; spf=pass (imf20.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=1678495206; a=rsa-sha256; cv=none; b=3VgFE4inh6w2n4PACNqOFDawszmSiGMIo+V8oSgIoO/B99oK2FN5Mhx8/p94wWXLfWLFIb +e9GjSLhkqWYmu/kU3qO7RpQqnZwyqSRp4k4MjVT7ZI3Km9lEGEin88G8IEAaxyTVS5zw4 0cHDK0ulBndld6Qmb9bVv3e9ZHDjsvE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=gYseOYKW; spf=pass (imf20.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678495206; 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=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=pzmOGkN8YLdM1rl26/krjI/ifGHLPbUj6kcMEACRXC00t1mPQmWzi2KGEfkxEsMxBowwD6 qqaVdw+PQyOi5mZku6+ArMFnbik+mtCZE2r36KJc9/7DhjYnAtFk9TD180GhUuJdajX2pr 8Pyq1j1EMFotg1cSlrFnyYzyU+CpxcE= Received: by mail-qt1-f179.google.com with SMTP id cf14so7704117qtb.10 for ; Fri, 10 Mar 2023 16:40:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=gYseOYKWDMGUISiNkRcjSjvTTZsw5ZpxUtUzYky9ZIu/8x2vFtu1Ubj2/1NfS4ntqc hX/h/yEUyA2imIDBGlqwTwoMvCjauAQN3YL66devi+3PsmAyF6mABKzTGpk4hMd7icxM YEG/1j8Vk1YoVpNOoeMrCgh/Uo/Rnn3iQf+MpFu+gZkimrhV0E2qnQdFooilVD+K/hHa rndAxQ/V0FYCu+PEVJ8K+hWV4ROJd99Mv7LFTpRov8IlSAc9cA6LofsPSnb+8TjoRVr2 L5hPzI4NrF/E1TKlZrGIJ2bO/Ipsdij7LIspIYw/JuzSHIXAlX+sgOjl322atMjd1034 P2GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495205; 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:message-id:reply-to; bh=K0kuuT3+6RnS9K3QghRnceBdk8ynqQ1z+mh1LJkGVzo=; b=7QgCm63eD//+QBZN3HeggpMi8EMq8kfCN9XhJIOz/CTSmRJIi2H5V8F52/zvU1H10C zAnSC0MNg/JefJjBfAc1kN10bsmIt2ocebLPuCmy/EJ7utnTNtQPkBCG2EjpDbG7gYz3 cKW88bq2PwELDNdbilHPHk0xI83GuGPoJE+OqnCjSiqfj+Yl4uoddGUp2Ky0K6HaWcQc +qy9H1Q3rKlU34C6EENs1fFxDohnyropfOXnetsrZiACdfZkaUmPHXWl8PhLogqGE1Nz pULyBoTxCv2XggkYDzrlCAUdHBsFfxEU6X4SoZbrRO0jiIEjGNdId0G0KqkVVlXKDIE2 Xitw== X-Gm-Message-State: AO0yUKW9Y7uce+5VXV3Yc/HIiRvW9CNov+IiBXTqjwJWKwW3RP1hzSFc p+ADJxf9l4L3vDs52Js7sEY= X-Google-Smtp-Source: AK7set8ZGDP7wAjGGI9tJbICfiwjsQBTns3pou3iyFBkgtdpeY6NM2VuirqgiTSIHG6uE67a1R8tZQ== X-Received: by 2002:ac8:57cd:0:b0:3bf:d9a9:25f7 with SMTP id w13-20020ac857cd000000b003bfd9a925f7mr12075430qta.6.1678495205288; Fri, 10 Mar 2023 16:40:05 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:04 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 6/9] memblock: introduce MEMBLOCK_MOVABLE flag Date: Fri, 10 Mar 2023 16:38:52 -0800 Message-Id: <20230311003855.645684-7-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 285911C0003 X-Rspamd-Server: rspam01 X-Stat-Signature: nc5jpsqyn1eafunj1jxucyeuxzfu6p3u X-HE-Tag: 1678495205-252445 X-HE-Meta: U2FsdGVkX19oEEW9ewdtKKnHyB6rc7jrNT/a2UtWwC8ivYU7ABIhuwe3oi6XaG3ve04lnfgfrs5GAh8vvJKryNf28paL+tK/zNNTNd20v88yG3aG5VLbV794Ouiu/t+G6UfZsWEnB8uJpDLdnA8dIA/8gH4Lx7ShVOkKo5jyVbCkbQekg8J0z1i1HEeTx5P1aDg2GsgbQ1jbujMR16SDKdLyi/TIXHNSIiZsJhm42egmkqVrDAbTP7zGBD3thSS6AT7yksKjJhsxmSaLAW9kNtUBn3JCgAEUuusjKO98QoZA0dda0+6NTaLLk/tKurNpG5+B0XZisQvJRTnpyblBvnoJezYhWjdUbsl8M72JnYBbv1Jju1PlySOuJS+8SnyvxdK4hd5WrjoBLQYYZrDKZRiboguo0qM6STgqV42qi/spegr4r3nmujmw3c04jGG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J2fYfv2AD2t3BiAbatJKu8PBxRkDEPmIPIPA64hqollWHt9IS7GKcK7MVIXkYR8= 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 25fd0626a9e7..794a099ec3e2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -992,6 +992,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 Sat Mar 11 00:38:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170544 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 8994DC6FD19 for ; Sat, 11 Mar 2023 00:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F31436B0074; Fri, 10 Mar 2023 19:40:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB8328E0008; Fri, 10 Mar 2023 19:40:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D59FB6B0078; Fri, 10 Mar 2023 19:40:11 -0500 (EST) 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 C24B36B0074 for ; Fri, 10 Mar 2023 19:40:11 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9B30B140222 for ; Sat, 11 Mar 2023 00:40:11 +0000 (UTC) X-FDA: 80554760622.07.0E297C1 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf17.hostedemail.com (Postfix) with ESMTP id CB9D940005 for ; Sat, 11 Mar 2023 00:40:09 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E6LvORJl; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.178 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=1678495209; 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=5jXGljhJMOsOLQ0WVWyx9Qh8aJ4axzukipUofLqyH0c=; b=laM6Ps0NVNt+lAWjk0xRZsqM0l6kdlq3E1uYtKaBWkwk3skJNKS9Sue/rmTj8ABK2maSSv I65JrGqaxHXZrW2uZQBm3z5ssmW9zx1wkFIKEa7vQBAPwyNjXUOol1qudPeh1VAGnIHgYN oG+MOfPvp111EPCLFWBjdML0A0/+/I4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=E6LvORJl; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.178 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=1678495209; a=rsa-sha256; cv=none; b=CsJYLVbPr0oHIU0Tykj+I1be1+gekSVU+jAZetBatf7/aT2UDs4peM7YCM8E2aEmMSDiGi 3VFQMFhEXmBYeTG2LuidPeduuzRXlemQ6evb7RF8yhct95Oec3otkwDJlRO//a8zltinJ2 1+BsadyFsH7T62/07WG/XxcTU3hh5Tc= Received: by mail-qt1-f178.google.com with SMTP id z6so7811249qtv.0 for ; Fri, 10 Mar 2023 16:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5jXGljhJMOsOLQ0WVWyx9Qh8aJ4axzukipUofLqyH0c=; b=E6LvORJlN2jcni/5ioUWmsjOnXgl7B775URlFqKgBop4b56C+en9J/o5VQci/Gr3HZ mDdqxrmhy35dEWIEr0ibeFXQqzumxlSJvxH0I05R+AxhZTacM9/FvPnPJwWedeUC3cvi pQeNNZX6OTbmRuNopd8WQ1Ls+zrYG6cPajDLFXJgfwUMMroLFQt144s5fzywH9RwVKGB dmBEqLB4kzE3dqcZNzL4WQn30AqT97RuhmZuQIzcafVEHXu3L1817x/L3l9h/Gi2ryuc MrvohJM2ORGZfictxJHfVmKJwsQQjwobLzwvo9n/kzxDzegIeFbxcKr7T/9FtgMrtnZZ mFBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495209; 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:message-id:reply-to; bh=5jXGljhJMOsOLQ0WVWyx9Qh8aJ4axzukipUofLqyH0c=; b=P+Gh4T2sxE3ab2BsNpIQn1Q2zHuBzyBfQOtk1i8Ne717AW6K5egDDaynOEVrnM996y 54+i5t9tsYjMKoN7Khk/Yya/zwGL682uQtipF57k3MabDx2goNbnRuCroDex3nWwFsbN UeQpgPOk1+rgqtyZFIOiegJIMdxMy7rrm8d72McrHagzwpNB6wDF4rrzcX8k5fzq5QvX GrT/aYE0amhDPJ1cevbFpTXFYjwVt5QYbPPshiTdaES0T0ubGwGoGj56k008Is80qUOP VmozLreInUmwgEIMy1YIdD7jNwHjl+YMJS2oVcgLgDjiyqNAfzm/DM9+Zz1Msw0itjtm +i0Q== X-Gm-Message-State: AO0yUKVX9ht/5pW7Q5jtMkBs6R8PzwQmUMRsJUq49N4DuIjYcZ6LbZsl 5gbW9SPuau6FxEB8X81Exjc= X-Google-Smtp-Source: AK7set82JZQLeG0mnfSCEhr7dXawy4oS4wEWrjbePSKQBRygykBuuvLPI0fUBxrCTyPQT+oR+bashA== X-Received: by 2002:a05:622a:590:b0:3a7:e625:14f with SMTP id c16-20020a05622a059000b003a7e625014fmr44499078qtb.9.1678495208862; Fri, 10 Mar 2023 16:40:08 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:08 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 7/9] mm/dmb: Introduce Designated Movable Blocks Date: Fri, 10 Mar 2023 16:38:53 -0800 Message-Id: <20230311003855.645684-8-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: a37ehiognf6su75zksg6ef9ideyw6oc5 X-Rspamd-Queue-Id: CB9D940005 X-HE-Tag: 1678495209-614154 X-HE-Meta: U2FsdGVkX1/vk53TX3MQ6QiAh9ZT0+No7oLHwOsxUU81sUHSLBkZDhGttMf3MSi+3RIOUd7CXb2zMFZjq2cSjiz0Aa6FJUXzFKqmAE0SyycjAWu+lmQ4ZLWSeMSuPq303uG0We8hWNXTF0e1Uz4cFfWsklIvbFBMmRtJlyafuWVDCF/KFXhYBX2ltx7Tw2ghLIHGcywhqTTFVeAFlHJreG0LbDcxInGo8N0ojp5zc9lCDuh/5nnS7YKZ4aJc57npFFGKfTuv4j/Hg1X1D128+7ubqF2aHN+OWnKk8P0W9SO3pH/BkUp+oKSJulqZKFhXYosCTb1ZOW99UIptcrYG/RLM5O9FdL1/AXUBZszOF62fE728Zv3FIXGb07oZYn7uGBIu5uvo8s9zx9wh46XGB5D+HKcyIdjuYZr4etMXw5od5N6sGpQVDigffNTOoL4D3sWRwdt21tl69x87Ogc50wiLeiPlEMI235xXavkCAztp2aY9BJWDgNcJQG0V4hoiEVkd/bn8Oo32ahfhH2krQ31QBxTpGEOH7WiD2nwKXJM8DEGH/SwNEi6GgscNdMlaG8hhQ43uESWI1lXJR080CMUUlmZ9EJwlfZunJvP0wSrrK48ic+ZMjZ08FlvCoozVOIXS3P1eyQIWBuLi2jQDxgekJ2FwZKWGioh2qqR5lTh6cUZd1OPYApphK4zLXsvHg6h/zzcnB9WPSz/4JGVE5FLP1wetspp2+EYkAx35XX7iIU7h04mVDXWC1prB/3AywRQJoc49aS3/+wkyC+127vcl5iFs6R62T1xQT4G0/bA5q4hfMvoqBHF4VhYwV2MUSbxtwWzgs6TNRaF8v/vGb9WWFcTDYPiVrcDsoC3sRm088KrR2OrBUnaTvWYwoyMBbWq1HI86zab4HOEmYt+acJu7oFwH8TGG1kpsn6/KKkyjauxRg6dYRImFd50Ws8PqtU6mEPPuCq1nKdiShCN LKbSwj6i fDqHZH2suLentNkGbDAh4Zld/dyTo9aUUXfQ1NGI/Qz+uezPqAn5WbccjSQEQ1az6qtAOr/nEbe4i+mlUsWijhv1TmKv94lC20mwFvJu4lprQmlRqWx5SsAD2hqqH1bF2XeIDUhaQJB2VwraXUC4cumZYpdgdVHVqRbBIJlGYvCxcQPh66xBC6XpXsMfQkxDq4mvFL80etWhNd25u67D5iZmvKfYsTVkc9z31srJ5zpDWHOl4G4WQ3QNl6k2kEjESbx3/+b0xC3jsn3FzmdZPAzNJjhF/lFpmtiSU1XniKLBzkkARgLspM+9odbIAi6hKBZ7yL5PEdQtpjVbd1xZCUTe4cFLK7dCtOFh8rBiEBk8YbToSy7uHGXnvVCKCqoXlM9pQO5J4Ng1Z/ar4Aa5gz7hmyytjtTW/pE+UMwwNKPSFzwYsUR5zYY4GXvbBJp3XBVMzZWfoLof0cZ09IhGdejfVFQeI1WgYsgk0yRZY73gh8G/qApvVXWyWBxulHJi3lb3ZSwZrEme8JNus24q5x/2aVQ== 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 | 95 ++++++++++++++++++++++++++++++++++++++------- 6 files changed, 220 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 4751031f3f05..85ac5f136487 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -913,6 +913,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 8e105e5b3e29..824be8fb11cd 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 794a099ec3e2..3db06288a5c0 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -2103,13 +2104,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 da1af678995b..26846a9a9fc4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -414,6 +415,8 @@ 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 max_dmb_pfn[MAX_NUMNODES] __initdata; static unsigned long zone_movable_pfn[MAX_NUMNODES] __initdata; bool mirrored_kernelcore __initdata_memblock; @@ -2171,7 +2174,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)); @@ -7022,6 +7025,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); @@ -7482,6 +7489,12 @@ 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 && max_dmb_pfn[nid]) { + if (*zone_start_pfn == *zone_end_pfn) + *zone_end_pfn = max_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; @@ -7550,12 +7563,21 @@ 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 && max_dmb_pfn[nid]) { + if (zone_start_pfn == zone_end_pfn) + zone_end_pfn = max_dmb_pfn[nid]; + else + zone_end_pfn = zone_movable_pfn[nid]; + zone_start_pfn = min(zone_start_pfn, min_dmb_pfn[nid]); + nr_absent += zone_end_pfn - 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; @@ -7565,6 +7587,19 @@ 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; + } + + 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; @@ -7584,18 +7619,27 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, { unsigned long totalpages = 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 (max_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; unsigned long zone_start_pfn, zone_end_pfn; unsigned long spanned, absent, 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); @@ -8047,15 +8091,27 @@ unsigned long __init node_map_pfn_alignment(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; + + nid = memblock_get_region_node(r); + start_pfn = memblock_region_memory_base_pfn(r); + end_pfn = memblock_region_memory_end_pfn(r); - totalpages += pages; - if (pages) + pages = end_pfn - start_pfn; + if (pages) { + totalpages += pages; node_set_state(nid, N_MEMORY); + if (memblock_is_movable(r)) { + if (start_pfn < min_dmb_pfn[nid]) + min_dmb_pfn[nid] = start_pfn; + if (end_pfn > max_dmb_pfn[nid]) + max_dmb_pfn[nid] = end_pfn; + } + } } return totalpages; } @@ -8068,7 +8124,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 */ @@ -8196,13 +8252,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; @@ -8351,6 +8418,8 @@ 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, 0xff, sizeof(min_dmb_pfn)); + memset(max_dmb_pfn, 0, sizeof(max_dmb_pfn)); memset(zone_movable_pfn, 0, sizeof(zone_movable_pfn)); find_zone_movable_pfns_for_nodes(); From patchwork Sat Mar 11 00:38:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170545 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 58AA6C6FA99 for ; Sat, 11 Mar 2023 00:40:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBA378E0008; Fri, 10 Mar 2023 19:40:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6A0F8E0006; Fri, 10 Mar 2023 19:40:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0BFB8E0008; Fri, 10 Mar 2023 19:40:18 -0500 (EST) 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 C162D8E0006 for ; Fri, 10 Mar 2023 19:40:18 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A27111C5E7D for ; Sat, 11 Mar 2023 00:40:18 +0000 (UTC) X-FDA: 80554760916.19.4B295DD Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf01.hostedemail.com (Postfix) with ESMTP id C651240015 for ; Sat, 11 Mar 2023 00:40:16 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (imf01.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.173 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=1678495216; 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=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=iKpNrUy2pV3YDj1eNN4yY/dqW2Kb6WV8eQeRIQS6sXbiGrbBMgWtycTW2MTJ/EyJrHBQwj 6wgn/E4ZiV2+xBqP2+J+fyMMGAPsU9GKNhAe1V49INj2jeVMNiL2S40etqfghx3NEhCvtn HIQNN9tkmtMToKv6MAu0EVHuzmYqdO4= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=b8xlkMmx; spf=pass (imf01.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.173 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=1678495216; a=rsa-sha256; cv=none; b=2xeNsn1RHl0/S0chvuZZUkbQ6inf4kfjxG6Y8uVeANvYzL+4PgjFyedW10RFm50jaU9m6c XaDyUDVBaGnYHPCAxol6nGeu5AUiRm5uoykF50Jes/8xUyqSiIIMGRHkge92BsYjW/jAyV +9MhPyxxu77N4sHXcJ4j98HH7F4L8cg= Received: by mail-qt1-f173.google.com with SMTP id l18so7766700qtp.1 for ; Fri, 10 Mar 2023 16:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=b8xlkMmx2Va+LMTaL4tjD8wYbm4UC16eGq/CrQTHkbnm9E2UfknGNDOooRPnWFHGH6 HXTiYXZS1Z4zgkWMhxH4u7I5AbqAc5eeOZhtfDX036xKJJ+55cFVd3c276/H96DePLC8 NxCS1PwmJLpvBg7BPQFk06uiCf28nVWffj5kbhUi3KznMOjevla6Bq8op4cw4ED6lVfx 6utHCbAoUN93i+J0xNphYV6jvsuIXhNDDr9S6CzOTcNB+n/aroO0U+CSERlTywJM50e6 ZLL4BiS8iPRnwj68gAb4ZS7lToep1wKzor8UHnBFdOyaf37GDfSlrp6Wutseal3QZY+N YWAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495216; 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:message-id:reply-to; bh=ZUweBIxK1ApmrVss49z+UC3wE/nMfv3P38hD7KfWAG8=; b=UJ1r6trUXF7kYgx379STD8ET5luHz5KnAYY98+D97QTnShP0Dfu+rsmcpOfaAyC4k2 bUhTZSdlwzYsWFJ/Loe1qZihYPuYNphqxYC2HxEfv85nXgmmkoUcH4hNsTkyGMtb1grT 1ILYpkxIAOiFBl4PKJxRfoMzokvpVT3/iDiNQnkgnO14haoIPQZUaFOdRVofbtDAjIbq R43ytFPabNcf4GwkzAAt6BBjeJlfg/gtfjQ0Y+jkskszgJe1FWWidEX9MpXmBIoyI/RV /aiUsCSZ3FWig1JQs1YGaEUe9iasfwWfKDIgEOz2rTlHrrLVDptYnt/vlSu6sZonLq4C 2jlA== X-Gm-Message-State: AO0yUKUTD0gUNuaQqBrioqld72AB5bbUo03q+Pf77l7a+mQSKaP/XBgK QnnPgylexEQ1rv9fw7OC/o0= X-Google-Smtp-Source: AK7set9au5WlIK4MR23yBqVZHrwwWy+PuYch9qrfX49bao0ol0Y+CZl0Oj9zvXShGjOoENldS5rAGQ== X-Received: by 2002:a05:622a:5c9:b0:3bf:d366:50d5 with SMTP id d9-20020a05622a05c900b003bfd36650d5mr42637917qtb.56.1678495215959; Fri, 10 Mar 2023 16:40:15 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:40:15 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 9/9] mm/page_alloc: allow base for movablecore Date: Fri, 10 Mar 2023 16:38:55 -0800 Message-Id: <20230311003855.645684-10-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C651240015 X-Stat-Signature: tks7pygnrpakmqhxq5qpd9izxfx6qth7 X-HE-Tag: 1678495216-135314 X-HE-Meta: U2FsdGVkX19/o16Xi6MzeC2jt0wNWYamjA5zZcHvHWXu4Q3+bPrMn/Vp45RFAW6O3bTiCuGdT04ssiGm83QEfaUxaxf3BD6NyIhGicx1qnWJhQboF50w7bm9EGZZHzMUavP9hDegWtQEN6EFtfk0POqc9e1kmKtN6XwsnyUACq2cpHVunoWXnQ8oqhkBElCYCQtD7auyKzZU96lSrdYOpFz5BvbWLrccFd2VnzAn+JYoBDDaJ+01zxxfsxj477tdC5YC2bMlxa1s4Nu+aFPsPWc576xNgIeI9MfSiKUv2Q/ZcWZOckWDkDlYChkZ2+GoIsYNskVT02/tZxPvDvkDkn5/5ZFCxy8BFCKx0AM1IrVZZpVNc8GBVOeP+5dwFqvusLc5AYWKr1lMsHIaMKsRkqqMkzTG3VeJBDNFK1yyt1wSpQB1k0llJyQ+15b4jQgu2ytrkH6czc16NxdLPmNiV6VGHDd3IFXVrunODvNfduVcS0ts9cb/gFs0Scoa4dao26DAEx81IZ7H4BiYBSiNQCd97HsMjCyBmg0JZPe1gTkbA+EbdGtGJ6mC9uROwA501iuzqtRBRoRpD8O9gnBP261ShM6An982RTg68h8us1weeZwmc5dY9OlsxYZJKzhnY0ongXwszupLLSrmv/Zvmhrgm7PU17WZCJ73nB3BOKwSUVdy4Gxjoxj/SkWZPicbP5pAaC0s/WBM4EaEJYPAsQFFoB9YO2HysLrgEqYq/2JAljZ2XMNbQY5ZLV2Kyfj/7zQKvTzFdQBG7vLCJGnd1G4/49RXEtzpE0gihftYFexbLirO3/3XZc19WwoaoM9SbftEjfh+k0sG+frTGAbflG9gRdREtWS9iLFFimSauOqJNVfmw++HHPYN0zHgGg0E6zeMJ3rpHChaEoUiD21yaQxmCxS2H94cwJENb53z9lE4YYeGDJjK2fEJqEYWiV+WhvWwZjAVZqGYpmIA83U ovQwGIvH MfxCYfY0qn8dFsIhus/3FX2Ar9rFsoKRUUUfeFINIFaIDP0fyqtQSYi0gbJZFZDozFMVWmwH0tOMX5Yr1SvFOf1er4MmF0UpsibSG3q4acQCi30Cq/VWO7xNAfvYtBm2szCLdzowa1LqUPbjFixFP2aWxAQvTXGG4IDYOZkdHaAg8gQ00PzaHvdBuM/2n97sW35b7d27nsydvBDW5viY6N3SZg8Qz6AtdhOXhpt/C3xJlM4qAGe4fnc2jAuAt/VLCNk4oG39lJm6+K0yXtVsvwVg029dD4vjqEN+cFNbnYz61YsS/+erZ+H7GMJy4XJXKLz7oHBMNLlKdySqi/we2IxnAKeqU/f2gXhy3i8QgIJN57O9ja3UQi3+jQOrmzVIhwxnhl5XjJmK+axDKxJh5NQNjthS+n+vckI9GyUhh+kEphuwQrKpaBJc5/2qmdBeLUoHGpT/dGoxmiT4qrpV18+6XTlcjcgMpJXH8LXpDhmeFl8WsvICirTOZLHzQI5AaIaWiOrqM2lGZnpJcal8rVki2wMyKsku51kYmAM7j/FchwLtwafwM7vYQsHP0mcQNcQhvoRjre++w9P4= 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 6221a1d057dd..5e3bf6e0a264 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3353,7 +3353,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 @@ -3363,6 +3363,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 d4358d19d5a1..cb3c55acf7de 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8504,9 +8504,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) @@ -8521,6 +8521,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); @@ -8543,17 +8554,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);