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 67EC3C433F5 for ; Fri, 1 Oct 2021 07:14:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0088F6128C for ; Fri, 1 Oct 2021 07:14:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0088F6128C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 69FB89400F7; Fri, 1 Oct 2021 03:14:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 650689400E4; Fri, 1 Oct 2021 03:14:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 517749400F7; Fri, 1 Oct 2021 03:14:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 42C479400E4 for ; Fri, 1 Oct 2021 03:14:46 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 05D298249980 for ; Fri, 1 Oct 2021 07:14:46 +0000 (UTC) X-FDA: 78647006172.34.C272963 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf01.hostedemail.com (Postfix) with ESMTP id ACBCC506BE01 for ; Fri, 1 Oct 2021 07:14:45 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id 75so8626798pga.3 for ; Fri, 01 Oct 2021 00:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=hQ5Dp9x0o7vj9OmS5x46emFCr7Zl/nJolk9+Z2BpJ/M=; b=fe9H/w2X2vuAp8bhFAjKcirq956EvG0Xsc4F/qPYLCr7shEcx/7zVRCvPxYTKIseYq cM0bGEaE6AOBmeVWMByscucDo3qj28Mo1bYpVvfDkpGyt16RzahFoQ3vLK88+7PljDI8 g4xwbvUg0m6Q0tlQhV1A905dnxfllF0FbKG5g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=hQ5Dp9x0o7vj9OmS5x46emFCr7Zl/nJolk9+Z2BpJ/M=; b=AcKGS3Nib4vsFbPhkSAEaaKj2ce9dCfphFum4yzqRLWqE0E7PGRoS10+hbiG0OJSNv bZvMubiVkyZVkuHD+rs0d6vZeDKIos17se6dIYK2Tv5BJM41UPQ3zfuTg/N6PZ50jwZZ 5uFZe3SQghqCrAyZnKMgjinqKa6R6ssidSFarOkkW7wphiTbozsRWrsAMzPUCZqlcevV 0e4X2SqoyrJ9D2PZYNr8iHkDBnS2ETbz7p5n3SDX84+aHVS4R9j2xIRtTFeJHFyh8jZu u83rmwcow4LcC2/TkRwgBtoJ+fDPH9H1mbxJqzWQ/nMmskpQpKxFmXt3RSzi7SCqhj3X fq1g== X-Gm-Message-State: AOAM533q51CKZBkZpd5A5Q+1aXflYIthwpc/PcTVAN0Bj4eIwR6XOgss A2dibZ2Y3wBu5zBMdGuhpCfZYw== X-Google-Smtp-Source: ABdhPJybs5wSHjwxNYuL3Oj52Xlb/bebURrnTQ6GT1WSxewTOdLpU3woiWbsUUuDzK3q3lC/kp1vUA== X-Received: by 2002:aa7:9a0e:0:b0:44a:3ae2:825c with SMTP id w14-20020aa79a0e000000b0044a3ae2825cmr8564635pfj.28.1633072484450; Fri, 01 Oct 2021 00:14:44 -0700 (PDT) Received: from localhost ([2001:4479:e200:df00:c98c:9868:6328:c144]) by smtp.gmail.com with ESMTPSA id k12sm1219967pjf.32.2021.10.01.00.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 00:14:43 -0700 (PDT) From: Daniel Axtens To: Christophe Leroy , Andrew Morton , arnd@arndb.de Cc: 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 In-Reply-To: <1d40783e676e07858be97d881f449ee7ea8adfb1.1633001016.git.christophe.leroy@csgroup.eu> References: <9ecfdee7dd4d741d172cb93ff1d87f1c58127c9a.1633001016.git.christophe.leroy@csgroup.eu> <1d40783e676e07858be97d881f449ee7ea8adfb1.1633001016.git.christophe.leroy@csgroup.eu> Date: Fri, 01 Oct 2021 17:14:41 +1000 Message-ID: <87ilyhmd26.fsf@linkitivity.dja.id.au> MIME-Version: 1.0 Content-Type: text/plain X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ACBCC506BE01 X-Stat-Signature: 1zyg6t9cqgxdytx7n1xgpnp1coso114u Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=axtens.net header.s=google header.b="fe9H/w2X"; spf=pass (imf01.hostedemail.com: domain of dja@axtens.net designates 209.85.215.169 as permitted sender) smtp.mailfrom=dja@axtens.net; dmarc=none X-HE-Tag: 1633072485-385085 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: > #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. Kind regards, Daniel