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 041CCC6FD1F for ; Tue, 26 Mar 2024 12:34:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BDB86B008A; Tue, 26 Mar 2024 08:34:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86DA46B0092; Tue, 26 Mar 2024 08:34:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 735A16B0095; Tue, 26 Mar 2024 08:34:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6076A6B008A for ; Tue, 26 Mar 2024 08:34:51 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2D7ED1A04AC for ; Tue, 26 Mar 2024 12:34:51 +0000 (UTC) X-FDA: 81939134382.06.2354FD6 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by imf30.hostedemail.com (Postfix) with ESMTP id 1701E8000C for ; Tue, 26 Mar 2024 12:34:48 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=nG6Bjz7j; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf30.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.167.174 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711456489; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yLhSmKap/8NhcrPPuisW3sLtoAISq9zwTAJR88n1HH8=; b=LSFen+a3wypQsmGLGlg8ws3/wgA08Y7AQturLY9T/PB17Xb8jIzb9PuiuHAz1iwujCB8bj Kgzy++VqLkzGd3VPktgUL6CwW2z1BzYOOzPhYpXgTXkP+2FdnjvNWMvu5FfUTzHlezrJmN Hs6/XoAcVeBpsGWEfo9Tq4ZFB7LYdFg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=nG6Bjz7j; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf30.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.167.174 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711456489; a=rsa-sha256; cv=none; b=FcZEbvHLMN3mtDDix1TJrnKZoPJHFerjzhxtsDYzPaVK5RUIKKDsTNeKh+75Bqgwp1qOeX CVkqITQKPftJ+2U+Ko6L3wm1TxywJrfoJ7NTc0N7Moah6I48tY/FCi2fe5am6RD8w10IGM LWXkUerTt21vrMhIKc/IplBBF9ii3QQ= Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3c3d3710018so864336b6e.0 for ; Tue, 26 Mar 2024 05:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1711456488; x=1712061288; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yLhSmKap/8NhcrPPuisW3sLtoAISq9zwTAJR88n1HH8=; b=nG6Bjz7je7dZf5ZQLhkuQ9Xh6F5U0XBTlREPyK/3AIH9mFCWVx16AzuR587KoZXxZa 1MjVV+c8ShPzam3mqmqbT1cIfRgWq3lK5m82LwguOQv2YcplJC/iWPN8684L6Wfe8Sm4 5yI+WS2mQQ3LaD2Q736on5lzCkBUOMjcP6CU6PzTS+npZwzSW9HzwmrSTJ4RlllSWwoW DFGZ9lG08F8fkfGi24X6P13+Nrjc+rFf3ekJ2wSWWORpoW1NB5/TerMttKsh3flPjFCP 3EzCeFrS4JBa72kW+sjIDmm1CzMIt06IuiePhK+cBpB5rsW9fIXrxB3UByG84sbVwhzk ISuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456488; x=1712061288; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yLhSmKap/8NhcrPPuisW3sLtoAISq9zwTAJR88n1HH8=; b=fzl5zYbsthNdfbzp4O8bffsFVkDj2gF+PrlYYZqzmhZgNaz9PysjmW4u5626faXvo1 0myzS2otCI2saiV2spfEEiteCIIKN5gOrNPRjd84Hq7wnSIQp57J6VwUYtuE843Hoj9w s8tRfvnU865zJ1Z9kSSFyZ+1xyyss/Eg88OGJp3Z9xVdAl90Nh9EpYbj06imw03WsXzX wtDzan9RwAH7465VJ+NOoQRfUMh1hsq5O6dXKP/0RnNVFZyTotNhyoe25HRlsOxqpQ8B 1/wtd2xibD9abzzcGz1B7EIHMkTwvbLp8iCSGAsy/pOB7GpGV2caqGleF4l6uTi8KZdS 70ng== X-Forwarded-Encrypted: i=1; AJvYcCU5y/jGTZERSoKqteMs71qtCABuKvNb73zG0KvDvLh8s2cyjgmOeDKvoYuILfOKEPzmS3ecVj4Q2aTcYU76oNAIhIU= X-Gm-Message-State: AOJu0YwYJVEP9qKlN1Yd5jPeWATX4LiIcW/WhqO5WL6uWmnn84bgfLeT +dVXzA5inrwsQt73ITAmfz+8n/c85T+Fq8hYPrpOgAIz0/kFgefGDKOvp/Q+wVg= X-Google-Smtp-Source: AGHT+IHFwjvbdUEtQgGG/iRcu/LkHH5mq23uCIK1+e4WJCT6zbP5CZMoAFleDB7POR5LXun8sTh+9A== X-Received: by 2002:a05:6808:1782:b0:3c3:d496:e5e0 with SMTP id bg2-20020a056808178200b003c3d496e5e0mr924730oib.44.1711456488019; Tue, 26 Mar 2024 05:34:48 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id fy15-20020a05622a5a0f00b00430911bac01sm3635429qtb.74.2024.03.26.05.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:47 -0700 (PDT) Date: Tue, 26 Mar 2024 08:34:42 -0400 From: Johannes Weiner To: Vlastimil Babka Cc: Andrew Morton , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/10] mm: page_alloc: fix freelist movement during block conversion Message-ID: <20240326123442.GA229434@cmpxchg.org> References: <20240320180429.678181-1-hannes@cmpxchg.org> <20240320180429.678181-7-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 1701E8000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 676sexfw5qykq9b57r88u88jkuz353mp X-HE-Tag: 1711456488-426779 X-HE-Meta: U2FsdGVkX19EvaHxSs2km4/Q3IlsO437pLRX07apMoJ0UgdO+uyMVSOm1DxAr6PR/jE53EERwq8Wrr9B6IBprvu7Lm7IGHr5FBofklQXoseiKgJ4ZiY9g4KW8S7f0/L0FjxXQfe2HAmsft5UGyuddUj3l/45g2gc2BtO3nnCSRkr6V9l9skN/VEPaEg56l0jSfkyTX/8CAUyWOAUd3ufrvb4MM+V/Fhq8U2a75Nj7cR1rrgHnwRZaPZuAIpIUnjoVv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5hu/NgzThVvEbDkIABpTR138QYV0mTyRCgLh8LRg1j9kjZ5/J32bdIPPFD8yVYylAYS0cmjLajs0CR9ad6r1qw0YWOcGGCDmf3ryVz6XPpPPzCnG25iBKuEGu645zX8TISE9YGl/OPvvQrOyAPUc1A60CtHNUIqhtkJodOPv+s2ELd/Vh7VBanbrqc0QkN9WHtBfzJoUJseQ== 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 Tue, Mar 26, 2024 at 12:28:37PM +0100, Vlastimil Babka wrote: > On 3/20/24 7:02 PM, Johannes Weiner wrote: > > Currently, page block type conversion during fallbacks, atomic > > reservations and isolation can strand various amounts of free pages on > > incorrect freelists. > > > > For example, fallback stealing moves free pages in the block to the > > new type's freelists, but then may not actually claim the block for > > that type if there aren't enough compatible pages already allocated. > > > > In all cases, free page moving might fail if the block straddles more > > than one zone, in which case no free pages are moved at all, but the > > block type is changed anyway. > > > > This is detrimental to type hygiene on the freelists. It encourages > > incompatible page mixing down the line (ask for one type, get another) > > and thus contributes to long-term fragmentation. > > > > Split the process into a proper transaction: check first if conversion > > will happen, then try to move the free pages, and only if that was > > successful convert the block to the new type. > > > > Tested-by: "Huang, Ying" > > Signed-off-by: Johannes Weiner > > Reviewed-by: Vlastimil Babka Thanks! > > /* Take ownership for orders >= pageblock_order */ > > if (current_order >= pageblock_order) { > > + del_page_from_free_list(page, zone, current_order); > > change_pageblock_range(page, current_order, start_type); > > - goto single_page; > > + expand(zone, page, order, current_order, start_type); > > + return page; > > Is the exact order here important (AFAIK shouldn't be?) or we could just > change_pageblock_range(); block_type = start_type; goto single_page? At the end of the series, the delete function will do the (type-sensitive) accounting and have a sanity check on the mt. So we have to remove the page from the list before updating the type. We *could* do it in this patch and revert it again 4 patches later, but that's likely not worth the hassle to temporarily save one line. > > single_page: > > - move_to_free_list(page, zone, current_order, start_type); > > + del_page_from_free_list(page, zone, current_order); > > + expand(zone, page, order, current_order, block_type); > > + return page; > > }