From patchwork Tue Dec 3 08:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13895602 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 13FCEE7716D for ; Thu, 5 Dec 2024 15:35:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B9AF6B0124; Thu, 5 Dec 2024 10:19:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAFC66B0135; 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 7C6926B0100; Thu, 5 Dec 2024 10:19:15 -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 D0BB96B007B for ; Tue, 3 Dec 2024 03:38:42 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 96762C07B5 for ; Tue, 3 Dec 2024 08:38:42 +0000 (UTC) X-FDA: 82852995960.17.8B526CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 165D140009 for ; Tue, 3 Dec 2024 08:38:30 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XCQjTvqk; spf=pass (imf17.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=1733215107; 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=F2Q1rlmay1UOIOICp6htnT+VXFJImtwZ9LwGEmJwC8BMFeRzUc+LDQIU5vb91/4YqbJ6kU gJ21u/ovqHHqL1R8EhO67ZGbxvQhBpA33U/dz5Yo77Zw9U0ILzm20b5yR+Q9MnQI2GvlNb 3+aqGPPLu7Jv4UL6Lltcm2FOtCpNElY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733215107; a=rsa-sha256; cv=none; b=HVTAVU6MddDsXoYkOT3TQOUQeYWunSpob7ArKIgmbxVeUQhb+U5NvMWgR/4JdqmevX4R3H +ebld55pgxsWa2VDEfKY+aehVf29V3niVf9dqrvKqZHExi/EZWb5DLjdizdDN8BbAI1rKZ 1mQbjIpW+Q1ORrDmvwKzmM5gOPSaHDw= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XCQjTvqk; spf=pass (imf17.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733215120; 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=XCQjTvqkD9a3X3Ru7yAQnczRkY6ogGvmnWa+O/WnbWQtEtBefziQuOIGrwvCSi7YykxY/e gN9S+iSwPY/1sN6vntpHyktdeeLaLZEZhnpgsFNY9Jjv41sdnmL3WZMPnoonzCaCM7Sqns hHrAOqyxeV5PKjK5c5q/tIcxgOrwRd4= Received: from mx-prod-mc-01.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-519-KIBg8WfaPjq4ggDyQfJJqQ-1; Tue, 03 Dec 2024 03:38:35 -0500 X-MC-Unique: KIBg8WfaPjq4ggDyQfJJqQ-1 X-Mimecast-MFC-AGG-ID: KIBg8WfaPjq4ggDyQfJJqQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B9DE1956058; Tue, 3 Dec 2024 08:38:34 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.88.109]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D4C0930001A0; Tue, 3 Dec 2024 08:38:29 +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 v2 6/6] powernv/memtrace: use __GFP_ZERO with alloc_contig_pages() Date: Tue, 3 Dec 2024 09:37:56 +0100 Message-ID: <20241203083756.112975-7-david@redhat.com> In-Reply-To: <20241203083756.112975-1-david@redhat.com> References: <20241203083756.112975-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 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5RzKIt58yOU9kzyVg+Q6FiiGC7 Sa/8efER duY36c/ZL/FqEj+45+hlCSmojbo+axd2tS/WBp7+MR9PJVCzZ6rVFlbzKIP+k96zeDrC9qIoEkrzIIVfT9BO9JqKINpMrQtcEeP/Zt0Gl0/I2hBL9se4QXzQPdA/pEegXHJfbjKMkvOcTWM6bliOxb3Lfcdffh1PIYcvTP9AxBO2REUUudZROI4cR7uj4AJS77dTUAc3GNfWs7aIvT8+9rhYpwdfp0JeTezDhT5ruWbcJTp8lHDp+ABTy7rrhGBH2uUjT/n52jqvSU3UGJhNsdXyvrTic1e8j0h426WjJ90104du6+hpo9+zBBk+XcBYGhQtXyxR7B0owX30WG1u/d5DOq33dTxg21uPygZOe+qXiie0AQOd+Adl0il9pFAu44WVfi5apd7/C40kukkNRAStmfA== 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,