Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1075313imm; Thu, 4 Oct 2018 07:51:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV60lY1VpQUZxyupgKJsM62mR1/XW1hlBM26eaz8qrwd2L6Ybm2lXQbTP0zbbQ1eXPmnlOL+h X-Received: by 2002:a63:ed55:: with SMTP id m21-v6mr6051673pgk.147.1538664702557; Thu, 04 Oct 2018 07:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538664702; cv=none; d=google.com; s=arc-20160816; b=YgKLbzJb8OvtVMfL+haYd/p4mKLBOYk5d2NAJp+pEXAMVUTNBIj4Ln0jN4pFya3g6I 0EfMQBMKEnti5IFkVf31YyrT9mo89wDQvXYdabi+BfcVIswmFfbMSq++l3FwR538RS7S IwQjq8HEDvduUCPOMgags1JJzDFndY0ZT9s6iLW/bpS2muakVPHXTdS7tqErPZUJT9Bb LDsyiE68/9578Vwm5VeydqBT8m/vlSUwYJdKY/PAVB7DanAVUatqr1Uvw1kiUuL78q/p iF7HrA5ZZGkmOmRJtSeSxldRB7t8H42OI/4eUOdP3l5Ze0f+0r8jHFO0vCqd8dW6G9pR c2cw== 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=ooS7MuxZKSr04kokbH2nXpa49taD43qQ68nciVq2HFg=; b=sjjAUq1ImCAeh2flhJj0NfUH/3zgDPIR9KIVt/ee4hCM4SdrgVm8EH8Z0+EvsFDFiQ qv57/BVyJINf35Adr4Ce//TuL6ThLB2xdQRC2Tw/3X6Eli62je7XbboG/JjDFVN7wzn7 DzF43TpqDCQ7NDfXtrVzcklpcXzMHCtEZTmEHCVGVg6heEatQU5Sd29fdnTamNVLFH/7 gYqHoy05XGucNKZ1wL0qCN4yaRBUCHI8cPAWD8rw5X9C4Ir2Sk1ejzY59E6C9VxrBgus wNNoRoY0Fm7OF1KKpKRHzMCiMlKT0cOFKCISwSI0dwbPnqJYm3/qRymk1zYMHskKkdP6 xYEw== 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 u34-v6si5161553pgn.272.2018.10.04.07.51.26; Thu, 04 Oct 2018 07:51:42 -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 S1727519AbeJDVou (ORCPT + 99 others); Thu, 4 Oct 2018 17:44:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:54774 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727293AbeJDVot (ORCPT ); Thu, 4 Oct 2018 17:44:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EB983AEA1; Thu, 4 Oct 2018 14:51:09 +0000 (UTC) Date: Thu, 4 Oct 2018 16:51:08 +0200 From: Michal Hocko To: Arun KS Cc: 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, vbabka@suse.cz, 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 v4] memory_hotplug: Free pages as higher order Message-ID: <20181004145108.GH22173@dhcp22.suse.cz> References: <1538573979-28365-1-git-send-email-arunks@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1538573979-28365-1-git-send-email-arunks@codeaurora.org> 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 Wed 03-10-18 19:09:39, Arun KS wrote: [...] > +static int online_pages_blocks(unsigned long start, unsigned long nr_pages) > +{ > + unsigned long end = start + nr_pages; > + int order, ret, onlined_pages = 0; > + > + while (start < end) { > + order = min(MAX_ORDER - 1UL, __ffs(start)); > + > + while (start + (1UL << order) > end) > + order--; this really made me scratch my head. Wouldn't it be much simpler to do the following? order = min(MAX_ORDER - 1, get_order(end - start))? > + > + ret = (*online_page_callback)(pfn_to_page(start), order); > + if (!ret) > + onlined_pages += (1UL << order); > + else if (ret > 0) > + onlined_pages += ret; > + > + start += (1UL << order); > + } > + return onlined_pages; > } [...] > -static void __init __free_pages_boot_core(struct page *page, unsigned int order) > +void __free_pages_core(struct page *page, unsigned int order) > { > unsigned int nr_pages = 1 << order; > struct page *p = page; > unsigned int loop; > > - prefetchw(p); > - for (loop = 0; loop < (nr_pages - 1); loop++, p++) { > - prefetchw(p + 1); > + for (loop = 0; loop < nr_pages; loop++, p++) { > __ClearPageReserved(p); > set_page_count(p, 0); > } > - __ClearPageReserved(p); > - set_page_count(p, 0); > > page_zone(page)->managed_pages += nr_pages; > set_page_refcounted(page); I think this is wort a separate patch as it is unrelated to the patch. -- Michal Hocko SUSE Labs