From patchwork Wed Mar 20 18:02:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 13598065 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 395A1C54E58 for ; Wed, 20 Mar 2024 18:05:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8AAF6B0096; Wed, 20 Mar 2024 14:05:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D14776B0098; Wed, 20 Mar 2024 14:05:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B44166B0099; Wed, 20 Mar 2024 14:05:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 947166B0096 for ; Wed, 20 Mar 2024 14:05:01 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 668B84027D for ; Wed, 20 Mar 2024 18:05:01 +0000 (UTC) X-FDA: 81918193602.30.0777093 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf08.hostedemail.com (Postfix) with ESMTP id 64C7B160023 for ; Wed, 20 Mar 2024 18:04:59 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=VJYqKXUM; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf08.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.171 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=1710957899; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OZwAKBxwvX8Cu8VK/08SCQc15oSmFIOnYtXDnl3jEr8=; b=troAhqngdUDHVaX5Sf4ZJnCEjAFQ0EtLNiyemGJDZDwzjxjxsGNdT9eKCMrpFmkwdOtWjg YI/HhTCvajYWXtIYqZt1Tdzj3Hc0PkH3sLvFpkkhAXeyJCrGRM1YjwppdYIf/XraglrF2P aPuSwaDJraMEwvB9Yaor2hIUk8nsIT4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=VJYqKXUM; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf08.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.171 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710957899; a=rsa-sha256; cv=none; b=5ioIDeNEWNBWckNu3AwAH//Oweu3svvUBND2REIVissVe7aUW2H7X6gXY2huJ/rgVHtj8u Ee6ldt0nh1eB884dD/pQwqWhkS73RI7LKxE1XzdkKrdKhIyh5kXMAW2D24o7lDW4E3zZlj Ta2T6Y9vwFIl3wzdI1FUN/lttY6UfDg= Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-78a26803f1aso9764285a.3 for ; Wed, 20 Mar 2024 11:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1710957898; x=1711562698; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OZwAKBxwvX8Cu8VK/08SCQc15oSmFIOnYtXDnl3jEr8=; b=VJYqKXUM3Y1Hk4ZpbGt3VhJSICBmevAx1UTTAxme28v3djiHHu74wMjnMwBOIufQET EVuju1CEPAZ4QJBmnvoFcbhBAvMkokI9L/pWUAFhN2X8DJBrZo/4cPqlSB7XQz91GZgK tARtv/znttGhOKedp8DqgMQRfjScocJiquvMsU5biMp1d4u/M3TRXZjv2LgDFJhXrWb3 4G96IvUREPAesTp7kkeuiMxc1I53Yubiu1KChoKxFf0oCioTEG5W+KQWRXxrb1tLbZFH LL3iFeG0n8Si/stpXcEsHhgNWHPGOr8aIFPy+6f2/20s83gcQFGMYbhp1+BpEiveOXNB qpyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710957898; x=1711562698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OZwAKBxwvX8Cu8VK/08SCQc15oSmFIOnYtXDnl3jEr8=; b=jgrpI8P7n1Nrul1IrHnhyeTqSP+qxF8neciy/0F6pA+dCFzjhjOeWIZ8Vej5o8Dfo4 0zBEyeVHbllDyq0eSWUsloBEGho4gUHrUvVVBxIhALPC10b33LpdZCUcRsCrDmRHDT+5 TqmTxMTL02lM0NnHCOZbrZcB0q/BSKBlSHhLVNGYQIVnG6qrmzjxGC9Zv2XXRaVsgGAV wq/IjKV942fDzWgNqx2OKe9OCWmNjXV8GELfXpspSUtdvCWZPKOdurzyKppFevL5wGdE pC5wpiSjQtmRmg4CUn62ARrAULYYV7Z9EQKev4SXnZxwUPPph+VI0w4b5EZESlrDJ+jw 33nw== X-Forwarded-Encrypted: i=1; AJvYcCWUs50OkuOzAKw5m11ZDOegKsDKkHlO/W48V3FyuhHADweEX++9VsZYOE4jK0NSCKnWz8f9hnOC2F0iIv187MIlzjA= X-Gm-Message-State: AOJu0YxoQSAjrWtBFh+IwBFpso+eTtJvE6wzgxpf0+DQ9KXvcTmNjj6s aTnHfZJ7RT7OYpWE5YOWXngVfytAVcOhGVu1dvF+IdA74zb7dMcF9evnRl1VW19M2EHKE1v5fYP q X-Google-Smtp-Source: AGHT+IHMMH7iyyjW9zOuIWSxf38EdGRhEKTJ2fArhuWu3NYukGvTXw1ChW+Vsv6SLoiTkEyfuwoNTQ== X-Received: by 2002:a05:620a:821b:b0:78a:47e:282d with SMTP id ow27-20020a05620a821b00b0078a047e282dmr8998670qkn.56.1710957898421; Wed, 20 Mar 2024 11:04:58 -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 y1-20020ae9f401000000b00789ed16d039sm4402405qkl.54.2024.03.20.11.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 11:04:57 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Vlastimil Babka , Mel Gorman , Zi Yan , "Huang, Ying" , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/10] mm: page_alloc: fix move_freepages_block() range error Date: Wed, 20 Mar 2024 14:02:10 -0400 Message-ID: <20240320180429.678181-6-hannes@cmpxchg.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240320180429.678181-1-hannes@cmpxchg.org> References: <20240320180429.678181-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 64C7B160023 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kx7yk5qxi19gboiunb74zceoi1wdip5i X-HE-Tag: 1710957899-861360 X-HE-Meta: U2FsdGVkX19CI5NBYVktsGDKpvryh/o3E9h+zHIySy8kucXE1aw3lFqF1TwHVOOxExRI7sxx/h8iwoX+wTkDyITdq7xa/PykFNZl1V8fal32nVI4SZZFV3zQKDJDbjJsWJw56v4ECIEk7Kg/L1FBFAUqPK8Hbxj41NSRs0MeBO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.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When a block is partially outside the zone of the cursor page, the function cuts the range to the pivot page instead of the zone start. This can leave large parts of the block behind, which encourages incompatible page mixing down the line (ask for one type, get another), and thus long-term fragmentation. This triggers reliably on the first block in the DMA zone, whose start_pfn is 1. The block is stolen, but everything before the pivot page (which was often hundreds of pages) is left on the old list. Signed-off-by: Johannes Weiner Reviewed-by: Vlastimil Babka --- mm/page_alloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a1376a6fe7e4..7373329763e6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1645,9 +1645,15 @@ int move_freepages_block(struct zone *zone, struct page *page, start_pfn = pageblock_start_pfn(pfn); end_pfn = pageblock_end_pfn(pfn) - 1; - /* Do not cross zone boundaries */ + /* + * The caller only has the lock for @zone, don't touch ranges + * that straddle into other zones. While we could move part of + * the range that's inside the zone, this call is usually + * accompanied by other operations such as migratetype updates + * which also should be locked. + */ if (!zone_spans_pfn(zone, start_pfn)) - start_pfn = pfn; + return 0; if (!zone_spans_pfn(zone, end_pfn)) return 0;