[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/grant-table: Simplify the update to the per-vCPU maptrack freelist


  • To: Julien Grall <julien@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 9 Jun 2021 12:20:12 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qTDl0/KVhcTvFDB9ZTaEJZ7ejh9uPJ6WnYYJjdsfbV8=; b=R9Qn6fBhZ7IwC/cUziUfRuKYJHit9k+RPkD33r/PENPG0FC9pA5gmg5O8/H8cCd8YQ+7moSX6CeyuplBkD+KOHyrxssZJ3fuxJOCVRmXL8Re4WzodiattBOv/ajE0SaQ/XTd26+uQv+98zoPac+iyJQSxNJ6/tPKCrKdAax/GdSFyZBZjynTy+XxBmALTpSUGxJXNtKJBVqJtTEq0/LezxOMixVSXRaj8yvrKc1TzXWFFIQIzTo5HgHp0hV9y+uuJxYsIhFwmhFnVd1uxGrerfURh+IrDXxfm0TuoRCZt7F10olYPH7BiV66ASICPHe2h20dkh90vVvNTt0UxB2RZw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i+BVWQg5YP4FfYdAuHIUDZh5xllIbDw+fEiothxeplKy+0LsCUcB6KbQFTQQFjiBT6yV6QQin6dMbyhRdwT7lDD3um29bXGFKr85eALl2DflR6d2raXYiwRlvzGnb4AYGffsXbwajFzYKLpx6nbr3lzDZeILJ9mVoU3eLt/3M5ZGKmUgTgUkwNoeBv5IoDEjYbQ2P4SUSgqBYbMGthGbyWLKkHe2h7Ax9rDu7AwdtHLc/o6VTtsgI+1umi1Iq0UGggs1hPlaqYJ1I32dV/xNjZLEUFJ5U7DVYhSSH6MCw4QHbUyQLFmEGi0ICl4NIZJArd6SjM4nqA+ZYb+0E9dOVQ==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 09 Jun 2021 10:20:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08.06.2021 12:08, Julien Grall wrote:
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> Since XSA-228 (commit 02cbeeb62075 "gnttab: split maptrack lock
> to make it fulfill its purpose again"), v->maptrack_head,
> v->maptrack_tail and the content of the freelist are accessed with
> the lock v->maptrack_freelist_lock held.
> 
> Therefore it is not necessary to update the fields using cmpxchg()
> and also read them atomically.
> 
> Note that there are two cases where v->maptrack_tail is accessed without
> the lock. They both happen in get_maptrack_handle() when initializing
> the free list of the current vCPU. Therefore there is no possible race.
> 
> The code is now reworked to remove any use of cmpxch() and read_atomic()
> when accessing the fields v->maptrack_{head, tail} as wel as the
> freelist.
> 
> Take the opportunity to add a comment on top of the lock definition
> and explain what it protects.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
with one nit:

> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -255,7 +255,13 @@ struct vcpu
>      /* VCPU paused by system controller. */
>      int              controller_pause_count;
>  
> -    /* Grant table map tracking. */
> +    /*
> +     * Grant table map tracking. The lock maptrack_freelist_lock
> +     * protects to:

I don't think you want "to" here.

Jan

> +     *  - The entries in the freelist
> +     *  - maptrack_head
> +     *  - maptrack_tail
> +     */
>      spinlock_t       maptrack_freelist_lock;
>      unsigned int     maptrack_head;
>      unsigned int     maptrack_tail;
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.