Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3637213imu; Mon, 14 Jan 2019 06:34:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+Z69O0G5GQZWS4Vqg7EdtlTLF9EKGbfR+sGfvyEwepnTPcOWAHFPat89UnSxfu6Iofo4f X-Received: by 2002:a62:1112:: with SMTP id z18mr25495458pfi.173.1547476460829; Mon, 14 Jan 2019 06:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547476460; cv=none; d=google.com; s=arc-20160816; b=txxB/kXah9apjICf0RPvBbtAKEm9IBJve1G4aeGaWd5gcdD+8ZmojVwNBgX3TVUMZC WSvCbhkhw4tcPu8kf1DfG/pAjo8n3HaOcFoEtmOab2xzTBxzjpM0kWUinMX65ED44PHZ UYuF+g3Mq9245fjYRgTw3q2iZFe1QJST1BwNn5Mv1ANgLaZwIaMByqWLXKDMxk69uYnB dM7ocaGFYJu7DD93FFtpDR7ouxGO2KJFrB7EUov9TXa6hgnDDN1C+/oe80+YzJuZXm6z KQreKStV/xqnrH4WkjPZAIuQEs69Rp+m973sNl9+3OnS7MIwjHxWziKTMgDtly4Djnm3 YWvQ== 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=DDbmxdZJr1tegktYwuErqH48k4UJ3AEpP/IHmW5HPGg=; b=AVXGpJBny4VDDdHd/uGGMsxklDwJOU9l/Iqdxk414IxJJu8LDMZ6X0xu2X4elGiek8 jJ4Ml9NY32/vqIhYPESkTRdGaZZ/1DKM1TZsBGvIsm5aNtnLkAz5FEOaCsf7BFhQAER2 tZe/s7jzMqVO7+fFWSoiSA8KwAphxzk5nuzPlOwLuFguwe4CgWDVu7EQNMQXzGVQrAuS 80freIe8dgnvTvNbLDqJSp7Gd/ZH5IaJcNZ/A+yj9WtKXhErZserruRVx6+PNP8wZTOF HAdtmDbVdSy4qcHOsSaH8aojkzMksLujwMVKP2ipAaKYT5h4Z0ZDg4XqJPsHq2MZ6lJU RwWA== 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 w15si449240plk.357.2019.01.14.06.34.05; Mon, 14 Jan 2019 06:34:20 -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; 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 S1726628AbfANOcx (ORCPT + 99 others); Mon, 14 Jan 2019 09:32:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:57468 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726526AbfANOcx (ORCPT ); Mon, 14 Jan 2019 09:32:53 -0500 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 3B43EAF1B; Mon, 14 Jan 2019 14:32:52 +0000 (UTC) Date: Mon, 14 Jan 2019 15:32:51 +0100 From: Michal Hocko To: Arun KS Cc: Alexander Duyck , arunks.linux@gmail.com, akpm@linux-foundation.org, vbabka@suse.cz, osalvador@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, getarunks@gmail.com Subject: Re: [PATCH v9] mm/page_alloc.c: memory_hotplug: free pages as higher order Message-ID: <20190114143251.GI21345@dhcp22.suse.cz> References: <1547098543-26452-1-git-send-email-arunks@codeaurora.org> 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 Mon 14-01-19 19:29:39, Arun KS wrote: > On 2019-01-10 21:53, Alexander Duyck wrote: [...] > > Couldn't you just do something like the following: > > if ((end - start) >= (1UL << (MAX_ORDER - 1)) > > order = MAX_ORDER - 1; > > else > > order = __fls(end - start); > > > > I would think this would save you a few steps in terms of conversions > > and such since you are already working in page frame numbers anyway so > > a block of 8 pfns would represent an order 3 page wouldn't it? > > > > Also it seems like an alternative to using "end" would be to just track > > nr_pages. Then you wouldn't have to do the "end - start" math in a few > > spots as long as you remembered to decrement nr_pages by the amount you > > increment start by. > > Thanks for that. How about this? > > static int online_pages_blocks(unsigned long start, unsigned long nr_pages) > { > unsigned long end = start + nr_pages; > int order; > > while (nr_pages) { > if (nr_pages >= (1UL << (MAX_ORDER - 1))) > order = MAX_ORDER - 1; > else > order = __fls(nr_pages); > > (*online_page_callback)(pfn_to_page(start), order); > nr_pages -= (1UL << order); > start += (1UL << order); > } > return end - start; > } I find this much less readable so if this is really a big win performance wise then make it a separate patch with some nubbers please. -- Michal Hocko SUSE Labs