Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2149043pxb; Thu, 4 Nov 2021 14:57:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3WQyqTtX1OO80ZhIaBW86tBD5C+IXvXilRpfpCqM7oli6qsCjw0sZE3EFQMiLgk4klTZN X-Received: by 2002:a05:6602:2812:: with SMTP id d18mr38195977ioe.53.1636063029162; Thu, 04 Nov 2021 14:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636063029; cv=none; d=google.com; s=arc-20160816; b=Zxc11kZFleR+MgPjD7vSZKieXRx2hEr3jqH3pUGwb0cew1GgaOYDNQya0N+0vnbqot QxbvrZ01331s6iGkJc5pFXaICtwCldtq3ke6AS0sxr4ybtAZEZvrpNhxzgwjIeHDVp62 I2U2RPrnFJ5asaUykeWZhLqTKrU50yPa366mVpyNOOIdooGZvnw1EizdfgVf0ftrF07/ c2pVA7u8siX1wafzFy7U0+LarRUEAgHNJ6cVqefPjf04JEL7jRw/A+vDyygE9tULWTXg 75OhscozhZFM5ZHfCk4gGAmalnauoJuQl2kUUTNjXJRXV7jwR9mWxe1Uy7zTV2NVYIp0 enqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=QaFX3Kct3Ys3Hkqu101/yXwkSB13EcocG9DdWDFEXUo=; b=dEHoHiOC41k7F8iqc/ttGp+tfKNw2M/+BE6nUpAjL/hY2Co3y4O4cR+KCoeVPn8swV pO4+7ZQg3otICrJBJNRFhrBVY/1Nxj5QrzihlVNmJIysmKvHIH+d6yZ9qUrdjrgUbFuh 23JNz5iwpuD7vQLmZhIIOEluHy7Tc0htNyVDtXTBWzwOTfN3gN61hnw/XuOKFkBGIU9U VqU7naP7fW2V+IDd2yo5nEntLqyUOF1L/7ymfUuLfFu6s4ah6qG99FOZwx7qIFudRKjP dhOxJTS/p+0MtvToiLYzH//NTRhjtWKx8zthV2Ci9VTV7B2EfUthXnqF/Z8cOLk9B3p2 hhDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=xYAjZ8zs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n44si7458669jaf.76.2021.11.04.14.56.55; Thu, 04 Nov 2021 14:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=xYAjZ8zs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbhKDVr0 (ORCPT + 99 others); Thu, 4 Nov 2021 17:47:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:53016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbhKDVrZ (ORCPT ); Thu, 4 Nov 2021 17:47:25 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?