From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 5DC9935E1AA for ; Mon, 13 Jul 2026 20:49:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783975782; cv=none; b=Ypk+UbeLjhNSGpxpJXrk8GPuqKBGL2uQcyUHDLX9rwvICv14LZ8cX7RhzwNt4nb1Eu6cy2s59Voc7mamWohIItZM+tPiHEfav4wPdvpXiL0Y26FAsSZ9fG+s6U+IrZHWeWH1C8JT/M6rLOqSnziE9gaknGX8dMXTB6oOxrcLORs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783975782; c=relaxed/simple; bh=KXWsv30gE2s0GMl2XfNulLmfi185CojKSIxyONXqRFw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=b7LuQk61tVw+YPnDqawEllQ8iemu94P2LVCGQGEnZsXPh4vBgXSN8f2aFkEGM+xegKEAFzFm3in9Lc8fLRCdrYWvv/r5znPTmS6ILTUe4uQBgmutUygZk53wmpTzT5mqHIGjKVMAnfbl3EGzaRqsWZk4JaDFFj0bz+RS3ewyLdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=p5i1qy3W; arc=none smtp.client-ip=209.85.210.201 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=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p5i1qy3W" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-84a251c2e3eso357263b3a.1 for ; Mon, 13 Jul 2026 13:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783975781; x=1784580581; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hg67XY3VqVr1xT4YbJfB+2ZOPF2cG732AuNnOCY2r7I=; b=p5i1qy3WK3tEfli+Y0tHqY63oMH9SuqZxbreHTIUV2lAsT2IjV745xcQm9a86HHNrk 9fZ3LWjFXAxHOAVF7FO7u/hJJQwkcrXMOiRp41s31qdidGF3kIJMtqY87JqPIeKQokOJ o6a5SA7sgXOO4RdCrUX7FaLA+6CeIdjKZ2guwujEyNSEYrlTinvG30mHRco+sw8Zm/3C 6B8BQGHj3svrDxpiCjzk04Oyco1TLBqqmfwBbRLF5S76vmoOvIXi767LiyJwWGdrrKuT UpqIFC9ZMU9asYiHZmND4mtdsY1BBgROSseUOTVMhry6XZ6/TWfRPP7xwj8yahfVE58n Phgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783975781; x=1784580581; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hg67XY3VqVr1xT4YbJfB+2ZOPF2cG732AuNnOCY2r7I=; b=WcbmvxbprnMkABrZ5DrqDaYoVDliSeiMh/jNzd35lWinqgcbNL/r07YKk6sL7+XDUQ HDhZtg3qtqJ2Mq/ET3mrk3EPLI6bNtmIiiBAWuFfZQI0x6AdjL3eOQzrmaEnbZqr0SYt rTZKy64sdx06J3bc8HPRbLO3/kTi0S5UVKmj3pg88b20hgt6X6IhkFcGSGtetxIB5beB oLDlRsnT8DnMrXS45i1+ZKrJBtA7ogFKfFRZ4vZAMVwKXhyB1/V26qiY4Mux1pYnhg0V g4KaIrgxp2x9zWHt1ZDNMen2UTRalYn5BqkStcAuTCJv9fjChsb1sx+xxP/DynfMzUGS Sprw== X-Forwarded-Encrypted: i=1; AHgh+RoM6Pviq6qPkx+Wnsl0LcV1WluyXOsdC6XTSuKx97HasIG8g2b1gN5zAkD9RW67bsWarej3NF7Htp+KylE=@vger.kernel.org X-Gm-Message-State: AOJu0YwaReQ4CF5HIU/LIHBR2tBndltvg6vqf9L7h1m85CpiPXvECONi gKvR0K4XS84xdPQPRMjH7QgtFplwgaywV3l6gtbaxpJQb0kxM9FbJYji7nd7s90jS0qdHECYzqG LAw== X-Received: from pgl36.prod.google.com ([2002:a63:b24:0:b0:c89:2504:2df5]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6f01:b0:3b3:ccd0:cf62 with SMTP id adf61e73a8af0-3c0f0c11140mr14952998637.36.1783975780428; Mon, 13 Jul 2026 13:49:40 -0700 (PDT) Date: Mon, 13 Jul 2026 20:49:34 +0000 In-Reply-To: <20260713204935.3069000-1-praan@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260713204935.3069000-1-praan@google.com> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog Message-ID: <20260713204935.3069000-2-praan@google.com> Subject: [RFC PATCH v2 1/2] kho: Introduce a helper to init unsplit pages From: Pranjal Shrivastava To: Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: Alexander Graf , Samiullah Khawaja , David Matlack , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pranjal Shrivastava Content-Type: text/plain; charset="UTF-8" The current KHO restoration logic assumes all multi-page blocks are split into independent 4KB pages. Break out a helper to prepare for supporting high-order non-compound pages. Extract kho_init_unsplit_pages() to handle the refcount pattern where only the head page is refcounted. Use the helper for folio restoration that requires a similar refcount logic. Signed-off-by: Pranjal Shrivastava --- kernel/liveupdate/kexec_handover.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 4834a809985a..07f6f453cd69 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -357,6 +357,24 @@ int kho_radix_walk_tree(struct kho_radix_tree *tree, } EXPORT_SYMBOL_GPL(kho_radix_walk_tree); +/* For physically contiguous pages. */ +static void kho_init_unsplit_pages(struct page *page, unsigned int order) +{ + unsigned long nr_pages = (1UL << order); + + /* Head page gets refcount of 1. */ + set_page_count(page, 1); + /* Clear head page's codetag to avoid accounting mismatch. */ + clear_page_tag_ref(page); + + /* For high-order blocks, tail pages get a page count of zero. */ + for (unsigned long i = 1; i < nr_pages; i++) { + set_page_count(page + i, 0); + /* Clear each page's codetag to avoid accounting mismatch. */ + clear_page_tag_ref(page + i); + } +} + /* For physically contiguous 0-order pages. */ static void kho_init_pages(struct page *page, unsigned long nr_pages) { @@ -369,16 +387,7 @@ static void kho_init_pages(struct page *page, unsigned long nr_pages) static void kho_init_folio(struct page *page, unsigned int order) { - unsigned long nr_pages = (1 << order); - - /* Head page gets refcount of 1. */ - set_page_count(page, 1); - /* Clear head page's codetag to avoid accounting mismatch. */ - clear_page_tag_ref(page); - - /* For higher order folios, tail pages get a page count of zero. */ - for (unsigned long i = 1; i < nr_pages; i++) - set_page_count(page + i, 0); + kho_init_unsplit_pages(page, order); if (order > 0) prep_compound_page(page, order); -- 2.55.0.141.g00534a21ce-goog