From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DEACC346774 for ; Wed, 12 Aug 2026 13:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786542545; cv=none; b=iyS+8uLfpwCeM5IBHyxLeb6cFizAC0yp4lfytm4DXisGSWh/XOKX7k8YiQY4zHaPzRLwciiWzYNOPShKoszogKHH4bD3UpO1U3tOIb9+HZLz0rXeGMnj0Hp0QuFRH4tpWceHk1PM6Pz9QaxPaX6JAoDyNuFnHfZDx1NWXIaj+M8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786542545; c=relaxed/simple; bh=O5BIXR0rp1vkRvGWKJBFCZmSQ7mBIMXoWAwpbFLFLhE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=ibpjO+9tejYwAK+UbOF3VyHUhlEKW2/M3FNm1vhA2r/NbFbnk6JUvMt6Ro1G0KspkUCeHT72ZUOwFVhtG/ip1eugRMCKdyp5f3nLgiZJoG7cwWVRbRfn5MaIoUa/w62CwaMCUY/sULcaC1+H4vZASheAEFWv9eifvoaV8VWCTdg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UexFnpIW; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UexFnpIW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9664D1F000E9; Wed, 12 Aug 2026 13:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786542543; bh=OenMr5nT85sI6+yUZ5su20Q5jfaEjzyJzi9hJtpz57s=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=UexFnpIWk2+YiBJrt9VA2Sfiyzo5Isjw4CnK/CaYnaL2+bfwDCWo7W7E1fiiHF6bt NTBmKRKR2t20kh915uCjvT6d2N1ALd3LLMhii3XVXwSAYBYYoyYEukDPCAldIAf4vC sEHEObdblFY4n+akVftR4rtv4qfB3ZSFuSROdY4gQ97JnRWwbMtamPLobUoM9FYUQY SWpAc1UtsLTNSBn/HA5nd92QIvNPIGFU3EdPkhcSwama+ZcyD4fijjoSsJQE3Mt+3n frnZA5FzMSQWct/bezhFsRc1DKWbD8pb6l2s01bXo9zvXWRJMMZpHvWJur6a7N1IPe JFnGvrKJyIeFw== From: Pratyush Yadav To: Pranjal Shrivastava Cc: Pratyush Yadav , Mike Rapoport , Pasha Tatashin , Alexander Graf , Samiullah Khawaja , David Matlack , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/2] kho: Introduce preserve/restore APIs for high-order pages In-Reply-To: (Pranjal Shrivastava's message of "Wed, 12 Aug 2026 12:46:43 +0000") References: <20260803113944.3694290-1-praan@google.com> <20260803113944.3694290-3-praan@google.com> <2vxzmrur3880.fsf@kernel.org> Date: Wed, 12 Aug 2026 15:49:00 +0200 Message-ID: <2vxza4qr30vn.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Aug 12 2026, Pranjal Shrivastava wrote: > On Wed, Aug 12, 2026 at 01:10:23PM +0200, Pratyush Yadav wrote: >> On Mon, Aug 03 2026, Pranjal Shrivastava wrote: >> >> > The current KHO page preservation APIs (e.g. kho_preserve_pages) assume >> > that multi-page blocks are split into independent 4KB pages during >> > restoration. This is incompatible with high-order non-compound pages, >> > such as DMA buffers, which must be restored with tail pages having a >> > zero reference count. >> > >> > Introduce explicit preserve and restore APIs for high-order pages, >> > which preserve and restore a high-order page block as a single unit, >> > applying a refcount of 1 to the head page while leaving tail pages at 0. >> > Rename the existing internal helper to __kho_restore_page() and >> > consolidate the common restoration code into it. >> > >> > Signed-off-by: Pranjal Shrivastava >> >> The code here looks very convoluted TBH. I think it will be simpler to >> make kho_restore_page() only return non-compound pages. That is, it >> returns 0 or higher order non-compound page. >> >> Then kho_restore_pages() can call kho_restore_page() and then do >> split_page() on the page it got to turn it into 0-order pages. >> kho_restore_folio() can call kho_restore_page() and then do >> prep_compound_page() on the page it got. >> >> And then you expose kho_restore_page() to be used by DMA APIs to get >> non-compound high order pages directly. >> >> How does that sound? >> > > I like the suggestion to use a single base primitive and mold it via > split_page() and prep_compound_page(). > > However, To implement this, we'll need __kho_restore_page(phys, &order) > as the internal base primitive because callers (like kho_restore_folio) > need to retrieve the order from the KHO metadata to pass into > prep_compound_page(), and a raw non-compound struct page doesn't store > its order. Oh, right. I didn't think of that. > > By having __kho_restore_page() initialize the head_ref = 1 & all_tails > =0 refcount pattern by default, all three public APIs can just wrap it > and call the appropriate MM subsystem helpers. I'll spin v5 with this Makes sense I think. -- Regards, Pratyush Yadav