Received: by 10.192.165.156 with SMTP id m28csp284161imm; Tue, 10 Apr 2018 21:51:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+3+JqAnlQDT77Uu3r15BC1bmWZ3MhhAXMv8sTihe3stQlj50B9+IGmzc2cNYIQl+CYH06b X-Received: by 10.101.96.65 with SMTP id b1mr2355269pgv.340.1523422296397; Tue, 10 Apr 2018 21:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523422296; cv=none; d=google.com; s=arc-20160816; b=qA941fwaoxO2iWzUwFnM6Wn34g05qY2LhCWKb2yGGnEh/kYUFTah+WE4rks9Vf43Y6 sFWajTkT712sBc0ygRWjvdGOhr9lf+KmziUBfjW0VkL3yV/3oPKKSV09mWj+rbDMePmJ m6OYhSQNSopqf5upllx1cR4e1Lgdf6C24APFWwo0pjB6xOi8bBgI/ODM6jcLUK+34vKP xpLVa09xfIskI0ZFJ7SFhi6sCggXE/u0ZH13ruAI5/USVU9L8LyChcdW/wUXxnvorUoN xRvVd5TeA/z+io+ZCryM1eeGtK/zkOhqM47MXlEiwwMOMTK7ttvJiRk4eIo234zKqfKO x3FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:dkim-signature:arc-authentication-results; bh=eEXVby5gWtMBjumnkdcWoL1MgxxDFYbY3GmWN1uqoN0=; b=WY+A1PhY8npMt2zwuWakpvz1fW+lrJkpMZgVdR7RzjN/fpiS3zmiJOZw5orWApnFRZ Slgd4AOax8XPIwSICArY107w29l2O2dG6Yu5yTEOdDNI3NYjnVLVJssBMp8QWwgDxHFO zRyW1lvyiCWekGBVsZOzD6aU6JWlqYKUNtbMgR539l5w2hyIuvOgbv6ZWSMFegs9ODXs 7/z9EWI+e0tm6lWt6xSX3kYVtmREUHmwXarjSIgqhgRb+Scm4DvhBtKPQl8zv7sADuve dQVzEZ4TY6pgv3vDtwxNM3tXRo/IsrHrceLQuTGGDRMm5bFuaooXqP5iA+nn9a8fCvtQ +/xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R3l4wco8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b63si212752pga.222.2018.04.10.21.50.59; Tue, 10 Apr 2018 21:51:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R3l4wco8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbeDKEre (ORCPT + 99 others); Wed, 11 Apr 2018 00:47:34 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43583 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750785AbeDKErc (ORCPT ); Wed, 11 Apr 2018 00:47:32 -0400 Received: by mail-pl0-f66.google.com with SMTP id a39-v6so464442pla.10 for ; Tue, 10 Apr 2018 21:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=eEXVby5gWtMBjumnkdcWoL1MgxxDFYbY3GmWN1uqoN0=; b=R3l4wco8b73BOnmxibsKQ211fECjkoqg22vankHN0JtS5bPA2oGTuMRlA30RD9celj Bn+RMPfq2ksBwIntfEp2FuL+y3jodMwzUuBzGcp4Z8IRKFP2VHzVlZmXU1ZOJ8YlQ9CD Orn4DVtJp3GeI0Yra8cTaNvNu11sPcunio2a83STOeN3SzNwlUqg/EnJoZ0l9RQ0TbzZ 9jqHf5WAvG5dIg+ogPX3Yw/LrD0xmmStX2fgdlyezgRX/6MhoAViqWtsGXV7lw6hc6TZ bbIJbXe0Xp3hBu1mOrgQq8ZSDQC/SAgBhY3Mxf2OiSZl8HVeFxt2cl7uiBX8zvutQB9n OdeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=eEXVby5gWtMBjumnkdcWoL1MgxxDFYbY3GmWN1uqoN0=; b=UZEdKimqEn3QkcO0HYwJLmziS6VRTI57ux/+e0H9asj4FOlQ6x+nMbAAHIjjW9kP6j Lo7uLV0Nu1Gk/582sIiutbJm4tWO9ylKshK5XX0NPf7I9QMvKpkDx77VFxEXz69imkiV 1SZIEMBLILqWwmITE4v7MAXp/Vksio5+X/s2nZatMQc1Hf7cPC6+UWlDKwIDQQhqb8pU 21xdWb7Ty09c7ea1qNpvBOQ0Mnvno0H9nsFDC/ug9MKYNC4tgccmeSBo21ty/mYiw2tR X0zR0tGKXezHXS+durw29MGtZHXmRyF1jfZTuzYY7Anu07FSQJpIfGbPmp9GLWEEejxh 3j1g== X-Gm-Message-State: ALQs6tCYiXf+O0nJ4s2Jn6tVPAmVtJ771etzKHpId+mpDp6lYVTwDB/t 9xAX6H/MjcYQKcP8qnShosk= X-Received: by 2002:a17:902:2863:: with SMTP id e90-v6mr3470349plb.58.1523422052242; Tue, 10 Apr 2018 21:47:32 -0700 (PDT) Received: from [0.0.0.0] (67.216.217.169.16clouds.com. [67.216.217.169]) by smtp.gmail.com with ESMTPSA id d77sm567082pfe.127.2018.04.10.21.47.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 21:47:31 -0700 (PDT) Subject: Re: [PATCH v5 1/5] mm: page_alloc: remain memblock_next_valid_pfn() on arm and arm64 To: Ard Biesheuvel Cc: Russell King , Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Michal Hocko , Wei Yang , Kees Cook , Laura Abbott , Vladimir Murzin , Philip Derrin , AKASHI Takahiro , James Morse , Steve Capper , Pavel Tatashin , Gioh Kim , Vlastimil Babka , Mel Gorman , Johannes Weiner , Kemi Wang , Petr Tesarik , YASUAKI ISHIMATSU , Andrey Ryabinin , Nikolay Borisov , Daniel Jordan , Daniel Vacek , Eugeniu Rosca , linux-arm-kernel , Linux Kernel Mailing List , Linux-MM , Jia He References: <1522636236-12625-1-git-send-email-hejianet@gmail.com> <1522636236-12625-2-git-send-email-hejianet@gmail.com> <41445229-043c-976f-3961-13770163444f@gmail.com> From: Jia He Message-ID: <4577f3be-1183-c857-6933-ca182fb34a2f@gmail.com> Date: Wed, 11 Apr 2018 12:47:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/2/2018 3:53 PM, Ard Biesheuvel Wrote: > On 2 April 2018 at 09:49, Jia He wrote: >> >> On 4/2/2018 2:55 PM, Ard Biesheuvel Wrote: >>> On 2 April 2018 at 04:30, Jia He wrote: >>>> Commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns >>>> where possible") optimized the loop in memmap_init_zone(). But it causes >>>> possible panic bug. So Daniel Vacek reverted it later. >>>> >>>> But as suggested by Daniel Vacek, it is fine to using memblock to skip >>>> gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID. >>>> >>>> On arm and arm64, memblock is used by default. But generic version of >>>> pfn_valid() is based on mem sections and memblock_next_valid_pfn() does >>>> not always return the next valid one but skips more resulting in some >>>> valid frames to be skipped (as if they were invalid). And that's why >>>> kernel was eventually crashing on some !arm machines. >>>> >>>> And as verified by Eugeniu Rosca, arm can benifit from commit >>>> b92df1de5d28. So remain the memblock_next_valid_pfn on arm{,64} and move >>>> the related codes to arm64 arch directory. >>>> >>>> Suggested-by: Daniel Vacek >>>> Signed-off-by: Jia He >>> Hello Jia, >>> >>> Apologies for chiming in late. >> no problem, thanks for your comments ;-) >>> >>> If we are going to rearchitect this, I'd rather we change the loop in >>> memmap_init_zone() so that we skip to the next valid PFN directly >>> rather than skipping to the last invalid PFN so that the pfn++ in the >> hmm... Maybe this macro name makes you confused >> >> pfn = skip_to_last_invalid_pfn(pfn); >> >> how about skip_to_next_valid_pfn? >> >>> for () results in the next value. Can we replace the pfn++ there with >>> a function calls that defaults to 'return pfn + 1', but does the skip >>> for architectures that implement it? >> I am not sure I understand your question here. >> With this patch, on !arm arches, skip_to_last_invalid_pfn is equal to (pfn), >> and will be increased >> when for{} loop continue. We only *skip* to the start pfn of next valid >> region when >> CONFIG_HAVE_MEMBLOCK and CONFIG_HAVE_ARCH_PFN_VALID(arm/arm64 supports >> both). >> > What I am saying is that the loop in memmap_init_zone > > for (pfn = start_pfn; pfn < end_pfn; pfn++) { ... } > > should be replaced by something like > > for (pfn = start_pfn; pfn < end_pfn; pfn = next_valid_pfn(pfn)) After further thinking, IMO, pfn = next_valid_pfn(pfn) might have impact on memmap_init_zone loop. e.g.context != MEMMAP_EARLY, pfn will not be checked by early_pfn_valid, thus It will change the memhotplug logic. So I would choose the old implementation: if (!early_pfn_valid(pfn)) { pfn = next_valid_pfn(pfn) - 1; continue; } Any comments? Thanks -- Cheers, Jia