Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1660173imm; Wed, 10 Oct 2018 19:52:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV60BJiFFUWjT9Ok8xNViItEpWiYt+H/r29aHuXi6iGv6WwcBhp+jo5M8brO2iAfOSAo5Amh6 X-Received: by 2002:a63:fa4e:: with SMTP id g14-v6mr32046244pgk.18.1539226336669; Wed, 10 Oct 2018 19:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539226336; cv=none; d=google.com; s=arc-20160816; b=nKNmPrbWBvVhOxBP09UkhyhyhEcR48D8m5NbT5040C3MwF2W5d9yW+AsVa5n7QZopv +OvGjEy6VmJMIIz/jMGK/0I/4f90cg+T+x6lvbCRUJuMfPrd5mpM8nfa76l6e+V2rpBl HyBmLqrHg9wnmJT40hzHzlawg+R1Matjkou2kynSMALOMiJHJdPpHG0eLCJUiZY9rdeB o+kEnLdGozwCtxrhP1/6a3WyZkXxuNlJny9CkX5WYbdDq2VNq9+A4F01UgsB5bdVyZ2K Ji/nAgm5Vl1lxbo0FhbdtAH9O//5uafKwWiRaetg0ANtka7wQaCyS3AfKgscWZyTDBLQ Yybw== 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=qKCV87xNAu0fTDANbzzfxFvtHUVZGdvXWEmgLeo9k5Q=; b=PIzUw+jywc4qn/cp0qMBV3Lw4H7Zkt3SGR8QXtbRfHDsw7k6WqiFu0En910PtVwCyo HjvDm2ZZk1g4mRP9BwIdGLnE87TRTKzpJbA3G28c5Iv5wmE8984YLXOW8JFnwiEUJR2Q M0noTBNlczmaGEunrPyl5wRc216Kck+HJxm90XhSH2DsSvFx6fg3/avELM2vPnRNfB3r Oqu9uSI/hr+VX2Ms36YzSW4ypzVPoG094N5F66Wg8Q0Bz6kV+NSeOb+QYCXdUTDlhT8g W23R0A0Bu6sUj4QXI1BbOqfuuOdgpSk7fmTuy/pya1ZEr01+NjZGRyy0EJBln4WAU+lo ghAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Li+CBxcG; dkim=pass header.i=@codeaurora.org header.s=default header.b=T+ZpZ34f; 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 e2-v6si33498640pfh.64.2018.10.10.19.52.01; Wed, 10 Oct 2018 19:52:16 -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=Li+CBxcG; dkim=pass header.i=@codeaurora.org header.s=default header.b=T+ZpZ34f; 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 S1726515AbeJKJyg (ORCPT + 99 others); Thu, 11 Oct 2018 05:54:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59896 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbeJKJyg (ORCPT ); Thu, 11 Oct 2018 05:54:36 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C31860C86; Thu, 11 Oct 2018 02:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539224974; bh=24QEhOa6b6pADby9FH9M7zyM17kAfwnL7p3AeNWQ2Do=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Li+CBxcGjseQzmCMj88IZKYZhL53E5OiVnrJJkCIej9Ai1j6hvGDV+neOXPXhDFcP kIiT0YLRBOyTNOB7hz9L+biTEmrTArSjcwvJYtsoQozvuls8lMJa7oeBhZf6ZquUat fGkLhHsOreqgZvngy8N43hYJPuDv4UxjdCTE7LBQ= 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.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED 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 49E3960C64; Thu, 11 Oct 2018 02:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539224972; bh=24QEhOa6b6pADby9FH9M7zyM17kAfwnL7p3AeNWQ2Do=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=T+ZpZ34f3qOEaokTvoxoMTF88l6DJfHiEQsQztiKuQKQau+4qyzDTIRZx2XnXhhO0 oOHj6mPHsWfWqy+lVk+GYxIDxo5PrOWrQR79YyvzOAt87wy/E8OwF1ylbIXm4buIci i5rR1EvzGPs1fiB7CuRVyRbkD06PMtv5tR3cz/6g= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 11 Oct 2018 07:59:32 +0530 From: Arun KS To: Michal Hocko Cc: Vlastimil Babka , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, boris.ostrovsky@oracle.com, jgross@suse.com, akpm@linux-foundation.org, dan.j.williams@intel.com, iamjoonsoo.kim@lge.com, gregkh@linuxfoundation.org, osalvador@suse.de, malat@debian.org, kirill.shutemov@linux.intel.com, jrdr.linux@gmail.com, yasu.isimatu@gmail.com, mgorman@techsingularity.net, aaron.lu@intel.com, devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, xen-devel@lists.xenproject.org, vatsa@codeaurora.org, vinmenon@codeaurora.org, getarunks@gmail.com Subject: Re: [PATCH v5 1/2] memory_hotplug: Free pages as higher order In-Reply-To: <20181010173334.GL5873@dhcp22.suse.cz> References: <1538727006-5727-1-git-send-email-arunks@codeaurora.org> <72215e75-6c7e-0aef-c06e-e3aba47cf806@suse.cz> <20181010173334.GL5873@dhcp22.suse.cz> Message-ID: 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 On 2018-10-10 23:03, Michal Hocko wrote: > On Wed 10-10-18 22:26:41, 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. > > Why does it matter actually? We cannot online/offline memory in > parallel. This is not the case for the boot where we initialize memory > in parallel on multiple nodes. So this seems to be safe currently > unless > I am missing something. A comment explaining that would be helpful > though. Other main callers of adjust_manage_page_count(), static inline void free_reserved_page(struct page *page) { __free_reserved_page(page); adjust_managed_page_count(page, 1); } static inline void mark_page_reserved(struct page *page) { SetPageReserved(page); adjust_managed_page_count(page, -1); } Won't they race with memory hotplug? Few more, ./drivers/xen/balloon.c:519: adjust_managed_page_count(page, -1); ./drivers/virtio/virtio_balloon.c:175: adjust_managed_page_count(page, -1); ./drivers/virtio/virtio_balloon.c:196: adjust_managed_page_count(page, 1); ./mm/hugetlb.c:2158: adjust_managed_page_count(page, 1 << h->order); Regards, Arun