Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1306022lqt; Fri, 7 Jun 2024 14:22:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXe7yaRPXnnBhE4YDXbF+H5l0IEaIRT7g9VxJUJIRGVI31jpGBYOdye5FPx+nqo2GEg741mBgPknUIRWYyfV9av+oG1J6TscZBtqPKcEA== X-Google-Smtp-Source: AGHT+IHNkKdKdpgTtbWFYPjI6Ccq87H99EHRQWx40M7lyAgWM2WEjwzI7o0Je8xwv7mGJ6L3cI62 X-Received: by 2002:a05:6a00:8c6:b0:702:55b0:66bf with SMTP id d2e1a72fcca58-7040c748675mr4360716b3a.31.1717795323391; Fri, 07 Jun 2024 14:22:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717795323; cv=pass; d=google.com; s=arc-20160816; b=mriwEArNA5fPWv5VDU6PJjzhkqVkW5PzMT1lG4bI42tu8BS0j0pRNb26DRidslP20e zu7mMdkELEu77/Qto+O+KckykcOGZmQd+ofm5dvUdtW3wQojEALx8oMxSTJhiYP5sMoh 6eGotp0zUnsluHja343hxnnqZSS5pBx5r6JShmJ40KbVM5eRRD7lOergZ0obBDUS/mct a7mmVibyLNqonkcVn2n7jN/HoyC1WfRtzqav2WzRnm746LYIM+YwkEhqj2In9j0qyZUO Rw/8mS9ZH4oPD3Eaj+FDv4Qhgbwxwqly0sgA8EiAuDJxZgT/r9gD+691Ja5sDm7XX461 LAGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=sF5YRENgZEtOUMrU/g3ca4JZDZZzoyXil4SeViNHSqk=; fh=H3SigoqdWHXbDphnRupetVDrJYjUd9w2M0/m0hV5YNQ=; b=GeUtQQqLLCLed3a93jzyGH3dAfSsoTTOT18KUml6ZUaESMgFgmt6KAsxKNYyCSvkGF n6LZgrL7Eiue/HfwmL2dG1Uu08NJkeCU6Vtob4HJy1Nd6bB2TVfRNwhGd9Agsc1uWtvA ePm41eQvunmn5xH3bY3CUwivbSLN7GPkZ5JAEZpWfRB3Jej/NQpC3WLPCqE1xho+pdoK FBxBcw0RdPlVuPRvaxT9EvJuosmfcW28iJLJgnc96RbDoho7quiFwb7lVTpfWFOBDBJT Hua1bgMhJEV339M29hK3n0EBY7okJYmCHv+8UxX6hQcsOjv8BKbSA9h4VllifDBfx+ED X6bQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=kVWh+fXJ; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-206769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206769-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd390715si12415b3a.60.2024.06.07.14.22.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 14:22:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-206769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=kVWh+fXJ; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-206769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-206769-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 033BC284566 for ; Fri, 7 Jun 2024 21:22:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73387155308; Fri, 7 Jun 2024 21:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="kVWh+fXJ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 25E874204F for ; Fri, 7 Jun 2024 21:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717795315; cv=none; b=AOdXcd4M974SBBpBG/Gajtp8TWRAFGEz9AZxO+UkccqN5+sT7dzKaREoI+H0Qv3/8lZbeeLdYzEhQQq6XiX+/urb1NxSH7MF9z/8ycqoC7VYJ8uxc+kRDizM6xvCyJDzaiK39BCjfZxmKYhlMjCzgvUk0YjuYsp5zjUmILFcfBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717795315; c=relaxed/simple; bh=niTAMUGF7k/DXZw+eMEI5mOMYLMUkkEXdjowDG1fQ8w=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Dn+kAybjtcc3Q76cF9RZ4P+eTlXpJ5m18G/tf2cIoSKe9MsJ7JgJp97J4yKa5YZQTYiZujSgFRdXE78qrwIDZ+aNpyPbhoC7qfvIvUvQ6s6IruNWn1zp7ZA3nNu1K1/UCrM63y2FAJMPt/hH2fRdeOMQOwfUqzUn6M73fCAGaEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=kVWh+fXJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45A32C2BBFC; Fri, 7 Jun 2024 21:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1717795314; bh=niTAMUGF7k/DXZw+eMEI5mOMYLMUkkEXdjowDG1fQ8w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kVWh+fXJCRkU06HQ1AEAyWPlDVLDyblp/dDq3Z0MzjYRcrIeC5lFiVeel6tz8K6DR oK3kuTs7OdPeWLMHPZtFDCPaffGfBlaRdQfdzoYJ/UBCKyg+DaZzIqgWrK68VHTbOp YIkhPn5+zlNK7NrVfE7YJDPYH0YeJiripgi5quyE= Date: Fri, 7 Jun 2024 14:21:53 -0700 From: Andrew Morton To: Cc: , , , , , , , Subject: Re: [PATCH linux-next v3] mm: huge_memory: fix misused =?ISO-8859-1?Q?mapping=5Flarge=5Ffolio=5Fsupport()=A0?= for anon folios Message-Id: <20240607142153.5cc922f1f2c96989dc809cd3@linux-foundation.org> In-Reply-To: <202406071740485174hcFl7jRxncsHDtI-Pz-o@zte.com.cn> References: <202406071740485174hcFl7jRxncsHDtI-Pz-o@zte.com.cn> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 7 Jun 2024 17:40:48 +0800 (CST) wrote: > 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 the 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. > > Also add a VM_WARN_ON_ONCE() in mapping_large_folio_support() > for anon mapping, So we can detect the wrong use more easily. > > THP folios maybe exist in the pagecache even the file system doesn't > support large folio, it is because when CONFIG_TRANSPARENT_HUGEPAGE > is enabled, khugepaged will try to collapse read-only file-backed pages > to THP. But the mapping does not actually support multi order > large folios properly. > > Using /sys/kernel/debug/split_huge_pages to verify this, with this > patch, large anon THP is successfully split and the warning is ceased. > Can we pleae identify a Fixes: target for this? Is it c010d47f107f ("mm: thp: split huge page to any lower order pages")? It would be good to add a selftest which would have caught this.