From patchwork Tue Dec 3 09:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13892064 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 EB41BD4979A for ; Tue, 3 Dec 2024 09:47:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 784A76B0099; Tue, 3 Dec 2024 04:47:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 735846B009A; Tue, 3 Dec 2024 04:47:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AF0C6B009B; Tue, 3 Dec 2024 04:47:59 -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 37E7C6B0099 for ; Tue, 3 Dec 2024 04:47:59 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1738C40FA4 for ; Tue, 3 Dec 2024 09:47:58 +0000 (UTC) X-FDA: 82853171268.28.070ACE8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 0D2AD40010 for ; Tue, 3 Dec 2024 09:47:45 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IXulOmKM; spf=pass (imf17.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=1733219269; 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=xX/Q3/3Rp0ILyMXyKGOcZrJDDur/TZdwfSuBal5fAnM=; b=5xVbUM7zw14PMZEFI8RO1CkkHUS3DCbBtZqVYwYCivLT0MAFUyus0XBDga/IeeIjfCucZ8 hIWA2JZf5MoyvVEgXxLbqevzrbo9zKDsMIprsCPJHQyJZ7j80lnbRxCFuiZ2SPCUiiPcHk 8Efd5kuVC131jOboBoFOyOeCiDgGt50= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733219270; a=rsa-sha256; cv=none; b=EAtjzvJjA5tOZfYh+w0Wh1caCz/VlLqHmfG9Sofu+TGbKlXFaDIoIKb94toqUtW2/2CJlA dsGuwf0S2qdttIMB2/QWIno1GR19Q0iSU8tn/PN+q9+CAEefVPp9Ff3XgW7fzNN5Qg87uj oMi7tmfTVyFoPChAPmV84z+XZVB4oUw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IXulOmKM; spf=pass (imf17.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=1733219275; 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=xX/Q3/3Rp0ILyMXyKGOcZrJDDur/TZdwfSuBal5fAnM=; b=IXulOmKMu5wxyW43yzFUuxRR4gwP4R0hARlPCbzOlityI0bvSp+D7tf/I7J9fUBNaq6lB0 Q28Kd7839XYC0nquBxV90qHulUm7G2UIurvfNC4X7k/Q90dGXdy3due4KaBz2/4dA6EMbu VjUEEcaD60k2EhXdE3heUxMDtqU4U8k= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-1A-UdxHTN16K-x5N7LsJ2g-1; Tue, 03 Dec 2024 04:47:54 -0500 X-MC-Unique: 1A-UdxHTN16K-x5N7LsJ2g-1 X-Mimecast-MFC-AGG-ID: 1A-UdxHTN16K-x5N7LsJ2g Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-434a467e970so37367865e9.2 for ; Tue, 03 Dec 2024 01:47:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733219273; x=1733824073; 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=xX/Q3/3Rp0ILyMXyKGOcZrJDDur/TZdwfSuBal5fAnM=; b=ACLfcoadoTTeRC1VJEwVxqM4si+UdBZSIqvO/BHCTOv93oBRIpLIm0Fwq7n81fO15L tdWXXZL63hdkq7cfuYn8yqRrICk12tM6h5IsOfGqZS206gi9aIbDqSq1+l1rBrav3HM2 lcd6JE1p2nYJ0cDwhCarijT1CNXhEEI6KGNOM7J14x6BSaKE2Uygxn88vnXb3w9G0hsc 09y/vhaKSYVHVgXAsogcKnsrBXLafwGVr+zr9Ch2zkKMSuZhOVJCEwGAaHBZ1h7nTvg4 FN8UmgkL9lvXwCccFruDF8jo+R8Kz1jAV6RgawGcXy8PBIa0aegdovnhrvbJdc4fozUn AA6g== X-Gm-Message-State: AOJu0YxvGVpl2dPgd8UsXPHr/A5yfHF7Vu1NtxmTo8H2OTYBDdAfBIRy 2bbDSmzEjVfwyoy01ulu46XhH+EGbfWRI0DqVnwrnFhQODRKbqwcnXH+AZ/8mD91d4O5YwaqT7O 071tf+n6CB56xGoDGuWC+3Vo5yhBOyKzxIZDE7uuMu6cioUB8 X-Gm-Gg: ASbGncu4LIX3iX6X84VHPQaqAdr3GCsLBA/L2zma6r1LfRYi6TjTAHT4z2mBOWZiiqi Y20fSKY5/liL257aGa13ppokPiSErO2RQtF0kFJDliL0dE1fDTrc5SFWVjn+2UX9e4Jfu7ZxCOd 24mk5rpLrnCSEn3eH8OsqN55Os+Dv+UP+RAwLXveQLYlprT47zJiAo0jQD1s5GHvVh+ofXQLRy+ RYMyXHP0IoIn4+nylcUheykcYUNToBeHXm0iBoFOz7QX7NnOPlb6ikwnGoHk5Cdq1yjTKSzrYc6 WnSRJudf1YfdkuKXZaA/uTjXZojvUGIZzGo= X-Received: by 2002:a5d:64e8:0:b0:385:d7f9:f15d with SMTP id ffacd0b85a97d-385fd3f2203mr1331586f8f.11.1733219273166; Tue, 03 Dec 2024 01:47:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDQ5OaqVY3m0DLSpLsQFBtVdXjpTP6F01guYNPwPEOIqC9M1Xr0t++bvv36PMaxbsj7juBag== X-Received: by 2002:a5d:64e8:0:b0:385:d7f9:f15d with SMTP id ffacd0b85a97d-385fd3f2203mr1331571f8f.11.1733219272794; Tue, 03 Dec 2024 01:47:52 -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 ffacd0b85a97d-385ccd68c1bsm15299309f8f.84.2024.12.03.01.47.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Dec 2024 01:47:52 -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 6/6] powernv/memtrace: use __GFP_ZERO with alloc_contig_pages() Date: Tue, 3 Dec 2024 10:47:32 +0100 Message-ID: <20241203094732.200195-7-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: va9lACX2PRnzFOETK_x1ulM1AY1LCBIoR0_ku0U1E4I_1733219273 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0D2AD40010 X-Stat-Signature: aof31bfrw8gwnsg6boj7gxo9fn1j4pd6 X-Rspam-User: X-HE-Tag: 1733219265-636529 X-HE-Meta: U2FsdGVkX1/jlxtHS1poChLU7+rT5Vlhq/e/3g2U/nNN8XLiVtMzLNIDHQ8wMUCxqnCg/FCyjzrevysjusopllSPc37KrwZUBtXCIT6Zf2Oqq08Ecb1JO/Eg2dhCkVk4htyYjeJlCo3396zH14NF/naSI2TlmbKc0a4a93SjrfvanO20q4fRiAw96FTtf6obcUwdAihR40x+R3/5tyV2gERX69gnkI7Pv+AQLRcTqEwZGTfsRXswOyIl+MloLjAsJBEbs6q8LT9PPdYsowzfIQYwvrsdfapfScjFWSjm7cdRMTCf+CSV2Q7bxGSKBu/PUstOrAt++btiPczgmuxU8yRGjp1t15L3LP+DJGIvhZMf4lR8cH1AoE94ijNdaWBsI+Ua4ITR1Gk5C5+3PhI3E82eXW9QQt0iEASQVyGzbeKsUY4P5WoKBGbpjC/5bJFPOHySGi95x9K8bgfRmXmY487a5ha9VWRChbXlTr06C/U/+9Ek7FVYwR8hLM1HzQqfwu7nN7EJmwdQOwyTI6yILFQXGfMcgCpbP/O6PB633ykqT3lmTWIvkInOrDxQRUQZZktk08O/D9B7TT7y9/4qLrOMoJg/Ij9en+WCHVqeZcpThn7JvttySM9Ah2DTzwuTbGboYxTvux4TVoqwgS0yLSfa5tbYU6F7MDaMJkNLqST9zlXuJvnq0ycj6Mf8RknqDtzL/nM7JVxlEIXSYOpKDwtRsYLo1A638VgW0UsEi+zyLCX4paMd5zPtrTfF04JqkvLL9Bterystm+mp4pnkHHUaoJfJVemFVKKWzxoOdqEzi8QubCVNOSk+DyOBZDOhNPlHzF7Q3PAhfBk7Jga9k/xEjUHLfO3zlgt7bfCH3IrrUeItU1Zna2RSuRXK2imNPSOt5HoOux4y7gqYyy8gz4JwUEpRK2qrYwuRPFG1r2d+f0QqwfhFjqotjMKeYJCQvBpO4oTuH8bIh6j8MK3 22DgrGsr SyvoxQGg7sBegp0ygdQt3f90mr6a1Wqu9nI4uDmvlmSeoIi73AneZVCg/7uUVPfti27F46+1HZrbxEw7ycyrp8eBzAYzyugyVbLvwNIwqcrMSs67J0kybsqQ7IUoAEwpLr8vaw94l+aLHrtfdest+W3qUvReX8NxTUws/Z9umeYahTju1yxuOkYCLaCfed146pMz/U7p1J8fy6Y46KUy3RSoDuQ2xFxZh4+G6WO2OARrV9lzls+VSPNOQYidH2X8HAL8ozD7bO0ks99JJZbJaxQUxPIhLEQsM93CygHZ2jO9MxbyK6sY1xzhOxSCpl1THhGCLAtnWwCKAMmoAnVD8QRK8vBIKFK9tnGHWzeF88lLP95jvaiMtiF2UEvKUffHkvarF2MP7huGQHlU4RYV0b0gwweQlSHnjGxELi7IEPcAFMElh+b13ERBVyAmKwtc0lGE19QlekMLMEofJLqVVJv+HuQPWc6O5sYnR 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: alloc_contig_pages()->alloc_contig_range() now supports __GFP_ZERO, so let's use that instead to resolve our TODO. Signed-off-by: David Hildenbrand Reviewed-by: Vlastimil Babka --- arch/powerpc/platforms/powernv/memtrace.c | 31 +++++------------------ 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index 877720c64515..4ac9808e55a4 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c @@ -88,26 +88,6 @@ static void flush_dcache_range_chunked(unsigned long start, unsigned long stop, } } -static void memtrace_clear_range(unsigned long start_pfn, - unsigned long nr_pages) -{ - unsigned long pfn; - - /* As HIGHMEM does not apply, use clear_page() directly. */ - for (pfn = start_pfn; pfn < start_pfn + nr_pages; pfn++) { - if (IS_ALIGNED(pfn, PAGES_PER_SECTION)) - cond_resched(); - clear_page(__va(PFN_PHYS(pfn))); - } - /* - * Before we go ahead and use this range as cache inhibited range - * flush the cache. - */ - flush_dcache_range_chunked((unsigned long)pfn_to_kaddr(start_pfn), - (unsigned long)pfn_to_kaddr(start_pfn + nr_pages), - FLUSH_CHUNK_SIZE); -} - static u64 memtrace_alloc_node(u32 nid, u64 size) { const unsigned long nr_pages = PHYS_PFN(size); @@ -119,17 +99,18 @@ static u64 memtrace_alloc_node(u32 nid, u64 size) * by alloc_contig_pages(). */ page = alloc_contig_pages(nr_pages, GFP_KERNEL | __GFP_THISNODE | - __GFP_NOWARN, nid, NULL); + __GFP_NOWARN | __GFP_ZERO, nid, NULL); if (!page) return 0; start_pfn = page_to_pfn(page); /* - * Clear the range while we still have a linear mapping. - * - * TODO: use __GFP_ZERO with alloc_contig_pages() once supported. + * Before we go ahead and use this range as cache inhibited range + * flush the cache. */ - memtrace_clear_range(start_pfn, nr_pages); + flush_dcache_range_chunked((unsigned long)pfn_to_kaddr(start_pfn), + (unsigned long)pfn_to_kaddr(start_pfn + nr_pages), + FLUSH_CHUNK_SIZE); /* * Set pages PageOffline(), to indicate that nobody (e.g., hibernation,