Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp198183img; Wed, 27 Mar 2019 20:37:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx44J4xULsR3S7/QLREpFe/T5ysdC05ySKvKnIn6B5AybFgOJvgpmjWAHRR8foEZexJBTp X-Received: by 2002:a17:902:8a8b:: with SMTP id p11mr32596239plo.227.1553744249663; Wed, 27 Mar 2019 20:37:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553744249; cv=none; d=google.com; s=arc-20160816; b=EzvR28AIqec/2k9oQab+JWdr5FNBzT0kTwM2isMvMaTceAWT6wSnRdm7NNQ75Xtb41 KhA+NgR8vc8/OqMZrLX4yKUGVN9bdXD7yZmc5zOM6BTXVxWj+wDmbuiLHEhYVYp8y2Xn aIBJmk5ySa5cNaQOR5sWgwGBS8YNIJv72Y7XgVp0NN0scvJ1YDG8q5pdKjHhZp3VV6Cw ta/J4H21T74EFMjk04frZFO7h6WrdIl1GwSNcrxlxXXCBFR9w/TR+xTg/E9kLWtZZqAC iNHSjmh0vYc97rCdDZsxmYsgmmh8wNGZ6HX2C30VnLiikHz0/Tjr1VnAPz99Dulu23cn 8Clg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=tZDnXAg/njPx1tdELHHB69tvfD7z1KtJLSgI6MOidvs=; b=v7EqV8OtADCgM70uRKda2xH6Rl7+qfOsAG9zTT246zVCJfMhlMGeIF14sYscLTI45n bABOgwp5h79oxhugsvpi01l+n5RZ1L3T984xQJrVC5pWLcJySx85JvwMZKfW8SQK14gO g6GfJuW1bw2pb7hj/ZT/gW63dmmpseU8SorF4eRPeIKhAdFZytVolVrQ321c6odOsqLC +nb6/JTDS1HWnCfDEQ3i0x6kU9mou/vBFW0cEGWRa9dHjRUEZbkhz2HyyWqP6jJHxjl+ 8wlTbtPhUvVmWA78KdZ09w2bviFG+Tgr8zQX1UZJJUkn2sv2t0zrlp2IQlojodqON9op CWjw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r23si19542702pgv.406.2019.03.27.20.37.03; Wed, 27 Mar 2019 20:37:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfC1DgL (ORCPT + 99 others); Wed, 27 Mar 2019 23:36:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:29522 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfC1DgL (ORCPT ); Wed, 27 Mar 2019 23:36:11 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2019 20:36:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="130813594" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga006.jf.intel.com with ESMTP; 27 Mar 2019 20:36:09 -0700 Date: Thu, 28 Mar 2019 11:35:48 +0800 From: Wei Yang To: Thomas Gleixner Cc: Wei Yang , x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.or Subject: Re: [PATCH 4/6] x86, mm: make split_mem_range() more easy to read Message-ID: <20190328033548.GA19364@richard> Reply-To: Wei Yang References: <20190212021215.13247-1-richardw.yang@linux.intel.com> <20190212021215.13247-5-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 24, 2019 at 03:29:04PM +0100, Thomas Gleixner wrote: >Wei, > >On Tue, 12 Feb 2019, Wei Yang wrote: >> >> This patch changes the implementation from the first perception to the >> second to reduce one different handling on end_pfn. After doing so, the >> code is easier to read. > >It's maybe slightly easier to read, but it's still completely unreadable >garbage. > > Not your fault, it was garbage before. > >But refining garbage still results in garbage. Just the smell is slightly >different. > >Why? > > 1) Doing all the calculations PFN based is just a pointless > indirection. Just look at all the rounding magic and back and forth > conversions. > > All of that can be done purely address/size based which makes the code > truly readable. > > 2) The 5(3) sections are more or less copied code with a few changes of > constants, except for the first section (A) which has an extra quirk > for 32bit. Plus all the 64bit vs. 32bit #ifdeffery which is not making > it any better. > > This copied mess can be avoided by using helper functions and proper > loops. > > 3) During the bootmem phase the code tries to preserve large mappings > _AFTER_ splitting them up and then it tries to merge the resulting > overlaps. > > This is completely backwards because the expansion of the range can be > tried right away when then mapping of a large page is attempted. Surely > not with the current mess, but with a proper loop based approach it can > be done nicely. > > Btw, there is a bug in that expansion code which could result in > undoing the enforced 4K mapping of the lower 2M/4M range on 32bit. It's > probably not an issue in practice because the low range is usually not > contiguous. But it works by chance not by design. Hi, Thomas I want to confirm with you, this bug is in adjust_range_page_size_mask(), right? -- Wei Yang Help you, Help me