Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3254155pxb; Fri, 5 Nov 2021 12:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkTdR23nrqsiIMGt8oY1Ibs5zIM+5BdYl7CkE/2Oobe3nWnZ4Q9VL9kWnMM2TNC9RPHMqt X-Received: by 2002:a92:c20f:: with SMTP id j15mr41175354ilo.185.1636140174217; Fri, 05 Nov 2021 12:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636140174; cv=none; d=google.com; s=arc-20160816; b=ig2h+3Xj7UEXhtJsF3LgX0pagdAUVtPGvMcxoKNQvBpHAtZBE8Sf+F9MItLE+7b6lY M3CCYFL6LFBZwgER3J6rDqBWPvgyI71QDnTEKNptOaneCdAfQ06LC/eWf0WHo7oXGqGv u9ErHHxgDJaQhD8TKRaq91mdDQCZ4WbsMqEOBHd0o1jiRuGCSr04qY5DehKFQPwtbChg YfcjFri/Vl+aXhCY9ik92lzMeYc78nMF5adKM8E9veP/Az+6dzrtH6SDqqMwqgRRJJ0K Y+NYyRYSPmNNSpMY6Z1crcrA2pwHXMi7XTzVWqK3SscuxZ/v7dJ0HxykIPD8BFFinvhG Luew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=0Z0mOKBqCOrsP37L3qd/ffcxpWNly+F4ZDYOjWocr0g=; b=nBm8zFVprqC64eOPAGA9ZSm+7JOti4yNgLY00H7yXkuoLoTQSCbUP5GTl7QFB/UgVg oJHOeLmGE4MpuCwvbC69C1K3UyXyhlXa8CgbMbqaHLNR0iPwpivOLRkcXyzdOENgLKmd x263CMfeGJKWllNbr8zrLf4Q71o8kxi/QFaNjfWfH18DFdRKWj6c4oaq+/F61K0bUdJa XLiw1k2P51T1pKHut81qWwqjpEMv6fVY5Y6SAXhEBTHT7q2jWLnD9Cw6Rvw6IbVxFadq R8ISJuUNjP+HRVkgZIZV8zOXXzvmuihKDrhnpqKpwcNQpxLC2utFu1c6diPaGx9IgyIr nSSw== ARC-Authentication-Results: i=1; mx.google.com; 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 f5si13556228jat.97.2021.11.05.12.22.40; Fri, 05 Nov 2021 12:22:54 -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; 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 S233191AbhKER0h (ORCPT + 99 others); Fri, 5 Nov 2021 13:26:37 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:47333 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbhKER0g (ORCPT ); Fri, 5 Nov 2021 13:26:36 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Hm6mp3JY9z9sSb; Fri, 5 Nov 2021 18:23:54 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hbpmo9jN3v01; Fri, 5 Nov 2021 18:23:54 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Hm6mp2FcNz9sSV; Fri, 5 Nov 2021 18:23:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 338768B786; Fri, 5 Nov 2021 18:23:54 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id c50ensR6JB-3; Fri, 5 Nov 2021 18:23:54 +0100 (CET) Received: from [192.168.233.150] (unknown [192.168.233.150]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9C5F58B763; Fri, 5 Nov 2021 18:23:53 +0100 (CET) Message-ID: <459684e7-73bf-fbfb-c666-cc16299d858b@csgroup.eu> Date: Fri, 5 Nov 2021 18:23:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v3 2/4] mm: Make generic arch_is_kernel_initmem_freed() do what it says Content-Language: fr-FR To: Andrew Morton , Daniel Axtens Cc: 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 References: <9ecfdee7dd4d741d172cb93ff1d87f1c58127c9a.1633001016.git.christophe.leroy@csgroup.eu> <1d40783e676e07858be97d881f449ee7ea8adfb1.1633001016.git.christophe.leroy@csgroup.eu> <87ilyhmd26.fsf@linkitivity.dja.id.au> <20211104144442.7130ae4a104fca70623a2d1a@linux-foundation.org> From: Christophe Leroy In-Reply-To: <20211104144442.7130ae4a104fca70623a2d1a@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 04/11/2021 à 22:44, Andrew Morton a écrit : > 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? > Sorry for answering late. I've been thorugh free_initmem() in each architecture. The only sections involved in the freeing actions are [__init_begin, __init_end], so I think checking against __init_being, __init_end is enough. If some architecture has init text outside of this section, then it is not freed hence not necessary to check. Christophe