From patchwork Tue Dec 3 09:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13892063 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 729DAD7833F for ; Tue, 3 Dec 2024 09:47:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00AA56B0095; Tue, 3 Dec 2024 04:47:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFB456B0096; Tue, 3 Dec 2024 04:47:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D52166B0098; Tue, 3 Dec 2024 04:47:55 -0500 (EST) 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 A2B606B0095 for ; Tue, 3 Dec 2024 04:47:55 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5E845120805 for ; Tue, 3 Dec 2024 09:47:55 +0000 (UTC) X-FDA: 82853170680.27.ADD0BBD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id E7CE0A0004 for ; Tue, 3 Dec 2024 09:47:39 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="PsXufix/"; spf=pass (imf15.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733219267; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0fQppTuvH7gihnzA0jS0S7Nrs9VtQXSbfqTsq5GHr48=; b=7MsvrkElVRIFGK/iLYNkqpSE4JRF4kp0rKXT086UMpXk3DvcpNnmTn+KKl7+lQhP5O8q52 elohm9sHqY5STVvMKdCXDFMyDZ3j1sgYb2SLD8QAz1HeAx+udEsj/Ddp+A2KIAKeIPt5Dq t/mX53pExK4/fNU1uloExTVaBiyXxfA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733219267; a=rsa-sha256; cv=none; b=d3k9hWCjCl3tcdXtLMcPg6CcUzeEBSq9h1+iTSmZcpchlWkHZBYNWuE889vouH5vVgQZww AKU2MXtRB6dow0IGuHK+KHZdOIJJEPxfDLoS6yveOr60kCojlDlxoXAefYp9H275aYecSX akdOrV81ZLBURSrKDYZH/yxfLtcLoFc= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="PsXufix/"; spf=pass (imf15.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733219272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0fQppTuvH7gihnzA0jS0S7Nrs9VtQXSbfqTsq5GHr48=; b=PsXufix/wJaO+Ojtf74uBYDzb8BNmWelq4knTbNu8zxEjzo9syCLKmqd12zi6R5yee+hAH PAx5LkLWGuf9Dmgi1KmEz16w7ETmlZ2XwVeyQyqlP1cGyQ2OBhZQJm9j+kJApkYS9CQoXE 1QWZd47fsFNM863J5youXYz1CJ7130s= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-IVMm5i90NnaFUD-eey6sng-1; Tue, 03 Dec 2024 04:47:51 -0500 X-MC-Unique: IVMm5i90NnaFUD-eey6sng-1 X-Mimecast-MFC-AGG-ID: IVMm5i90NnaFUD-eey6sng Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-434a27c9044so30033615e9.0 for ; Tue, 03 Dec 2024 01:47:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733219270; x=1733824070; 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=0fQppTuvH7gihnzA0jS0S7Nrs9VtQXSbfqTsq5GHr48=; b=vQbBXz+IsvlCG3ZLuAvb11I1TpsKyeSV8lUdxPLM06hBZzomUsITlYqMO+WgyrgD7i lKycG5Hdr4OPzukHe6OFoUvRO558T/krvcltC4CLYEFrp+5S4tRnhaqRjZ0LSqJ5pfVS P4peAsSY1wBAXNAAM3G1qlgsSWXsE2cdU9ZmmtTI8r3sungvOQzoTTrNAEay5rXYQ6Oj X+sFhZn1X7gPNbnSCjfh8JrmuDV2Fvxpuv+HF7BstrsMgs5HH5bZy8PkvurpHnJnGSPU 1lsCOhxKADSJQpDkgd8pa05wzIiQksSp14x4+RodauL2uffI3pLzfW7fM7ad4+w5HsaA j4Rw== X-Gm-Message-State: AOJu0YxD7c+/l9+VSpSZFctXKee3zoeAk8vi3dfFzVAm5K8QdW6xL4vg idi8fHtFmbyFcoAs4w2znEGFiLpYlx/gpJFAEPp/lzNM2FzEl868puJfOshqmN1oqb+tNIEjKcx 7O9tDUoubRYSI3MrjX+zhd4A1/jyjTFMaTRrSDr/rxX1c6W3k X-Gm-Gg: ASbGnctwf81KMNKw+7onbenhwEdr3mkRTYrtDozceF6nfJ+iLEH4OR5RlldFZJUANfX hZ1uam+Rxpbx6cdnNMN4mXj91zIoIp+h7jSvM6B1FF5kP3co/a8omSDs6qfSFZQYU0bVG/yd8rQ toquENID5SLLxtzwmtr/piF6oY/0gWXS0+unlVoNsYSa4kJ8+alNlZV+d1rJPDJSjNyFlMDeV7u zKmRuyv9CRTCcQCNOATVKmDTqXouas4ymJSwcHctVCOfa1VILSKuCkBDfYwwXzVp8CA+bGQBLVN M1Ub4S5y8fGIDoeYjdX1sdj2Hjiub8YxpC4= X-Received: by 2002:a05:600c:4fc9:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-434d09bf4b7mr16320815e9.13.1733219270399; Tue, 03 Dec 2024 01:47:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGScK9nYDBCgbazhX5KZLpi1/ltXaWURuwLWZA1yYPBlDObPA+UiToZ3Fi0RuyRTQ0aGN5NvQ== X-Received: by 2002:a05:600c:4fc9:b0:431:6153:a258 with SMTP id 5b1f17b1804b1-434d09bf4b7mr16320445e9.13.1733219269891; Tue, 03 Dec 2024 01:47:49 -0800 (PST) Received: from localhost (p200300cbc7461b00fd9ec26cc5521de7.dip0.t-ipconnect.de. [2003:cb:c746:1b00:fd9e:c26c:c552:1de7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-434b0dbe2e7sm183147395e9.11.2024.12.03.01.47.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Dec 2024 01:47:48 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Zi Yan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan Subject: [PATCH RESEND v2 5/6] mm/page_alloc: forward the gfp flags from alloc_contig_range() to post_alloc_hook() Date: Tue, 3 Dec 2024 10:47:31 +0100 Message-ID: <20241203094732.200195-6-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241203094732.200195-1-david@redhat.com> References: <20241203094732.200195-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: cgQFVnMbYIB9Lw03Bt55RlsEQIWuVdxhgM8U3ZQSoaU_1733219270 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E7CE0A0004 X-Stat-Signature: w586idqk7rhcbn6pahmymnax5bz4u3j3 X-Rspam-User: X-HE-Tag: 1733219259-401458 X-HE-Meta: U2FsdGVkX1+FvoO9837RNchffp6IFpJQM1Ss8NUj7fx7oD54crmjg/KKXNLtQaIBvomE0cusjL5ArZcrLMcb+rXi0opi2/N4gyG/2qwec1uAewa9C6Q9JXy8psi4faRAuAn3vUMdc6kTsQvu0FVo0OjYJSzKuOyfGO2rJ+qp699+FuFaauOshr6L9CZRwc3prd/3+q3hiL7VAH5YHeLPR2qZ976sCbWs1MMlarq+Ll4KcOpPdgmWFjGgyD6si1dLBf4Rw2uq7SvvdUruIavhPqnIxSkDM/vuMDG27tMEb9pbRkOj9iMGgO2j/cohF+PMSXdfpL+/E9+tFryJyZZK0qRt9kvchj5oSz4Ha0yz5ywCR2g7jWGJiaBgHn5C2/Dp1rRIHIVYl+Ti+PyQS9bGc6fbDM/am5OHjZ36iFjZjTVhoV4xTvoHeCz5cej7tfRicXH7HFngNGKjIp3ZR6vaUug7RiiNwwlLNNS/78+k+cySY3k3U3tItJtC3jBhRope/Ttq0JG/50BDYzG21wS/h6NsVew9VvvaeQTSov2vY7vqeXBBB3ko8UDI1tJE+rZqTN5sFSSdhMKwoCgudy7Es5thR2GAJTUgndf1zUvKMa5s48rrjrzstQ3Fqn7lGIzfhMQ38uN4P0QEBOa0+CmKP22jKyaz60EAIz2MDUQ+dY9yuBNS4CQ+hbiY16O+/Z36ewX+/26PKFFDm1lN9Qch+kxpQQZOWKIt9Of9Bb7IMOtobPmtt4wp7CFVmOXehdFuw8dD3c2T+lus/u2ZFnLbvyPPSF60NEQEQPuqC1iYs+8kLDpHXB0BVB3t5Cu8gD+xAgjxwVY3UFBoUawe0o8J7w4UXST4VB7SNPxFoRsVsgaBF2EmzdCCHCm2uC9/Ybm4SSwpsRqEV1cnmKtcxhXHGZdzSCUmbNlbD55W6fyCdmVb3ypgfNURtARCNF1La3sj/dGJpVeW7lrO3TuAV0w cU2S/kXL ibACyKN3HIlm8zFFKGXK9jDgaAmYqXvIcAlsjQIF+hsEtO28WNzTRme3sETx6y1LqoWJ/TYcJIzCkEirqxMioxAnluoaFyEyecaWtxFa48g9jRmaBc8oDw1mMCAQro3bzL8Hc4DsO2lKeA76elpnt8AcIYZK/2H8AJyS3wAqMLOWkLRv1Kg4K+xZTasHSicGAvOHTDs0ad4bPZcnGkB2pr6dFqRQYWVAWxyInHUa/JkMI0BdrIw50tiH0vW52xrZlMaHHa1jt5Ie4pMCKDWhKWWlJzwbnowsRgKIZVR976jMl4aOHPkEIgrYqfsUSpXvBLyS0SqXHqcUjfaJErN6NCtYTZxJE6qrpy+/aRa9MtMNRTStBe5HY/UMUk3KVqs5URp0DwFlstudOQtCdkr56pe0ijdw8ESjlaiV5QNndPRxPCqYnyUa+w5lhEZ4VeKyld+LGha5MP6KEOFHKfs9nyO6PX0zs0SBaZ65O X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the __GFP_COMP case, we already pass the gfp_flags to prep_new_page()->post_alloc_hook(). However, in the !__GFP_COMP case, we essentially pass only hardcoded __GFP_MOVABLE to post_alloc_hook(), preventing some action modifiers from being effective.. Let's pass our now properly adjusted gfp flags there as well. This way, we can now support __GFP_ZERO for alloc_contig_*(). As a side effect, we now also support __GFP_SKIP_ZERO and__GFP_ZEROTAGS; but we'll keep the more special stuff (KASAN, NOLOCKDEP) disabled for now. It's worth noting that with __GFP_ZERO, we might unnecessarily zero pages when we have to release part of our range using free_contig_range() again. This can be optimized in the future, if ever required; the caller we'll be converting (powernv/memtrace) next won't trigger this. Signed-off-by: David Hildenbrand Reviewed-by: Vlastimil Babka Reviewed-by: Oscar Salvador --- mm/page_alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 54594cc4f650..71d70bc0ad79 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6364,7 +6364,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, return (ret < 0) ? ret : 0; } -static void split_free_pages(struct list_head *list) +static void split_free_pages(struct list_head *list, gfp_t gfp_mask) { int order; @@ -6375,7 +6375,7 @@ static void split_free_pages(struct list_head *list) list_for_each_entry_safe(page, next, &list[order], lru) { int i; - post_alloc_hook(page, order, __GFP_MOVABLE); + post_alloc_hook(page, order, gfp_mask); set_page_refcounted(page); if (!order) continue; @@ -6393,7 +6393,8 @@ static void split_free_pages(struct list_head *list) static int __alloc_contig_verify_gfp_mask(gfp_t gfp_mask, gfp_t *gfp_cc_mask) { const gfp_t reclaim_mask = __GFP_IO | __GFP_FS | __GFP_RECLAIM; - const gfp_t action_mask = __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; + const gfp_t action_mask = __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWARN | + __GFP_ZERO | __GFP_ZEROTAGS | __GFP_SKIP_ZERO; const gfp_t cc_action_mask = __GFP_RETRY_MAYFAIL | __GFP_NOWARN; /* @@ -6541,7 +6542,7 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, } if (!(gfp_mask & __GFP_COMP)) { - split_free_pages(cc.freepages); + split_free_pages(cc.freepages, gfp_mask); /* Free head and tail (if any) */ if (start != outer_start)