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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BD3EC433EF for ; Fri, 10 Dec 2021 07:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235184AbhLJHdx (ORCPT ); Fri, 10 Dec 2021 02:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237609AbhLJHds (ORCPT ); Fri, 10 Dec 2021 02:33:48 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED7C2C0617A1 for ; Thu, 9 Dec 2021 23:30:13 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id u17so5690987plg.9 for ; Thu, 09 Dec 2021 23:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=gqnhaZdO12ibnFTEUYTRcyNDsVi4fZjKWuF1d+1IX2QtK+zXEl/CleEzgCXcZCKWk4 DeGXeYahXgF25toJDTBvItitvosjjzyrdtCOfzBPXJUv2sNA46FGCrVbWvzev5Gqa7Ak meZ3c5sCNkdjOENTF0nlgXWFhqmZAwIOkT71xtM4OT2BCJb5l3qSGmgij0kaSHc39jlT lz+NQj74lZEDNXhnwDnJm6MBPftfgIEvxzLs37o6722DhjM05TgsyYdxT05vxKbTRo5c paO1XE+hWA5qYswHrUze+qL1vRsNsy/KmrR7y+w/OwTPs4iJXL+3vAPXn7Z6f5NDhlEr bj6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=1ySWgSFWf84ELVLo962qv15ExN3oacj9ojHXRKqRNkEYrXTSrQC9wKo+BSYju9eF/U s+5QO9OM2beCGgV3H2V3mF+JCG9kLFlxewhUyNhPrK7GFZnKmZk9WpA6pTtDERlnaoYE R5YSMIeB45RXqm6Mxy18hpUWK8L3dDUUw7dVLIyvS0LnixPsTW0Fu3BzMoQpxpEAHhF3 AISAGKQb28GZ4B0nhMu4mIPKlKK1yYObElyjKvvttvqdrPCOFLV5gaLw9bMfhs1LH6PB AwQtvmlNvu8W08nWYi7h3T+rJZsDa3h9RWFnhEqXCJBRgL+he/fRA4SDwgun8ZUialsZ IzQg== X-Gm-Message-State: AOAM532SJ2t17rWa4Hp79S8n87x8hfzcq+TFhze7PW/Ajlb2pYShux3Q quy5ssC/cic/MwgO2TfEHrc= X-Google-Smtp-Source: ABdhPJxRm9ttF7FhbBeprnb6+zsZD1lD+fI51oOUlTadE/AU/yNXP9DA3iOR8FWZWbadxSA9RFDXLw== X-Received: by 2002:a17:902:f687:b0:141:cf6b:fee7 with SMTP id l7-20020a170902f68700b00141cf6bfee7mr71919578plg.75.1639121413466; Thu, 09 Dec 2021 23:30:13 -0800 (PST) Received: from [30.240.98.4] ([205.204.117.108]) by smtp.gmail.com with ESMTPSA id c17sm185764pfc.163.2021.12.09.23.30.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 23:30:13 -0800 (PST) Message-ID: <07f11dfc-f491-3b08-a2cb-3c8f5a8102d3@gmail.com> Date: Fri, 10 Dec 2021 15:30:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [RFC PATCH v2 0/7] Use pageblock_order for cma and alloc_contig_range alignment. To: Zi Yan , David Hildenbrand , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman , Christoph Hellwig , Marek Szyprowski , Robin Murphy , linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, iommu@lists.linux-foundation.org, Vlastimil Babka , Mel Gorman References: <20211209230414.2766515-1-zi.yan@sent.com> From: Eric Ren In-Reply-To: <20211209230414.2766515-1-zi.yan@sent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Zi Yan, On 2021/12/10 07:04, Zi Yan wrote: > From: Zi Yan > > Hi all, > > This patchset tries to remove the MAX_ORDER - 1 alignment requirement for CMA > and alloc_contig_range(). It prepares for my upcoming changes to make MAX_ORDER > adjustable at boot time[1]. > > The MAX_ORDER - 1 alignment requirement comes from that alloc_contig_range() > isolates pageblocks to remove free memory from buddy allocator but isolating > only a subset of pageblocks within a page spanning across multiple pageblocks > causes free page accounting issues. Isolated page might not be put into the > right free list, since the code assumes the migratetype of the first pageblock > as the whole free page migratetype. This is based on the discussion at [2]. > > To remove the requirement, this patchset: > 1. still isolates pageblocks at MAX_ORDER - 1 granularity; Then, unplug fails if either pageblock of theĀ  MAX_ORDER - 1 page has unmovable page, right? Thanks, Eric > 2. but saves the pageblock migratetypes outside the specified range of > alloc_contig_range() and restores them after all pages within the range > become free after __alloc_contig_migrate_range(); > 3. splits free pages spanning multiple pageblocks at the beginning and the end > of the range and puts the split pages to the right migratetype free lists > based on the pageblock migratetypes; > 4. returns pages not in the range as it did before this patch. > > Isolation needs to happen at MAX_ORDER - 1 granularity, because otherwise > 1) extra code is needed to detect pages (free, PageHuge, THP, or PageCompound) > to make sure all pageblocks belonging to a single page are isolated together > and later pageblocks outside the range need to have their migratetypes restored; > or 2) extra logic will need to be added during page free time to split a free > page with multi-migratetype pageblocks. > > Two optimizations might come later: > 1. only check unmovable pages within the range instead of MAX_ORDER - 1 aligned > range during isolation to increase successful rate of alloc_contig_range(). > 2. make MIGRATE_ISOLATE a separate bit to avoid saving and restoring existing > migratetypes before and after isolation respectively. > > Feel free to give comments and suggestions. Thanks. > > > [1] https://lore.kernel.org/linux-mm/20210805190253.2795604-1-zi.yan@sent.com/ > [2] https://lore.kernel.org/linux-mm/d19fb078-cb9b-f60f-e310-fdeea1b947d2@redhat.com/ > > > Zi Yan (7): > mm: page_alloc: avoid merging non-fallbackable pageblocks with others. > mm: compaction: handle non-lru compound pages properly in > isolate_migratepages_block(). > mm: migrate: allocate the right size of non hugetlb or THP compound > pages. > mm: make alloc_contig_range work at pageblock granularity > mm: cma: use pageblock_order as the single alignment > drivers: virtio_mem: use pageblock size as the minimum virtio_mem > size. > arch: powerpc: adjust fadump alignment to be pageblock aligned. > > arch/powerpc/include/asm/fadump-internal.h | 4 +- > drivers/virtio/virtio_mem.c | 6 +- > include/linux/mmzone.h | 11 +- > kernel/dma/contiguous.c | 2 +- > mm/cma.c | 6 +- > mm/compaction.c | 10 +- > mm/migrate.c | 8 +- > mm/page_alloc.c | 203 +++++++++++++++++---- > 8 files changed, 196 insertions(+), 54 deletions(-) > 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 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45ACAC433FE for ; Sat, 11 Dec 2021 14:57:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E1B8240441; Sat, 11 Dec 2021 14:57:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0TJlzC4JzQph; Sat, 11 Dec 2021 14:57:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id A224340012; Sat, 11 Dec 2021 14:57:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 85F1EC002F; Sat, 11 Dec 2021 14:57:44 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 25F96C0012; Fri, 10 Dec 2021 07:30:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1296961399; Fri, 10 Dec 2021 07:30:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9P5jQyU7bJ3X; Fri, 10 Dec 2021 07:30:14 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2786A61120; Fri, 10 Dec 2021 07:30:14 +0000 (UTC) Received: by mail-pj1-x1035.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso6859748pjb.0; Thu, 09 Dec 2021 23:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=gqnhaZdO12ibnFTEUYTRcyNDsVi4fZjKWuF1d+1IX2QtK+zXEl/CleEzgCXcZCKWk4 DeGXeYahXgF25toJDTBvItitvosjjzyrdtCOfzBPXJUv2sNA46FGCrVbWvzev5Gqa7Ak meZ3c5sCNkdjOENTF0nlgXWFhqmZAwIOkT71xtM4OT2BCJb5l3qSGmgij0kaSHc39jlT lz+NQj74lZEDNXhnwDnJm6MBPftfgIEvxzLs37o6722DhjM05TgsyYdxT05vxKbTRo5c paO1XE+hWA5qYswHrUze+qL1vRsNsy/KmrR7y+w/OwTPs4iJXL+3vAPXn7Z6f5NDhlEr bj6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=BUxoOEOquksKUBrgSHmPgb/FI+QCIKUYki7HLvCKuD0xa9vShJlMc0+kJrqAOkj+rk MXd7DLP2PCImoSm839KX7CbLC/Rb2ajLewpQ9zIwwoXP2OGukdYrOgAl2CCe8E1iUbZu OWjRunrNydTck0+BLPsXQWJrir6f5Mm+GE+FTv+aOwl6G+12jkUNencTcwGiIpMZMsLU 837eX8N6YR7Zt5AaTZrYCBFha3V4ejVShK440vCfiPI67+6nzPmhRd1QFa7ShNHlSIlB 6RBE4zkXVpQBdas740Lr9d2TDhSv2EHZA9KLFZAesiypbELOKdxx9MC0fUBgUSm+l+x1 vfnw== X-Gm-Message-State: AOAM5332vobu7K+TzvOyp15vpJBucm+aOn/3ygdw5E1f4x8wNzFApj3w ZwfUixtqWNqOU63hQX4TKbM= X-Google-Smtp-Source: ABdhPJxRm9ttF7FhbBeprnb6+zsZD1lD+fI51oOUlTadE/AU/yNXP9DA3iOR8FWZWbadxSA9RFDXLw== X-Received: by 2002:a17:902:f687:b0:141:cf6b:fee7 with SMTP id l7-20020a170902f68700b00141cf6bfee7mr71919578plg.75.1639121413466; Thu, 09 Dec 2021 23:30:13 -0800 (PST) Received: from [30.240.98.4] ([205.204.117.108]) by smtp.gmail.com with ESMTPSA id c17sm185764pfc.163.2021.12.09.23.30.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 23:30:13 -0800 (PST) Message-ID: <07f11dfc-f491-3b08-a2cb-3c8f5a8102d3@gmail.com> Date: Fri, 10 Dec 2021 15:30:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [RFC PATCH v2 0/7] Use pageblock_order for cma and alloc_contig_range alignment. To: Zi Yan , David Hildenbrand , linux-mm@kvack.org References: <20211209230414.2766515-1-zi.yan@sent.com> From: Eric Ren In-Reply-To: <20211209230414.2766515-1-zi.yan@sent.com> X-Mailman-Approved-At: Sat, 11 Dec 2021 14:57:43 +0000 Cc: Mel Gorman , Michael Ellerman , Robin Murphy , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, Christoph Hellwig , Vlastimil Babka X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" SGkgWmkgWWFuLAoKT24gMjAyMS8xMi8xMCAwNzowNCwgWmkgWWFuIHdyb3RlOgo+IEZyb206IFpp IFlhbiA8eml5QG52aWRpYS5jb20+Cj4KPiBIaSBhbG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vY29udGlndW91cy5jICAgICAgICAgICAgICAgICAgICB8ICAgMiAr LQo+ICAgbW0vY21hLmMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICA2ICst Cj4gICBtbS9jb21wYWN0aW9uLmMgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgMTAgKy0K PiAgIG1tL21pZ3JhdGUuYyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgOCArLQo+ ICAgbW0vcGFnZV9hbGxvYy5jICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMjAzICsrKysr KysrKysrKysrKysrLS0tLQo+ICAgOCBmaWxlcyBjaGFuZ2VkLCAxOTYgaW5zZXJ0aW9ucygrKSwg NTQgZGVsZXRpb25zKC0pCj4KCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fCmlvbW11IG1haWxpbmcgbGlzdAppb21tdUBsaXN0cy5saW51eC1mb3VuZGF0aW9u Lm9yZwpodHRwczovL2xpc3RzLmxpbnV4Zm91bmRhdGlvbi5vcmcvbWFpbG1hbi9saXN0aW5mby9p b21tdQ== 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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 972D5C433F5 for ; Sun, 12 Dec 2021 22:48:17 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JC0Cz6PRqz2yY0 for ; Mon, 13 Dec 2021 09:48:15 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=gqnhaZdO; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::632; helo=mail-pl1-x632.google.com; envelope-from=renzhengeek@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=gqnhaZdO; dkim-atps=neutral Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4J9Mxm0l3Hz2xsX for ; Fri, 10 Dec 2021 18:30:17 +1100 (AEDT) Received: by mail-pl1-x632.google.com with SMTP id y8so5723984plg.1 for ; Thu, 09 Dec 2021 23:30:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:to:cc:references :from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=gqnhaZdO12ibnFTEUYTRcyNDsVi4fZjKWuF1d+1IX2QtK+zXEl/CleEzgCXcZCKWk4 DeGXeYahXgF25toJDTBvItitvosjjzyrdtCOfzBPXJUv2sNA46FGCrVbWvzev5Gqa7Ak meZ3c5sCNkdjOENTF0nlgXWFhqmZAwIOkT71xtM4OT2BCJb5l3qSGmgij0kaSHc39jlT lz+NQj74lZEDNXhnwDnJm6MBPftfgIEvxzLs37o6722DhjM05TgsyYdxT05vxKbTRo5c paO1XE+hWA5qYswHrUze+qL1vRsNsy/KmrR7y+w/OwTPs4iJXL+3vAPXn7Z6f5NDhlEr bj6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :to:cc:references:from:in-reply-to:content-transfer-encoding; bh=kqdwZyEU31KaNW+cOFp1dor6RRAOvhH6zrtcJuFenfA=; b=2FD4E9wwKMpuIcr6YzuoYA6fcEUAEysI9TdQiRXDcXyWc45NZC4bEU9nHr06E1C3i3 cr/HCdwejLlJgyVe/sEuZriRoBPQM524vYHrbQ2StrXAym/V7AOR/y7dGgJ7wDvCHUrn xScuB6Sbu4XSjInBj1TGf3fx32vYpIsPwe97/8C1KnpBaRDMySZMZoAnBlSgirQHJbbC eoBo5qmxq/VAKe8XTMpMeiVDKkACLpHIR0yOBht9PWMDg1rwA6uJRYWjWmMiq/7YtgGZ Ewryzt+WW1lZXo1S4Rmjs/kOu1z6HV6l9FJPx79guq1o5XvL5dUx+K9DCpp6w7jGt0+Y crbw== X-Gm-Message-State: AOAM533Al+/pDZcNexPu9LC6B90RmYns+eisVnJ4lBhZNs+1diBVrIq/ hW+YkUO6wtD8qL3PZGL3t48= X-Google-Smtp-Source: ABdhPJxRm9ttF7FhbBeprnb6+zsZD1lD+fI51oOUlTadE/AU/yNXP9DA3iOR8FWZWbadxSA9RFDXLw== X-Received: by 2002:a17:902:f687:b0:141:cf6b:fee7 with SMTP id l7-20020a170902f68700b00141cf6bfee7mr71919578plg.75.1639121413466; Thu, 09 Dec 2021 23:30:13 -0800 (PST) Received: from [30.240.98.4] ([205.204.117.108]) by smtp.gmail.com with ESMTPSA id c17sm185764pfc.163.2021.12.09.23.30.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 23:30:13 -0800 (PST) Message-ID: <07f11dfc-f491-3b08-a2cb-3c8f5a8102d3@gmail.com> Date: Fri, 10 Dec 2021 15:30:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [RFC PATCH v2 0/7] Use pageblock_order for cma and alloc_contig_range alignment. To: Zi Yan , David Hildenbrand , linux-mm@kvack.org References: <20211209230414.2766515-1-zi.yan@sent.com> From: Eric Ren In-Reply-To: <20211209230414.2766515-1-zi.yan@sent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 13 Dec 2021 09:47:48 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mel Gorman , Robin Murphy , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linuxppc-dev@lists.ozlabs.org, Christoph Hellwig , Vlastimil Babka , Marek Szyprowski Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi Zi Yan, On 2021/12/10 07:04, Zi Yan wrote: > From: Zi Yan > > Hi all, > > This patchset tries to remove the MAX_ORDER - 1 alignment requirement for CMA > and alloc_contig_range(). It prepares for my upcoming changes to make MAX_ORDER > adjustable at boot time[1]. > > The MAX_ORDER - 1 alignment requirement comes from that alloc_contig_range() > isolates pageblocks to remove free memory from buddy allocator but isolating > only a subset of pageblocks within a page spanning across multiple pageblocks > causes free page accounting issues. Isolated page might not be put into the > right free list, since the code assumes the migratetype of the first pageblock > as the whole free page migratetype. This is based on the discussion at [2]. > > To remove the requirement, this patchset: > 1. still isolates pageblocks at MAX_ORDER - 1 granularity; Then, unplug fails if either pageblock of theĀ  MAX_ORDER - 1 page has unmovable page, right? Thanks, Eric > 2. but saves the pageblock migratetypes outside the specified range of > alloc_contig_range() and restores them after all pages within the range > become free after __alloc_contig_migrate_range(); > 3. splits free pages spanning multiple pageblocks at the beginning and the end > of the range and puts the split pages to the right migratetype free lists > based on the pageblock migratetypes; > 4. returns pages not in the range as it did before this patch. > > Isolation needs to happen at MAX_ORDER - 1 granularity, because otherwise > 1) extra code is needed to detect pages (free, PageHuge, THP, or PageCompound) > to make sure all pageblocks belonging to a single page are isolated together > and later pageblocks outside the range need to have their migratetypes restored; > or 2) extra logic will need to be added during page free time to split a free > page with multi-migratetype pageblocks. > > Two optimizations might come later: > 1. only check unmovable pages within the range instead of MAX_ORDER - 1 aligned > range during isolation to increase successful rate of alloc_contig_range(). > 2. make MIGRATE_ISOLATE a separate bit to avoid saving and restoring existing > migratetypes before and after isolation respectively. > > Feel free to give comments and suggestions. Thanks. > > > [1] https://lore.kernel.org/linux-mm/20210805190253.2795604-1-zi.yan@sent.com/ > [2] https://lore.kernel.org/linux-mm/d19fb078-cb9b-f60f-e310-fdeea1b947d2@redhat.com/ > > > Zi Yan (7): > mm: page_alloc: avoid merging non-fallbackable pageblocks with others. > mm: compaction: handle non-lru compound pages properly in > isolate_migratepages_block(). > mm: migrate: allocate the right size of non hugetlb or THP compound > pages. > mm: make alloc_contig_range work at pageblock granularity > mm: cma: use pageblock_order as the single alignment > drivers: virtio_mem: use pageblock size as the minimum virtio_mem > size. > arch: powerpc: adjust fadump alignment to be pageblock aligned. > > arch/powerpc/include/asm/fadump-internal.h | 4 +- > drivers/virtio/virtio_mem.c | 6 +- > include/linux/mmzone.h | 11 +- > kernel/dma/contiguous.c | 2 +- > mm/cma.c | 6 +- > mm/compaction.c | 10 +- > mm/migrate.c | 8 +- > mm/page_alloc.c | 203 +++++++++++++++++---- > 8 files changed, 196 insertions(+), 54 deletions(-) >