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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D70DC433FE for ; Thu, 4 Nov 2021 21:44:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F145861186 for ; Thu, 4 Nov 2021 21:44:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F145861186 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 77FFB6B0071; Thu, 4 Nov 2021 17:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72F546B0072; Thu, 4 Nov 2021 17:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D28940007; Thu, 4 Nov 2021 17:44:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 539A06B0071 for ; Thu, 4 Nov 2021 17:44:48 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2058071441 for ; Thu, 4 Nov 2021 21:44:48 +0000 (UTC) X-FDA: 78772577856.17.2E47EDD Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP id ACE19801A89F for ; Thu, 4 Nov 2021 21:44:47 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E73D6120F; Thu, 4 Nov 2021 21:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1636062286; bh=j99yLbawhP8nS65VSNwoVEG61+ELDW3rr3unGR3UBCg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xYAjZ8zs9+oJOMxv1KXwonQ+aKbWfMmO7HfIsxDFjLoqTAj3LyGtnvu5GAHO6i8F6 tTLnvU37UqoYDFqxPz0RM33U6DPFdsgJFgmUGeovTBXOeZZ1uqUtmKClxR9BsD+2R8 BoNWN1J1HRZWj563lpDBMFRDadPRbxs05FsdJ6oM= Date: Thu, 4 Nov 2021 14:44:42 -0700 From: Andrew Morton To: Daniel Axtens Cc: Christophe Leroy , arnd@arndb.de, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Kefeng Wang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Gerald Schaefer , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v3 2/4] mm: Make generic arch_is_kernel_initmem_freed() do what it says Message-Id: <20211104144442.7130ae4a104fca70623a2d1a@linux-foundation.org> In-Reply-To: <87ilyhmd26.fsf@linkitivity.dja.id.au> References: <9ecfdee7dd4d741d172cb93ff1d87f1c58127c9a.1633001016.git.christophe.leroy@csgroup.eu> <1d40783e676e07858be97d881f449ee7ea8adfb1.1633001016.git.christophe.leroy@csgroup.eu> <87ilyhmd26.fsf@linkitivity.dja.id.au> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: ACE19801A89F X-Stat-Signature: ewmxm54ynaqyhmd6smuqut9n98srxgob Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=xYAjZ8zs; spf=pass (imf06.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1636062287-247781 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 Fri, 01 Oct 2021 17:14:41 +1000 Daniel Axtens wrote: > > #ifdef __KERNEL__ > > +/* > > + * Check if an address is part of freed initmem. After initmem is freed, > > + * memory can be allocated from it, and such allocations would then have > > + * addresses within the range [_stext, _end]. > > + */ > > +#ifndef arch_is_kernel_initmem_freed > > +static int arch_is_kernel_initmem_freed(unsigned long addr) > > +{ > > + if (system_state < SYSTEM_FREEING_INITMEM) > > + return 0; > > + > > + return init_section_contains((void *)addr, 1); > > Is init_section_contains sufficient here? > > include/asm-generic/sections.h says: > * [__init_begin, __init_end]: contains .init.* sections, but .init.text.* > * may be out of this range on some architectures. > * [_sinittext, _einittext]: contains .init.text.* sections > > init_section_contains only checks __init_*: > static inline bool init_section_contains(void *virt, size_t size) > { > return memory_contains(__init_begin, __init_end, virt, size); > } > > Do we need to check against _sinittext and _einittext? > > Your proposed generic code will work for powerpc and s390 because those > archs only test against __init_* anyway. I don't know if any platform > actually does place .init.text outside of __init_begin=>__init_end, but > the comment seems to suggest that they could. > Christophe?