From patchwork Mon Dec 2 12:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13895601 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 8F52CE7716D for ; Thu, 5 Dec 2024 15:35:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D528E6B0104; Thu, 5 Dec 2024 10:19:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9D06B012C; Thu, 5 Dec 2024 10:19:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 509626B0102; Thu, 5 Dec 2024 10:19:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8840D6B0082 for ; Mon, 2 Dec 2024 07:58:55 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 478E1121142 for ; Mon, 2 Dec 2024 12:58:55 +0000 (UTC) X-FDA: 82850023704.02.D8AD4D9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 6025F100002 for ; Mon, 2 Dec 2024 12:58:40 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=co35R3SJ; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@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=1733144320; 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=xX/Q3/3Rp0ILyMXyKGOcZrJDDur/TZdwfSuBal5fAnM=; b=6CWzP3eHvJg4qSK4uC9kezYJkwGo2XHWp1F80xLZ2+/H3vQsPT395xxPQHzuHpOh5V3Y0c /oS9ZvFE/EadDY6c8iCEQ39U1u4zu6kNyZVB+iNFKjnRl1laOVqoxIzwwVFVmUCEYFZpno PUcYidt5EoBDuTgufymZpZP4cGBWorI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=co35R3SJ; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733144320; a=rsa-sha256; cv=none; b=7/muJ/O4u/wDntwD5W8GDcXkMWzJIJIenQbzV5xQ387QeIwdHiQvWA7/Aa9euCRoqAPMZG HtOVPoHHdJ8uwU3+2G08/MUL7AzWVDQM3KANjdtueq8nBHYDpRqCLyIeWH0C0etAlJD0OE H0oqsgvK/J5ZKRtUkXDOFl5HBmC7ASc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733144332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xX/Q3/3Rp0ILyMXyKGOcZrJDDur/TZdwfSuBal5fAnM=; b=co35R3SJpz/oRKuujuXLEkLCxtsST7xL7HI4CA+9QkVrpiAqSEymQ7svN997/+TP0CANmR wvMfy2G0ctQNhKQNe+B3xjWFufjsvGkDg0KSt7bq1SbVAFloy92s758simfVCSJCUpLu+W cEMLNWKnAUU6v9BF777zssJ9d10Gmgw= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-hwR66AWaPNO_VM0dBSx8pQ-1; Mon, 02 Dec 2024 07:58:51 -0500 X-MC-Unique: hwR66AWaPNO_VM0dBSx8pQ-1 X-Mimecast-MFC-AGG-ID: hwR66AWaPNO_VM0dBSx8pQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9324B1964CDA; Mon, 2 Dec 2024 12:58:49 +0000 (UTC) Received: from t14s.cit.tum.de (unknown [10.39.194.150]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B055C195605A; Mon, 2 Dec 2024 12:58:45 +0000 (UTC) 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 v1 6/6] powernv/memtrace: use __GFP_ZERO with alloc_contig_pages() Date: Mon, 2 Dec 2024 13:58:12 +0100 Message-ID: <20241202125812.561028-7-david@redhat.com> In-Reply-To: <20241202125812.561028-1-david@redhat.com> References: <20241202125812.561028-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6025F100002 X-Rspam-User: X-Stat-Signature: 8n4k8gei894dq9nhphn4enpbdmm99j11 X-HE-Tag: 1733144320-564179 X-HE-Meta: U2FsdGVkX180YYMxnrJBsrikNYNr+DcPQFHdIKdcGKpkeob89dtFAYczPfvn01zq6L9+nNEwFnJbLvOUqPj7zOHxB4nxsI4ahf4UhRNxs9c+6vBSZRVVT4zrHK33qUdjuNPAg0+wXU7tUnXUjfnaRy7hTvMTcEuzUOrH16S7gcCVHAUNUOzYMVeAciVg4YtekLz0f4J61J0QvrVb6kDu2vNxssA3N6GxzZ7btt74vsXDE3pbGaY/hHRFmIJPBisbkGPs/tRkpmrtRiBjo6aUVwtaw0S0nTYnbZFvQEFqhChcRO2bKkAjp7DIwUqd+l2vDaDXRrIlZa2zITLIdNey9mH+TZGP0HIDGWgxU2o/xA3m35UtiSbfodbuFhcSwlC29rL1bBR0gp+fscK4x6CivhR7uXbvNpJwBYnKCjL6UXgzDeD9oIbs8MvQfnzGXDdr7y6D7rWW7KqHFWROnVlbO5A4asI7DHw2ywdV/g/34IEMSwK2xKWgq9R6DwQNxVk8WVByuwrxlLwiX/zpFI+1gb4iiIiV1P9fQSZzdD+CUckmYZLPSYQirG/nQcojZtOXBHTgaSVBP2SRXoX1lbeqjViLByhbc4moYxiN0oqe3spSEqTDxvWu6uo1tknJ/YNrHnTaEHYXkK7tRoJOhKQmR7kyYZF2ioa07B1uDJxf3wHICyo6kOe0/j0T/mgsKVtYddkHucENnK97ec9x5wQvy77eVlVbSg7EzE6cM2Xdb486BKHvL4IVvEG3rgyiPonwHwxxzoiGAB3dXjqxf78YQ4YKtNT8Z9wSkgda5SyPLZw9kOvRZZ6tncDMA7a9dyzZjPFyOtxn+syURws/Do087CSx3yKaffadbrrMeTyo4CAYrnuxUUFTti3afKZbiRJXQogQzBcH139uP0A8SlJxyyufqfrId7mS1olM6qwdvGawT15YDtPQE7dmRe6yyY3qkqniRqn0cseU1GacL6Y uFgePOUi e6p21qvWenV5cGjVifalbU/4Lem2hyoRnVmH8LohTfFVdXIOTuuIwCIt3fLAVf608i1c/HSo02QBbtdBN8FMeeiVi1esWjpAUpek650Yp7WXwGbonKhnQgGy/wNMa2yOkfJhM0YSpyideB0fVMDMZW9MPCiiLjp54eVaBtgy1W7vogXceJVxpNJXmAV8RpkvC3y0iBHL28UivOnaIenlpVj01xVh2l/o9eTMzM1V/mfft41cWeIvlDjtRjE5fJVQ/JMimuFsCuSivRL4t6RpXRjocH8JLiZAF/qfDmkmHFB9f7eEtatW8G1zhihD5uT4V8zWPZnKNZX+xC7tj+k9uCHEn8sLV9jn+nxoY/UDBzbLDvmAn/s5W3yfIOqOOls1+jlfdcvpMwcq9Ng4YjpMXNqglGw== 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 --- 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,