All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/kvm: Use 'hlist_for_each_entry' to simplify code
@ 2021-04-28  9:08 Christophe JAILLET
  0 siblings, 0 replies; only message in thread
From: Christophe JAILLET @ 2021-04-28  9:08 UTC (permalink / raw)
  To: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, tglx,
	mingo, bp, x86, hpa
  Cc: kvm, linux-kernel, kernel-janitors, Christophe JAILLET

Use 'hlist_for_each_entry' instead of hand writing it.
This saves a few lines of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
 arch/x86/kernel/kvm.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index d307c22e5c18..35f5a0898b92 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -89,14 +89,11 @@ static struct kvm_task_sleep_head {
 static struct kvm_task_sleep_node *_find_apf_task(struct kvm_task_sleep_head *b,
 						  u32 token)
 {
-	struct hlist_node *p;
+	struct kvm_task_sleep_node *n;
 
-	hlist_for_each(p, &b->list) {
-		struct kvm_task_sleep_node *n =
-			hlist_entry(p, typeof(*n), link);
+	hlist_for_each_entry(n, &b->list, link)
 		if (n->token == token)
 			return n;
-	}
 
 	return NULL;
 }
@@ -169,14 +166,12 @@ static void apf_task_wake_all(void)
 	for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) {
 		struct kvm_task_sleep_head *b = &async_pf_sleepers[i];
 		struct kvm_task_sleep_node *n;
-		struct hlist_node *p, *next;
+		struct hlist_node *next;
 
 		raw_spin_lock(&b->lock);
-		hlist_for_each_safe(p, next, &b->list) {
-			n = hlist_entry(p, typeof(*n), link);
+		hlist_for_each_entry_safe(n, next, &b->list, link)
 			if (n->cpu == smp_processor_id())
 				apf_task_wake_one(n);
-		}
 		raw_spin_unlock(&b->lock);
 	}
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-28  9:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28  9:08 [PATCH] x86/kvm: Use 'hlist_for_each_entry' to simplify code Christophe JAILLET

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.