Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp921451imm; Mon, 21 May 2018 17:17:56 -0700 (PDT) X-Google-Smtp-Source: AB8JxZocT56uby6EGlgwNy2hGVIpBUZqYQtnLFqkctw0qFhC5kv1N2dpeUAx4s4kkkWObtxdMOrj X-Received: by 2002:a63:894a:: with SMTP id v71-v6mr17730072pgd.423.1526948276682; Mon, 21 May 2018 17:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526948276; cv=none; d=google.com; s=arc-20160816; b=u0OuDUiVeGKhbNo8ARRjKM2JPuFijp157Xvo5N46IShr6miYFNGC8vnC3P/r3jKyle aRdy+DHgP9nMBtqlAX+83A9a4I7J+gvmRFrSMsdgQClryacm4n0aqdXhv5zkT3pPYxFW WdAafWruxEDyh330W2SUeyKgR65dhGSEY+lT37VVFISEzLLSuOmxSKc3PDxqU91DIGE4 SmwH3l3694IreD8gGILkSyUq189u5zKV0pN+uT7voVIMVp6593DDjteSQGP+ou0k5/yu Wf/9Uv/8LowGXEUCPESZ4I4/u49V1UEeS5sbMecPJBW87ivvwoTsxY4QafTq27TiopVk go/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=C9aDnYNEIFP6Caywg0eVhrNxwjVHCPVDsHgamI5WMFc=; b=tVTE1N8rwkABynqCj+Vf+C8cTZBoPEFFNfdF0R1UHq/4slfQ98Aa0iAGVxi5tCGxas Q8lyf0D8cSSPSJKIDVLOrH5hiMyKamz971kpfpxjCo5mA+O0RqiiIZStBXazLYnpglfk WQUfVRo6WDazTFDlwlKH7qvGw9e34OF5iP4byrHO1Vq2pUHBPwWUoieo+d0K44SsCp0e bIRM0RMdAIzJWVGNkSpUWAdmLgqr4as+9OKG9ySwu6I2GLZhbPDKXbEvjCa1rKfUsgUp L0ke7eKNY6tYt1izzzzeGoFuDP9PnWc+QN8bTx7IReQkWyw3DMqsyrczdyv517Wkri8q jnjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=TWvui5I7; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15-v6si9744544pgd.421.2018.05.21.17.17.40; Mon, 21 May 2018 17:17:56 -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=@oracle.com header.s=corp-2017-10-26 header.b=TWvui5I7; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751571AbeEVAPz (ORCPT + 99 others); Mon, 21 May 2018 20:15:55 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:52704 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbeEVAPw (ORCPT ); Mon, 21 May 2018 20:15:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4M0BfvK095410; Tue, 22 May 2018 00:15:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=C9aDnYNEIFP6Caywg0eVhrNxwjVHCPVDsHgamI5WMFc=; b=TWvui5I7GGoJPMZWPGxolv0Ujj6uim9V8iSPsLo7zQI+z0oZQbCfP5ccGtU/kVFagQU9 Pp2N7qK407yZyman22W4SXbf72c+JdHQhXBThc/IfpcPttIq8QATOGxXDmhOD391wi3O HHEYSuXqKAG4s+Hps43/pPcmoG1N/pAaHy12/eCDx5yEha27uqDevE6eijIe2a931VUM GbpZn6dL2AHpPEOWR9cl6yWxwMiC7SdxhWq2QS/y3cZ5n7qmBHsQd5rHwj9pcHy7blWm TBCuOnLd0DMGHKGWOwFsuVw3Hl3oRGH+WwcgODt6f89Rxs3tNByRdGgSpX2ZyjysPdkS Rw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2j2ck9ebbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 May 2018 00:15:11 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4M0FB0v025464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 May 2018 00:15:11 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4M0F8dK001114; Tue, 22 May 2018 00:15:08 GMT Received: from [192.168.1.164] (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 May 2018 17:15:08 -0700 Subject: Re: [PATCH v2 0/4] Interface for higher order contiguous allocations To: Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Reinette Chatre , Michal Hocko , Christopher Lameter , Guy Shattah , Anshuman Khandual , Michal Nazarewicz , David Nellans , Laura Abbott , Pavel Machek , Dave Hansen , Andrew Morton References: <20180503232935.22539-1-mike.kravetz@oracle.com> <8ce9884c-36b0-68ea-45a4-06177c41af4a@suse.cz> From: Mike Kravetz Message-ID: <8c3906cf-ffd3-00fe-b690-2902fc5b4e5a@oracle.com> Date: Mon, 21 May 2018 17:15:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <8ce9884c-36b0-68ea-45a4-06177c41af4a@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8900 signatures=668700 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=951 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805220000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/21/2018 05:00 AM, Vlastimil Babka wrote: > On 05/04/2018 01:29 AM, Mike Kravetz wrote: >> Vlastimil and Michal brought up the issue of allocation alignment. The >> routine will currently align to 'nr_pages' (which is the requested size >> argument). It does this by examining and trying to allocate the first >> nr_pages aligned/nr_pages sized range. If this fails, it moves on to the >> next nr_pages aligned/nr_pages sized range until success or all potential >> ranges are exhausted. > > As I've noted in my patch 3/4 review, in fact nr_pages is first rounded > up to an order, which makes this simpler, but suboptimal. I think we > could perhaps assume that nr_pages that's a power of two should be > aligned as such, and other values of nr_pages need no alignment? This > should fit existing users, and can be extended to explicit alignment > when such user appears? I'm good with that. I do believe that minimum alignment will be pageblock size alignment (for > MAX_ORDER allocations). >> If we allow an alignment to be specified, we will >> need to potentially check all alignment aligned/nr_pages sized ranges. >> In the worst case where alignment = PAGE_SIZE, this could result in huge >> increase in the number of ranges to check. >> To help cut down on the number of ranges to check, we could identify the >> first page that causes a range allocation failure and start the next >> range at the next aligned boundary. I tried this, and we still end up >> with a huge number of ranges and wasted CPU cycles. > > I think the wasted cycle issues is due to the current code structure, > which is based on the CMA use-case, which assumes that the allocations > will succeed, because the areas are reserved and may contain only > movable allocations > > find_alloc_contig_pages() > __alloc_contig_pages_nodemask() > contig_pfn_range_valid() > - performs only very basic pfn validity and belongs-to-zone checks > alloc_contig_range() > start_isolate_page_range() > for (pfn per pageblock) - the main cycle > set_migratetype_isolate() > has_unmovable_pages() - cancel if yes > move_freepages_block() - expensive! > __alloc_contig_migrate_range() > etc (not important) > > So I think the problem is that in the main cycle we might do a number of > expensive move_freepages_block() operations, then hit a block where > has_unmovable_pages() is true, cancel and do more expensive > undo_isolate_page_range() operations. > > If we instead first scanned the range with has_unmovable_pages() and > only start doing the expensive work when we find a large enough (aligned > or not depending on caller) range, it should be much faster and there > should be no algorithmic difference between aligned and non-aligned case. Ok, I will give that a try. Thanks again for looking at these. -- Mike Kravetz