From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 41E4643849B for ; Wed, 8 Jul 2026 17:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532670; cv=none; b=fSHAR/pvoDjOpSZDgNR2UxhPZm67NHOR+gMYHaJCkSyK8k5AjOWi6fEu+7klTyHw2ynvUEhoyhCA3gs9D0SwXDiplLfYgpiXFIOonnBC+FtOGJ2+/79pqnv87wJHgBR7+iUmlSR4Q/vJVpYB1yHs/pvMcyiApJhRklwIe5mDuPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532670; c=relaxed/simple; bh=YqVnsr3d2jsWTVNJrz9uMiGLUTpbRWAalnxVMEU7BrA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D4rGMltBODeNY8RJ/i2wnsXBiCWUdFSO5h5Ln3L3K6ffzdCntMwDqQANG1DZjYDBEDpIZnQCZ80PdqII7krfiUupf9kqn2g/9sETqDQHe+nvPuTHSK2eWE7alx4+ctv4AfYSNj5/fMFV68dUpzHDzjFZrgsdZqIDEB8qdoAFXKw= 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=gpLCsIXB; arc=none smtp.client-ip=209.85.214.178 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="gpLCsIXB" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cab97c86bdso7925ad.1 for ; Wed, 08 Jul 2026 10:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783532668; x=1784137468; 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=xmyFw2R0UQPIDfzvj9wMwsWmgYLjmqNhoTqDamPgvg8=; b=gpLCsIXBRULBaOsQ7wJKP/ZPzLJ6AiUMHq+WE4OWN/8i/IuwR/VzvGu9ICDdV7AIOO a2HTdbawMG6PU3lYH4n9axOxHJA8+hIJ3nkigG3301tGy2PpQYf4DQ2HxeuH7jvLXtcf zK/GQGwsJ/ENhVCI7Q4SXeFJpCVGS1erlALqMpc1t+HZB7iFvFcZROfuM77UFi/PYVlJ oY1TnxxiawV3kiEJp0UulxtYbBYLewLaSsQ6SO7WaS8RFyzVKLPXO0PHrgOlpzi52+LL y8//dh3RKw8fZjhOMRHFBiBKAPVcTB66YpPjr+8wk0ufznw6TRomLj2JI3rlPguvQNGT oy2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783532668; x=1784137468; 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=xmyFw2R0UQPIDfzvj9wMwsWmgYLjmqNhoTqDamPgvg8=; b=tVw4/RtfBIhzRIPr2ukV5VtfYg8qD4n5rzrfVk8yfdazijX6WyrY92opuc6y4SK6hK eRSWT2A3NvTInYnIfumOmqgMXDleH6G5y49kyeQ+qOzHkbSEbvqYV2F6TshgNMl7db1b 9Qfx9XJbjw1x6akAZdgD6lmpEOUnfLMwISKdhU0K76uQqUP/tj0CCNcBPmZWqunWAenW L7PWjziEFJJGkJ/50FvOdV4YOQlP+OSf4uhu/8Ikq44UD41jTQUsPpaiaHfqsWkhyuAP dujp7NKqaoBpzdsr/7faECghYgE8Msqt42H9kgC3XSfe/fUuOsO1nqiiAjizF9HeZhCe O7Cg== X-Forwarded-Encrypted: i=1; AHgh+Ro3BWrIyzTg3bRgWme0o8FXZAxKySSQkwtL0Mdi0yI0+42v40lV0zu+8opaRPZS8wiFgX4Dc1DwgqMzNME=@vger.kernel.org X-Gm-Message-State: AOJu0YyjpLwxxgCZ12q4GE6GT9jzbDvNdQQ7fL3K+P19ehJlc4QWmN2f s4i2vIMKmRFAQRkGYxoIYcY3qdlypHLnMc9tnJnEr3VY/cukWFEQpUN2Avzx0E2Tig== X-Gm-Gg: AfdE7cmzEN25NIvhip71ES9PyJbxlBkHftXaHZb6q/SLEgBx+4m3hTAIigKm5Bv+dgK 3KF+8QeZQXucr7yttZ20w6m/Se/tCiWV7UT0SnxOvd1yJQJs1oZLNL3dBCKNub9Dfou7syEGAmd ++fAWuogtB1gz1jYBgGOxLncN5uFPBK0DfIil8wyWtH/NFVs5G2F9ImZ2BRB5Xgm4xCq9d8Yu9b mm68ysGwf/+eKi2Fz5Xn0yOlfrTlMkfVZ2oDVmlO5XdS2M5mzt+BiYef1Be3QJF+rCJIF/v7qa5 kfCSeJNJ/OXuQbUOS7yY0n61cL9mAsWBhaO/2noRVhNQwsEh1y3OpVrqDglIf7flwA/yXWg3Q6V x1B2f0IewLZ5VEb5ELZR/VoF14YGxSGCPmlGZ0/bQ3mzcaY3OW+JcuIBJbB1gWiogKLrVjTHjHt LXhAjfde1nmARUf9Ug1EkamdOJn0YYa8WsfCeRjuZ3U3Ci4F0= X-Received: by 2002:a17:903:38d0:b0:2cc:7759:ffcf with SMTP id d9443c01a7336-2ccff916ae6mr403275ad.17.1783532668070; Wed, 08 Jul 2026 10:44:28 -0700 (PDT) Received: from google.com (10.129.124.34.bc.googleusercontent.com. [34.124.129.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9bdb746sm30815595ad.7.2026.07.08.10.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 10:44:27 -0700 (PDT) Date: Wed, 8 Jul 2026 17:44:22 +0000 From: Pranjal Shrivastava To: Samiullah Khawaja Cc: Pratyush Yadav , Mike Rapoport , Pasha Tatashin , Alexander Graf , David Matlack , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 0/4] kho: Support preserving unsplit high-order pages Message-ID: References: <20260703020832.1731864-1-praan@google.com> <2vxz7bn5mv0n.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: On Wed, Jul 08, 2026 at 05:14:40PM +0000, Samiullah Khawaja wrote: > On Wed, Jul 08, 2026 at 05:05:20PM +0000, Pranjal Shrivastava wrote: > > On Wed, Jul 08, 2026 at 04:36:46PM +0000, Samiullah Khawaja wrote: > > > On Wed, Jul 08, 2026 at 04:11:04PM +0200, Pratyush Yadav wrote: > > > > On Fri, Jul 03 2026, Pranjal Shrivastava wrote: > > > > > > > > > > [snip] > > > > > > > > > > 3. kho_restore_page() applies the correct refcount pattern based on the > > > > > preserved metadata. > > > > > > > > Why do you need to save the type of pages in KHO metadata? For example, > > > > for pages or folios, we don't store any type information and leave it to > > > > the caller choose the right API. So reserve-mem and kho vmalloc need > > > > pages, they can call kho_{preserve,restore}_pages(), and memfd needs > > > > folios so it can call kho_{preserve,restore}_folio(). The radix tree > > > > itself does not hold the information. The caller knows what its memory > > > > is supposed to be so it calls the right restore API. > > > > > > > > So why can't we add a kho_{preserve,restore}_page_multi() (pick a better > > > > name; we can argue about the naming later)? Then your driver knows it is > > > > restoring DMA buffers so it can call kho_restore_page_multi(), and KHO > > > > takes care of initializing the pages with the right refcounts. > > > > > > > > You won't have to muck about with the ABI in that case. > > > > > > +1 > > > > > > I think this makes sense. The mm already relies on the allocator to > > > track the type of pages it has and expectes it to use free_pages or > > > put_page() or free_page(), so it is natural for KHO to rely on the > > > caller to call the right restore API. > > > > > > Lets add kho_preserve/restore_page_contig|_order|_nonsplit and the dma > > > preservation can use the appropriate one during restore. > > > > Ack. I like kho_restore_contig, I don't think we'll need a preserve for > > this though? Preserve doesn't seem to be preserving refcounts, I guess > > we could rely on kho_preserve_pages and the caller can use > > kho_restore_pages_contig() to set refcount correctly for unsplit pages? > > I think for consistency we can add both, even if preserve doesn't do > anything special internally. Ack, alright. > > > > Thanks > > Praan > > Sami Praan