Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1889821imm; Thu, 11 Oct 2018 01:16:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61n9GkdeheIc57zDLJgAm3Zz4CBvOrVIHX4Qr5Tprkym3cEsgBuP09o7TKdsClngfuQB73v X-Received: by 2002:a17:902:4503:: with SMTP id m3-v6mr576501pld.168.1539245768179; Thu, 11 Oct 2018 01:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539245768; cv=none; d=google.com; s=arc-20160816; b=0HS9A6ud0Ztocp9xavdgQMkuSZlOglS9xAL5+CjEOq3qUIid1MVcZomjtJ9lCjzU5C /oQT7e5UbOZ4I4CO64rDuTFO6hr5syzuQsRxw5OgHMa249dAvSmNG1Av3gfJMFE8mRvn Cgznn5nq0IYIkW77YdVV0/jWQ1O8eB/ku8ookAMaFxbPhBEJVBQ+atlubWbRi4F6gTPk UvBBiZEHitiwZC/xDB58ocx3WpeM3IofhYHywl7vi6X6+ZUG452T/fwpKOrvXJ8IVxt/ 4jiMi/WJlpvWfZpeewcpsplhKYq2Ey8WQmeRJnd4W/aP0+1+20TgxZq0d1SRQdWVUAJ4 Nl3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=38MySq9Y9drlAizbDZyZeL/nS38P0cKf9j7MJqLkFE4=; b=v4Z34Ugo7r25sMPtbTPCV9/r8UKrZHR2YknjUixEsX5fL42GXyZx/yL9IxYyz2g0ON JwcN/3ojtCY/Z5xe1W0NRp4nEzK0WBp4kAHcETC55Zv9yeqinVxMCOexmtyFPg9DZJpW oQam4nY8nute7rbfcDHTRxW4Kjjo54lCky6U6QGNCPk/RBHaBqiMgnhdKG1zQd62RrJp nKrTogjbIaHOWmgScKX8nATupTqEpYE6ZZgstkIxeXTQAebG5ldNa76yl7s86JTGEVkO VNkOp9psp4RN5ofvaE8wkhS7BkF9YPk6zhRxrmjeu0XlvdZgLSKIZqQ//V7PxAb0USVm sh8Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6-v6si27126137pfg.87.2018.10.11.01.15.53; Thu, 11 Oct 2018 01:16:08 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbeJKPVO (ORCPT + 99 others); Thu, 11 Oct 2018 11:21:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:54572 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726933AbeJKPVO (ORCPT ); Thu, 11 Oct 2018 11:21:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 334D5B136; Thu, 11 Oct 2018 07:55:06 +0000 (UTC) Date: Thu, 11 Oct 2018 09:55:03 +0200 From: Michal Hocko To: Arun KS 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 Message-ID: <20181011075503.GQ5873@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 11-10-18 07:59:32, Arun KS wrote: > 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); They can, and I have missed those. -- Michal Hocko SUSE Labs