Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5516459imm; Wed, 12 Sep 2018 07:09:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbNQhL3haj+L7Xa3fhzlIprWpGDPBJL++l6EaG5Uhoq6hjoynqxN8SWoegcHxmmqSKEq9Oo X-Received: by 2002:a62:bd4:: with SMTP id 81-v6mr2590400pfl.67.1536761399252; Wed, 12 Sep 2018 07:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536761399; cv=none; d=google.com; s=arc-20160816; b=gO4VFFFRE+NcaHGIwWdL3WPsRJ8I1mu6MmoIj80swrYC3/GNN8anwtS7863rho6f/d yMBNAwWesF7SuGlRnC8yNBskODuNA7EuhPtaSzeeAlmWRJB+LjpqFq41fPwNmjprTIkH sfRCv+xJbrS0MCMslB9FUTYM+cspGXatnOpJ/RfJg4T8RcuJOmx1VN363QCZqrRqMVVK AVwWatEi0Kayfv1RNwJEj+NTbNcKvEH9uCnZ7pPgQCXW/qpA3pML/HgO0J2Ps57ykwjJ vW5dVAhjh7+iXRWrq0skZeRq9fFS1wm/oMvnpC23eR0h/sH9xHGG8XEFqfsPxu7mYxpt rPVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=dpiDyXMOnXH4wEg47VbgKqwFqJ+Qw1AuCigW7IYm7jA=; b=llSyQbha/K98aX1aLJp7lS7e8n2eGVB+AIHawNFvVY2Dsj2c66esVHMQ4mcujNqeZ5 NosZ+56r0QOTJdkPRhXL/PlN+sfR+ZtN4luiuuZDmgSJ7ir2hcLJUf5gzgaQQcSbYEcn x2iJiwTJ8FDrwZuVBUWptvDON9pLXy6LTzfXBn4n0bVa3WnGVPlNNAaSqUiomKhDHEM3 7PKkWUWqrBpQT4K5+nBAqIhfJ2Dw7+0O7ifCTD4YpGPfGq6ZUFx244wqeCih1xC4ZIZZ 0N9os/ZTmvO7HG48w3dYNV7Urq8VrJnlMLq51eFF3Q936xoGNnyEzWWUVVZhzgb0y0vF X44Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QRGOLGrd; dkim=pass header.i=@codeaurora.org header.s=default header.b=OVAALX3P; 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 n10-v6si1321499pgf.415.2018.09.12.07.09.43; Wed, 12 Sep 2018 07:09:59 -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=@codeaurora.org header.s=default header.b=QRGOLGrd; dkim=pass header.i=@codeaurora.org header.s=default header.b=OVAALX3P; 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 S1727660AbeILTOK (ORCPT + 99 others); Wed, 12 Sep 2018 15:14:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34362 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbeILTOJ (ORCPT ); Wed, 12 Sep 2018 15:14:09 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E1F076083E; Wed, 12 Sep 2018 14:09:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536761367; bh=DRIe1HTR507OMAPE4kLMiDMFdZSRXxQIgeXau95325A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QRGOLGrd/o8nWcmPxLgNcoVLrY/Io+6AvbHaF59ynEJsIspOeGzh91LPoC0XqaAYn TAFNX2LLJWpzlftyH/bab8kOzmLNOi62gvZvvjG7UvJb1mK7631Xy955Bf3eJfNwHv 83p5M7m3D6hJf5ygbqLVnX0SMtCr3uKljNbOXFRE= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 6D8136029D; Wed, 12 Sep 2018 14:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536761366; bh=DRIe1HTR507OMAPE4kLMiDMFdZSRXxQIgeXau95325A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OVAALX3PX8/loDE1tre6Tk8lbDLX0lOukjrbreJo5eg/UNrVzWIdNWvSp62yhv8qn ikrkbglNmuX7lMrB8UQgxf5CqYn8vgOSYSKi+LdNY1K5eICQMCHgAJHQ63+/8DILz4 xX7+qRtKyMjw367ZSmrHNVigCOaLLTE4gnHtflj0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 12 Sep 2018 19:39:26 +0530 From: Arun KS To: Balbir Singh Cc: Michal Hocko , akpm@linux-foundation.org, dan.j.williams@intel.com, vbabka@suse.cz, pasha.tatashin@oracle.com, iamjoonsoo.kim@lge.com, osalvador@suse.de, malat@debian.org, gregkh@linuxfoundation.org, yasu.isimatu@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, arunks.linux@gmail.com, vinmenon@codeaurora.org, getarunks@gmail.com Subject: Re: [RFC] memory_hotplug: Free pages as pageblock_order In-Reply-To: <20180912125743.GB8537@350D> References: <1536744405-16752-1-git-send-email-arunks@codeaurora.org> <20180912103853.GC10951@dhcp22.suse.cz> <20180912125743.GB8537@350D> Message-ID: <4b2f53342b68535b5635a3e46783163a@codeaurora.org> X-Sender: arunks@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Michal and Balbir, Thanks for reviewing. On 2018-09-12 18:27, Balbir Singh wrote: > On Wed, Sep 12, 2018 at 12:38:53PM +0200, Michal Hocko wrote: >> On Wed 12-09-18 14:56:45, Arun KS wrote: >> > 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%. >> >> Where does the improvement come from? You are still doing the same >> amount of work except that the number of callbacks is lower. Is this >> the >> real source of 60% improvement? >> > > It looks like only the first page of the pageblock is initialized, is > some of the cost amortized in terms of doing one initialization for > the page with order (order) and then relying on split_page and helpers > to do the rest? Of course the number of callbacks reduce by a > significant > number as well. Currently, order zero pages are freed one by one, they goes to pcp list and later when pcp->count >= pcp->high, kernel calls __free_one_page() in a loop. __free_one_page() tries to merge these pages to create bigger order page. But when we free with higher order page(pageblock_order), this merging is not done. AFAIU, this is the reason for improvement in hot add latency. > > >> > >> > If this looks okey, I'll modify users of set_online_page_callback >> > and resend clean patch. >> >> [...] >> >> > +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; >> > + } >> >> Could you explain why does the pages_per_block step makes any sense? >> Why >> don't you simply apply handle the full nr_pages worth of memory range >> instead? Yes. We can move the this loop to generic_online_pages and do __free_pages() of pageblock_order. >> >> > +/* >> > + if (rem_pages) >> > + onlined_pages += online_page_single(start_pfn + i, rem_pages); >> > +*/ > > Do we expect no rem_pages with this patch? I ll remove this code, in assumption that section size will be always multiple of pageblock_order. Regards, Arun > >> > + >> > + 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); > > > Balbir Singh.