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 DFA82C433F5 for ; Mon, 24 Jan 2022 18:48:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B9C16B00A9; Mon, 24 Jan 2022 13:48:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4688D6B00AE; Mon, 24 Jan 2022 13:48:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3305A6B00B0; Mon, 24 Jan 2022 13:48:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id 1F29B6B00A9 for ; Mon, 24 Jan 2022 13:48:08 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D2A801842B106 for ; Mon, 24 Jan 2022 18:48:07 +0000 (UTC) X-FDA: 79066065414.19.6A03BFC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id EEC9C140008 for ; Mon, 24 Jan 2022 18:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8ZxSf7vRGmtmjPRVRuc/UAtt0g7lispoIvSffcp1Qyk=; b=g6yrZ37hc7PRrLe90OF1G9oYOT 5dOCrI/gA/wzT/K15vRfpSwCqD1iRC10W4iuptigIekHQWhPfOktVNreow1Dq20yJEmQkIWgC6JhV YhpVPX1SU1+k8QPzh05WdnlpyD6H0/n9EjArlOvcwTnPUVL9hVBPivaiIgJnZlBj9n6JE1B+basIC tSyVzTf2zn6XwgIHtI5u8NB7CRqKR3FX7dBseDx74wr/qmQWxJYNea5eF0q00IDnk/sOwQGc1GvZ7 lyy+CKiMGen5ZSGss9V/Bk8jWm55T5xXDO4TjUEnQ8/m3awaoICONB9FTpOUMI5oNpgqB1zd9YSNn ukSyu7hg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC47v-001452-K9; Mon, 24 Jan 2022 18:31:39 +0000 Date: Mon, 24 Jan 2022 18:31:39 +0000 From: Matthew Wilcox To: Ard Biesheuvel Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: make 'highmem' symbol ro_after_init Message-ID: References: <20220124170555.1054480-1-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124170555.1054480-1-ardb@kernel.org> X-Stat-Signature: nq5fmotyk4ejtdjmx4hzj1jmuun6t73a Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=g6yrZ37h; dmarc=none; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EEC9C140008 X-HE-Tag: 1643050086-782713 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: On Mon, Jan 24, 2022 at 06:05:55PM +0100, Ard Biesheuvel wrote: > The 'highmem' variable is only set at boot, so we can make it > ro_after_init and prevent it from being corrupted inadvertently, or from > ending up in a contended cacheline. I'm not against this patch, but it'd be nice to go further and remove it entirely for !CONFIG_HIGHMEM builds? Adding something like static inline bool is_high_pfn(unsigned long pfn) { #ifdef CONFIG_HIGHMEM return pfn <= max_low_pfn; #else return false; #endif } static inline bool is_high_phys(phys_addr_t pa) { return is_high_pfn(pa / PAGE_SIZE); } static inline bool is_high_addr(void *addr) { return is_high_phys(virt_to_phys(addr)); } should be all the primitives you need, from a quick grep. > Signed-off-by: Ard Biesheuvel > --- > mm/memory.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/memory.c b/mm/memory.c > index c125c4969913..50e82cb94ccc 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -106,7 +106,7 @@ EXPORT_SYMBOL(mem_map); > * highstart_pfn must be the same; there must be no gap between ZONE_NORMAL > * and ZONE_HIGHMEM. > */ > -void *high_memory; > +void *high_memory __ro_after_init; > EXPORT_SYMBOL(high_memory); > > /* > -- > 2.30.2 > >