From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 3C15633ADB3 for ; Thu, 21 May 2026 23:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406469; cv=none; b=bxB8wcKFz7H2cz4978iOPf1MIOXkqRWhSGQ9cO1gcSWiWSJ36+9Qq3v6eVHb1MNyoFaImeFy9DzUIJwfZ705s0Jw/1KzxisZkYg0yiprZVeUykoCPxVs+u5/m1rS11d1E3pQGzbsGpckWYEofx5+UIU2x5R0Kg4l5Xm3Wl101sE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779406469; c=relaxed/simple; bh=dONyumMl/H6Ry3o7VHRgaXQCi9DNqVi1sHbk/KKuZI0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uqiEQzoEm4lrV/aKrXQKZgGqmmK1oOwk4ETi0vRjbI53i/dCnow47Plx7gN2kb17vUCpRB3a0H+LSP4XWPEjaux4hKUHBeWqSl+Ah7A1F4SPCQqhhRLjRaPMMTiwF/o7fJzQDFIcL0C3PhRqGskZWE9kdx6cbpH5iBw87IHVx/8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=MrWpKMk7; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="MrWpKMk7" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-8b1f2b7f1bcso101360146d6.1 for ; Thu, 21 May 2026 16:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1779406467; x=1780011267; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2qvJumL5Uy9qaseIh6HBDqg5ydk4M44ynTEuc1EKrP8=; b=MrWpKMk7XLfdxj/OpheSNA/fWF7P/DqG9Pw34VvRIFEVIn4ZSteOqyXUgpze+PON91 WRzaW2+g11bcFPthLfz9aMmbCT5Ne5wv6UjlztUibJenSQiQ7yfPDEPm3brhdCnaDNDs acbV1V/7xMbgoKcmXoedP7TtWaKBhtVaItVe1fXEgM2mzR6DB/yInO7HBW0btDNQf7FM BsGjA9alzwVcJJFjcKSv6UZgB55+/PauqfPC8AVQqcAsaVkYL2nrWzGWoZKYXqkihf3H oBXi0fo+s1rXs9Mt8ONaxe+rIXIojkCJZra5Tt9WZy5BdGB1AvdspLGzneRiXeBTzkTg JZ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779406467; x=1780011267; h=in-reply-to:content-disposition: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; bh=2qvJumL5Uy9qaseIh6HBDqg5ydk4M44ynTEuc1EKrP8=; b=eFY/BDGAHgOSApO3iHgcK7nNWX8/XV6fd9kF9wVvL11xHkj/PaS6ECwZ8k1bGB1N+J BuwWaH4fbfgW8UUl44LZpVACDk66oKZTkoBUNqzv8rSK32DMNGGORI66IYAZ7DzfYeRL QifzchgJAOaNRe312JigZGGn+4uox5aKPOnW8oBgVXgC6pfAlzc4QW8xPV8JX6kJ01Dr JxFfi0sn247QIRjIrWJK2Czbb+SF8pL3kwFDxZK/2+sO1btHqvOYZXrzifOydImsvItn bkoQRUEvJ5T7pN7nYESqEGb+kzp0wtFZ5KvrqAR7HL5zE1GQC/m5DY73ThtTg+U78ny8 z2Jw== X-Forwarded-Encrypted: i=1; AFNElJ/nK2mL7yLjWA9N70PATmllgIya3JK2EVRfjct6bAVYbH84QJUmOWbVyqV3m1mhedi/5l2b+QgGcFgaMEc=@vger.kernel.org X-Gm-Message-State: AOJu0YyqBiyClm4AD77nCKvYbf5fKO2zS1gFCfvmzLPjiau400CEB47C NpLVbIxznVVm187ZHcSaGUnLR9ds3CkXWGOOEpTDkGSGw91hwuSyc+kPDIccwmjAD9o= X-Gm-Gg: Acq92OHWlMJef+yCy5kEW66wMPEDKMHOvfxO4sTGsn/PX5ooSgDA4whDkghO+WrxO4P pYfm5ZfYWOdGS9uRltNrwJvBWrIj9DjgQKvV9m4SkvCFlfDYCbGvF3ECcZZ0FYvGLhRdYnQLbIK DgeS3eLCPqYr+ZxotKJ8mwz9SXWrivQzBV+3f3UR/vaZamESBF6yqtYz2v9cdVGgPWMej0fO17a y0Mq7DMYUIUKcQk8UUVZJ5NVvn177h002tFpRwTti03ScPcqqHiUiYHMgsI9g34oBsJPQjMC588 Y6RteCgxkoPAYBt/Kx7bSZP2ybyB/ffg03N6hxSgvI5q00IK0ls0FYbp+/OV51yghbmj8o5AOYF HapQGpbl9VKL9D1i9doSxpMEbRxewf5zyWpK4ubvxtBi5rGQNBCUUx8Ny1G1N0LFppDFEh9uSJe wSQc/K38I9krIri1GT32Q7gM8pA0nzk5Kd/c+wNT/v293kA4hIpUw= X-Received: by 2002:a05:6214:5882:b0:8a7:164c:d5c8 with SMTP id 6a1803df08f44-8cc7bf194acmr13939606d6.24.1779406467102; Thu, 21 May 2026 16:34:27 -0700 (PDT) Received: from plex ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8cc8132429bsm1526136d6.47.2026.05.21.16.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 16:34:26 -0700 (PDT) Date: Thu, 21 May 2026 23:34:25 +0000 From: Pasha Tatashin To: Pratyush Yadav Cc: Mike Rapoport , Pasha Tatashin , Alexander Graf , Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Jason Miu , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/12] kho: add data argument to radix walk callback Message-ID: References: <20260429133928.850721-1-pratyush@kernel.org> <20260429133928.850721-6-pratyush@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: <20260429133928.850721-6-pratyush@kernel.org> On 04-29 15:39, Pratyush Yadav wrote: > From: "Pratyush Yadav (Google)" > > Add an opaque data pointer argument to kho_radix_walk_cb_t. This can be > used for callers to pass extra information to the callback. > > Signed-off-by: Pratyush Yadav (Google) > --- > include/linux/kho_radix_tree.h | 8 ++++---- > kernel/liveupdate/kexec_handover.c | 24 +++++++++++++----------- > 2 files changed, 17 insertions(+), 15 deletions(-) Reviewed-by: Pasha Tatashin > > diff --git a/include/linux/kho_radix_tree.h b/include/linux/kho_radix_tree.h > index fe7151d89361..6c0f7d82716b 100644 > --- a/include/linux/kho_radix_tree.h > +++ b/include/linux/kho_radix_tree.h > @@ -44,8 +44,8 @@ struct kho_radix_tree { > * return value is directly returned to the caller. > */ > struct kho_radix_walk_cb { > - int (*key)(unsigned long key); > - int (*table)(phys_addr_t phys); > + int (*key)(unsigned long key, void *data); > + int (*table)(phys_addr_t phys, void *data); > }; > > #ifdef CONFIG_KEXEC_HANDOVER > @@ -53,7 +53,7 @@ struct kho_radix_walk_cb { > int kho_radix_add_key(struct kho_radix_tree *tree, unsigned long key); > void kho_radix_del_key(struct kho_radix_tree *tree, unsigned long key); > int kho_radix_walk_tree(struct kho_radix_tree *tree, > - const struct kho_radix_walk_cb *cb); > + const struct kho_radix_walk_cb *cb, void *data); > > #else /* #ifdef CONFIG_KEXEC_HANDOVER */ > > @@ -66,7 +66,7 @@ static inline void kho_radix_del_key(struct kho_radix_tree *tree, > unsigned long key) { } > > static inline int kho_radix_walk_tree(struct kho_radix_tree *tree, > - const struct kho_radix_walk_cb *cb) > + const struct kho_radix_walk_cb *cb, void *data) > { > return -EOPNOTSUPP; > } > diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c > index 94ca831b41c9..d0a4f78eccfe 100644 > --- a/kernel/liveupdate/kexec_handover.c > +++ b/kernel/liveupdate/kexec_handover.c > @@ -267,14 +267,14 @@ void kho_radix_del_key(struct kho_radix_tree *tree, unsigned long key) > EXPORT_SYMBOL_GPL(kho_radix_del_key); > > static int kho_radix_walk_leaf(struct kho_radix_leaf *leaf, unsigned long key, > - const struct kho_radix_walk_cb *cb) > + const struct kho_radix_walk_cb *cb, void *data) > { > unsigned long *bitmap = (unsigned long *)leaf; > unsigned int i; > int err; > > if (cb->table) { > - err = cb->table(virt_to_phys(leaf)); > + err = cb->table(virt_to_phys(leaf), data); > if (err) > return err; > } > @@ -283,7 +283,7 @@ static int kho_radix_walk_leaf(struct kho_radix_leaf *leaf, unsigned long key, > return 0; > > for_each_set_bit(i, bitmap, PAGE_SIZE * BITS_PER_BYTE) { > - err = cb->key(key | i); > + err = cb->key(key | i, data); > if (err) > return err; > } > @@ -293,7 +293,7 @@ static int kho_radix_walk_leaf(struct kho_radix_leaf *leaf, unsigned long key, > > static int __kho_radix_walk_tree(struct kho_radix_node *root, > unsigned int level, unsigned long start, > - const struct kho_radix_walk_cb *cb) > + const struct kho_radix_walk_cb *cb, void *data) > { > struct kho_radix_node *node; > struct kho_radix_leaf *leaf; > @@ -302,7 +302,7 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root, > int err; > > if (cb->table) { > - err = cb->table(virt_to_phys(root)); > + err = cb->table(virt_to_phys(root), data); > if (err) > return err; > } > @@ -323,10 +323,10 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root, > * node is pointing to the level 0 bitmap. > */ > leaf = (struct kho_radix_leaf *)node; > - err = kho_radix_walk_leaf(leaf, key, cb); > + err = kho_radix_walk_leaf(leaf, key, cb, data); > } else { > err = __kho_radix_walk_tree(node, level - 1, > - key, cb); > + key, cb, data); > } > > if (err) > @@ -340,6 +340,7 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root, > * kho_radix_walk_tree - Traverses the radix tree and calls a callback for each key. > * @tree: A pointer to the KHO radix tree to walk. > * @cb: Set of callbacks to be invoked during the tree walk. > + * @data: Opaque data pointer passed to each callback in @cb. > * > * This function walks the radix tree, searching from the top level down to the > * lowest level (level 0), invoking the appropriate callbacks. > @@ -348,14 +349,15 @@ static int __kho_radix_walk_tree(struct kho_radix_node *root, > * value from the callback that stopped the walk. > */ > int kho_radix_walk_tree(struct kho_radix_tree *tree, > - const struct kho_radix_walk_cb *cb) > + const struct kho_radix_walk_cb *cb, void *data) > { > if (WARN_ON_ONCE(!tree->root)) > return -EINVAL; > > guard(mutex)(&tree->lock); > > - return __kho_radix_walk_tree(tree->root, KHO_TREE_MAX_DEPTH - 1, 0, cb); > + return __kho_radix_walk_tree(tree->root, KHO_TREE_MAX_DEPTH - 1, 0, cb, > + data); > } > EXPORT_SYMBOL_GPL(kho_radix_walk_tree); > > @@ -501,7 +503,7 @@ static struct page *__init kho_get_preserved_page(phys_addr_t phys, > return pfn_to_page(pfn); > } > > -static int __init kho_preserved_memory_reserve(unsigned long key) > +static int __init kho_preserved_memory_reserve(unsigned long key, void *data) > { > union kho_page_info info; > struct page *page; > @@ -1392,7 +1394,7 @@ static int __init kho_mem_retrieve(const void *fdt) > > kho_in.radix_tree.root = phys_to_virt(kho_get_mem_map_phys(fdt)); > mutex_init(&kho_in.radix_tree.lock); > - return kho_radix_walk_tree(&kho_in.radix_tree, &cb); > + return kho_radix_walk_tree(&kho_in.radix_tree, &cb, NULL); > } > > static __init int kho_out_fdt_setup(void) > -- > 2.54.0.545.g6539524ca2-goog >