Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1250539imm; Thu, 5 Jul 2018 18:39:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfuu4vzT0TY/pZSShTsO37Adt2QoInZVXR1zKyz0W0iIRYEOWVOBnm+x2hSYZwsKTX4/Ce2 X-Received: by 2002:a63:4924:: with SMTP id w36-v6mr7665317pga.143.1530841182415; Thu, 05 Jul 2018 18:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530841182; cv=none; d=google.com; s=arc-20160816; b=dexj363pVEUYC+ZoSd1BkV4uvDlZjUJ5U5+JUL+I0whBXYsuCfNCqiS+JfefRtwjIR m57GmnQ0KgdlW8Xr+xRqazlnRzSvfajr4Xl5kAyLagVuljXQSn2zzDFHgWPGwCo+LS2n 13LqlCDyeP92miCLxPwE08ffnPe8k85D+DHy508D5lmt1OyadhibmCDKTttk8cYaKLXX ZavqZKu6oGWTHaRD9rtaN470+qXpseaeiO5i6j6dDsqdzwlasbP24POXO1LPYKPIpbac zqNm79RTkOIXSwe30Fua8NyFlO1hQ/Ed3Ghsu/YnOZEcRvwjyb5+SK20RCvoy8yus97a ObRQ== 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:references:cc:to:subject :from:dkim-signature:arc-authentication-results; bh=wW1J0B36vMqTKWbd66RzDYIjkOL92Jca6cQu4ExdRdk=; b=RwBW4kaHpFJES7SNtK9tQqH/iQ3upCbXBs3vcNmUuci9rgGmHdMcX+Q4AwouJ+7paN t96ShOu7k2v/l/rEjZZSOaKTLCx4VWOQVu1Nj9Bg+vWB1S5J9QZswQrDDwgsxF6V05Uj zG0wG3XpJPo/UTUuf93fexyXV9PGwuspWwokP56qwUN6RyXfwck2xPmyUt+FFBnzXZ98 xHxYuPPYHcAN7MVBNhlRGpwDIvR2GPw8sb9yNARwjn3kF8r1qd9aJJvajwDsjrZtoNIh 0ko7Px9d73ohnH4MdwEG/i9ParXQNrrjJDb4i3gVc7UKoslDPY/PCjohbGZyeH2xLtdE dyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pWhfwuFP; 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 ay6-v6si6959163plb.210.2018.07.05.18.39.28; Thu, 05 Jul 2018 18:39:42 -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=pWhfwuFP; 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 S1753898AbeGFBiu (ORCPT + 99 others); Thu, 5 Jul 2018 21:38:50 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40749 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753715AbeGFBis (ORCPT ); Thu, 5 Jul 2018 21:38:48 -0400 Received: by mail-pf0-f196.google.com with SMTP id z24-v6so6945767pfe.7 for ; Thu, 05 Jul 2018 18:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=wW1J0B36vMqTKWbd66RzDYIjkOL92Jca6cQu4ExdRdk=; b=pWhfwuFPZYhrLtDw5jaR7rvVzJs/32cgOP4LlUeR8xpTq9OOwFapIqYguUU5L2JAnW TCHkqW/q7y/yo+oDEvtQkqPc2ZoorW2Q5H0GZK8DVKiUHT2K95Tsa99xiPsBK2aZADN4 oXfnYPFBIopm4JsJLguX1062Vy3pz75yQ+dmSjjR82FxmhoJFZ6fwCWKeDlpKxhs4b5u MO+DQ8nBCdjCBQG25zFqnMtUL7+AOdYi4Ukt+c4DZfzVlRG9BB5Gx2pgQAEuSp/NH6yD r1nLi83mcPNBGx+qC4/j78Krjo5Y7XG1BrrJ+wj8bFlDKuJ8kBCWtfibnphWhySUg5wa GSsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=wW1J0B36vMqTKWbd66RzDYIjkOL92Jca6cQu4ExdRdk=; b=gSesCLtPvEtL0xwPJnMQUNCNumYd48lw9HYUiNf6WK53Nt0kbOpueOFwdwjFPV3S2y yxW1xZOi27E4vJbhYJE007BRvH+f60v7kLP3/a4B5Yg17DetXpLEpy+YO2rCTp6CxlvP 6Wa9cy1CNLvt855N1IjhcDv3vrybjEABsVv75Jjd4ScoC+Qm5Yw5E1kgno8qtgfJtPdk GEnh3lsu9LLXEhXn0a2JPOZ4htEX6BLChCIc9OJ0G59E5ITSidydfmB1qttCoikVJCc5 u2eoM5P4H2hU1hvtUZxViUjMYpsd9Xq2Fr8NI+SngP+r0zc7lJxziwPN9v4kxG2cdEH5 7+OA== X-Gm-Message-State: APt69E0QFM90ATBaauBJzVEYrmrrruTyIyOCZd6ZVtZRVLfXkEUT2US+ z5zfiejA7e4xRI7dkG6xrXs= X-Received: by 2002:a62:3687:: with SMTP id d129-v6mr8607775pfa.137.1530841128396; Thu, 05 Jul 2018 18:38:48 -0700 (PDT) Received: from [0.0.0.0] (65.49.234.56.16clouds.com. [65.49.234.56]) by smtp.gmail.com with ESMTPSA id e5-v6sm9633912pgs.59.2018.07.05.18.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 18:38:47 -0700 (PDT) From: Jia He Subject: Re: [PATCH v9 2/6] mm: page_alloc: remain memblock_next_valid_pfn() on arm/arm64 To: Pavel Tatashin Cc: linux@armlinux.org.uk, Andrew Morton , Michal Hocko , Catalin Marinas , Mel Gorman , will.deacon@arm.com, mark.rutland@arm.com, hpa@zytor.com, Daniel Jordan , AKASHI Takahiro , Gioh Kim , Steven Sistare , neelx@redhat.com, erosca@de.adit-jv.com, Vlastimil Babka , LKML , Linux Memory Management List , james.morse@arm.com, ard.biesheuvel@linaro.org, steve.capper@arm.com, tglx@linutronix.de, mingo@redhat.com, gregkh@linuxfoundation.org, kstewart@linuxfoundation.org, pombredanne@nexb.com, Johannes Weiner , kemi.wang@intel.com, ptesarik@suse.com, yasu.isimatu@gmail.com, aryabinin@virtuozzo.com, nborisov@suse.com, Wei Yang , jia.he@hxt-semitech.com References: <1530239363-2356-1-git-send-email-hejianet@gmail.com> <1530239363-2356-3-git-send-email-hejianet@gmail.com> Message-ID: Date: Fri, 6 Jul 2018 09:38:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pavel, sorry for the late reply On 6/30/2018 1:07 AM, Pavel Tatashin Wrote: > On Thu, Jun 28, 2018 at 10:30 PM 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. > > Hi Jia, > > Is this a bug? Should we make other arches that support memblock to > use memblock_is_map_memory() ? it is more expensive, but if the > default is broken, maybe it makes sense to change? > IIUC, the bug is in memblock_next_valid_pfn instead of pfn_valid. memblock_next_valid_pfn will return the incorrect next valid pfn on !arm arches (e.g. X86). Please refer to b92df1de5. Currently only arm/arm64 use MEMBLOCK_NOMAP, it is really beyond my power to implement it on all other arches ;-) -- Cheers, Jia