From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACE8C433E1 for ; Sun, 16 Aug 2020 12:31:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3E2D4207DA for ; Sun, 16 Aug 2020 12:31:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QcunH7/3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E2D4207DA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C81706B0002; Sun, 16 Aug 2020 08:31:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0E916B0003; Sun, 16 Aug 2020 08:31:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AACEF6B0005; Sun, 16 Aug 2020 08:31:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 927796B0002 for ; Sun, 16 Aug 2020 08:31:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 43517181AEF21 for ; Sun, 16 Aug 2020 12:31:32 +0000 (UTC) X-FDA: 77156367624.06.art49_27073012700e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 10A891003C07F for ; Sun, 16 Aug 2020 12:31:32 +0000 (UTC) X-HE-Tag: art49_27073012700e X-Filterd-Recvd-Size: 10042 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Sun, 16 Aug 2020 12:31:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597581090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=VmIH4nzxZa4zSsWGwybAap+P+9WmPMBO3cC/LBOmfJc=; b=QcunH7/3eTOl90EHuaW6hDgiYAnIYF2anSuDEKQUBvab06SiDWEvJliwAZ+qc5n6QysM/n C/zPJR2d7O05Ck4uqMxK6kLW4jf/CFr8GkkurI8e2R88+c7J1Uy3b/dQ3UylxAo1brboub qyAXu58ll68UumtLMGdxheoVXwKxrqw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-497-WFKykWGqMhyG5mE7kg4Srw-1; Sun, 16 Aug 2020 08:31:28 -0400 X-MC-Unique: WFKykWGqMhyG5mE7kg4Srw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 932F810051D3; Sun, 16 Aug 2020 12:31:26 +0000 (UTC) Received: from [10.36.112.43] (ovpn-112-43.ams2.redhat.com [10.36.112.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3248E39A75; Sun, 16 Aug 2020 12:31:23 +0000 (UTC) Subject: Re: [RFC 0/7] Support high-order page bulk allocation To: Minchan Kim , Andrew Morton Cc: linux-mm , Joonsoo Kim , Vlastimil Babka , John Dias , Suren Baghdasaryan , pullip.cho@samsung.com References: <20200814173131.2803002-1-minchan@kernel.org> From: David Hildenbrand Autocrypt: addr=david@redhat.com; prefer-encrypt=mutual; keydata= mQINBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABtCREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT6JAlgEE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v7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat GmbH Message-ID: <4e2bd095-b693-9fed-40e0-ab538ec09aaa@redhat.com> Date: Sun, 16 Aug 2020 14:31:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200814173131.2803002-1-minchan@kernel.org> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 X-Rspamd-Queue-Id: 10A891003C07F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 14.08.20 19:31, Minchan Kim wrote: > There is a need for special HW to require bulk allocation of > high-order pages. For example, 4800 * order-4 pages. >=20 > To meet the requirement, a option is using CMA area because > page allocator with compaction under memory pressure is > easily failed to meet the requirement and too slow for 4800 > times. However, CMA has also the following drawbacks: >=20 > * 4800 of order-4 * cma_alloc is too slow >=20 > To avoid the slowness, we could try to allocate 300M contiguous > memory once and then split them into order-4 chunks. > The problem of this approach is CMA allocation fails one of the > pages in those range couldn't migrate out, which happens easily > with fs write under memory pressure. Why not chose a value in between? Like try to allocate MAX_ORDER - 1 chunks and split them. That would already heavily reduce the call frequen= cy. I don't see a real need for a completely new range allocator function for this special case yet. >=20 > To solve issues, this patch introduces alloc_pages_bulk. >=20 > int alloc_pages_bulk(unsigned long start, unsigned long end, > unsigned int migratetype, gfp_t gfp_mask, > unsigned int order, unsigned int nr_elem, > struct page **pages); >=20 > It will investigate the [start, end) and migrate movable pages > out there by best effort(by upcoming patches) to make requested > order's free pages. >=20 > The allocated pages will be returned using pages parameter. > Return value represents how many of requested order pages we got. > It could be less than user requested by nr_elem. >=20 > /** > * alloc_pages_bulk() -- tries to allocate high order pages > * by batch from given range [start, end) > * @start: start PFN to allocate > * @end: one-past-the-last PFN to allocate > * @migratetype: migratetype of the underlaying pageblocks (eith= er > * #MIGRATE_MOVABLE or #MIGRATE_CMA). All pageblo= cks > * in range must have the same migratetype and it = must > * be either of the two. > * @gfp_mask: GFP mask to use during compaction > * @order: page order requested > * @nr_elem: the number of high-order pages to allocate > * @pages: page array pointer to store allocated pages (must > * have space for at least nr_elem elements) > * > * The PFN range does not have to be pageblock or MAX_ORDER_NR_PAGES > * aligned. The PFN range must belong to a single zone. > * > * Return: the number of pages allocated on success or negative error c= ode. > * The allocated pages should be freed using __free_pages > */ >=20 > The test goes order-4 * 4800 allocation(i.e., total 300MB) under kernel > build workload. System RAM size is 1.5GB and CMA is 500M. >=20 > With using CMA to allocate to 300M, ran 10 times trial, 10 time failed > with big latency(up to several seconds). >=20 > With this alloc_pages_bulk API, ran 10 time trial, 7 times are > successful to allocate 4800 times. Rest 3 times are allocated 4799, 478= 9 > and 4799. They are all done with 300ms. >=20 > This patchset is against on next-20200813 >=20 > Minchan Kim (7): > mm: page_owner: split page by order > mm: introduce split_page_by_order > mm: compaction: deal with upcoming high-order page splitting > mm: factor __alloc_contig_range out > mm: introduce alloc_pages_bulk API > mm: make alloc_pages_bulk best effort > mm/page_isolation: avoid drain_all_pages for alloc_pages_bulk >=20 > include/linux/gfp.h | 5 + > include/linux/mm.h | 2 + > include/linux/page-isolation.h | 1 + > include/linux/page_owner.h | 10 +- > mm/compaction.c | 64 +++++++---- > mm/huge_memory.c | 2 +- > mm/internal.h | 5 +- > mm/page_alloc.c | 198 ++++++++++++++++++++++++++------- > mm/page_isolation.c | 10 +- > mm/page_owner.c | 7 +- > 10 files changed, 230 insertions(+), 74 deletions(-) >=20 --=20 Thanks, David / dhildenb