From patchwork Wed Nov 2 09:08:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xinhui X-Patchwork-Id: 9408515 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 291D460234 for ; Wed, 2 Nov 2016 05:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A7D629E05 for ; Wed, 2 Nov 2016 05:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EFC729E08; Wed, 2 Nov 2016 05:15:41 +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=-1.2 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_03_06, RCVD_IN_DNSWL_MED autolearn=no 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 9A37829E05 for ; Wed, 2 Nov 2016 05:15:40 +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 1c1nrk-0001vM-Cu; Wed, 02 Nov 2016 05:13:36 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1nrj-0001vB-Lj for xen-devel@lists.xenproject.org; Wed, 02 Nov 2016 05:13:35 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id B5/69-21485-EF579185; Wed, 02 Nov 2016 05:13:34 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRWlGSWpSXmKPExsUyZfEcRt1/pZI RBrePMVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBlvnhcU7OOueP/kDGMD4xPOLkYuDiGBS4wS /Z8esEI4LUwSW49OZYFw3jBKbGn8yQbhnGaUOLF+FlTZBkaJTcd3Q2V2MUpcfHEXqIcTyFnHK HHutQ1E4jajxPXLs5hBEmwCBhI3LmwCGywi0M0k8WrDGkaQBLPAeWaJ818Muhg5OIQFAiT239 MDCbMIqEp8W/yJFSQsISAv8ex2PUiYU8BP4tHHZcwQu3wlll34DjZFQkBEYuLf92wQtqrExTk zmSFadSR2XwyBCFtIrGi4ygphG0nMuvmZCcTmBRqzbcdlqDFZEvv33ga7UkLgP6PEl9ML2Scw SixgZFjFqFGcWlSWWqRrZKyXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iREYHwxAs IPxz/zAQ4ySHExKory6wLgR4kvKT6nMSCzOiC8qzUktPsQow8GhJMG7ugQoJ1iUmp5akZaZA4 xUmLQEB4+SCK85SJq3uCAxtzgzHSJ1ilFRSpx3MUhCACSRUZoH1wZLDpcYZaWEeRmBDhHiKUg tys0sQZV/xSjOwagkzGsDMoUnM68EbvoroMVMIIuTJEAWlyQipKQaGHmZNxexHuL6ev/J9nUP wj9/zFO9IrUgPins5eyKh0+SA6OOPZ0+Obj75rzHb3fz1yaYL2u54Gr+QTAuQlPK6eTKdevCn iyfpTylWXW61k2JjXyz5CX/xE6y2CwZ/IyrSkHU5+dphwZ+Z2/7X5vPVpw/W7Qw2E7fnHvnVt Ur9+WjJ2j1is7fV6zEUpyRaKjFXFScCADUePViCQMAAA== X-Env-Sender: xinhui.pan@linux.vnet.ibm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1478063612!35046218!1 X-Originating-IP: [148.163.156.1] X-SpamReason: No, hits=2.1 required=7.0 tests=DATE_IN_FUTURE_03_06, UNPARSEABLE_RELAY X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15498 invoked from network); 2 Nov 2016 05:13:33 -0000 Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by server-4.tower-21.messagelabs.com with AES256-SHA encrypted SMTP; 2 Nov 2016 05:13:33 -0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA25DSVN055894 for ; Wed, 2 Nov 2016 01:13:32 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0a-001b2d01.pphosted.com with ESMTP id 26f8xujb7r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 02 Nov 2016 01:13:31 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Nov 2016 15:13:29 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 Nov 2016 15:13:27 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 098073578052; Wed, 2 Nov 2016 16:13:27 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uA25DQP319529972; Wed, 2 Nov 2016 16:13:26 +1100 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id uA25DPJr007176; Wed, 2 Nov 2016 16:13:26 +1100 Received: from ltcalpine2-lp13.aus.stglabs.ibm.com (ltcalpine2-lp13.aus.stglabs.ibm.com [9.40.195.196]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id uA25CnXf006036; Wed, 2 Nov 2016 16:13:20 +1100 From: Pan Xinhui To: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, xen-devel-request@lists.xenproject.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org Date: Wed, 2 Nov 2016 05:08:28 -0400 X-Mailer: git-send-email 2.4.11 In-Reply-To: <1478077718-37424-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> References: <1478077718-37424-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110205-1617-0000-0000-00000172B634 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110205-1618-0000-0000-0000470A96CB Message-Id: <1478077718-37424-2-git-send-email-xinhui.pan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-02_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611020096 Cc: kernellwp@gmail.com, jgross@suse.com, dave@stgolabs.net, David.Laight@ACULAB.COM, rkrcmar@redhat.com, peterz@infradead.org, benh@kernel.crashing.org, bsingharora@gmail.com, will.deacon@arm.com, Pan Xinhui , borntraeger@de.ibm.com, mingo@redhat.com, paulus@samba.org, mpe@ellerman.id.au, pbonzini@redhat.com, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com Subject: [Xen-devel] [PATCH v7 01/11] kernel/sched: introduce vcpu preempted check interface 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 This patch support to fix lock holder preemption issue. For kernel users, we could use bool vcpu_is_preempted(int cpu) to detect if one vcpu is preempted or not. The default implementation is a macro defined by false. So compiler can wrap it out if arch dose not support such vcpu preempted check. Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Pan Xinhui Acked-by: Christian Borntraeger Acked-by: Paolo Bonzini Tested-by: Juergen Gross --- include/linux/sched.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 348f51b..44c1ce7 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -3506,6 +3506,18 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) #endif /* CONFIG_SMP */ +/* + * In order to deal with a various lock holder preemption issues provide an + * interface to see if a vCPU is currently running or not. + * + * This allows us to terminate optimistic spin loops and block, analogous to + * the native optimistic spin heuristic of testing if the lock owner task is + * running or not. + */ +#ifndef vcpu_is_preempted +#define vcpu_is_preempted(cpu) false +#endif + extern long sched_setaffinity(pid_t pid, const struct cpumask *new_mask); extern long sched_getaffinity(pid_t pid, struct cpumask *mask);