From nobody Sat Nov 30 00:32:04 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=1620757206; cv=none; d=zohomail.com; s=zohoarc; b=f/IX3/APbBrram0B60cf5nhFquKNqwUMtyyrF9yEXbb9g/cTyDlH8qqqRSzXy7fXzYpBhZWBdzDt7WJ0CW9Ttl1bo4kyqJWx7NUZbOJmRdPSdsqb8pROpA6kr6dt7Y+50TVfam9yx70WIuJ5OSUD4wpbm2HzzlqY+KjHKIRkRPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620757206; 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=atFGF3AqQXko+sLgRqc7RZZC82n2e1nJoPilJ833Wdg=; b=EVrLXHwUyKMOQ0xo48JXI9pF1h4tZYnkO7z4LtNrcVMa1w3mdlyGhbS3NHzV0w/9lpa+dQqd2fAkA+NNE/lU9q1aUJTzppOFSFco3/D+3T+DynXlqhbZAdGla+FPq3/MSH2IsqwIkKN/eADCTYi6pK3s10OLxPH1JRR8zQBVKbQ= 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 1620757206175749.645330737442; Tue, 11 May 2021 11:20:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.125962.237109 (Exim 4.92) (envelope-from ) id 1lgWz3-0008Hn-TC; Tue, 11 May 2021 18:19:53 +0000 Received: by outflank-mailman (output) from mailman id 125962.237109; Tue, 11 May 2021 18:19:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgWz3-0008Hc-Pj; Tue, 11 May 2021 18:19:53 +0000 Received: by outflank-mailman (input) for mailman id 125962; Tue, 11 May 2021 18:19:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgWz2-0007g6-GI for xen-devel@lists.xenproject.org; Tue, 11 May 2021 18:19:52 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 19b3bfa7-5419-49b1-8051-bd5514dfe581; Tue, 11 May 2021 18:19:47 +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: 19b3bfa7-5419-49b1-8051-bd5514dfe581 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620757187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EoaUpYs9b5JtY9mZ1Jy5aNZ4/ohnkMdircO88bxkg44=; b=CHcTnBQ+gbXHApTpscebxkhpzBSOUA1WUEEhTnbrMVn8fA7Px6OwgTy6 CJXlvR4R0vmzePd3hrxiwsEeAN+FVR9TMtNpODlef+6CwGiTvmjdqOpXQ 0rdtuwvkbZi5XXNHCab4tjr7TPLbNw3eJ6v/5TiOJeZBvhWbQg3qO31J8 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: jXvHeAJvDN1mXXdaAWfqlPHHazwViQ0FtFAp5WTIfOpuEqy+a0KF3Ohxx4UIqAk8EUleoTu5tl NaRTf4EMlBhS6a9UrEyQLomS4Wry7YRe26ICnZ1n3MP+FaDaqd00tixNEsozcWIN57bePj/hax edxjqei4oFFQWlggOIaVjGXhk65Cv4ADXQpot/PjgaArEdGdKc/BdQ0ZoLWxXOTwYyB+AmSWNU bA7dWsMaQJtOWZuXtTDd3+JHwpqYGEwrX6TOKyQYRB70rd9+tD6X9LR5T8hwevckaH4hv/jYQa a7Y= X-SBRS: 5.1 X-MesageID: 43562364 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:afEZh6mNz+/LDj4Xj8abPvWYjILpDfIW3DAbv31ZSRFFG/Fxl6 iV/cjzsiWE8Ar5OUtQ4OxoV5PwIk80maQb3WBVB8bHYOCEghrPEGgB1/qB/9SIIUSXnYQxuZ uIMZIOb+EYZWIK9voSizPZLz9P+re6GdiT9ILj80s= X-IronPort-AV: E=Sophos;i="5.82,291,1613451600"; d="scan'208";a="43562364" 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 Subject: [PATCH v2 12/17] tools/ocaml/libs/mmap: mark mmap/munmap as blocking Date: Tue, 11 May 2021 19:05:25 +0100 Message-ID: <294a60be29027d33b0a1d154b7d576237c7dd420.1620755942.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) These functions can potentially take some time, so allow other OCaml code to proceed meanwhile (if any). Signed-off-by: Edwin T=C3=B6r=C3=B6k --- tools/ocaml/libs/mmap/xenmmap_stubs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/ocaml/libs/mmap/xenmmap_stubs.c b/tools/ocaml/libs/mmap/= xenmmap_stubs.c index d7a97c76f5..e8d2d6add5 100644 --- a/tools/ocaml/libs/mmap/xenmmap_stubs.c +++ b/tools/ocaml/libs/mmap/xenmmap_stubs.c @@ -28,6 +28,7 @@ #include #include #include +#include =20 #define Wsize_bsize_round(n) (Wsize_bsize( (n) + sizeof(value) - 1 )) =20 @@ -69,7 +70,9 @@ CAMLprim value stub_mmap_init(value fd, value pflag, valu= e mflag, caml_invalid_argument("negative offset"); length =3D Int_val(len); =20 + caml_enter_blocking_section(); addr =3D mmap(NULL, length, c_pflag, c_mflag, Int_val(fd), Int_val(offset= )); + caml_leave_blocking_section(); if (MAP_FAILED =3D=3D addr) uerror("mmap", Nothing); =20 @@ -80,10 +83,15 @@ CAMLprim value stub_mmap_init(value fd, value pflag, va= lue mflag, CAMLprim value stub_mmap_final(value intf) { CAMLparam1(intf); + struct mmap_interface interface =3D *Intf_val(intf); =20 - if (Intf_val(intf)->addr !=3D MAP_FAILED) - munmap(Intf_val(intf)->addr, Intf_val(intf)->len); + /* mark it as freed, in case munmap below fails, so we don't retry it */ Intf_val(intf)->addr =3D MAP_FAILED; + if (interface.addr !=3D MAP_FAILED) { + caml_enter_blocking_section(); + munmap(interface.addr, interface.len); + caml_leave_blocking_section(); + } =20 CAMLreturn(Val_unit); } --=20 2.25.1