From patchwork Wed Feb 22 22:16:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haoran Li X-Patchwork-Id: 9587503 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 D0314600CA for ; Wed, 22 Feb 2017 22:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD27C28582 for ; Wed, 22 Feb 2017 22:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF0B4286CA; Wed, 22 Feb 2017 22:20:32 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, 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 97CFE28582 for ; Wed, 22 Feb 2017 22:20:31 +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 1cgfDt-0001kL-Sa; Wed, 22 Feb 2017 22:17:21 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgfDs-0001kF-LC for xen-devel@lists.xenproject.org; Wed, 22 Feb 2017 22:17:20 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 1E/70-31649-FED0EA85; Wed, 22 Feb 2017 22:17:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplkeJIrShJLcpLzFFi42K5GHrNUfcd77o Ig4utFhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bVez+ZCjbwVry9GdbAOJe7i5GLQ0hgOqPE 0Q0L2EEcFoFLLBJ3/25kAnEkBN6xSOzduIKli5ETyImReLH1B1sXIweQXSZxe5cQSFhIQEli6 tFeZohJM5kkOq7OYwRJsAmoSpz7/QOsVwSo6N6qyUwgNrOAlUTf0ltgtrCAu8SKMxfB6lmA6r d//wEW5xVwkph8+x4zxF45iZPHJrNOYORbwMiwilGjOLWoLLVI18hSL6koMz2jJDcxM0fX0MB YLze1uDgxPTUnMalYLzk/dxMjMFDqGRgYdzA27fU7xCjJwaQkyvvnztoIIb6k/JTKjMTijPii 0pzU4kOMMhwcShK8S3nWRQgJFqWmp1akZeYAQxYmLcHBoyTCawmS5i0uSMwtzkyHSJ1iNOZ4c GrXGyaOT/2H3zAJseTl56VKifNKAqNBSACkNKM0D24QLJYuMcpKCfMyMjAwCPEUpBblZpagyr 9iFOdgVBLmrQRZyJOZVwK37xXQKUwgpzivBTmlJBEhJdXAyPtSZKOsd8yplULPVCZGujIL14h JCLpv7w/4dVryv/ls0TkvBPqWfXgz5fOFxU8DonfLTBdfeP1B/YyY9upDcqemx2ZELDB+GHz0 rX6D0/R3CduNFeX3J+WcL5A6W/fnwKRj1kcabyow1O7OfHvkoei21zYKXZ3LXrx5xbSpJsNwT 8F9FsUgXyWW4oxEQy3mouJEAHA0iE6gAgAA X-Env-Sender: naroahlee@gmail.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1487801837!79375031!1 X-Originating-IP: [209.85.214.65] 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 4271 invoked from network); 22 Feb 2017 22:17:18 -0000 Received: from mail-it0-f65.google.com (HELO mail-it0-f65.google.com) (209.85.214.65) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Feb 2017 22:17:18 -0000 Received: by mail-it0-f65.google.com with SMTP id 203so2443390ith.2 for ; Wed, 22 Feb 2017 14:17:18 -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; bh=rBi2kgwdtCmoszzOuheP/MJemg5Ro5rpWJO7+zI8I3A=; b=VI8cRVnnGHkZAy8H3MFHzv4NEwMgBXs5zLH7r9EMRE/L6aOxb5cJAyS9/2MtnQvi01 j3JpWG+Y8EllsyilzNzuFi7aspJbEjmv7fU5xbh6/Nx1ViIB97rTcl+HjRLe57kjgr/Q p5IpfD6O3nQh7FijtZDHwBOvlxiTI/Z8t5wRXaQU67VdJBsmMljXqEVaO0u/yLKKy0PM /Y5dyn93QIOc9A1+xolu9SZutGlJ8/qHjx/EZiSdjQk9re28KuEwJza9tPM7idyygeuW xljY2F7hMTQthQzdJQm/CdRA5K/FsLn/wTEOUnMPW67GRkuyumKyogrNy83IO7lCZvTg rQ+Q== 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; bh=rBi2kgwdtCmoszzOuheP/MJemg5Ro5rpWJO7+zI8I3A=; b=L66RcYa6Ge1c8ng8VWLzZmWjx0YVJzmoJKfNm1s9RTPHvAYIfF41Oupv3FlsTQSxzU DrBWy1Gt/S+44RX8oG/1AXKdBmQ1/0vGlLhtKCI1Afjy+4pnZ5Q4np4YUavnD9+d3KTW fPXPdavjR74UAQoE6yQpEnWSfXjVxyby5VWU8Wy8x4c6sjZzz8FiBOF1iaSplvYXvJ0w /PoZyZORs2GG4KrOBWb2cnZCxeGtlh53wOkc7c0yerSHhxoh0znF/Fa74YdDXzKbnCaB G0cYsz33FLWyWr65T3BD4Mn3pv94Zr2Q+RShZU1Upw1aDsUVgtn+bAdHdspeMy6wTFMD OSmA== X-Gm-Message-State: AMke39mMkrCqYlc/i5r2oGBTEnEhxv0+IZEp6UkCP1YQNHoCiGOCQFPiy8RF5Nzb44E55g== X-Received: by 10.36.53.78 with SMTP id k75mr806603ita.45.1487801837449; Wed, 22 Feb 2017 14:17:17 -0800 (PST) Received: from E5-2863v4.seas.wustl.edu (admin998.cec.wustl.edu. [128.252.20.193]) by smtp.googlemail.com with ESMTPSA id v136sm1074653ita.0.2017.02.22.14.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 14:17:16 -0800 (PST) From: Haoran Li To: xen-devel@lists.xenproject.org Date: Wed, 22 Feb 2017 16:16:34 -0600 Message-Id: <1487801794-5506-1-git-send-email-naroahlee@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: mengxu@cis.upenn.edu, naroahlee Subject: [Xen-devel] [RTDS Patch for Xen4.8] xen: sched_rt.c Check not_tickled Mask 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: naroahlee Modify: xen/common/sched_rt.c runq_tickle(): Check not_tickled Mask for a Cache-Preferenced-PCPU The bug is introduced in Xen 4.7 when we converted RTDS scheduler from quantum-driven model to event-driven model. We assumed whenever runq_tickle() is invoked, we will find a PCPU via a NOT-tickled mask. However, in runq_tickle(): Case1: Pick Cache Preference IDLE-PCPU is NOT masked by the not-tickled CPU mask. Buggy behavior: When two VCPUs tried to tickle a IDLE-VCPU, which is now on their cache-preference PCPU, these two VCPU will tickle the same PCPU in a row. However, only one VCPU is guranteed to be scheduled, because runq_pick() would be executed only once in rt_schedule(). That means, another VCPU will lost (be descheduled) a Period. Bug Analysis: We need to exclude tickled VCPUs when trying to evaluate runq_tickle() case 1 Signed-off-by: Haoran Li --- xen/common/sched_rt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 1b30014..777192f 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1175,7 +1175,8 @@ runq_tickle(const struct scheduler *ops, struct rt_vcpu *new) cpumask_andnot(¬_tickled, ¬_tickled, &prv->tickled); /* 1) if new's previous cpu is idle, kick it for cache benefit */ - if ( is_idle_vcpu(curr_on_cpu(new->vcpu->processor)) ) + if ( is_idle_vcpu(curr_on_cpu(new->vcpu->processor)) && + cpumask_test_cpu(new->vcpu->processor, ¬_tickled)) { SCHED_STAT_CRANK(tickled_idle_cpu); cpu_to_tickle = new->vcpu->processor;