From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 404A3232395 for ; Fri, 14 Nov 2025 03:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763090752; cv=none; b=Hfhm0kvI1UTXkRzw4249NEtlesUt4JPcYTccKRH8FUpfXKWMDfrTyKM1ZV1GR24T3eJtBMXYFswv+s9WxKpZuDQWWn/rmU5EKHrqXX8jxZtfhqs1Jhiy5NYPq2mqIkje1rooEbC/OtH8t629dEMSKtEFjGpiTjCjl/RjT8RS/m0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763090752; c=relaxed/simple; bh=8sB4Q2iQRaMvF5BFPrUmihNUIjWVVSeDxpC1BYZ6w10=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D+o1TVC5taJIZxSoWVNlrECSZTy8+7InppjwPXRDiCsnjAkh6dlmfui7i2/QmxiSwShnnPMRSGYot6xpMlG9cQZgEAr1U8lUNXhYcPQaJz2RfXoRN6VcNh+zeqT8OAaRF6RTuTKou3CckaW0PCW8HsUqy+X9EGa6OEJ4gZ9dTXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c6vvzgFK; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c6vvzgFK" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-b73161849e1so254549466b.2 for ; Thu, 13 Nov 2025 19:25:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763090748; x=1763695548; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=8BOAaIJj5XwJhKO1WBdjW9luvIK9JXdag1HuhMw79QE=; b=c6vvzgFKshfPnDAK/voCH8mz0Eejd/8iTap4XCVBaGZlNPThvCRi2gmcQKh2Ctd3Tl h8TsUVIgBsCRXH5UasCja/NUNHHv19Try5mZJeGUDR7RsrcLmQicQdMB3+tCBQT+bVSI KXe0f5Gi0TCq9VWxpK9cbLVwH5DfIvZ4ehxwV2l2ofP+vcoRHY7jZAQXj6MLtX9xCVYV /U9nsFPrImOBjikGsKoHjbjGENjb9C46ceJuIHfsfB2zht4gWYpBsaz+1UWsIAH9aPTK rWKVdVRH31bUh9q8+mzJ44WkmcybIxyMguav4jyA03wBLhR2wV9jP7GzBoJqrwWCE8XW Ehcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763090748; x=1763695548; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8BOAaIJj5XwJhKO1WBdjW9luvIK9JXdag1HuhMw79QE=; b=CTGArYI5NSMPcOnK2bmJPlRA5UDky0rkLurvj4nSq2ZLa/s2EFGAsgqk8CcWdHgc14 S/kYS4qpRFnufFY4xXEY++jLx0hI3/Jtc88RNhQM/KbKTaru7h1+q9qwyPw99c9qLGi9 ATfJAFiAJMQj2jHLUrBEH/lsmtEQW1Z3xFTHkMChppSsv24a3aTClJFnEc320owuNKmN yqswPF3I0v4UZnqAop0iFR/s3PMEsZSg8bzEhQuDlxPNlyzeAQGOsT5bWxxQAAu6yhYj z4oXq5F2qpuy1HpYsYl135CKxrebbxewzTIOwu6BIUScPHNx76qa6uSEXsozoVMc+oDK q5ow== X-Forwarded-Encrypted: i=1; AJvYcCVAH79DCnC8To18+kTkn2VJh/FI/EBaTHcIbioTU66spyHUWZb718KUDt3uUKgzjhtynZb7VaMaYzTrtJc=@vger.kernel.org X-Gm-Message-State: AOJu0YzqQ8Zpp8qPxkWxX1zGcvXvFj91svfEiQ2Fr5wL+Az+UBcw9vyE aebvNGV5WETsJKbfJhhy8wiZ7rpAS3XJPEkNE720HWYhZH7GUcSZ+L+B X-Gm-Gg: ASbGncv/LLJRFVFx2vEyRs10k6+qIXlkNl7F0mw1cKxu6eqbtcJki19znHqFt/f9GGD z58/+54xy12j+5HLOmXna2vmdJZxwa4xhNdu7AR2fqWF3KzD0Phq69vjQ4O1+SBEaKn9X4OaSex 2djPOnFkfC3PVHKTmXk3tqH4wZYNUiihKcsB/abS4RS0REqVomozw37XFroQqxooUHeKkw7QHaE gz83d+BbFePXphB1IV4TJqzV527c1TBclLqZCA/LvZX8IV34AUvws2DBqot6MVIrg0TzFVwJ8BR vaf0EVNwYLAnaAzVoWaIlxyKvfxtqzvmH516wTw8Fc1SRjCcRMDLum0ufnPOMULMn8Eb0W8iiDM PxHFIW530LbioKYCJKw3jC1wzHrWT496N7DinGYNrFTPywvMLpYwTq8YpbY+yGoup8ovci690SG d8d75h/w52ZyTT5Q== X-Google-Smtp-Source: AGHT+IEjsfUWKv0dMN7iEw++28D290GN2raAylUVWloG8c1aNiR9QCg2B1VyrKJNEtRpL0OsqHQ6aQ== X-Received: by 2002:a17:907:3f1a:b0:b73:2fe3:db09 with SMTP id a640c23a62f3a-b73678f4722mr150819766b.34.1763090748488; Thu, 13 Nov 2025 19:25:48 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b734fb11f80sm291996866b.32.2025.11.13.19.25.47 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Nov 2025 19:25:48 -0800 (PST) Date: Fri, 14 Nov 2025 03:25:47 +0000 From: Wei Yang To: Wei Yang Cc: Balbir Singh , linux-kernel@vger.kernel.org, linux-mm@kvack.org, dri-devel@lists.freedesktop.org, Andrew Morton , David Hildenbrand , Zi Yan , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Oscar Salvador , Lorenzo Stoakes , Baolin Wang , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lyude Paul , Danilo Krummrich , David Airlie , Simona Vetter , Ralph Campbell , Mika =?iso-8859-1?Q?Penttil=E4?= , Matthew Brost , Francois Dugast Subject: Re: [PATCH] mm/huge_memory.c: introduce folio_split_unmapped Message-ID: <20251114032547.bxw4koznsoqlov5d@master> Reply-To: Wei Yang References: <20251114012228.2634882-1-balbirs@nvidia.com> <20251114032105.sdkjaoiwpdmpynew@master> 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-Disposition: inline In-Reply-To: <20251114032105.sdkjaoiwpdmpynew@master> User-Agent: NeoMutt/20170113 (1.7.2) On Fri, Nov 14, 2025 at 03:21:05AM +0000, Wei Yang wrote: >On Fri, Nov 14, 2025 at 12:22:28PM +1100, Balbir Singh wrote: >[...] >>@@ -4079,6 +4091,36 @@ static int __folio_split(struct folio *folio, unsigned int new_order, >> return ret; >> } >> >>+/* >>+ * This function is a helper for splitting folios that have already been unmapped. >>+ * The use case is that the device or the CPU can refuse to migrate THP pages in >>+ * the middle of migration, due to allocation issues on either side >>+ * >>+ * The high level code is copied from __folio_split, since the pages are anonymous >>+ * and are already isolated from the LRU, the code has been simplified to not >>+ * burden __folio_split with unmapped sprinkled into the code. >>+ * >>+ * None of the split folios are unlocked >>+ */ >>+int folio_split_unmapped(struct folio *folio, unsigned int new_order) >>+{ >>+ int extra_pins, ret = 0; >>+ >>+ VM_WARN_ON_FOLIO(folio_mapped(folio), folio); >>+ VM_WARN_ON_ONCE_FOLIO(!folio_test_locked(folio), folio); >>+ VM_WARN_ON_ONCE_FOLIO(!folio_test_large(folio), folio); >>+ > >Compared with original logic, we did check folio_split_supported() and >check whether new_order is supported for the file system. > >Currently folio_split_unmapped() only pass 0 as new_order, which looks good. >But for a generic helper, it looks reasonable to do the check, IMHO. > BTW, I proposed to do the min_order/new_order check in folio_split_supported() in [1], which may help to make the code looks cleaner. [1]: lkml.kernel.org/r/20251107072944.zvqvr4kyibyofhuw@master >>+ if (!can_split_folio(folio, 1, &extra_pins)) >>+ return -EAGAIN; >>+ >>+ local_irq_disable(); >>+ ret = __folio_freeze_and_split_unmapped(folio, new_order, &folio->page, NULL, >>+ NULL, false, NULL, SPLIT_TYPE_UNIFORM, >>+ 0, extra_pins); >>+ local_irq_enable(); >>+ return ret; >>+} >>+ >> /* >> * This function splits a large folio into smaller folios of order @new_order. >> * @page can point to any page of the large folio to split. The split operation > > >-- >Wei Yang >Help you, Help me -- Wei Yang Help you, Help me