Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3326723imu; Mon, 19 Nov 2018 14:16:45 -0800 (PST) X-Google-Smtp-Source: AJdET5cH+aXSXnl5YVKozX30jQj3jiZfDmMprFW87nT8ZU1Ol/T40klPJi7vNg2Su1HqaJAZ5lNQ X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr23406247plc.120.1542665805259; Mon, 19 Nov 2018 14:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542665805; cv=none; d=google.com; s=arc-20160816; b=pdz+ZBTbcyK6MYOHKHGBWV6UOWcvwBkVKDKvuzhu4/LalO6P9M2PAYBRBaBbAU0/v3 kO6NQ6FqXuZn+dXIaDHFk3Fsuf7XYe2YrpRRe0sfQ6UiZxGvqFcd7YHBBPlnc03/WjQ6 ZA59gyDAhHYHU/ZXI8tislsZw7tI0+DUdgOvI+84AkvmmnzXs8RXEcBIhoFU70gValWC Pz+E9ZrtAB67WOMtGnXA+UPfuk/Cuy39pfv85FelLk0cdspuFTZk4ZcwHwPQ7jA7D8EG H9VQhdKUd1pYXDMPdhP/gz+xHXx7JJQV9xCJbczd84Dhkjwcwn8NrDx7Hqo2t8TuOpY0 pPHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UZA60v9JGvM3vbTrUvJ9DGgMp+pl+AqBEHCxNcp7Kzc=; b=PzOpNcFYuuJi5GoxRPWh+rmIFwdqFk7HFQ7b0KeDIGfx/fCUbBFHPq1SqYTO7SO6Nx +fYS5rLB6JPqFbfqgIqfnlA1FYEz5TvOblDcA1m7FxjWtbHo+x8NA0O8h0C1ymrt1Epu USs45j38sNOwH8MnWTooUITIed4YGiHlxXZ3uedmM0SQi5M0pqyfxSBDn7yCqyfngb5K RlRRCVp4FrBmd1JPWozWTUd8iUCghHQwl1m3817TmDp1dOaeQmarEvHD5NudZuvR4dc1 B1j/0enjBOq9UZ+AX168Zg1BxlZ8AWrRcZe6hfZ7EOYdWQPOpmiXIyTFmo4MPZg9+btf 1bQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="K/KCPfWL"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si8313825pfg.245.2018.11.19.14.16.28; Mon, 19 Nov 2018 14:16:45 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="K/KCPfWL"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731376AbeKTIlh (ORCPT + 99 others); Tue, 20 Nov 2018 03:41:37 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:50986 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731313AbeKTIlg (ORCPT ); Tue, 20 Nov 2018 03:41:36 -0500 Received: by mail-it1-f194.google.com with SMTP id a185so525710itc.0 for ; Mon, 19 Nov 2018 14:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UZA60v9JGvM3vbTrUvJ9DGgMp+pl+AqBEHCxNcp7Kzc=; b=K/KCPfWLSGlzqjklTm9LirDJErmK8mGBS1JVlogDi/P8L1URE6CljFcHPqlZxsmQRx M18MoFqCBzmAEBZ89bjOZjikEALfNL3PyPKES82XrghybHaa5uv4QEqO7aJK9pdorD6P 6Gflj1LX/NNTRGLOA++rG1wg0viJKIp1By1tlAYru2khNb7OM46Cs7YCvkov9h6RV77A m3oDz1LCRzRm9dByjojIg7WY4xy8K2+uLeu1nNL01VDWxLhSkst7cNOXCZU+pd44Csxb YyvPwyyw8RvtKoVrGvVziUXbiUulaIl1XUI37RSz9ahbp40Q0cmeK6Ku+SISQcZhfjr3 ywWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UZA60v9JGvM3vbTrUvJ9DGgMp+pl+AqBEHCxNcp7Kzc=; b=uVnZQ9v7urVbWTfsTk3TyxhzRgHBj8Nfxa2/YEXP8R58UPCv2aNt7K3/3Q+XpFCMwF pQ+zOPo5IqcI03Yo0uuhclnLHNG0vix3z0WtGMn2z7MH9/AvvOlvvz4nHumbhs8FFex+ WwBlwVKdChpJ5i3hl3Z7Z/05qmlCAgaHRgnXGaX55SyNkZXvtMNRketxjm1w7d8xGdoU vSGKms+mAxUqguB5Y6nXHO680AvwqMECqVIlPA2nTQYT6uFiIHc6sWttrrLtCXlcoYuo zyT+ZkQpU8wLCOH/rKTQlqo7eaRK5JL4q8i8mdWzQBoqwEeeJR3+jY02gTuCIJGYbIfI C/Cw== X-Gm-Message-State: AGRZ1gIr6Ijoukqu+9iWTV0AT7+Z0gUWnRJC0JLEMaYsJgk90OjnbEH1 Z/OAIYncaYnBl3LcyjrEim2acR4ziYnTfku3pw4= X-Received: by 2002:a24:5284:: with SMTP id d126mr9957434itb.91.1542665750709; Mon, 19 Nov 2018 14:15:50 -0800 (PST) MIME-Version: 1.0 References: <1538727006-5727-1-git-send-email-arunks@codeaurora.org> <72215e75-6c7e-0aef-c06e-e3aba47cf806@suse.cz> <97d8db4c-f117-8216-5f48-d5991692c867@suse.cz> In-Reply-To: <97d8db4c-f117-8216-5f48-d5991692c867@suse.cz> From: Wei Yang Date: Tue, 20 Nov 2018 06:15:39 +0800 Message-ID: Subject: Re: [PATCH v5 1/2] memory_hotplug: Free pages as higher order To: Vlastimil Babka Cc: arunks@codeaurora.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Boris Ostrovsky , jgross@suse.com, Andrew Morton , Dan Williams , Michal Hocko , iamjoonsoo.kim@lge.com, Greg Kroah-Hartman , Oscar Salvador , Mathieu Malaterre , "Kirill A . Shutemov" , jrdr.linux@gmail.com, Yasuaki Ishimatsu , Mel Gorman , aaron.lu@intel.com, devel@linuxdriverproject.org, Linux Kernel Mailing List , Linux-MM , xen-devel@lists.xenproject.org, vatsa@codeaurora.org, Vinayak Menon , getarunks@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 6:05 PM Vlastimil Babka wrote: > > On 10/10/18 6:56 PM, Arun KS wrote: > > On 2018-10-10 21:00, Vlastimil Babka wrote: > >> On 10/5/18 10:10 AM, Arun KS wrote: > >>> When free pages are done with higher 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%. Modify external > >>> providers of online callback to align with the change. > >>> > >>> Signed-off-by: Arun KS > >> > >> [...] > >> > >>> @@ -655,26 +655,44 @@ void __online_page_free(struct page *page) > >>> } > >>> EXPORT_SYMBOL_GPL(__online_page_free); > >>> > >>> -static void generic_online_page(struct page *page) > >>> +static int generic_online_page(struct page *page, unsigned int order) > >>> { > >>> - __online_page_set_limits(page); > >> > >> This is now not called anymore, although the xen/hv variants still do > >> it. The function seems empty these days, maybe remove it as a followup > >> cleanup? > >> > >>> - __online_page_increment_counters(page); > >>> - __online_page_free(page); > >>> + __free_pages_core(page, order); > >>> + totalram_pages += (1UL << order); > >>> +#ifdef CONFIG_HIGHMEM > >>> + if (PageHighMem(page)) > >>> + totalhigh_pages += (1UL << order); > >>> +#endif > >> > >> __online_page_increment_counters() would have used > >> adjust_managed_page_count() which would do the changes under > >> managed_page_count_lock. Are we safe without the lock? If yes, there > >> should perhaps be a comment explaining why. > > > > Looks unsafe without managed_page_count_lock. I think better have a > > similar implementation of free_boot_core() in memory_hotplug.c like we > > had in version 1 of patch. And use adjust_managed_page_count() instead > > of page_zone(page)->managed_pages += nr_pages; > > > > https://lore.kernel.org/patchwork/patch/989445/ > > Looks like deferred_free_range() has the same problem calling > __free_pages_core() to adjust zone->managed_pages. I expect > __free_pages_bootmem() is OK because at that point the system is still > single-threaded? > Could be solved by moving that out of __free_pages_core(). > Seems deferred_free_range() is protected by pgdat_resize_lock()/pgdat_resize_unlock(). Which protects pgdat's zones, if I am right. > But do we care about readers potentially seeing a store tear? If yes > then maybe these counters should be converted to atomics... > > > -static void generic_online_page(struct page *page) > > +static int generic_online_page(struct page *page, unsigned int order) > > { > > - __online_page_set_limits(page); > > - __online_page_increment_counters(page); > > - __online_page_free(page); > > + unsigned long nr_pages = 1 << order; > > + struct page *p = page; > > + > > + for (loop = 0 ; loop < nr_pages ; loop++, p++) { > > + __ClearPageReserved(p); > > + set_page_count(p, 0); > > + } > > + > > + adjust_managed_page_count(page, nr_pages); > > + set_page_refcounted(page); > > + __free_pages(page, order); > > + > > + return 0; > > +} > > > > > > Regards, > > Arun > > >