Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5193361imm; Wed, 12 Sep 2018 02:27:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYWj1newoCCFHA1sPkvcXHaSpnD3fIl/O6z+y9dd5hngy8MCfCDGqQ+rF/Fs/b8VeCohigt X-Received: by 2002:a65:560a:: with SMTP id l10-v6mr1182243pgs.130.1536744469388; Wed, 12 Sep 2018 02:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536744469; cv=none; d=google.com; s=arc-20160816; b=EC2I3xs6iU0aeLMuTgQwyDhN90elgtfM/0f4+f11OW1KJV3a0CXKgpeyMNDADGwx7Q Pc7tTm1NPxfjq/uJOMbj/jYDe6CCoMoVaPRRj7oqWRCE868uXcPDoZ05YYkEChOitQYW zT7FSjFLvJWBc1My11eh68UIyLd2WYuKgBsy6lX14JL7nzmT3COyuG1kQxIR3ON3Oyoa wkUJP/8QKx8sHWd3G+s7qDII6dO410PPPjRQOFJi9baE7cwNb6M0yhgyvyxReLr/QSNw 33yiv028nuNjQ9euVDHpl/UDSHPwOt+WtfujKakzKac6AjRgrZ+h2cuFPBzEu8lq9Iiz 6Lyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=r4/VTKod0gV8NXfed4HWHLAS8EJF4ba+9NViZzyajPQ=; b=SPtwR3J5hsK9zUA6p52jhkWA6SZMiNeY7iO9p8y551k61Waw8xIZsJJrcHyt7YzyNq C8dnoao6fWW3kCQNvvGZdcs47Uog629GJzfxSeWhHgAmxRosR2JOgPK3pda2a1VTZ26i L3xNqdwGtDV/14CRDVhaQn4hvoTiAYZLYG2s0uoUCthSbseWPXJi0c35QPb/vErpFL+0 c+mS/5UGcQyV1wDF7WTO/OSWzPA36F86lFXM/DcYejIwBokdGdTo6t/y6legrCsrpvnD uykY4WqncCIKPcBAEml46bE5obC9zNGoE9G4RtDlaGO63NMLXUfwXmB4/l2Bg2BCKGu/ jNzQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j125-v6si501829pfc.243.2018.09.12.02.27.33; Wed, 12 Sep 2018 02:27:49 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbeILObA (ORCPT + 99 others); Wed, 12 Sep 2018 10:31:00 -0400 Received: from alexa-out-blr-02.qualcomm.com ([103.229.18.198]:51322 "EHLO alexa-out-blr.qualcomm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727183AbeILObA (ORCPT ); Wed, 12 Sep 2018 10:31:00 -0400 X-IronPort-AV: E=Sophos;i="5.53,364,1531765800"; d="scan'208";a="164674" Received: from ironmsg02-blr.qualcomm.com ([10.86.208.131]) by alexa-out-blr.qualcomm.com with ESMTP/TLS/AES256-SHA; 12 Sep 2018 14:57:17 +0530 X-IronPort-AV: E=McAfee;i="5900,7806,9013"; a="1111909" Received: from blr-ubuntu-104.ap.qualcomm.com (HELO blr-ubuntu-104.qualcomm.com) ([10.79.40.64]) by ironmsg02-blr.qualcomm.com with ESMTP; 12 Sep 2018 14:57:16 +0530 Received: by blr-ubuntu-104.qualcomm.com (Postfix, from userid 346745) id F037829BF; Wed, 12 Sep 2018 14:57:15 +0530 (IST) From: Arun KS To: akpm@linux-foundation.org, dan.j.williams@intel.com, mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, iamjoonsoo.kim@lge.com, osalvador@suse.de, arunks@codeaurora.org, malat@debian.org, gregkh@linuxfoundation.org, yasu.isimatu@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: arunks.linux@gmail.com, vinmenon@codeaurora.org Subject: [RFC] memory_hotplug: Free pages as pageblock_order Date: Wed, 12 Sep 2018 14:56:45 +0530 Message-Id: <1536744405-16752-1-git-send-email-arunks@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When free pages are done with pageblock_order, time spend on coalescing pages by buddy allocator can be reduced. With section size of 256MB, hot add latency of a single section shows improvement from 50-60 ms to less than 1 ms, hence improving the hot add latency by 60%. If this looks okey, I'll modify users of set_online_page_callback and resend clean patch. Signed-off-by: Arun KS --- include/linux/memory_hotplug.h | 1 + mm/memory_hotplug.c | 52 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 34a2822..447047d 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -88,6 +88,7 @@ extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, extern void __offline_isolated_pages(unsigned long, unsigned long); typedef void (*online_page_callback_t)(struct page *page); +typedef int (*online_pages_callback_t)(struct page *page, unsigned int order); extern int set_online_page_callback(online_page_callback_t callback); extern int restore_online_page_callback(online_page_callback_t callback); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 38d94b7..853104d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -662,19 +662,57 @@ static void generic_online_page(struct page *page) __online_page_free(page); } +static int generic_online_pages(struct page *page, unsigned int order); +static online_pages_callback_t online_pages_callback = generic_online_pages; + +static int generic_online_pages(struct page *page, unsigned int order) +{ + unsigned long nr_pages = 1 << order; + struct page *p = page; + unsigned int loop; + + for (loop = 0 ; loop < nr_pages ; loop++, p++) { + __ClearPageReserved(p); + set_page_count(p, 0); + } + adjust_managed_page_count(page, nr_pages); + init_page_count(page); + __free_pages(page, order); + + return 0; +} + +static int online_pages_blocks(unsigned long start_pfn, unsigned long nr_pages) +{ + unsigned long pages_per_block = (1 << pageblock_order); + unsigned long nr_pageblocks = nr_pages / pages_per_block; +// unsigned long rem_pages = nr_pages % pages_per_block; + int i, ret, onlined_pages = 0; + struct page *page; + + for (i = 0 ; i < nr_pageblocks ; i++) { + page = pfn_to_page(start_pfn + (i * pages_per_block)); + ret = (*online_pages_callback)(page, pageblock_order); + if (!ret) + onlined_pages += pages_per_block; + else if (ret > 0) + onlined_pages += ret; + } +/* + if (rem_pages) + onlined_pages += online_page_single(start_pfn + i, rem_pages); +*/ + + return onlined_pages; +} + static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages, void *arg) { - unsigned long i; unsigned long onlined_pages = *(unsigned long *)arg; - struct page *page; if (PageReserved(pfn_to_page(start_pfn))) - for (i = 0; i < nr_pages; i++) { - page = pfn_to_page(start_pfn + i); - (*online_page_callback)(page); - onlined_pages++; - } + onlined_pages = online_pages_blocks(start_pfn, nr_pages); online_mem_sections(start_pfn, start_pfn + nr_pages); -- 1.9.1