From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 6F62738236E for ; Wed, 8 Jul 2026 17:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532917; cv=none; b=s91VXsCT8R+/pbMmCOmLBBQZzaRAVWUwdC4bcsnaGMci4+z9hiaGeOhQcV9w5a+VAJ/gExQ7kbsTURb8jLzxZzY4WfX8FC2nIa7Zg42iEZRyKVon81d3hoLIYYpa+kwASVxzeLxh6HGRvZYjhJyDVyub+yYWDOzzBMqWc6nVao0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783532917; c=relaxed/simple; bh=ABXWNyC2E/dJGLby1SXs7FptWULkgISkugOkiJ6i3Os=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=e2lwxI+5mkLnR6pcFe32n0NkfdPQCTuldwAui8oVJ62WRRyecin8zDwqxxa4CFlYM7iXQVtD+kt9Ji6JYTQmJ6VkVjg/hPthKEF6CkZGDr6K9nCQct28bpmOZS5Eof00s3LtvuUi77kN1HvDPoiju8LuK8KPJS2kdt2CdF1BlKA= 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=bFE87VbL; arc=none smtp.client-ip=209.85.214.180 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="bFE87VbL" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2cacef7d299so8225ad.1 for ; Wed, 08 Jul 2026 10:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783532916; x=1784137716; 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=3n+7WeSImaE/4g038c1rdz4vAq6B0NjqEh02G408iWI=; b=bFE87VbLme7CIkZ6QFBWOM+G+fW7DFsyj2QAXTi6qmFpzSYIrFftAmBTxuEie91FvW OJHnJ8Biu9BD7hdDp9Li0htkfSvHFIlwdDUBHR70UC1D/k3U0LYmeZO2XdQ6v4UA8B9k Pv7TbOJ6Ndgy0pJyvIHKYjTZXliV6G52aqOV9SZ2GZSshWShy4jsmRwCKYkby326xkjF XhgBuf64gYOstYt6XUlWKBY0DIENyb7YvnouQpiCLX0Ybx+5YvOaNaCeVH20hvy9mWlx bLz3eRwKe6cuRziei/8EzJk3wezc4fX4EM9iUM7/3b03HifyiOqGT1N/Xk1Nyyy02/sn ry+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783532916; x=1784137716; 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=3n+7WeSImaE/4g038c1rdz4vAq6B0NjqEh02G408iWI=; b=PFJ3X+sxqnUry7PRUuJQhMk06fL3lH2dIWmJTFuVAk6pOaeF5ihnA1drF4r/zTb++W UCxFckb/ptUFh5HnUl9UiyOMp176FmHRGYvrMKrOuSaWoWNpydBIYb0OShYefh02Nlfa cT/sTGgAiD7/vCi1dBuueWU2dAwWxN20fTru2XBNIKBCVCMb+34mtvlOfNkeFn7uLD9Y Ia6EckHLvCi+f+K4jaN/x1RSrQR9+/aMxz1GSOmHj61eVjLB6R1MbJNN+JHmXwBpUjl6 6WzjM2HB2IwjCI2SWmyif7kxFuOZ/Cn7UuuSw1CFMX8FrCvfSyE3TWAxBfnr2DCre1nT LyzQ== X-Forwarded-Encrypted: i=1; AHgh+RoO3hjKWZNs0nSYxbTDFqVEK4qdXhM0dbHRBP/RRkdhqU8sWSq3i5vHztfrcUgih9bg9usTlCbMT+36/ko=@vger.kernel.org X-Gm-Message-State: AOJu0YyJtsM2zvvNCaAcnglViUypWVlqQ3u3r+RLPS/hbCSLFCi1M8b3 3nYBm+je50cZf6XojF1wJ7DwXO/kZAJfpTWwe0Re2qTkfTocvheJoKv8ZYH62Kg7QQ== X-Gm-Gg: AfdE7ckzImx9Ye9Q3r2Ns7rW5qiD0GvkdenUNeI6hSDC4DColJOasCdt0t6ie3ct7hm mTjcwgTnV8wD98nGbaJMgGWfCQTwZjSBen/i+VtAVrcAsaKPrS2LMFjNjEFYq7U38cxQdnRqyDp 21lcEqBRKPBNqBn/qYgwKFe/Fwkg5smTWvQJYVVBTCOsHvXqCTvXzLgzgkgxJ8GGOToYX0yy4Yq b5LZ9qx+D8jXg7cqAPvB+wksqsYmwGw+b1RiicbuPRd/7VaYQ8q3puU8Bc+sNs6LOdki3/FJUx1 tRou7FZBT2hnj7a35VBly/42w45Rf2AemKNLtZEUFzswQN6B0GRoiLGTWe5mQ/5twYBjodm1PyE y2QxYBNyiKioggVgULFZjHgKRdAnYOGVkNCeGx73FMbpiGWNwDV9OFiJXMXOva0H0WPcIx1A7R1 M9x3CCnoKLCJ6ABezRaSUm8l6TaxeCA8b47SIPDOpzhKXAU9o= X-Received: by 2002:a17:903:120f:b0:2ca:cbe5:c3af with SMTP id d9443c01a7336-2ccff8db91fmr332755ad.7.1783532915006; Wed, 08 Jul 2026 10:48:35 -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-2ccc9d3bcc0sm31299635ad.67.2026.07.08.10.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 10:48:34 -0700 (PDT) Date: Wed, 8 Jul 2026 17:48:28 +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: [RFC PATCH 0/4] kho: Support preserving unsplit high-order pages Message-ID: References: <20260703020832.1731864-1-praan@google.com> <2vxz7bn5mv0n.fsf@kernel.org> <2vxztsq9l6x7.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: <2vxztsq9l6x7.fsf@kernel.org> On Wed, Jul 08, 2026 at 07:36:52PM +0200, Pratyush Yadav wrote: > On Wed, Jul 08 2026, Pranjal Shrivastava wrote: > > > On Wed, Jul 08, 2026 at 04:11:04PM +0200, Pratyush Yadav wrote: > >> On Fri, Jul 03 2026, Pranjal Shrivastava wrote: > >> > >> > This series is required for the ongoing effort to preserve DMA allocations > >> > across KHO [1]. It addresses a fundamental mismatch between the current KHO > >> > restoration logic and adds support for high-order buddy allocations. > >> > > >> > The Problem > >> > =========== > >> > The current KHO restore implementation treats all multi-page blocks as > >> > split pages during restoration, i.e. kho_restore_pages() initializes > >> > every 4KB page with a refcount of 1. > >> > > >> > However, many kernel subsystems, most notably the DMA allocator (via > >> > dma_alloc_coherent), frequently return high-order non-compound pages. > >> > In this unsplit state, only the head page carries a refcount of 1, > >> > while all tail pages have a reference count of 0. > >> > > >> > Consequently, when these contiguous but unsplit blocks are restored by > >> > KHO in the new kernel, the forced refcount of 1 on tail pages causes some > >> > trouble with the buddy allocator. Downstream of the eventual free path > >> > the __free_pages_prepare() [2] ends up calling page_expected_state() [3] > >> > when is_check_pages_enabled() returns true (only when CONFIG_DEBUG_VM or > >> > debug_pagealloc=on). > >> > > >> > This detects the non-zero refcounts on tail pages [4] and incorrectly > >> > taints the kernel while leaking the pages in question. > [...] > >> > > >> > 4. A new helper, kho_split_preserved_pages(), is provided for subsystems > >> > that may need to split memory after it has already been preserved. > >> > >> Umm, that sounds scary... Why do you need to do that? What's the use > >> case? Why is the driver reconfiguring its memory after preservation? I > >> assume these are DMA buffers, so why do they suddenly look different? > >> > >> And in either case, why does KHO need to do the split? Why can't the > >> driver unpreserve old preservation, then split the pages, and then > >> preserve the new ones? > > > > Ack. I was trying to cover up an edge-case I guess but if we're simply > > moving to an explicit restore API none on this would be needed. > > Even with an explicit restore API, I'd say it would be a bad idea to > preserve using one API and restore using another. The driver really > should be unpreserving and represerving. And even that if it really has > to. Ack, I'll add a new pair of preserve/unpreserve APIs for this and mention it in the kdoc that the driver is responsible for handling splitting preserved pages by unpreserving & represerving. > > -- > Regards, > Pratyush Yadav Thanks Praan