From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 C967D43BDD8 for ; Wed, 12 Aug 2026 12:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786538817; cv=none; b=iurXhgZXThz1f/NU0J5njI06OLjtEGKOdqJAvBJDpuDOSQtKwo9pnXX+uKaTbKUXGPL/V3lZ8hnvV+16mBriS6rOUTmJsS8pVmOgYgRGSOeFVt/iJKXJGZCgPHdwRrhh11FvH2J/0P4NKq5bj4BcGmgmkh5S6bkdBpTCNjqYLj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786538817; c=relaxed/simple; bh=mBDIjKotE0PbWwvvQ2076JqtHKd1YG3mQJfTWDYz1UY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bfjxjRoEa0KKC/0qsks8k1+doetNDj1dVQE6HNlgqRROQe8xHefy6YJE1wT48kV6bOpysroRP2DXExcGLEmtWEHdq/5lWCgELwP9PxblCs8GxCV9NOtJqoU+D8yS3ys4mx2hIRH2cADjD0yDV/s1orThEzrZkeqEVnSITmhIO4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Wt3t+/4l; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Wt3t+/4l" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2cacef7d299so91515ad.1 for ; Wed, 12 Aug 2026 05:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786538810; x=1787143610; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=oxYdP471DepeKW2rJLqfMlMTWPdcu+KytJwblc34E7I=; b=Wt3t+/4lYSLqqMpbf15ZHlLBDPNZ8j4A5zMOip25cSR/wNuQiqmjOYKMjOJa+qG2o7 J+adA42gLLo/eEULy+oxXWYtlTTPHbIagOPiemBln/ZvkIRMNHqgNy02AcnhFPsEjtr5 KTzAVlWvomdQ2N37OGWQtMZ96P/9Fhw+U0N5uaVVTNKe1GBcXJHiPE6yFTmKnv/BjOWh +0nSr93+iLnAb+dgL833c1hMKGpPOtydygJk2ase8tCOG0EZhePscKgejAg9CgcbcETN gi0b4x5w1/bciseWh53tVJYRV4UX5gNFZ8RDWDY6S6ynGp6klzzt+6vZG7hAQot/5ot2 UiUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786538810; x=1787143610; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oxYdP471DepeKW2rJLqfMlMTWPdcu+KytJwblc34E7I=; b=K3GCwt0WyXvjOocpA14td/fT+GjdeVG7zmLf313E/yQuGKzY6pFYCEYSwe1PiZPUju +sBNel0PABIMRf7iAtPZTiI5schJ2PWMMuu+9HaxGTpKE8AnDdjRZkGWUricXJn/AMaG h3D5LUTfwBERBQkASnfwOcLP12imMAevG9bYA3k7GESKrgAvI0sR70sENCfN1TAS7714 oKP0C6upIxIHtkKM8HGnbsUtjCu9MyQFHjLoVaDSBqX7enLHJxFaMoGzPjWz4SfqrKsp bYvd5AxWiRIsRHfdFE0FE81wnB5xL8ts8j+i0phTNOwBaJuy3Siu2+i6SvH+FBMmD2Ru q8cQ== X-Forwarded-Encrypted: i=1; AHgh+RoP1SVMHkLKRBwrxsRGHcZapy7UnnuQe7RmDhMWzsac+8rDkk0Kvx+pq2vPS1Q7WcuSPTxwOEuMwJMKMhE=@vger.kernel.org X-Gm-Message-State: AOJu0YxDPcVDn3S6SvoObkhIqsy4kv4BLiHwdx2Lc+MEuP6+/7EltrMq uNZoqNgEU5haEKoeztPmjApb6qDP11af3R/vrYq4EvA3Q6ZRnL/IkDztxIEGy4hBxQ== X-Gm-Gg: AR+sD12/zW9MaeL0KCo8uFlYrziyNEy3VV0HtP4l3fBxmETAUP2p+zQQ7AqJicxZZES UFZbBC4uz4xDSvQH+GrkaV+wtvPN8Bn7PeOwSMiwhT5rXkwktW27WtVbeo/9MMo21ypxkqI4rdI J28YuNFoTuh18zBX4TtyR3lPvNY2gRtK5KiNcj3wDtChXrOeGo30lgYnrRo9LFwrJLvKkZG3fdT HoM7xVopZq+70zKmsZ6H1yh6PxEM9GBQXoHsN5UvfnS3SkPg6P+Ihg3Io2PYsvgxSlA7OjiKndD iHs8XCoteLUxZ/PSRzkBVZQre5OSzyo8uL5LW0fr7EhdM9e8oAS0Y/H27ZyZ1hHjcLha2dcn8aj xfrW2jpqneoUIbmD95GMdZldMdtmEg7mpGAmhDjOCK6fx0/6By1JYeCFp0/vK0yLktGxNZZY9LR lC6fWdALk+S67Wb2gSCDxXUBIaU7t+FEzUFqoqVzvvn9WZOl1lDnywnF2vX/tUv1Iee7Oe6oynU 8/2vh1oAdMqp47dk4UdWH4= X-Received: by 2002:a17:902:ffcf:b0:2ca:bf8e:360b with SMTP id d9443c01a7336-2d34aa71fedmr6106885ad.9.1786538810039; Wed, 12 Aug 2026 05:46:50 -0700 (PDT) Received: from google.com (21.168.124.34.bc.googleusercontent.com. [34.124.168.21]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-392f8893496sm3642752a91.2.2026.08.12.05.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 05:46:49 -0700 (PDT) Date: Wed, 12 Aug 2026 12:46:43 +0000 From: Pranjal Shrivastava To: Pratyush Yadav Cc: 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 Message-ID: References: <20260803113944.3694290-1-praan@google.com> <20260803113944.3694290-3-praan@google.com> <2vxzmrur3880.fsf@kernel.org> 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: <2vxzmrur3880.fsf@kernel.org> 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. 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 Thanks, Praan