Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201Ab2F3UPt (ORCPT ); Sat, 30 Jun 2012 16:15:49 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:38348 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751158Ab2F3UPr (ORCPT ); Sat, 30 Jun 2012 16:15:47 -0400 MIME-Version: 1.0 In-Reply-To: <1341047274-5616-1-git-send-email-jiang.liu@huawei.com> References: <1341047274-5616-1-git-send-email-jiang.liu@huawei.com> Date: Sat, 30 Jun 2012 13:15:46 -0700 X-Google-Sender-Auth: 5YdSap12FOqSs_Ljb3hdLf2bf60 Message-ID: Subject: Re: [PATCH] mm: setup pageblock_order before it's used by sparse From: Yinghai Lu To: Jiang Liu Cc: Andrew Morton , Mel Gorman , Tony Luck , Xishi Qiu , KAMEZAWA Hiroyuki , KOSAKI Motohiro , David Rientjes , Minchan Kim , Keping Chen , linux-mm@kvack.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, Jiang Liu Content-Type: multipart/mixed; boundary=f46d042f9e84eb415f04c3b63a76 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5233 Lines: 102 --f46d042f9e84eb415f04c3b63a76 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sat, Jun 30, 2012 at 2:07 AM, Jiang Liu wrote: > From: Xishi Qiu > > On architectures with CONFIG_HUGETLB_PAGE_SIZE_VARIABLE set, such as Itan= ium, > pageblock_order is a variable with default value of 0. It's set to the ri= ght > value by set_pageblock_order() in function free_area_init_core(). > > But pageblock_order may be used by sparse_init() before free_area_init_co= re() > is called along path: > sparse_init() > =A0 =A0->sparse_early_usemaps_alloc_node() > =A0 =A0 =A0 =A0->usemap_size() > =A0 =A0 =A0 =A0 =A0 =A0->SECTION_BLOCKFLAGS_BITS > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0->((1UL << (PFN_SECTION_SHIFT - pageblock_= order)) * > NR_PAGEBLOCK_BITS) > > The uninitialized pageblock_size will cause memory wasting because usemap= _size() > returns a much bigger value then it's really needed. > > For example, on an Itanium platform, > sparse_init() pageblock_order=3D0 usemap_size=3D24576 > free_area_init_core() before pageblock_order=3D0, usemap_size=3D24576 > free_area_init_core() after pageblock_order=3D12, usemap_size=3D8 > > That means 24K memory has been wasted for each section, so fix it by call= ing > set_pageblock_order() from sparse_init(). > can you check attached patch? That will kill more lines code instead. Thanks Yinghai --f46d042f9e84eb415f04c3b63a76 Content-Type: application/octet-stream; name="kill_set_pageblock_order.patch" Content-Disposition: attachment; filename="kill_set_pageblock_order.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h434r2q20 U3ViamVjdDogW1BBVENIXSBtbTogc2V0IHBhZ2VibG9ja19vcmRlciBpbiBjb21waWxpbmcgdGlt ZQoKVGhhdCBpcyBpbml0aWFsIHNldHRpbmcsIGFuZCBjb3VsZCBiZSBvdmVycmlkZSBieSBjb21t YW5kIGxpbmUuCgpTaWduZWQtb2ZmLWJ5OiBZaW5naGFpIEx1IDx5aW5naGFpQGtlcm5lbC5vcmc+ CgotLS0KIG1tL3BhZ2VfYWxsb2MuYyB8ICAgNDUgKysrKysrLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgNiBpbnNlcnRpb25zKCspLCAzOSBk ZWxldGlvbnMoLSkKCkluZGV4OiBsaW51eC0yLjYvbW0vcGFnZV9hbGxvYy5jCj09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K LS0tIGxpbnV4LTIuNi5vcmlnL21tL3BhZ2VfYWxsb2MuYworKysgbGludXgtMi42L21tL3BhZ2Vf YWxsb2MuYwpAQCAtMTQ3LDcgKzE0NywxMiBAQCBib29sIHBtX3N1c3BlbmR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wIHRoZSB6b25lIGRhdGEgc3RydWN0dXJlczoKICAqICAgLSBtYXJr IGFsbCBwYWdlcyByZXNlcnZlZApAQCAtNDQxMyw3ICs0MzgxLDYgQEAgc3RhdGljIHZvaWQgX19w YWdpbmdpbml0IGZyZWVfYXJlYV9pbml0XwogCQlpZiAoIXNpemUpCiAJCQljb250aW51ZTsKIAot CQlzZXRfcGFnZWJsb2NrX29yZGVyKCk7CiAJCXNldHVwX3VzZW1hcChwZ2RhdCwgem9uZSwgc2l6 ZSk7CiAJCXJldCA9IGluaXRfY3VycmVudGx5X2VtcHR5X3pvbmUoem9uZSwgem9uZV9zdGFydF9w Zm4sCiAJCQkJCQlzaXplLCBNRU1NQVBfRUFSTFkpOwo= --f46d042f9e84eb415f04c3b63a76-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/