Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1388981lqj; Mon, 3 Jun 2024 22:53:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVq8rG3VbdhS2NBzDq50fNwujZket69m4BbnBJWXnVKDu5JNwPnMt+HArZ2h9HlTXWo/urtSKDEc8gCZSWuH0spW+5qd21sMxYKJyKDtA== X-Google-Smtp-Source: AGHT+IG06hzpH0NihI51yQ4jsED6gxHoH+l/ePR1oTi+yXumA2/KzVC47z7OZomEZr7r5b5Ezo2b X-Received: by 2002:a0c:fb08:0:b0:6ae:d383:d706 with SMTP id 6a1803df08f44-6aed383d727mr106528326d6.62.1717480416607; Mon, 03 Jun 2024 22:53:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717480416; cv=pass; d=google.com; s=arc-20160816; b=c295g0V1Ne/lXkvogQYJS4uNj+xbIK0bvF88J6nVTBvglIKB0fk42Lgsv5WauC03gT 2bor1TUTeB/2n7GwwLBfyX+kxDR/hDOALO9KmA23sq32+7Tb1YZY/L/6lEUeOAR/p7N7 aJkeoBjkH5858e6UL038DnwtKOhoe5Yr61v7MB8bGUQsA/E86tamFBTXHrX6xldFJPot Nwx8ZAE2SB/HCo/B5oRbs21DRI3C7GT4pZC9Rao4P8sABRzuaEMuhy2v8geM5KMkV61n SxunLQFyuhz5wooygX5XBoxyVa9NfMguYr/R1Q3xFxJVw8o8dTVp2AWfmeBmIl9AZp8u lR6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date; bh=U2EBXtbIigci+9bdY/33CLPYAzBTLHKvUNqD9wGPnMg=; fh=wbCiaQG9tWWlppC7PQR7iYQSZLbXXvLWhBfgyYtVuws=; b=tsOQToZq7FiitusLzypxtrABRdAH80y5uQBuVxxoD4Et+0X0p6BFto1PS61SjTFpgm 968AXTt2CrXnV9a8FsC+iLaQhGOS6ZN6XL03pvD2/Bz/5RgxuofsGEMFTFyYQVQgA6LL WzfMYBO6t+3GhLF5EAgaGHcmWv3KKhOQ+8fSVDWqepDG/jUESrfcx+eU4drgaBu4WlK3 itluole/ykhmnB+peORpiWle0EpSwxj0fiz72bJuvxcAhMkVFmB7S5wdWLOvmmvJ6twg MtAtoaemdHK7tCsvHLn9JedeBk0qV97urOOnokmzCPaHISCgQqDjX/DESnVHL65ogLjm +Mpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=zte.com.cn dmarc=pass fromdomain=zte.com.cn); spf=pass (google.com: domain of linux-kernel+bounces-200075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4a742049si14931666d6.133.2024.06.03.22.53.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 22:53:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=zte.com.cn dmarc=pass fromdomain=zte.com.cn); spf=pass (google.com: domain of linux-kernel+bounces-200075-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 57E7E1C21BE2 for ; Tue, 4 Jun 2024 05:53:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FAF813DDA6; Tue, 4 Jun 2024 05:53:28 +0000 (UTC) Received: from mxct.zte.com.cn (mxct.zte.com.cn [58.251.27.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C899199BC for ; Tue, 4 Jun 2024 05:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=58.251.27.85 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717480408; cv=none; b=h76D13KE+YGWV+F7ZnKtHyMzUSjgtIpMf/zk9SV+Ch1zU4HSVCkatyv78NH8z0bTk2th2iHk1Q97sj/6Ht2axzAk0qI0KY5ReLVtqkUbud5ZIZpvYgcIVHD4DIeircou54Ds6cIWFOOBmo+/SeNsZH7LDk0yUEKg+v6m3gD31EY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717480408; c=relaxed/simple; bh=IoB/yV/6K+QghVV3rsD9UF32nbZm90OaPHf1zCxHcuM=; h=Date:Message-ID:Mime-Version:From:To:Cc:Subject:Content-Type; b=pj0+scUvNJ2xJhe8t3BS3HeJRdPFtFOVXVh8IHSRM5MiQAOEMBFpuRrgfc+MwzBZxGKurUeA/p414b/WQimnUE8jLlzUxjlRU//elH7oLU6vhGlJW7FCfpF9TPilk36q8PsFUDf5Y+NvCBzcbK7kL0tw70LV3irOTJPbbFgi0XY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn; spf=pass smtp.mailfrom=zte.com.cn; arc=none smtp.client-ip=58.251.27.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zte.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zte.com.cn Received: from mxde.zte.com.cn (unknown [10.35.20.165]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4Vtfl34DhpzKhm for ; Tue, 4 Jun 2024 13:47:59 +0800 (CST) Received: from mxhk.zte.com.cn (unknown [192.168.250.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxde.zte.com.cn (FangMail) with ESMTPS id 4Vtfkw4tx9z5TCG9 for ; Tue, 4 Jun 2024 13:47:52 +0800 (CST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4Vtfkl3JFsz5R9kD; Tue, 4 Jun 2024 13:47:43 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl2.zte.com.cn with SMTP id 4545laZs009782; Tue, 4 Jun 2024 13:47:36 +0800 (+08) (envelope-from xu.xin16@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid32; Tue, 4 Jun 2024 13:47:38 +0800 (CST) Date: Tue, 4 Jun 2024 13:47:38 +0800 (CST) X-Zmail-TransId: 2af9665eaa7a03e-7c67f X-Mailer: Zmail v1.0 Message-ID: <20240604134738264WKaKYb3q_YTE32hNAy2lz@zte.com.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 From: To: , Cc: , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG1tOiBodWdlX21lbW9yeTogZml4IG1pc3VzZWQgbWFwcGluZ19sYXJnZV9mb2xpb19zdXBwb3J0KCnCoGZvciBhbm9uIGZvbGlvcw==?= Content-Type: text/plain; charset="UTF-8" X-MAIL:mse-fl2.zte.com.cn 4545laZs009782 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 665EAA8E.000/4Vtfl34DhpzKhm From: Ran Xiaokai When I did a large folios split test, a WARNING "[ 5059.122759][ T166] Cannot split file folio to non-0 order" was triggered. But my test cases are only for anonmous folios. while mapping_large_folio_support() is only reasonable for page cache folios. In split_huge_page_to_list_to_order(), the folio passed to mapping_large_folio_support() maybe anonmous folio. The folio_test_anon() check is missing. So the split of the anonmous THP is failed. This is also the same for shmem_mapping(). We'd better add a check for both. But the shmem_mapping() in __split_huge_page() is not involved, as for anonmous folios, the end parameter is set to -1, so (head[i].index >= end) is always false. shmem_mapping() is not called. Using /sys/kernel/debug/split_huge_pages to verify this, with this patch, large anon THP is successfully split and the warning is ceased. Signed-off-by: Ran Xiaokai Cc: xu xin Cc: Yang Yang --- mm/huge_memory.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 317de2afd371..4c9c7e5ea20c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3009,31 +3009,33 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, if (new_order >= folio_order(folio)) return -EINVAL; - /* Cannot split anonymous THP to order-1 */ - if (new_order == 1 && folio_test_anon(folio)) { - VM_WARN_ONCE(1, "Cannot split to order-1 folio"); - return -EINVAL; - } - if (new_order) { /* Only swapping a whole PMD-mapped folio is supported */ if (folio_test_swapcache(folio)) return -EINVAL; - /* Split shmem folio to non-zero order not supported */ - if (shmem_mapping(folio->mapping)) { - VM_WARN_ONCE(1, - "Cannot split shmem folio to non-0 order"); - return -EINVAL; - } - /* No split if the file system does not support large folio */ - if (!mapping_large_folio_support(folio->mapping)) { - VM_WARN_ONCE(1, - "Cannot split file folio to non-0 order"); - return -EINVAL; + + if (folio_test_anon(folio)) { + /* Cannot split anonymous THP to order-1 */ + if (new_order == 1) { + VM_WARN_ONCE(1, "Cannot split to order-1 folio"); + return -EINVAL; + } + } else { + /* Split shmem folio to non-zero order not supported */ + if (shmem_mapping(folio->mapping)) { + VM_WARN_ONCE(1, + "Cannot split shmem folio to non-0 order"); + return -EINVAL; + } + /* No split if the file system does not support large folio */ + if (!mapping_large_folio_support(folio->mapping)) { + VM_WARN_ONCE(1, + "Cannot split file folio to non-0 order"); + return -EINVAL; + } } } - is_hzp = is_huge_zero_folio(folio); if (is_hzp) { pr_warn_ratelimited("Called split_huge_page for huge zero page\n"); -- 2.15.2