From nobody Sat Nov 30 00:35:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620757209; cv=none; d=zohomail.com; s=zohoarc; b=E/79A7QPYL+otkHs7VBdv3SrbRBvm5xQc8rXuHrnNvXXXCmNxIVpC0OqGM4vwh8tW5zAox/lRYhitp07qef13rx5KGKeG9xZSR893ib5rvigUCIjNjlqE5xItynW0JuACK20mq/Mg/HZzv4taNCSYtdUt5vvBYRen/itrEZP6y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620757209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZWqvvfH/pSuceHqfiA4kqYHT6DIfxmT8+4jW3pShXB0=; b=WgoGIt0SFWoNNoizt2nTeTqWxsAwgktAIYBMN/gWPGzxXApKCq3AEDo9F/I1YFgNx36vWh3dhQ3ifEvrdBmZU0I9OooihROP/jo1ySIS/GprrlI2QvNJDGicwix3BCqbSEed+A7TlIKchZulvjcimeeR402++o8VSrUHxOXOIpQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620757209220979.2123440320045; Tue, 11 May 2021 11:20:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.125963.237120 (Exim 4.92) (envelope-from ) id 1lgWz7-0000Bd-5n; Tue, 11 May 2021 18:19:57 +0000 Received: by outflank-mailman (output) from mailman id 125963.237120; Tue, 11 May 2021 18:19:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgWz7-0000BV-2T; Tue, 11 May 2021 18:19:57 +0000 Received: by outflank-mailman (input) for mailman id 125963; Tue, 11 May 2021 18:19:56 +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.92) (envelope-from ) id 1lgWz6-0007fz-5J for xen-devel@lists.xenproject.org; Tue, 11 May 2021 18:19:56 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 004134c6-8940-498b-b7f6-53c71747813c; Tue, 11 May 2021 18:19:52 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 004134c6-8940-498b-b7f6-53c71747813c DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620757192; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/QT5ezwDnkjXc3nVgBVAB8DaWEl/4FRFCADP++oYh28=; b=Jdu6ymxTEyir3Wpq1Vlje0oTSI8uvRDp3EyQ5XHU8GofqKnyO/4yfL/T tadaeJnDhPWPHVau6fdtmwh0bZEN92ikFEct1VuRWE+8T+4Bto5mRkjmo XhPMYX+n/3LKVu7pP4SrfkG0+/zf7153MPrjkTArPJkUgO2F6N1x6W1iT o=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: CKYOs+i1d3uxTBukfgQWpA1/0Q6N5xF4YW3jDwQw4XsDP1Yu/ygVFpSXvRJ3wFHVWtIMu3qyOX F9MHR0nLkK4Jyspb534EhqoXML/Esnp857rRv0rWlQ5smYpGBZDZx0sGM3p6785xDL2X7wBbEX Qb5pYN3pIQllJJ3iigpKUx5qV+7pSHODIad8Vvb/r5S/HNEiwr5l2rtW5DFqtLRrgjc6ygT9t2 zkO4fJLvzYevOalpREIDVvSWqSfkDcLy1i2K+LfbAv9VRyHxi/RD7guWQCnoUkR43o9Ah/vROA G+8= X-SBRS: 5.1 X-MesageID: 43676922 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:jUJ+BaDEC34bMKflHelo55DYdb4zR+YMi2TDt3oddfU1SL38qy nKpp4mPHDP5wr5NEtPpTniAtjjfZq/z/5ICOAqVN/PYOCPggCVxepZnOjfKlPbehEX9oRmpN 1dm6oVMqyMMbCt5/yKnDVRELwbsaa6GLjDv5a785/0JzsaE52J6W1Ce2GmO3wzfiZqL7wjGq GR48JWzgDQAkj+PqyAdx84t/GonayzqK7b X-IronPort-AV: E=Sophos;i="5.82,291,1613451600"; d="scan'208";a="43676922" From: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= To: CC: =?UTF-8?q?Edwin=20T=C3=B6r=C3=B6k?= , "Christian Lindig" , David Scott , "Ian Jackson" , Wei Liu , Andrew Cooper Subject: [PATCH v2 15/17] tools/ocaml/xenstored: use gnttab instead of xenctrl's foreign_map_range Date: Tue, 11 May 2021 19:05:28 +0100 Message-ID: <2e703b8a3e75370ed0208b2c1da9a3562df82a14.1620755943.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) This is an oxenstored port of the following C xenstored commit: 38eeb3864de40aa568c48f9f26271c141c62b50b tools/xenstored: Drop mapping of t= he ring via foreign map Now only Xenctrl.domain_getinfo remains as the last use of unstable xenctrl= interface in oxenstored. Depends on: tools/ocaml: safer Xenmmap interface (without it the code would build but the wrong unmap function would get called on domain destruction) CC: Andrew Cooper Signed-off-by: Edwin T=C3=B6r=C3=B6k --- tools/ocaml/xenstored/domains.ml | 7 +++++-- tools/ocaml/xenstored/xenstored.ml | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/ocaml/xenstored/domains.ml b/tools/ocaml/xenstored/domai= ns.ml index 17fe2fa257..d9cb693751 100644 --- a/tools/ocaml/xenstored/domains.ml +++ b/tools/ocaml/xenstored/domains.ml @@ -22,6 +22,7 @@ let xc =3D Xenctrl.interface_open () =20 type domains =3D { eventchn: Event.t; + gnttab: Gnt.Gnttab.interface; table: (Xenctrl.domid, Domain.t) Hashtbl.t; =20 (* N.B. the Queue module is not thread-safe but oxenstored is single-thre= aded. *) @@ -42,8 +43,9 @@ type domains =3D { mutable n_penalised: int; (* Number of domains with less than maximum cre= dit *) } =20 -let init eventchn on_first_conflict_pause =3D { +let init eventchn gnttab on_first_conflict_pause =3D { eventchn =3D eventchn; + gnttab; table =3D Hashtbl.create 10; doms_conflict_paused =3D Queue.create (); doms_with_conflict_penalty =3D Queue.create (); @@ -123,7 +125,8 @@ let resume _doms _domid =3D () =20 let create doms domid mfn port =3D - let interface =3D Xenctrl.map_foreign_range xc domid (Xenmmap.getpagesize= ()) mfn in + let mapping =3D Gnt.(Gnttab.map_exn doms.gnttab { domid; ref =3D xenstore= } true) in + let interface =3D Gnt.Gnttab.Local_mapping.to_pages doms.gnttab mapping in let dom =3D Domain.make domid mfn port interface doms.eventchn in Hashtbl.add doms.table domid dom; Domain.bind_interdomain dom; diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xen= stored.ml index a6b86b167c..75c35107d5 100644 --- a/tools/ocaml/xenstored/xenstored.ml +++ b/tools/ocaml/xenstored/xenstored.ml @@ -446,6 +446,7 @@ let main () =3D =20 let store =3D Store.create () in let eventchn =3D Event.init () in + let gnttab =3D Gnt.Gnttab.interface_open () in let next_frequent_ops =3D ref 0. in let advance_next_frequent_ops () =3D next_frequent_ops :=3D (Unix.gettimeofday () +. !Define.conflict_max_his= tory_seconds) @@ -453,7 +454,7 @@ let main () =3D let delay_next_frequent_ops_by duration =3D next_frequent_ops :=3D !next_frequent_ops +. duration in - let domains =3D Domains.init eventchn advance_next_frequent_ops in + let domains =3D Domains.init eventchn gnttab advance_next_frequent_ops in =20 (* For things that need to be done periodically but more often * than the periodic_ops function *) --=20 2.25.1