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=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 13214C04FE3 for ; Sun, 1 Aug 2021 15:25:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D950160243 for ; Sun, 1 Aug 2021 15:25:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D950160243 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=HGbI1J69/gkRMNyMov+dgRdJIIS+w8yFcOJG/lN+LL4=; b=OGdbh27mjAReh2 NkJee3ejoeTdq3MVtwSrM+l6UNtfXc3zy5qOw3gL2EvHGP1vWO67CKnNj3bXs15FP8fEYZr3YNXCc tKJANhK8b5FWS25IuU3QteVkNLtVGcxaT3G34jqvxTdkdUW0W+flAwoTVFU0yXT5uEqIVEPayqoJl jGR9NdNx2xhAagccMvJ0ngpSQ+U2hrEUCiJ19z4g7lMdubygJeP9Ei/4/areLGgqXXGOcM2crPlIU QQ95OSTIQgHoB7fIneZQVmyQaArVPNjkYubtgS9jfrzfRNzuZPXYGhlYAC1QbmVtkq+Qne7dwWKaC sa37nTL7j0qK6NzVqrbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mADJB-00Dlap-9r; Sun, 01 Aug 2021 15:23:21 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mADJ7-00DlaK-Lk for linux-arm-kernel@lists.infradead.org; Sun, 01 Aug 2021 15:23:19 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 666C560243; Sun, 1 Aug 2021 15:23:15 +0000 (UTC) Date: Sun, 1 Aug 2021 08:23:12 -0700 From: Catalin Marinas To: Kefeng Wang Cc: Will Deacon , Andrey Ryabinin , Andrey Konovalov , Dmitry Vyukov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: Re: [PATCH v2 1/3] vmalloc: Choose a better start address in vm_area_register_early() Message-ID: <20210801152311.GB28489@arm.com> References: <20210720025105.103680-1-wangkefeng.wang@huawei.com> <20210720025105.103680-2-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210720025105.103680-2-wangkefeng.wang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210801_082317_772883_E92F3675 X-CRM114-Status: GOOD ( 22.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jul 20, 2021 at 10:51:03AM +0800, Kefeng Wang wrote: > There are some fixed locations in the vmalloc area be reserved > in ARM(see iotable_init()) and ARM64(see map_kernel()), but for > pcpu_page_first_chunk(), it calls vm_area_register_early() and > choose VMALLOC_START as the start address of vmap area which > could be conflicted with above address, then could trigger a > BUG_ON in vm_area_add_early(). > > Let's choose the end of existing address range in vmlist as the > start address instead of VMALLOC_START to avoid the BUG_ON. > > Signed-off-by: Kefeng Wang > --- > mm/vmalloc.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index d5cd52805149..a98cf97f032f 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2238,12 +2238,14 @@ void __init vm_area_add_early(struct vm_struct *vm) > */ > void __init vm_area_register_early(struct vm_struct *vm, size_t align) > { > - static size_t vm_init_off __initdata; > + unsigned long vm_start = VMALLOC_START; > + struct vm_struct *tmp; > unsigned long addr; > > - addr = ALIGN(VMALLOC_START + vm_init_off, align); > - vm_init_off = PFN_ALIGN(addr + vm->size) - VMALLOC_START; > + for (tmp = vmlist; tmp; tmp = tmp->next) > + vm_start = (unsigned long)tmp->addr + tmp->size; > > + addr = ALIGN(vm_start, align); > vm->addr = (void *)addr; > > vm_area_add_early(vm); Is there a risk of breaking other architectures? It doesn't look like to me but I thought I'd ask. Also, instead of always picking the end, could we search for a range that fits? -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 6DF0EC432BE for ; Sun, 1 Aug 2021 15:23:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D739E610CC for ; Sun, 1 Aug 2021 15:23:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D739E610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3D3446B0033; Sun, 1 Aug 2021 11:23:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3831F6B0036; Sun, 1 Aug 2021 11:23:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 299976B005D; Sun, 1 Aug 2021 11:23:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id 128156B0033 for ; Sun, 1 Aug 2021 11:23:19 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A384B180AD820 for ; Sun, 1 Aug 2021 15:23:18 +0000 (UTC) X-FDA: 78426880476.07.B3E3017 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP id 30D2EB00019F for ; Sun, 1 Aug 2021 15:23:18 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 666C560243; Sun, 1 Aug 2021 15:23:15 +0000 (UTC) Date: Sun, 1 Aug 2021 08:23:12 -0700 From: Catalin Marinas To: Kefeng Wang Cc: Will Deacon , Andrey Ryabinin , Andrey Konovalov , Dmitry Vyukov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Subject: Re: [PATCH v2 1/3] vmalloc: Choose a better start address in vm_area_register_early() Message-ID: <20210801152311.GB28489@arm.com> References: <20210720025105.103680-1-wangkefeng.wang@huawei.com> <20210720025105.103680-2-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210720025105.103680-2-wangkefeng.wang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 30D2EB00019F Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Stat-Signature: j5w7wmnoucuhb8mahn3ko8buhymi5x6e X-HE-Tag: 1627831398-938707 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 Tue, Jul 20, 2021 at 10:51:03AM +0800, Kefeng Wang wrote: > There are some fixed locations in the vmalloc area be reserved > in ARM(see iotable_init()) and ARM64(see map_kernel()), but for > pcpu_page_first_chunk(), it calls vm_area_register_early() and > choose VMALLOC_START as the start address of vmap area which > could be conflicted with above address, then could trigger a > BUG_ON in vm_area_add_early(). > > Let's choose the end of existing address range in vmlist as the > start address instead of VMALLOC_START to avoid the BUG_ON. > > Signed-off-by: Kefeng Wang > --- > mm/vmalloc.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index d5cd52805149..a98cf97f032f 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2238,12 +2238,14 @@ void __init vm_area_add_early(struct vm_struct *vm) > */ > void __init vm_area_register_early(struct vm_struct *vm, size_t align) > { > - static size_t vm_init_off __initdata; > + unsigned long vm_start = VMALLOC_START; > + struct vm_struct *tmp; > unsigned long addr; > > - addr = ALIGN(VMALLOC_START + vm_init_off, align); > - vm_init_off = PFN_ALIGN(addr + vm->size) - VMALLOC_START; > + for (tmp = vmlist; tmp; tmp = tmp->next) > + vm_start = (unsigned long)tmp->addr + tmp->size; > > + addr = ALIGN(vm_start, align); > vm->addr = (void *)addr; > > vm_area_add_early(vm); Is there a risk of breaking other architectures? It doesn't look like to me but I thought I'd ask. Also, instead of always picking the end, could we search for a range that fits? -- Catalin