From: Peter Xu <peterx@redhat.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
David Hildenbrand <david@redhat.com>,
Cornelia Huck <cohuck@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Qian Cai <cai@lca.pw>
Subject: Re: [PATCH 4/7] KVM: selftests: Add helpers to consolidate open coded list operations
Date: Fri, 20 Mar 2020 18:47:44 -0400 [thread overview]
Message-ID: <20200320224744.GG127076@xz-x1> (raw)
In-Reply-To: <20200320205546.2396-5-sean.j.christopherson@intel.com>
On Fri, Mar 20, 2020 at 01:55:43PM -0700, Sean Christopherson wrote:
> Add helpers for the KVM sefltests' variant of a linked list to replace a
> variety of open coded adds, deletes and iterators.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> tools/testing/selftests/kvm/lib/kvm_util.c | 68 ++++++++++++----------
> 1 file changed, 37 insertions(+), 31 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index 9a783c20dd26..d7b74f465570 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -19,6 +19,27 @@
> #define KVM_UTIL_PGS_PER_HUGEPG 512
> #define KVM_UTIL_MIN_PFN 2
>
> +#define kvm_list_add(head, new) \
> +do { \
> + if (head) \
> + head->prev = new; \
> + new->next = head; \
> + head = new; \
> +} while (0)
> +
> +#define kvm_list_del(head, del) \
> +do { \
> + if (del->next) \
> + del->next->prev = del->prev; \
> + if (del->prev) \
> + del->prev->next = del->next; \
> + else \
> + head = del->next; \
> +} while (0)
> +
> +#define kvm_list_for_each(head, iter) \
> + for (iter = head; iter; iter = iter->next)
> +
I'm not sure whether we should start to use a common list, e.g.,
tools/include/linux/list.h, if we're going to rework them after all...
Even if this is preferred, maybe move to a header so kvm selftests can
use it in the future outside "vcpu" struct too and this file only?
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2020-03-20 22:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 20:55 [PATCH 0/7] KVM: Fix memslot use-after-free bug Sean Christopherson
2020-03-20 20:55 ` [PATCH 1/7] KVM: Fix out of range accesses to memslots Sean Christopherson
2020-03-20 22:17 ` Peter Xu
2020-03-20 22:40 ` Sean Christopherson
2020-03-20 22:58 ` Peter Xu
2020-03-20 23:07 ` Sean Christopherson
2020-03-24 7:12 ` Christian Borntraeger
2020-03-24 10:12 ` Claudio Imbrenda
2020-03-20 20:55 ` [PATCH 2/7] KVM: selftests: Fix cosmetic copy-paste error in vm_mem_region_move() Sean Christopherson
2020-03-20 20:55 ` [PATCH 3/7] KVM: selftests: Take vcpu pointer instead of id in vm_vcpu_rm() Sean Christopherson
2020-03-20 20:55 ` [PATCH 4/7] KVM: selftests: Add helpers to consolidate open coded list operations Sean Christopherson
2020-03-20 22:47 ` Peter Xu [this message]
2020-03-24 11:28 ` Paolo Bonzini
2020-03-20 20:55 ` [PATCH 5/7] KVM: selftests: Add util to delete memory region Sean Christopherson
2020-03-20 20:55 ` [PATCH 6/7] KVM: selftests: Expose the primary memslot number to tests Sean Christopherson
2020-03-23 19:12 ` Peter Xu
2020-03-23 21:28 ` Sean Christopherson
2020-03-20 20:55 ` [PATCH 7/7] KVM: selftests: Add "delete" testcase to set_memory_region_test Sean Christopherson
2020-03-23 19:06 ` Peter Xu
2020-03-23 21:43 ` Sean Christopherson
2020-03-23 21:58 ` Peter Xu
2020-03-24 11:30 ` [PATCH 0/7] KVM: Fix memslot use-after-free bug Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200320224744.GG127076@xz-x1 \
--to=peterx@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cai@lca.pw \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=sean.j.christopherson@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox