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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A659C47082 for ; Mon, 7 Jun 2021 08:30:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C8276108E for ; Mon, 7 Jun 2021 08:30:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C8276108E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 895CD6B006C; Mon, 7 Jun 2021 04:30:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 845D26B006E; Mon, 7 Jun 2021 04:30:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E6246B0070; Mon, 7 Jun 2021 04:30:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 37E576B006C for ; Mon, 7 Jun 2021 04:30:47 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BEC858249980 for ; Mon, 7 Jun 2021 08:30:46 +0000 (UTC) X-FDA: 78226256892.27.3372011 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf07.hostedemail.com (Postfix) with ESMTP id 5D87EA00025B for ; Mon, 7 Jun 2021 08:30:43 +0000 (UTC) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Fz61l5hvdz6wPm; Mon, 7 Jun 2021 16:27:39 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 7 Jun 2021 16:30:41 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 7 Jun 2021 16:30:40 +0800 Subject: Re: [PATCH v2 00/15] init_mm: cleanup ARCH's text/data/brk setup code To: Christophe Leroy , Mike Rapoport CC: , , , , , , , , "Andrew Morton" , , , , References: <20210604070633.32363-1-wangkefeng.wang@huawei.com> <481056ab-686e-9f42-3b8a-b31941f58af6@huawei.com> <006eb573-5a20-1ac7-6234-338d11346a08@csgroup.eu> From: Kefeng Wang Message-ID: Date: Mon, 7 Jun 2021 16:30:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <006eb573-5a20-1ac7-6234-338d11346a08@csgroup.eu> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Stat-Signature: kyzxtjjikc71nb6a7hi7fyj4ghtqfj41 X-Rspamd-Queue-Id: 5D87EA00025B X-Rspamd-Server: rspam02 X-HE-Tag: 1623054643-319088 Content-Transfer-Encoding: quoted-printable 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 2021/6/7 13:48, Christophe Leroy wrote: > Hi Kefeng, > > Le 07/06/2021 =C3=A0 02:55, Kefeng Wang a =C3=A9crit=C2=A0: >> >> On 2021/6/7 5:29, Mike Rapoport wrote: >>> Hello Kefeng, >>> >>> On Fri, Jun 04, 2021 at 03:06:18PM +0800, Kefeng Wang wrote: >>>> Add setup_initial_init_mm() helper, then use it >>>> to cleanup the text, data and brk setup code. >>>> >>>> v2: >>>> - change argument from "char *" to "void *" setup_initial_init_mm() >>>> =C2=A0=C2=A0 suggested by Geert Uytterhoeven >>>> - use NULL instead of (void *)0 on h8300 and m68k >>>> - collect ACKs >>>> >>>> Cc: linux-snps-arc@lists.infradead.org >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Cc: linux-csky@vger.kernel.org >>>> Cc: uclinux-h8-devel@lists.sourceforge.jp >>>> Cc: linux-m68k@lists.linux-m68k.org >>>> Cc: openrisc@lists.librecores.org >>>> Cc: linuxppc-dev@lists.ozlabs.org >>>> Cc: linux-riscv@lists.infradead.org >>>> Cc: linux-sh@vger.kernel.org >>>> Cc: linux-s390@vger.kernel.org >>>> Kefeng Wang (15): >>>> =C2=A0=C2=A0 mm: add setup_initial_init_mm() helper >>>> =C2=A0=C2=A0 arc: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 arm: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 arm64: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 csky: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 h8300: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 m68k: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 nds32: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 nios2: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 openrisc: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 powerpc: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 riscv: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 s390: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 sh: convert to setup_initial_init_mm() >>>> =C2=A0=C2=A0 x86: convert to setup_initial_init_mm() >>> I might be missing something, but AFAIU the init_mm.start_code and=20 >>> other >>> fields are not used really early so the new setup_initial_init_mm() >>> function can be called in the generic code outside setup_arch(), e.g = in >>> mm_init(). >> >> Hi Mike=EF=BC=8C each architecture has their own value, not the same, = eg m68K=20 >> and >> >> h8300, also the name of the text/code/brk is different in some arch,=20 >> so I keep >> >> unchanged. > > What you could do is to define a __weak function that architectures=20 > can override and call that function from mm_init() as suggested by Mike= , > > Something like: > > void __weak setup_initial_init_mm(void) > { > =C2=A0=C2=A0=C2=A0=C2=A0init_mm.start_code =3D (unsigned long)_stext; > =C2=A0=C2=A0=C2=A0=C2=A0init_mm.end_code =3D (unsigned long)_etext; > =C2=A0=C2=A0=C2=A0=C2=A0init_mm.end_data =3D (unsigned long)_edata; > =C2=A0=C2=A0=C2=A0=C2=A0init_mm.brk =3D (unsigned long)_end; > } > > Then only the few architecture that are different would override it. > > I see a few archictectures are usigne PAGE_OFFSET to set .start_code,=20 > but it is likely that this is equivalent to _stext. Yes,=C2=A0 the __weak function is option, but the change is only covered = 14=20 archs, there are 7 other archs=EF=BC=88alpha=C2=A0 hexagon=C2=A0 ia64 microblaze=C2=A0 mips sparc=C2=A0 um xtensa=EF=BC=89without related setup= code. Also like=20 x86, it has own brk , maybe there are some other different in some arch, so I think let's keep unchanged for now,=C2= =A0=20 thanks. > > Christophe > . >