Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp335991img; Thu, 28 Mar 2019 00:21:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHgZ0f9NVv0bbDMSuFvQbwRm3Ca/wIcpSFO3o9FJCs+zFavIK/gq0E8jMg77e1iYLDrKS6 X-Received: by 2002:a62:4290:: with SMTP id h16mr39733346pfd.8.1553757710145; Thu, 28 Mar 2019 00:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553757710; cv=none; d=google.com; s=arc-20160816; b=rMeCphcGAs6tjoOEDiOa1zSRhc+HEPMqt8A0VvvY2I5G8vGCsd1xo3pfDDVXMF8uqj Tlf5J/Q0A99gSuCMc5SDg+ZjsARUWZ9eRUgJq8iGX/2ieTbqTO3qsCN+FFQHjLQh0O+2 bbqLLVmMfeCkD8SdjYTw7LAMvd5g5AHusQJBL3HDBZ2s3YSvN/AxXc/L9FRuIyLHz80w VezY/DD8Avolaj5wl+Fd/8WmrYr7jL+5ZQvCwz7MCZcCb0iU5Xj7LTPRIaFbxz64cApz xIvhgG0ZzFrvEbTH9oHv1t9/JOico/nfeQsDJT9+FhHF7gpT+iTaxAIJ3gSF96nQKD+n Cgiw== 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=2tcoxIZvO1HTOBM680c9ecaH9VQpaGaIheV6w1gmPqc=; b=tnAMDqIsFTx0O4j8IPz4ip207FWgjW9BNLBRq1N/jNhWvoD2QEWfBCTg3gcBAbFBDb ww/c4DMuEY4AKy/VusAAdk9vkwt9YBbSLyEWY1gfkzWD9SIl49iYonJcZ9hCbeaPHDBQ WSpcUPsWOEVPQBWpMWn2Lbr/xsUGBLTG7ImQBfIoGobzZ8b/QHTNHandjkO2l8JTmr7c MkQFYhV0aWNOEoSqsvSKDWrrWbYsXlccb1kILGgFePzNesbXIwphlWtf1P4pyUmes0E7 6qZFTgUktpj1vDLbDymGK0NjDLxmP2Yw1O+KOhxt8HLDddKZ3/J4iw23diVCSeLGx2hp 24fQ== 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 y7si19776718pfe.248.2019.03.28.00.21.34; Thu, 28 Mar 2019 00:21:50 -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 S1726287AbfC1HUs (ORCPT + 99 others); Thu, 28 Mar 2019 03:20:48 -0400 Received: from mga03.intel.com ([134.134.136.65]:43665 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725779AbfC1HUs (ORCPT ); Thu, 28 Mar 2019 03:20:48 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 00:20:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,278,1549958400"; d="scan'208";a="135473853" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga008.fm.intel.com with ESMTP; 28 Mar 2019 00:20:45 -0700 Date: Thu, 28 Mar 2019 15:20:27 +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: <20190328072027.GA6531@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: > >+static int __meminit split_mem_range(struct map_range *mr, unsigned long start, >+ unsigned long end) >+{ >+ static const struct mapinfo mapinfos[] = { > #ifdef CONFIG_X86_64 >+ { .mask = 1U << PG_LEVEL_1G, .size = PUD_SIZE }, > #endif >+ { .mask = 1U << PG_LEVEL_2M, .size = PMD_SIZE }, >+ { .mask = 0, .size = PAGE_SIZE }, >+ }; >+ const struct mapinfo *mi; >+ struct map_range *curmr; >+ unsigned long addr; >+ int idx; >+ >+ for (idx = 0, addr = start, curmr = mr; addr < end; idx++, curmr++) { >+ BUG_ON(idx == NR_RANGE_MR); >+ mr_setup(curmr, addr, end); > >+ /* Try map sizes top down. PAGE_SIZE will always succeed. */ >+ for (mi = mapinfos; !mr_try_map(curmr, mi); mi++); > >+ /* Get the start address for the next range */ >+ addr = curmr->end; > } I re-arrange the code to make split_mem_range() here easy to read. My question is to the for loop. For example, we have a range +--+---------+-----------------------+ ^ 128M 1G 2G 128M - 4K If my understanding is correct, the original behavior will split this into three ranges: 4K size: [128M - 4K, 128M] 2M size: [128M, 1G] 1G size: [1G, 2G] While after your change, it will split this into two ranges: ?? size: [128M - 4K, 1G] 2M size: [1G, 2G] The question mark here is because you leave the page_size_mask unchanged in this case. Is my understanding correct? Or I missed something? -- Wei Yang Help you, Help me