Received: by 10.213.65.68 with SMTP id h4csp3040947imn; Mon, 2 Apr 2018 20:08:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+kfJAsxtjwOXi0Jrp54qGJTHQ2YVKpSBvNehXEhHLz6aQRhMU32YwLeDZVV8T3gtMebkAn X-Received: by 2002:a17:902:b70e:: with SMTP id d14-v6mr12425414pls.111.1522724938033; Mon, 02 Apr 2018 20:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522724937; cv=none; d=google.com; s=arc-20160816; b=EXNFMRBbnSntE4nduH7UImSe0mo+sU1TLj7TeUYbDdrIxbSWKgqXkTxrKJlyeZmF37 HfsyjbFReTEWmJBoKP80Xo35Y17DUK1GWVykyvbkdNZHvR72ViJD6iVG7dnPD288RyZG HJeLl1o1Ih2DbyB7ivOB/GnBCIi4e3nO8lg1AdZbn+ipMutdT3z2/0DRWd8wPCUWxBYk uj2sPkjP7xmlSovY29ugFNrQ/SJEzdeFxvafCXugK3KL9ybXTd4nSnQlXlMJgqvvAaNh kVc6PlWWMeKXtcm1Q6A/2XNre08GMwJV2oJv1wDOydjVaBo/fRZDot8Di9ev9dHN/fdq WB+A== 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=JgCvS5SlNzRSW1TzqXevAxpPIqoXK+5hHbF543Jtp8Y=; b=ROhWVoYCwbOoa2YhAfiDptEx1J2h2VsifGAE7w/6nqmrNm0tbwwnm8w1eiVVm5bfJR p+76CEX0v3jFT7wNtDO+giaotMRI8XwubQL01OSTtAQvu1JAjgMSFroh+L33QP1DlxRZ yzTqt8QHlUU2dsb0k3j+7svamuyu5aqLFVkWZFZzOmGBrKfOFvFbslZkrO9SiQAMY3bZ SdhlR8T1m74N7yP4HEEk5tBCVRlUMZUsY/yYxURuzTzr1IavHH0+I6n9T6D4CWlehue3 cXITcskIkQeB1ewyYTMaB3lYWrX21jsUZZO6HI27vbBU3k2fmUZMcDxMZnI7ExplZplu bvXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=beY+0CB7; 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 s76si1340668pfi.412.2018.04.02.20.08.42; Mon, 02 Apr 2018 20:08:57 -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=beY+0CB7; 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 S1752548AbeDCDHi (ORCPT + 99 others); Mon, 2 Apr 2018 23:07:38 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37743 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751131AbeDCDHg (ORCPT ); Mon, 2 Apr 2018 23:07:36 -0400 Received: by mail-pl0-f65.google.com with SMTP id v5-v6so4974418plo.4 for ; Mon, 02 Apr 2018 20:07:36 -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=JgCvS5SlNzRSW1TzqXevAxpPIqoXK+5hHbF543Jtp8Y=; b=beY+0CB7mOC51xN/vQwabn9ibBJ5QVJ/ezT/CgmGe9mpZgDaztmKMa3ogG56NHRoyS fRjeO4+IADVSv/v9/gLQPqU2DtKnMcPmOFzu0Xy+NH4+rpI8n1CiM94Wo02cMYDUjyII YTqQZ/s1dUtvP8ChW4w5PnejLNgzMfWvA1k+kgthYLeoyqejr9tVIUCr+2fVC2yZpBM0 aiXuu4LiMwYObiIHKGXFnfeYPDWLTIatxdPuUopiX4H7GLc+NQuHo7v8ngN6P6izX+zd hNwS2OpPx6mvdRbhenv48HDs8o9ZNbtFbaRgOt5EUxAwAfdlmmu2Ifel1QH3dYj77TAD KCUQ== 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=JgCvS5SlNzRSW1TzqXevAxpPIqoXK+5hHbF543Jtp8Y=; b=PxoOhUHK8H3dVxrivVFrLY3GxIN94TM9aNvOwDH47vhgcFgQr5jvLYT9K1QEf/pac3 lXUfzrh8Da7TFoxE4Bq9cvTQngGjVYM5d3kaqJvb7uqOBVWJI0fD7dYJxpajYWanyC6L 9A3dVJIhfbl3+g5hXBY5lve4CRbk2y9g5IYQXWlBBm7kS+XdHSu4tJ7891p85pynuSeP M8tiGy5aoQyLCbyjWo93lewEq1GGceATVEAvuvIlbz1a9SliI9yI5ldE+5q1Q8jMasMl i7XAYb5hJjTy4UsWt0Rd57E8/R1siyfekQ62QVUCPPXQBjuLVG9rbvp8r2DuYjbaBCkQ un4Q== X-Gm-Message-State: AElRT7FxQ3vZa9/Snaa8Jrse8KCRBy5zU1rdxeakYwQhROIARPaToOj2 oV5yjt9IK0HuUV3GX5PccNE= X-Received: by 2002:a17:902:d03:: with SMTP id 3-v6mr12356972plu.245.1522724856277; Mon, 02 Apr 2018 20:07:36 -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 f5sm2460966pgn.56.2018.04.02.20.07.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 20:07:35 -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: <392a8945-fe83-9864-0968-4a13a5443a02@gmail.com> Date: Tue, 3 Apr 2018 11:07:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.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)) > > where next_valid_pfn() is simply defined as > > static ulong next_valid_pfn(ulong pfn) > { > return pfn + 1; > } Hi Ard, Do you think a macro instead of simply fuction is better here? -- Cheer, Jia