From patchwork Thu Feb 16 12:03:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 9576985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53401600F6 for ; Thu, 16 Feb 2017 12:05:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5953528578 for ; Thu, 16 Feb 2017 12:05:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E1EE285A2; Thu, 16 Feb 2017 12:05:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DDCF0285B9 for ; Thu, 16 Feb 2017 12:05:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceKmj-0003aJ-Dp; Thu, 16 Feb 2017 12:03:41 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceKmi-0003Yb-Kg for xen-devel@lists.xenproject.org; Thu, 16 Feb 2017 12:03:40 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id A8/79-25093-B1595A85; Thu, 16 Feb 2017 12:03:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMbThsK7E1KU RBh82iFl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlzN+xkK3itUPF3/Tr2BsY9Ul2MXBxCAtMZ Jf5O/cMG4rAIvGSROHD1C5gjIdDPKnHpzG3GLkZOICdGYmvTYSCbA8iulvi+QQckLCSgJrHv0 HUWiEmzmSR6D35iAkmwCehKXH/1AMwWEVCSuLdqMhNIEbPAF0aJyx+WgCWEBQwlDuybDmazCK hKTO/oAVvGK+Amsfr9MzaIxXISN891MoPYnALuEiffPmWC2Owmcb+7hW0Co8ACRoZVjBrFqUV lqUW6RoZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBwcUABDsY/ywLOMQoycGk JMr7o39phBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3jWTgXKCRanpqRVpmTnAMIdJS3DwKInwP gNJ8xYXJOYWZ6ZDpE4xGnP0dJ1+ycSxZ9fll0xCLHn5ealS4rxvQEoFQEozSvPgBsHi7xKjrJ QwLyPQaUI8BalFuZklqPKvGMU5GJWEedeCTOHJzCuB2/cK6BQmoFM6I8BOKUlESEk1MJ6seut 7vvWfp400y3LrhM7rj5kncnu885U8+a+wb9pdn5upXxvOP/lnYq4jUvSZJ+/N7dS5Rpcb/O5t Nz/seFTTj/e98NOzf3I9Pprfm5a4e3PN84Y9++RTnHYbz3nhJuA0seBZfEHg/qVHPCVmX7ZMv HskJn/Pzeuc/r4Opq2veqW3pAtLMCmxFGckGmoxFxUnAgBC40RKugIAAA== X-Env-Sender: andrii.anisov@gmail.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1487246616!87478054!1 X-Originating-IP: [209.85.128.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27882 invoked from network); 16 Feb 2017 12:03:36 -0000 Received: from mail-wr0-f195.google.com (HELO mail-wr0-f195.google.com) (209.85.128.195) by server-9.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Feb 2017 12:03:36 -0000 Received: by mail-wr0-f195.google.com with SMTP id c4so1792212wrd.1 for ; Thu, 16 Feb 2017 04:03:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uoCUx9wPlvkc3AbZmC73MtvUELpjPDvbbv5MFFWYEvw=; b=KZkN4X0UHBExepsQO6vC48FNgngkV6HwLv9FjdMHP/QtvEtRnpHkHqCqstawiUjH2P KvTr6JbTzlj38HLVXLwehsgKFPaEycRsXZT2fspDIGIwUYAEeYd8JPScrlQ9PUF8Hmcl nhZoeqHuIsH/YEwyY/n8HbTvVdKkyD3LjonoLhv9zRnM69zJ/VtG+dc4BlMuYS+0E3Km 16i758HeGpvys0nu1qwok2yOSNX6Ej3Cnj0y9g9mFLatJ1tGYjh/SMrw0Cbx+DJWS9hP TUORrgZxAHs/j+8g8zbyeqo3Am1y7kjfCghRXiZYcfZCyLKOwaPogwMt4KVbQlEqxbo9 FLIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uoCUx9wPlvkc3AbZmC73MtvUELpjPDvbbv5MFFWYEvw=; b=PsBzt8yu5W14PwhLP/0cul2akNDPsFIrUA9L5Am7rDmOEB8UhBgSiJSXBDmDnwUPAS Q9pExlT3zcFRwRjm5N7Co6uXVC4iH5rEblfMut1xHh8BtQ2hUUNLrkIakPGRLnV9Kxrz 2JKl2Zzjv+SJBFm++X1nxZRY5uWlZZ4IPcjrTluR7uGUp4dtOUWQc6u3acB/oMAfhKIB BJ8n/t70yPF5/Pj8a2O5rKuwkoKxCcB5YbW4a7iMZN1GDl6/yFzT7xxuSji02X9GiLWc UPDNcWTVYwTpWmedUyhowmlq/Lh1oYIVgFBqgkCbNR/viCPJL80a6I4kxRjfuSpfFg0Y voCg== X-Gm-Message-State: AMke39lYnNCUI6HkaMd1yYALXyNH80FAeE5nzPggGVnIjOV7NXmOX6JecXQANiR9UZywEg== X-Received: by 10.223.135.219 with SMTP id c27mr1897444wrc.139.1487246616047; Thu, 16 Feb 2017 04:03:36 -0800 (PST) Received: from aanisov-work.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id w30sm8754047wrb.5.2017.02.16.04.03.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Feb 2017 04:03:35 -0800 (PST) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Thu, 16 Feb 2017 14:03:26 +0200 Message-Id: <1487246610-8298-3-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487246610-8298-1-git-send-email-andrii.anisov@gmail.com> References: <1487246610-8298-1-git-send-email-andrii.anisov@gmail.com> Cc: sstabellini@kernel.org, andrii_anisov@epam.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, paul.durrant@citrix.com, jbeulich@suse.com, wei.liu2@citrix.com Subject: [Xen-devel] [RFC 2/6] rangeset_destroy() refactoring X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Andrii Anisov rangeset_destroy is made domain agnostic. The domain specific code is moved to common/domain.c:domain_rangeset_destroy(). It is still left a rangesets list functionality: rangeset_destroy() will remove itself from a list. If a spinlock is provided it will be held for list deletion operation. This would be reconsidered further. Signed-off-by: Andrii Anisov --- xen/arch/x86/hvm/ioreq.c | 2 +- xen/arch/x86/mm/p2m.c | 2 +- xen/common/domain.c | 5 +++++ xen/common/rangeset.c | 15 ++++++++------- xen/include/xen/domain.h | 3 +++ xen/include/xen/rangeset.h | 9 ++++++--- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 6df191d..6ae5921 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -496,7 +496,7 @@ static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s, return; for ( i = 0; i < NR_IO_RANGE_TYPES; i++ ) - rangeset_destroy(s->range[i]); + domain_rangeset_destroy(s->range[i], s->domain); } static int hvm_ioreq_server_alloc_rangesets(struct hvm_ioreq_server *s, diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 46301ad..d39c093 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -141,7 +141,7 @@ static void p2m_teardown_hostp2m(struct domain *d) if ( p2m ) { - rangeset_destroy(p2m->logdirty_ranges); + domain_rangeset_destroy(p2m->logdirty_ranges, d); p2m_free_one(p2m); d->arch.p2m = NULL; } diff --git a/xen/common/domain.c b/xen/common/domain.c index 1b9bc3c..f03a032 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1553,6 +1553,11 @@ struct rangeset *domain_rangeset_new(struct domain *d, char *name, return r; } +void domain_rangeset_destroy(struct domain *d, + struct rangeset *r) +{ + rangeset_destroy(r, &d->rangesets_lock); +} /* diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c index 478d232..1172950 100644 --- a/xen/common/rangeset.c +++ b/xen/common/rangeset.c @@ -354,19 +354,20 @@ struct rangeset *rangeset_new(char *name, unsigned int flags, } void rangeset_destroy( - struct rangeset *r) + struct rangeset *r, spinlock_t *lock) { struct range *x; if ( r == NULL ) return; - if ( r->domain != NULL ) - { - spin_lock(&r->domain->rangesets_lock); - list_del(&r->rangeset_list); - spin_unlock(&r->domain->rangesets_lock); - } + if ( lock ) + spin_lock(lock); + + list_del(&r->rangeset_list); + + if ( lock ) + spin_unlock(lock); while ( (x = first_range(r)) != NULL ) destroy_range(r, x); diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index cd62e6e..3d9c652 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -111,4 +111,7 @@ void vnuma_destroy(struct vnuma_info *vnuma); struct rangeset *domain_rangeset_new(struct domain *d, char *name, unsigned int flags); +void domain_rangeset_destroy(struct domain *d, + struct rangeset *r); + #endif /* __XEN_DOMAIN_H__ */ diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h index 395ba62..deed54d 100644 --- a/xen/include/xen/rangeset.h +++ b/xen/include/xen/rangeset.h @@ -14,6 +14,7 @@ struct domain; struct list_head; +struct spinlock; struct rangeset; /* @@ -37,11 +38,13 @@ struct rangeset *rangeset_new(char *name, unsigned int flags, struct list_head **head); /* - * Destroy a rangeset. It is invalid to perform any operation on a rangeset @r + * Destroy a rangeset. Rangeset will take an action to remove itself from a + * list. If a spinlock is provided it will be held during list deletion + * operation. + * It is invalid to perform any operation on a rangeset @r * after calling rangeset_destroy(r). */ -void rangeset_destroy( - struct rangeset *r); +void rangeset_destroy(struct rangeset *r, struct spinlock *lock); /* * Set a limit on the number of ranges that may exist in set @r.