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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3166E7717F for ; Tue, 10 Dec 2024 21:40:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A03B8D001B; Tue, 10 Dec 2024 16:40:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84FC18D0013; Tue, 10 Dec 2024 16:40:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6CA808D001B; Tue, 10 Dec 2024 16:40:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 532AF8D0013 for ; Tue, 10 Dec 2024 16:40:26 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 19D1AA0F1B for ; Tue, 10 Dec 2024 21:40:26 +0000 (UTC) X-FDA: 82880367570.13.844EB49 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 2A98FC0009 for ; Tue, 10 Dec 2024 21:39:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HhBDA0k0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733866813; a=rsa-sha256; cv=none; b=K7KllRdbZDm3vCzXD9m30nFuV50P1tYGF6Hv2/x49kA8vK9XBZYavgoJNA/566qkkfWRcR K7nOMawZAh+FyHmfTl7zns1AoF43+Yq8+bCrfF9MuMD1dkTv8K+7wLTJKQqGsJOJSn1dMy bw0Sj1joEtM+wRdYHcLRtZyNPFGr9B0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HhBDA0k0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733866813; h=from:from:sender: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:dkim-signature; bh=m/tF51eXbb5jrkuUIZarKQ2cXR84PajfTI8ZKBMgFzo=; b=k3UeTjbbjj/Jhr4TH6r/4CdHT+FGNz7DLwosniJBev0L7utV+3HRhiqJ8baH54H4iK9J/S YGoSoa7BH476JMDS/bQU7YmNm73OMaoPgBuxJ/s0k3bp/bmvRlij7qeUFZO+wgkWpGi/+M gtXf0Nzs+RD2H/HeonHyAHC5dq+KlDE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733866823; 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=m/tF51eXbb5jrkuUIZarKQ2cXR84PajfTI8ZKBMgFzo=; b=HhBDA0k0Qwx8lEsbQT7pQrGxv/nb08ioy+Y6dyRcap+CQsTCs2ZNl+UDw2/YlnkNzPPG/4 t1EOKSav+3iQVidT+oacWULJDLxeFw748otKEe96LQNDpKCv41ffall2l1dLg5sob24Ui8 4Wt4+iEtfGvxJtyetH+ulCZeqXlsq1I= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-7EFwIA5HNnOEPTrjnHh_Sg-1; Tue, 10 Dec 2024 16:40:19 -0500 X-MC-Unique: 7EFwIA5HNnOEPTrjnHh_Sg-1 X-Mimecast-MFC-AGG-ID: 7EFwIA5HNnOEPTrjnHh_Sg Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385dcae001fso2288810f8f.1 for ; Tue, 10 Dec 2024 13:40:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733866818; x=1734471618; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=m/tF51eXbb5jrkuUIZarKQ2cXR84PajfTI8ZKBMgFzo=; b=uXyelvDAbMHuYnlWExYQ/ynF2Ubf0bWnsRb7VGbJuxVvpt9Jm6Nc/XltLizNxKIjwC wkcZh+ETR3QX7J0d49KAfuoetiDGKRCJHYbTo1+8P7XxxaOelktd26gmexLohKGSQgXX ydXtdHTm9gbLFlN+sQTENszjVhyYj8epp4jqjAQyPF7XdlYZfsXnNJyiKCnyT3E9+Uvl WsvoirZ855APbzpPYGeZTJJO/fbI2zb9+MadUWI15g+zTFL+mLBJB2x1bYPlIqjUCEMG C7SOO23aedeVTy/vCfdZCVU1jOLt1R7cC2+uzN1qP6iGTnZWKdL82dcOB9wzfFd7FKEE zmZQ== X-Forwarded-Encrypted: i=1; AJvYcCX75kHCML7V3OOkXpjwx1rnlDW1TYaKPAVdoaqfkD/Ch6cA+eLf7j0Q6D25kruu2aDt9D5EVN9V4w==@kvack.org X-Gm-Message-State: AOJu0Yywivfc/zqFHec/f0yQIlpfqEZqQOD5CxwTUQui9ciwgTNB7+Tw F5uWwC5g8n7ZGwWgHAGCvUqOEUFwUfcKQoR4TuGq0P//Y2fxiKlvHw3iW7V6+zr2PgDzty8f5LD nzfxxoKczIpzzfBw+NzqRpv/WPa7uO+jnR4MQSr1hXvOaYUhC X-Gm-Gg: ASbGncsBNwM7b2qiU7G9vG7m9cLF24LpXMB35Vv3sxolnsbuQqV65oXzf/vLpDQrky7 ILMqwTbT1ux1XHzlB+W75QInY31w1FBMeKVLI9XWgbkCZHKa0+Cl9Cv6ribyY3kLWBKJV6OCrtF nr35s/9c8RcV2Fe5+k2y53KA1DVw+LO4JnxHmtOLXe2SK961iYpncXEVX2aDX5PyZLRH7g8Nlwy 9rDNmXaEihQy8MYECEJ79bPhI114gg/p1AreRzs48RdZgDyz70m1h6+wdpVIS0s7TO/94Bu1Mxk kiWHmHM= X-Received: by 2002:a05:6000:186b:b0:385:fa2e:a354 with SMTP id ffacd0b85a97d-3864cec5a37mr492065f8f.47.1733866818506; Tue, 10 Dec 2024 13:40:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqTINoip0c57ha4zf1Bq/7M87ePT7gVjq3i20nCGv67CIscyoqQFcWasYGOOy1v37ekxP3Ag== X-Received: by 2002:a05:6000:186b:b0:385:fa2e:a354 with SMTP id ffacd0b85a97d-3864cec5a37mr492054f8f.47.1733866818114; Tue, 10 Dec 2024 13:40:18 -0800 (PST) Received: from [192.168.3.141] (p5b0c61ad.dip0.t-ipconnect.de. [91.12.97.173]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-386220b071dsm16609345f8f.101.2024.12.10.13.40.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 13:40:16 -0800 (PST) Message-ID: Date: Tue, 10 Dec 2024 22:40:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] mm/page_alloc: conditionally split > pageblock_order pages in free_one_page() and move_freepages_block_isolate() To: Johannes Weiner Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Zi Yan , Vlastimil Babka , Yu Zhao References: <20241210102953.218122-1-david@redhat.com> <20241210102953.218122-2-david@redhat.com> <20241210211613.GC2508492@cmpxchg.org> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+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 B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYXZpZCBIaWxk ZW5icmFuZCA8ZGF2aWRAcmVkaGF0LmNvbT7CwZgEEwEIAEICGwMGCwkIBwMCBhUIAgkKCwQW AgMBAh4BAheAAhkBFiEEG9nKrXNcTDpGDfzKTd4Q9wD/g1oFAl8Ox4kFCRKpKXgACgkQTd4Q 9wD/g1oHcA//a6Tj7SBNjFNM1iNhWUo1lxAja0lpSodSnB2g4FCZ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Red Hat In-Reply-To: <20241210211613.GC2508492@cmpxchg.org> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ULyMS1HqhACaoTO7fqML1SayPazQmwIV1XiTdHerVM8_1733866819 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2A98FC0009 X-Stat-Signature: s5abwwh4zsfsk5m3some964bsry736ze X-HE-Tag: 1733866798-856256 X-HE-Meta: U2FsdGVkX1+lsn720kU2olLRZJahp1DxPNI4atRa7kaxsPrPyr+xL9kkYZOCZmOo1k4pNUNPl8Ob5/vnpN+wPhdhiawJx6+042kqnRMkZHl/L0upFAkEaXKTRjRFt1VuNUtO8gA6hT33vS8z+I6Z7R9vOVNQFspXZpFCMuj03D6CLcCjYJqtpt8g8qzD4Ht8FLFMsNyzPDIC8g4nPv9lWPavNYzkTSGuWkQshpuUr+c2bVkUe8BPvFLkTploub7+Ayq1ZhP9lq5iTI+lOU7wDRcKOfadWQiYHZMp3cL0ayo8xX4mTUUx4HJ5my1Gzb8diiugSTz45xTGb4wLU9a5KHyCHWTqcp+DCcN7pJzcSy6efBNck8lbRTMRh2b1MH+zmpH0L1Qc6WidRK7Qa9qcV+oONfRKgVA3hIqdupuyQyOby8OMsC/LI/QDWdEonDdhXa++Q/HmdavH3caSk/wUq7V5cxLx0VGeL8ZXMG7T6QXDKoqwEU2xQjAQPyIb98qgl9IGSOAlaThPILrFLNFAgn5DKQXhYHa2cgKkgs7vfisq9jjrX1ArwzPuTPwDdtZAWF5N6samC5u16GW3pdIVXAD++Dr/DCY5+PDEb1HP7akPMmby11XK+5KsQ63EG7KYHYOX+eUASkFeYxNpHfO6EHPMqBB/S0EtI+OHp4JaCrDjVHMvw0DnYa8z3Ov+X3UOE8Ny1YoCWJvGgpSTMg0/zHNPyfa5awH8Sh4el/uvBRtKkWrDbAgro+OCRB+xVd0DQczfwVO3B088Gg9YktKKrm50ioJdYRxZFyfl/oNVcfw1+Nfn+Qtkeog/ZOkA+B8HHDYhtkyY+b724SDS+buw44T7JT1H/oWAD5VbHNl83E5yFZtdnB6+VybCaeavOVfqb1ZczPyzR1bCWN0Ww1cu/jTeUe0FB8CYcRUaaLyMmJ1/8AJy3X+cAnUR1+rgLylFoadEkBBOHqE3R9H5gvL Sukw09Yv OpLV/Nq43IhlePTgKCOqH5lD0hvv8hOlGnuisl1/uQTyXe9Ew91XPMgZvRFI40XPiOwpU34ZlQduJfHIzFXdEKHhWuP+WJXf1Vds2LbWHLEjyiDvZ15chU/dy8cxUd8JQw5grEbnxw1zoHlnhyCIibqFKYBAS4Q07qA+njLE14vQpvwoe9vihj5Pju9kfqRaPalHs4lF5mJ+pYwCwTa7Orikeg8tyzk8z/YXQd4YNTI134rc1Au64yHxwCyKCzQ3xxOOey/jzUfWoL8PTTlyTmlrkIEj6yxoZ8AGA5+f8O6EypGsmy4g2EMs/TiYaXjUXoY9Byaahe0mXoWGsp0sCCDkqAErqTeLEkFcESk5n3NubQTY3+q0iRKcyvHBKwf2yi0UIGuPOKuoCg/agZQKXa1TMFwk3fFAJQtg935jHj13aZpKNwIkXHmxSMK19hpdBh5chp6KCy04lOlo= 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: List-Subscribe: List-Unsubscribe: On 10.12.24 22:16, Johannes Weiner wrote: > On Tue, Dec 10, 2024 at 11:29:52AM +0100, David Hildenbrand wrote: >> @@ -1225,27 +1225,53 @@ static void free_pcppages_bulk(struct zone *zone, int count, >> spin_unlock_irqrestore(&zone->lock, flags); >> } >> >> -/* Split a multi-block free page into its individual pageblocks. */ >> -static void split_large_buddy(struct zone *zone, struct page *page, >> - unsigned long pfn, int order, fpi_t fpi) >> +static bool pfnblock_migratetype_equal(unsigned long pfn, >> + unsigned long end_pfn, int mt) >> { >> - unsigned long end = pfn + (1 << order); >> + VM_WARN_ON_ONCE(!IS_ALIGNED(pfn | end_pfn, pageblock_nr_pages)); >> >> + while (pfn != end_pfn) { >> + struct page *page = pfn_to_page(pfn); >> + >> + if (unlikely(mt != get_pfnblock_migratetype(page, pfn))) >> + return false; >> + pfn += pageblock_nr_pages; >> + } >> + return true; >> +} >> + >> +static void __free_one_page_maybe_split(struct zone *zone, struct page *page, >> + unsigned long pfn, int order, fpi_t fpi_flags) >> +{ >> + const unsigned long end_pfn = pfn + (1 << order); >> + int mt = get_pfnblock_migratetype(page, pfn); >> + >> + VM_WARN_ON_ONCE(order > MAX_PAGE_ORDER); >> VM_WARN_ON_ONCE(!IS_ALIGNED(pfn, 1 << order)); >> /* Caller removed page from freelist, buddy info cleared! */ >> VM_WARN_ON_ONCE(PageBuddy(page)); >> >> - if (order > pageblock_order) >> - order = pageblock_order; >> + /* >> + * With CONFIG_MEMORY_ISOLATION, we might be freeing MAX_ORDER_NR_PAGES >> + * pages that cover pageblocks with different migratetypes; for example >> + * only some migratetypes might be MIGRATE_ISOLATE. In that (unlikely) >> + * case, fallback to freeing individual pageblocks so they get put >> + * onto the right lists. >> + */ >> + if (!IS_ENABLED(CONFIG_MEMORY_ISOLATION) || >> + likely(order <= pageblock_order) || >> + pfnblock_migratetype_equal(pfn + pageblock_nr_pages, end_pfn, mt)) { >> + __free_one_page(page, pfn, zone, order, mt, fpi_flags); >> + return; >> + } Hi Johannes, > > Ok, if memory isolation is disabled, we know the migratetypes are all > matching up, and we can skip the check. However, if memory isolation > is enabled, but this isn't move_freepages_block_isolate() calling, we > still do the check unnecessarily and slow down the boot, no? Yes, although it's on most machines one additional pageblock check (x86), on some a bit more (e.g., 3 on s390x). As mentioned: " In the future, we might want to assume that all pageblocks are equal if zone->nr_isolate_pageblock == 0; however, that will require some zone->nr_isolate_pageblock accounting changes, such that we are guaranteed to see zone->nr_isolate_pageblock != 0 when there is an isolated pageblock. " With that boot time wouldn't suffer in any significant way. > > Having a function guess the caller is a bit of an anti-pattern. The > resulting code is hard to follow, and it's very easy to > unintentionally burden some cases with unnecessary stuff. It's better > to unshare paths until you don't need conditionals like this. > > In addition to the fastpath, I think you're also punishing the > move_freepages_block_isolate() case. We *know* we just changed the > type of one of the buddy's blocks, and yet you're still checking the > the range again to decide whether to split. Yes, that's not ideal, and it would be easy to unshare that case (call the "split" function instead of a "maybe_split" function). I am not 100% sure though, if move_freepages_block_isolate() can always decide "I really have a mixture", but that code is simply quite advanced :) > > All of this to accomodate hugetlb, which might not even be compiled > in? Grrrr. Jup. But at the same time, it's frequently compiled in but never used (or barely used; I mean, how often do people actually free 1Gig hugetlb pages compared to ordinary pages). > > Like you, I was quite surprised to see that GFP_COMP patch in the > buddy hotpath splitting *everything* into blocks - on the offchance > that somebody might free a hugetlb page. Even if !CONFIG_HUGETLB. Just > - what the hell. We shouldn't merge "I only care about my niche > usecase at the expense of literally everybody else" patches like this. After talking to Willy, the whole _GFP_COMP stuff might get removed sooner or later again once we hand out frozen refcount in alloc_contig_range(). It might take a while, though. > > My vote is NAK on this patch, and a retro-NAK on the GFP_COMP patch. I won't fight for this patch *if* the GFP_COMP patch gets reverted. It improves the situation, which can be improved further. But if it doesn't get reverted, we have to think about something else. > > The buddy allocator operates on the assumption of MAX_PAGE_ORDER. If > we support folios of a larger size sourced from other allocators, then > it should be the folio layer discriminating. So if folio_put() detects > this is a massive alloc_contig chunk, then it should take a different > freeing path. Do the splitting in there, then pass valid chunks back > to the buddy. That would keep the layering cleaner and the cornercase > overhead out of the allocator fastpath. That might be better, although not that completely trivial I assume. How to handle the "MAX_PAGE_ORDER page is getting freed but one pageblock is isolated" case cleanly is a bit of a head scratcher, at least to me. But I suspect we had it fullt working before the GFF_COMP patch. -- Cheers, David / dhildenb