From mboxrd@z Thu Jan 1 00:00:00 1970 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 67C7BC4167B for ; Thu, 30 Nov 2023 12:00:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F362D8D004B; Thu, 30 Nov 2023 07:00:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EE6428D0001; Thu, 30 Nov 2023 07:00:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD5798D004B; Thu, 30 Nov 2023 07:00:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D14398D0001 for ; Thu, 30 Nov 2023 07:00:21 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 949471C0138 for ; Thu, 30 Nov 2023 12:00:21 +0000 (UTC) X-FDA: 81514477842.03.C142152 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 816D740036 for ; Thu, 30 Nov 2023 12:00:19 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701345619; 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: in-reply-to:in-reply-to:references:references; bh=viRWPbpS6D5pd4CAQZCnMnPSdXhkOwhVzuSXaZk6Vns=; b=moRcoTnBjQQll5kxxZEkvRt3+0P/SuI6FPCl1XPHK+Jw4VOfe4BJdkDL1PMggVPN+oFbQc 1VmbBaow0ao1Ua+6QIgsBc/C9ZPFDAVpoI4m+663K1jCiq1QmqITCHzvO+W2tfVkdw3VlF Piz4ccEIrPXB0D+aqnxFSMmps9xBsY8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701345619; a=rsa-sha256; cv=none; b=1r/TgJIQGt+yG+BLJG/8w0CfvtlKQaBDRwdAp4RMk9Ay2fAP9EpZlvyTA9U9Z3pC0FdTeM JF+2tB5wLE06PDs/gv00h8F8Jai5uL0F2wQ2np4PMBSaBKMHi+zI+6swYsodiVwlZjtf/Y DAxjl7y/5U2IqVO1CVjkS3p8OhCxw0Q= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of alexandru.elisei@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=alexandru.elisei@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 31898143D; Thu, 30 Nov 2023 04:01:05 -0800 (PST) Received: from raptor (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B0BD73F5A1; Thu, 30 Nov 2023 04:00:13 -0800 (PST) Date: Thu, 30 Nov 2023 12:00:11 +0000 From: Alexandru Elisei To: Hyesoo Yu Cc: catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, arnd@arndb.de, akpm@linux-foundation.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mhiramat@kernel.org, rppt@kernel.org, hughd@google.com, pcc@google.com, steven.price@arm.com, anshuman.khandual@arm.com, vincenzo.frascino@arm.com, david@redhat.com, eugenis@google.com, kcc@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH RFC v2 15/27] arm64: mte: Check that tag storage blocks are in the same zone Message-ID: References: <20231119165721.9849-1-alexandru.elisei@arm.com> <20231119165721.9849-16-alexandru.elisei@arm.com> <20231129085744.GB2988384@tiffany> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231129085744.GB2988384@tiffany> X-Stat-Signature: 6orboy48xotgoau4df73xuaemqj4zw7x X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 816D740036 X-Rspam-User: X-HE-Tag: 1701345619-2132 X-HE-Meta: U2FsdGVkX19Foy1kZHfkAuwP088RkIxbpDKnc8gBeIOZ6d7BBVAldgv9/q5P76+2x7ZPyHVz1mTVmA9mb5Yolgve9cxb0u/rneWiYMRkinwjnDZMmO/Ll1Vol4fIU/9KNvUmwZ2x8yEHu3NLWxiSHFM3c5iPKWB76spmLjg80I2VOdo/WE6PrutJUEF+hdAAn0ixX8gUALbNDOiWQhoaApAd8LC7+anDpg7zx5s7EYM3IrWLh6/bL0gh8+dD6LfU2ntuM0D1z5r8Vv2mZnIJ7+swTR8AajSRUnlHBchA+qAAN5+3XDALKxzlyxcgrIFtOZ+iGvXEqqdUBlTsJUN3k5ZqdnbAdlIOL5I17XVDeTs8wC5+nNrngIDFM+rLWfQIUO8RQ8Dun1eeeONsLnEyfzwqwWFNDkxjxdkb24MEHroo3mh1xJQbG2UljsuPPeEGapnK9jYtJ5FphLw/2X2ZZ1/BtcyvF+Cz77jvQlpgB99cgydpjTKYo0f5/u77ertcuBq2CoZ/FUuQgB8wKNgHZ9shRhYQ8U0TbPsXVg3PTxhESze0IEEOFqREH3mzM11C6hcsaYtAQifN3+j6C/Ef86nDbKytf84TkT6tzwnyMXPO8JFJekPx8eG9xC4xtm0yMHruQWR+ps3tivGAvv3jDqHE9sP8ruAtwZQMpALkdwNeS8zzz95HLy8x6Jl44k6VTu5+067hkzL0YkYM7/5sfG+nyr0QeZmqgcdzPuXiY7HO2OAimQOqMKZC87g1O9iL5ZY2lkWEYRPbwCBYfHoHOwWzIw848k5GyC3QeEcaPnewM4XPTJKCdbxyQnpxuxD8CZalU7XZgNHNymxAU0gFxmc75Zlt0ejYz6mAeDQGtt5B5FAlfDDLIoUhy8R28PUgz0icMPNu4lK/6uQq8YGCSlSM9c5cYWDGrY2oqw19RtaCPI6OoTf8Lf7W8YZc9QonbJu//aTmXcN94u/VjlR VlQt3um+ VVBAXCQSbtAeq+oj0dVTwu2gE1mtPTWm+PQu8/R6ENy8rM2HDEq4DU8hfkYO3LbJ9Jq5MWihzyVZ/AtWBSf/e6FcgxOInBx9rfLRDCR/EerJ/Q5Qz5/TcQiV+am3IcYFG4vB2Mr2EuA+xIzdERI9qGoAlgYfcH9X8EtU2c764PpugRFopVdKa7lNt/wuWGnJp0+KFQQIFb3q6p6Y= 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: Hi, On Wed, Nov 29, 2023 at 05:57:44PM +0900, Hyesoo Yu wrote: > On Sun, Nov 19, 2023 at 04:57:09PM +0000, Alexandru Elisei wrote: > > alloc_contig_range() requires that the requested pages are in the same > > zone. Check that this is indeed the case before initializing the tag > > storage blocks. > > > > Signed-off-by: Alexandru Elisei > > --- > > arch/arm64/kernel/mte_tag_storage.c | 33 +++++++++++++++++++++++++++++ > > 1 file changed, 33 insertions(+) > > > > diff --git a/arch/arm64/kernel/mte_tag_storage.c b/arch/arm64/kernel/mte_tag_storage.c > > index 8b9bedf7575d..fd63430d4dc0 100644 > > --- a/arch/arm64/kernel/mte_tag_storage.c > > +++ b/arch/arm64/kernel/mte_tag_storage.c > > @@ -265,6 +265,35 @@ void __init mte_tag_storage_init(void) > > } > > } > > > > +/* alloc_contig_range() requires all pages to be in the same zone. */ > > +static int __init mte_tag_storage_check_zone(void) > > +{ > > + struct range *tag_range; > > + struct zone *zone; > > + unsigned long pfn; > > + u32 block_size; > > + int i, j; > > + > > + for (i = 0; i < num_tag_regions; i++) { > > + block_size = tag_regions[i].block_size; > > + if (block_size == 1) > > + continue; > > + > > + tag_range = &tag_regions[i].tag_range; > > + for (pfn = tag_range->start; pfn <= tag_range->end; pfn += block_size) { > > + zone = page_zone(pfn_to_page(pfn)); > > Hello. > > Since the blocks within the tag_range must all be in the same zone, can we move the "page_zone" > out of the loop ? Hmm.. why do you say that the pages in a tag_range must be in the same zone? I am not very familiar with how the memory management code puts pages into zones, but I would imagine that pages in a tag range straddling the 4GB limit (so, let's say, from 3GB to 5GB) will end up in both ZONE_DMA and ZONE_NORMAL. Thanks, Alex > > Thanks, > Regards. > > > + for (j = 1; j < block_size; j++) { > > + if (page_zone(pfn_to_page(pfn + j)) != zone) { > > + pr_err("Tag storage block pages in different zones"); > > + return -EINVAL; > > + } > > + } > > + } > > + } > > + > > + return 0; > > +} > > + > > static int __init mte_tag_storage_activate_regions(void) > > { > > phys_addr_t dram_start, dram_end; > > @@ -321,6 +350,10 @@ static int __init mte_tag_storage_activate_regions(void) > > goto out_disabled; > > } > > > > + ret = mte_tag_storage_check_zone(); > > + if (ret) > > + goto out_disabled; > > + > > for (i = 0; i < num_tag_regions; i++) { > > tag_range = &tag_regions[i].tag_range; > > for (pfn = tag_range->start; pfn <= tag_range->end; pfn += pageblock_nr_pages) > > -- > > 2.42.1 > > > >