Received: by 10.213.65.68 with SMTP id h4csp543538imn; Sat, 7 Apr 2018 04:29:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/K7JA7xKCsYHKGMXRBhPYQob2LqlM4+RXKNRHaN7i93uc8zgLHLlt7daq2UKQL/ERqw8ER X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr31562446plb.198.1523100589750; Sat, 07 Apr 2018 04:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523100589; cv=none; d=google.com; s=arc-20160816; b=aSQaVqWwnHeZkhhgH16ZGtDkiNhrC/+3rH03tFuPOFzc/4IyoUzKPGrAe3nVqRYIuJ ElyyD25Qiq4cQqor7lXJIo8RdOcb2SGluom7lBJr4XU81Rn5weXAamYW0i9C54Wp5fC8 aTlLAkF5CUu74zY8MK9zWwfHlhIESOQbwP61J79eYN7/yhMZSONAcK89PRlDgmZXGdMA q8L2zZAu/0TzPUf+0HWOjdU5S0zZLfWpmVGE7VdOkfYXTt7kP47K0QQzLjkbfGvXmPfL s+GZNdc/yYWD0unMMxxM8cyTMM0Vc/aih5Kc9FMpIbA4X2AMd764vTkTpO6U9lWj6c7N 8PCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=uOG/DB6fYpiQFVdVXNfuoJVRxV2if48nnxLJwwpsn1A=; b=rK5n0UEqEHsvb/hRlIvkVXU9kdOg+hCuXAwlX5D6KK+0DXPnNDtP+F39D+yIC4J60b Wb5BrcjbP/vcLo34DPVg1xYqHp2cy1mknqVJxFz58cSXn7wDViZtPfx6/SCRyS/WQQX5 /q7bYF1+W/qZXQcZDxN7+rBGEaLJkb2A1X6QdN0Nof9uIgI1VQeVDjBneZvuQASmUmjW fI9huH+WMh7GEfCWY88fHRRK23NVRKJlA3j7Kt2g6OEuTJR/RxixFyBdR2wp7DMY78BV B0K6QJhz/ZGf2B321G0QXM+sdLXiFUsEC2w6V/SehjfuiTCqjGWUTjJsLzw1VyMePZ/C Rmyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=b4MS0pUb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si8390779pgc.609.2018.04.07.04.28.56; Sat, 07 Apr 2018 04:29:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=b4MS0pUb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751602AbeDGLZj (ORCPT + 99 others); Sat, 7 Apr 2018 07:25:39 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:34494 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbeDGLZW (ORCPT ); Sat, 7 Apr 2018 07:25:22 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w37B3wLF188404; Sat, 7 Apr 2018 11:25:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=uOG/DB6fYpiQFVdVXNfuoJVRxV2if48nnxLJwwpsn1A=; b=b4MS0pUbaq26RHWsE8WgmS4zSTyjDxp73kv/hda3EPA5hKk9JzWtFSapZRvtyUEb0DuZ FvrkPnaZbpWiJ+EQBBb9YdDER4fbEZ8NeRxVkawNEe66SziS1t2bVYm/XhLLBX9L4L0N k7PiP0Icpj3IBS6U8YgEyWuFxTRqXimJbOeKdYQFUdxWXCjyqX9rMbKHUM/VTanbkBD/ KGjzCCVoI9jRpaHYm8cQJHLrYQAs4k8EtTRucT2j6Pr8dE0Kj8RDvAgQLClzg9zJX544 NpFQFwmuFQBmuyfURySWfyw+OQ8PXdjkyPMQnG2dOPa9jLaKZv6h4ImbcHGs6LMsePIl Xw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2h6kgt0rtx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 07 Apr 2018 11:25:15 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w37BPEvO015334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 7 Apr 2018 11:25:14 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w37BPEQp012921; Sat, 7 Apr 2018 11:25:14 GMT Received: from linux.cn.oracle.com (/10.182.69.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 07 Apr 2018 04:25:13 -0700 From: Dongli Zhang To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: boris.ostrovsky@oracle.com, jgross@suse.com, ian.jackson@eu.citrix.com, wei.liu2@citrix.com, srinivas.eeda@oracle.com Subject: [PATCH RFC xen 2/2] libxl: introduce xenwatch multithreading to xen toolstack Date: Sat, 7 Apr 2018 19:25:55 +0800 Message-Id: <1523100355-27647-3-git-send-email-dongli.zhang@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523100355-27647-1-git-send-email-dongli.zhang@oracle.com> References: <1523100355-27647-1-git-send-email-dongli.zhang@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8855 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=830 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804070121 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch is based on xen-4.10.0. This patch introduces xenwatch multithreading (or multithreaded xenwatch, abbreviated as 'mtwatch') on xen toolstack side. In addition to the existing single xenwatch thread, each domU has its own kernel thread ([xen-mtwatch-]) to process its xenwatch event. The create/destroy of each per-domU mtwatch thread is controlled by xenstore. The dom0 kernel watches at node '/local/domain/0/mtwatch', under which each domU has an entry. The node '/local/domain/0/mtwatch/' is written to xenstore first during domU creation, while the same node is removed from xenstore as the last xenstore operation during the domU destroy. The corresponding watch callback would create or destroy the per-domU mtwatch thread. Signed-off-by: Dongli Zhang --- tools/libxl/libxl_create.c | 12 ++++++++++++ tools/libxl/libxl_domain.c | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index f15fb21..579216a 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -527,6 +527,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, const char *dom_type; char *uuid_string; char *dom_path, *vm_path, *libxl_path; + char *mtwatch_path; struct xs_permissions roperm[2]; struct xs_permissions rwperm[1]; struct xs_permissions noperm[1]; @@ -601,6 +602,14 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, goto out; } + mtwatch_path = GCSPRINTF("%s/mtwatch/%d", + libxl__xs_get_dompath(gc, 0), *domid); + if (!mtwatch_path) { + LOGD(ERROR, *domid, "cannot allocate mtwatch path"); + rc = ERROR_FAIL; + goto out; + } + noperm[0].id = 0; noperm[0].perms = XS_PERM_NONE; @@ -615,6 +624,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, retry_transaction: t = xs_transaction_start(ctx->xsh); + xs_rm(ctx->xsh, t, mtwatch_path); + libxl__xs_mknod(gc, t, mtwatch_path, noperm, ARRAY_SIZE(noperm)); + xs_rm(ctx->xsh, t, dom_path); libxl__xs_mknod(gc, t, dom_path, roperm, ARRAY_SIZE(roperm)); diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c index 814f812..6638f66 100644 --- a/tools/libxl/libxl_domain.c +++ b/tools/libxl/libxl_domain.c @@ -1051,6 +1051,30 @@ out: return; } +static void libxl_rm_mtwatch_node(libxl__gc *gc, uint32_t domid) +{ + char *mtwatch_path; + xs_transaction_t t = 0; + int rc; + + mtwatch_path = GCSPRINTF("%s/mtwatch/%d", + libxl__xs_get_dompath(gc, 0), domid); + if (!mtwatch_path) { + LOGD(ERROR, domid, "cannot allocate mtwatch path"); + return; + } + + rc = libxl__xs_transaction_start(gc, &t); + if (rc) goto out; + + libxl__xs_path_cleanup(gc, t, mtwatch_path); + + libxl__xs_transaction_commit(gc, &t); + +out: + libxl__xs_transaction_abort(gc, &t); +} + static void devices_destroy_cb(libxl__egc *egc, libxl__devices_remove_state *drs, int rc) @@ -1083,6 +1107,8 @@ static void devices_destroy_cb(libxl__egc *egc, xs_rm(ctx->xsh, XBT_NULL, libxl__xs_libxl_path(gc, domid)); xs_rm(ctx->xsh, XBT_NULL, GCSPRINTF( "/local/domain/%d/hvmloader", domid)); + libxl_rm_mtwatch_node(gc, domid); + /* This is async operation, we already hold CTX lock */ lock = libxl__lock_domain_userdata(gc, domid); if (!lock) { -- 2.7.4