From patchwork Wed Sep 25 07:05:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11160099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EAA61599 for ; Wed, 25 Sep 2019 07:06:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 63FF921D7C for ; Wed, 25 Sep 2019 07:06:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63FF921D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD1MQ-00081w-1Z; Wed, 25 Sep 2019 07:05:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD1MO-000814-KH for xen-devel@lists.xenproject.org; Wed, 25 Sep 2019 07:05:12 +0000 X-Inumbo-ID: cdcb0dc2-df62-11e9-962b-12813bfff9fa Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id cdcb0dc2-df62-11e9-962b-12813bfff9fa; Wed, 25 Sep 2019 07:05:06 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 17180AE78; Wed, 25 Sep 2019 07:05:06 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 25 Sep 2019 09:05:02 +0200 Message-Id: <20190925070503.13850-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190925070503.13850-1-jgross@suse.com> References: <20190925070503.13850-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 1/2] xen/sched: fix locking in a653sched_free_vdata() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Josh Whitehead , Robert VanVossen , Dario Faggioli MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The arinc653 scheduler's free_vdata() function is missing proper locking: as it is modifying the scheduler's private vcpu list it needs to take the scheduler lock during that operation. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Dario Faggioli --- xen/common/sched_arinc653.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 72b988ea5f..d47b747ef4 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -442,16 +442,22 @@ a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd) static void a653sched_free_vdata(const struct scheduler *ops, void *priv) { + a653sched_priv_t *sched_priv = SCHED_PRIV(ops); arinc653_vcpu_t *av = priv; + unsigned long flags; if (av == NULL) return; + spin_lock_irqsave(&sched_priv->lock, flags); + if ( !is_idle_vcpu(av->vc) ) list_del(&av->list); xfree(av); update_schedule_vcpus(ops); + + spin_unlock_irqrestore(&sched_priv->lock, flags); } /** From patchwork Wed Sep 25 07:05:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11160095 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EA8E924 for ; Wed, 25 Sep 2019 07:06:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2382621D7C for ; Wed, 25 Sep 2019 07:06:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2382621D7C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD1ML-00080q-Nc; Wed, 25 Sep 2019 07:05:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iD1MK-00080f-5t for xen-devel@lists.xenproject.org; Wed, 25 Sep 2019 07:05:08 +0000 X-Inumbo-ID: cdd82066-df62-11e9-bf31-bc764e2007e4 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id cdd82066-df62-11e9-bf31-bc764e2007e4; Wed, 25 Sep 2019 07:05:07 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3B5A6AF10; Wed, 25 Sep 2019 07:05:06 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 25 Sep 2019 09:05:03 +0200 Message-Id: <20190925070503.13850-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190925070503.13850-1-jgross@suse.com> References: <20190925070503.13850-1-jgross@suse.com> Subject: [Xen-devel] [PATCH 2/2] xen/sched: fix freeing per-vcpu data in sched_move_domain() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In case of an allocation error of per-vcpu data in sched_move_domain() the already allocated data is freed just using xfree(). This is wrong as some schedulers need to do additional operations (e.g. the arinc653 scheduler needs to remove the vcpu-data from a list). So instead xfree() make use of the sched_free_vdata() hook. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Dario Faggioli --- xen/common/schedule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 13b5ffc7cf..13c17fe944 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -386,7 +386,7 @@ int sched_move_domain(struct domain *d, struct cpupool *c) if ( vcpu_priv[v->vcpu_id] == NULL ) { for_each_vcpu ( d, v ) - xfree(vcpu_priv[v->vcpu_id]); + sched_free_vdata(c->sched, vcpu_priv[v->vcpu_id]); xfree(vcpu_priv); sched_free_domdata(c->sched, domdata); return -ENOMEM;