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 5C83CC27C53 for ; Wed, 12 Jun 2024 07:12:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85EF6B00C4; Wed, 12 Jun 2024 03:12:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D34E38D0007; Wed, 12 Jun 2024 03:12:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFD128D0001; Wed, 12 Jun 2024 03:12:56 -0400 (EDT) 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 A01BD6B00C4 for ; Wed, 12 Jun 2024 03:12:56 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 263D11C25DD for ; Wed, 12 Jun 2024 07:12:56 +0000 (UTC) X-FDA: 82221369552.15.8A5849F Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by imf10.hostedemail.com (Postfix) with ESMTP id 679C6C0004 for ; Wed, 12 Jun 2024 07:12:54 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jf0muj0b; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718176374; 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=TMOlbMWIhtv5ZW8KP7JxP56vtG6g5t81RVE9Y7uaV7Y=; b=555Zg85pki4UBi2HLRT8xG9lth8fYS8jfSUqnHAsHP1Pd8cQaIhYzOwnJhogEAx3iQun0P 1cLjP+MGQoZKs3uD+T2wZo+FXTz0E3NfNGTp3UKIbcmN5M9ev55HKn7kDrMxrkJKZ0zWIb Nwnu4xUoz5JFwRkP5fpVyDSisqSqUds= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=jf0muj0b; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of hughd@google.com designates 209.85.128.174 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718176374; a=rsa-sha256; cv=none; b=hj5Pbx49DFY3HR4vuvteXikOKVPdHYp86l1/RM/opTg8q2zbeE1QKnapnfqbVKYc9iPKVJ ZczyYPdqHOCG/Bne/ZQfugVwDx0bPLgXS6lZHC416+t6bDanhAYJLD9M7kFnedbTnAD8mU Gs7pty20kCuZOVnuqsUn1m4uAgmG2pU= Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-62fffd5d36bso1832157b3.2 for ; Wed, 12 Jun 2024 00:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718176373; x=1718781173; darn=kvack.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=TMOlbMWIhtv5ZW8KP7JxP56vtG6g5t81RVE9Y7uaV7Y=; b=jf0muj0bDllLXoA7Iu6WkkJNZvBHFNB//PACFz8aHQMKfBJ7/OEF2z+A1U6+Uj2UBe WKmVj8mDi80cmjph0ZUvO1HxHW7gVPsF5Vv6Yx0yUyljf/w/TA9CYBhRqUJXHQKz5HeY eZFJMijQ32MZzm1b61viztHaAZulxTK5WmKHquBsdxJjPYdOVAlbLnpN0qLMm7En1qMq 7Smc7E4pJn6Jmcn3+Ubuq6JjnaebazRLO6iYgqQgzGu+CxVXStxXe1n7W360n6yIWqvn HadUr4eSY8P4wGjDcgHn4Kbd/BW7kxaSzZ/wlzVkqejUUKll2yToJkKLiUnutpMe23Sg OJzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718176373; x=1718781173; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TMOlbMWIhtv5ZW8KP7JxP56vtG6g5t81RVE9Y7uaV7Y=; b=G/KH7NdPhmPGdqiOrD4k0msjoxQ+rQzZeE6yNygFbcCzhBtJmdhny/4bipULXzL6QH PFnIDR2n+ayjzZUasGhl57JjRT6nT2wYwgCHmXjp81DCW4i0+unlRiTNoF7uqI272MNc HfY3MS/N0FIpTcAlTB3dkd13aJ4chctwb5C3FudxUKEONY1EXIaV5WRYSGo65wV/M0q8 2d1GhzvvHiN5Msmhr469TStd/bE44t5ipzZqJ9C7rBJ6Yknm5TDzXnBqlGrsQTcNXXYe gPeIE2oCuTmrPyUiaSAMB94oEUVck5bvYBTcJgkEtjnsEIQMHfiWQnZkVSS9OCD3ku+J Ybnw== X-Forwarded-Encrypted: i=1; AJvYcCXReZJGjryzmco/mWQ1sw18gsaMfM5U+WX8ECPiJULHjEIkwXwWBE9BxHWSppfBHY9EE3AGEJjcRRvHfVE132HHOdM= X-Gm-Message-State: AOJu0YwTuIJbblpkB6IU7mz/svAaGZ1IV2vCmdr7MnNVpPcceF8QYA0s 01beXeRu0Yh/ZS9kZ0vzs1+RPl0PHPVBSrLqFzjIJ0ellwogpFVJsOV8CkW/Qw== X-Google-Smtp-Source: AGHT+IH0dmFmSjBcBYJtXLX0exAkEh9EbUtyjH05fvRAz6s6k57nB3NLMTAcldBKNgeVxbCzwIVzzA== X-Received: by 2002:a81:e204:0:b0:627:e16f:ecf with SMTP id 00721157ae682-62fbc3dc394mr9487627b3.30.1718176372872; Wed, 12 Jun 2024 00:12:52 -0700 (PDT) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 00721157ae682-62d73441eafsm7464457b3.62.2024.06.12.00.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 00:12:52 -0700 (PDT) Date: Wed, 12 Jun 2024 00:11:44 -0700 (PDT) From: Hugh Dickins To: "Huang, Ying" cc: Hugh Dickins , Andrew Morton , Zi Yan , Baolin Wang , David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH hotfix] mm/migrate: fix kernel BUG at mm/compaction.c:2761! In-Reply-To: <87msnq7key.fsf@yhuang6-desk2.ccr.corp.intel.com> Message-ID: References: <46c948b4-4dd8-6e03-4c7b-ce4e81cfa536@google.com> <87msnq7key.fsf@yhuang6-desk2.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 679C6C0004 X-Stat-Signature: izditrz969yy49mta34ic78cghu77qn9 X-Rspam-User: X-HE-Tag: 1718176374-106885 X-HE-Meta: U2FsdGVkX1+IKW0xCsBjuqDQMwTqWdO2/9s0z4y+uVRK2i7oYL+6UB0pu07wVpkUVyW1w90096Il0zXfd5Brcun23FPCHvkR+YvzSfN778yaVniQg31+eqIs+Lc6rcrEeqWdV3+buvyGKqKaSmrqqpPd4Rwnd6l5oEDvoq5sYfqgbVMbuEDKg2w+uwAy7/cFDl6lv+4VinbWefN7UcQXQZmrAatubhpqDpLucn8gzO6cOwtbI1yxBkHJO+lDjPyu3UNkw3GykTpsidlnt3jLaECzAqHGhuBRhDyN5fyzEhjM7xCJLvUKw5GpAfFPE5G7V6fV4cxTYE9BeqBmRz8DlBB/uEifN4IlUhuzvdhcjsV1d/GHLHCRaYCq46MaQ5aAGp/mz5ycbvdMMcTWYdOAqyoNzcC0ZXwSYFv9Hog7oq7ySodmR6zQQZcN+reZsHhNJeaP22gSbAjiuqpInjHFRAPLWA7UxZvYGbz33vjKYx5zq30gcjP87P5k4BwrZVWfSjEnHXU9UHLrpz3KUUOr8nvKs1S/KyI8ltQszy4BKZ9mj+kpgatFRDiJrZnRzGM0sikIUJJqajF9dWEWw3DpsjdeXXZOWbide2WDzNvHm7CKfKNghDc230wLXe3N95UV8gYGfM91aiTnrPm44l+akOObilt9CEDnRN6ansnXLPBfJ6Rp40qDTW/o+11oU+nr/8Kw60CwJObjc4Nc5rB4DOP7IpufEFIHcJ5P9nSEkFQ7YUV4pVvG+06UyRxU3vtqQRQZ0cItt3IbHZ32ahyFDNUVV7Wn8sDfy2fDijIJMrgDr3Yh2MJdFk8a9AhjWnV2LOYeXtyajvvL6oJGCViq/CLYDkHGx3e/o5j89i/qdYpu0s88e0NhQK79PYLEElCdcDQE1KibWDrJchPExOJzLl2IBM27KM6NU61Vq3vvmAmBLQEpUarEZDHzfdPAnPJgS11NjilFI479OfSl8S1 bZc6Mq2e yGN2V+gXlk1j7og35kvrorvvluJXNC6DDhmsGKdMbPDPMcw2KR/DECp022BaHEfM96S5ojme+BoJmKAzSyg5oGC0lZzOKiubkZrY6tizzmR6x8+DvDUpgbseQKYSrU9WBGblRcz/bseQMDPvqsI9KrRUdiHpX+sxUQWmUYUtQDWs9QTUjDXDufyQ14RaKkUKAYlTMuwCYaCcvqzURPz3c4Q4OlQjzhj5eXl4NAvSRvKnsv4GKnCw1E81MoW/4SO6L0RPpklWL44goEo8InmOPi7A69ry0FMXDR0xI/9oaFvxnwwjHIl6KlR47Zj6UzoPkNyIgUqcuDpZIwO6qN/+s83ZQrA== 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 Wed, 12 Jun 2024, Huang, Ying wrote: > Hugh Dickins writes: > > > I hit the VM_BUG_ON(!list_empty(&cc->migratepages)) in compact_zone(); > > and if DEBUG_VM were off, then pages would be lost on a local list. > > > > Our convention is that if migrate_pages() reports complete success (0), > > then the migratepages list will be empty; but if it reports an error or > > some pages remaining, then its caller must putback_movable_pages(). > > > > There's a new case in which migrate_pages() has been reporting complete > > success, but returning with pages left on the migratepages list: when > > migrate_pages_batch() successfully split a folio on the deferred list, > > but then the "Failure isn't counted" call does not dispose of them all. > > > > Since that block is expecting the large folio to have been counted as 1 > > failure already, and since the return code is later adjusted to success > > whenever the returned list is found empty, the simple way to fix this > > safely is to count splitting the deferred folio as "a failure". > > > > Fixes: 7262f208ca68 ("mm/migrate: split source folio if it is on deferred split list") > > Signed-off-by: Hugh Dickins > > --- > > A hotfix to 6.10-rc, not needed for stable. > > > > mm/migrate.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > --- a/mm/migrate.c > > +++ b/mm/migrate.c > > @@ -1654,7 +1654,12 @@ static int migrate_pages_batch(struct list_head *from, > > > > /* > > * The rare folio on the deferred split list should > > - * be split now. It should not count as a failure. > > + * be split now. It should not count as a failure: > > + * but increment nr_failed because, without doing so, > > + * migrate_pages() may report success with (split but > > + * unmigrated) pages still on its fromlist; whereas it > > + * always reports success when its fromlist is empty. > > + * > > * Only check it without removing it from the list. > > * Since the folio can be on deferred_split_scan() > > * local list and removing it can cause the local list > > @@ -1669,6 +1674,7 @@ static int migrate_pages_batch(struct list_head *from, > > if (nr_pages > 2 && > > !list_empty(&folio->_deferred_list)) { > > if (try_split_folio(folio, split_folios) == 0) { > > + nr_failed++; > > It appears better to add > > stats->nr_thp_failed++; > > too. Otherwise, if migrate_pages_batch() is called via migrate_pages(, > MIGRATE_ASYNC, ), nr_thp_failed will not increase. But if > migrate_pages_batch() is called via migrate_pages(, MIGRATE_SYNC*, ), > nr_thp_failed will increase in migrate_pages_sync() via > > stats->nr_thp_failed += astats.nr_thp_split; > > That is, they are not consistent. The issue exists since commit > 7262f208ca68 ("mm/migrate: split source folio if it is on deferred split > list"). Sorry, I'll have to let you take over and send your own patch instead of mine - thanks. Those stats, and any attempt at consistency there, is way beyond me! I thought consistency was impossible, unless all the numbers were changed to order-0 counts. Hugh > > Otherwise, this looks good to me. Thanks! > > > stats->nr_thp_split += is_thp; > > stats->nr_split++; > > continue; > > -- > Best Regards, > Huang, Ying