From owner-freebsd-java@FreeBSD.ORG Sun Jun 2 11:20:32 2013 Return-Path: Delivered-To: java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 127E778A for ; Sun, 2 Jun 2013 11:20:32 +0000 (UTC) (envelope-from huanghwh@yahoo.com) Received: from nm30-vm2.bullet.mail.sg3.yahoo.com (nm30-vm2.bullet.mail.sg3.yahoo.com [106.10.151.177]) by mx1.freebsd.org (Postfix) with ESMTP id 59EB31F3C for ; Sun, 2 Jun 2013 11:20:30 +0000 (UTC) Received: from [106.10.166.60] by nm30.bullet.mail.sg3.yahoo.com with NNFMP; 02 Jun 2013 11:20:23 -0000 Received: from [106.10.167.141] by tm17.bullet.mail.sg3.yahoo.com with NNFMP; 02 Jun 2013 11:20:23 -0000 Received: from [127.0.0.1] by smtp114.mail.sg3.yahoo.com with NNFMP; 02 Jun 2013 11:20:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1370172023; bh=ERBz81LvEYYIihtXX3Xbt0Aw7CrVYzuIzcyZijI7tuI=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:References:In-Reply-To:Mime-Version:Content-Transfer-Encoding:Content-Type:Message-Id:Cc:X-Mailer:From:Subject:Date:To; b=QkWno5kxi1HEff83DJxDykm7zsb/TTA/tYpBuFWk5xaCw+8WFA+F9CrrtIZc7uwB44UsUTkrGPmsDCl0TKAW2VHemVA2/VRgaMbxInji8L9YenxYfCMtcrsRAXIEJ92/lb9uLe6NhsQErjn7SXkCnCqpHQv+lReohia2ytZ73J0= X-Yahoo-Newman-Id: 686673.7548.bm@smtp114.mail.sg3.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 8.e6hBwVM1nhanZRy2.SSR1R.MLW1lJwmakNWN131WFy0l9 K63niJtUmk2EnYaXBnKy_PsB1Hh17Woo6UNMRpPH2WedNLQwzXtxiNxFXXRK TWz0fy8.q_Q67OAbIjL3ovTSmseVpzfxpqk4LJRRAuH_NAD.3Tn0.I4ZSR.W zMlDEEJSLwSKDR7pmdsjbnGPZZc9S7k7lJiI0up0prywU.W.x88ovzKd8AaK SZuGEeTuA55.tnA6LwWRyclyGyOiom8OC7Tqvrd86ziKOe9RVwOVoWqlHEfQ GieyzQqveRMG1tJr0soacJwVeNv5tccy9l2cl8I8_DRN5UPVy7w9DvphnIIv fUEMRaXudloJ8cT2PBmeK_U2xQFq1fz9whCCmcY0MhF4JgLHgQHgqRJpWU5e iGHAHIQWBh.BZGErMhSlrs2fjui0dTmtGIESOfT_awKtQsymuhAcHQ2Rqig0 fBL6Izz9s7lydSWUdokhw8U9_ X-Yahoo-SMTP: v.XIDxGswBAouVqdU_xGZWjeZJnI X-Rocket-Received: from [10.34.46.160] (huanghwh@125.88.73.108 with ) by smtp114.mail.sg3.yahoo.com with SMTP; 02 Jun 2013 04:20:23 -0700 PDT References: <1370140389.34142.YahooMailNeo@web15306.mail.cnb.yahoo.com> <20130602051658.GZ3047@kib.kiev.ua> In-Reply-To: <20130602051658.GZ3047@kib.kiev.ua> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=GB2312 Message-Id: X-Mailer: iPhone Mail (10A551) From: =?GB2312?B?u8bOxLvU?= Subject: Re: System.currentTimeMillis() is totally wrong after call JNA mlockall Date: Sun, 2 Jun 2013 19:19:57 +0800 To: Konstantin Belousov Cc: "java@freebsd.org" X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2013 11:20:32 -0000 2013-6-2=A3=AC13:16=A3=ACKonstantin Belousov wrote=A3=BA= > On Sun, Jun 02, 2013 at 10:33:09AM +0800, huanghwh wrote: >> Hi, >> I recently found that Cassandra 1.2.4 could not shutdown when enable JNA,= >> so I try to solve it, and found that under OpenJDK6/FreeBSD,=20 >> System.currentTimeMillis() is totally wrong after call JNA mlockall, >> time seams to not change anymore. >=20 > You did not specified the version of the system. I assume this is either > 9-STABLE or HEAD ? =20 9-STABLE > Also, I believe you use TSC as timecounter, check > with the sysctl kern.timecounter.hardware. Yes, TSC-low Switch to HPET fix this problem. >=20 > Try the patch below. I also added the C program that should exhibit > the same behaviour of reporting the stale time. This patch is also fix this problem. Thanks! >=20 > diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c > index 3890157..c45b974 100644 > --- a/sys/kern/kern_exec.c > +++ b/sys/kern/kern_exec.c > @@ -1050,8 +1050,9 @@ exec_new_vmspace(imgp, sv) > vm_object_reference(obj); > error =3D vm_map_fixed(map, obj, 0, > sv->sv_shared_page_base, sv->sv_shared_page_len, > - VM_PROT_READ | VM_PROT_EXECUTE, VM_PROT_ALL, > - MAP_COPY_ON_WRITE | MAP_ACC_NO_CHARGE); > + VM_PROT_READ | VM_PROT_EXECUTE, > + VM_PROT_READ | VM_PROT_EXECUTE, > + MAP_INHERIT_SHARE | MAP_ACC_NO_CHARGE); > if (error) { > vm_object_deallocate(obj); > return (error); >=20 >=20 > /* $Id: time_mlock.c,v 1.4 2013/06/02 05:15:53 kostik Exp kostik $ */ >=20 > #include > #include > #include > #include > #include > #include > #include > #include >=20 > int > main(void) > { > time_t t; > pid_t child; >=20 > if (mlockall(MCL_CURRENT | MCL_FUTURE) =3D=3D -1) > err(1, "mlockall"); > fflush(stdout); > child =3D fork(); > if (child =3D=3D -1) { > err(1, "fork"); > } else if (child =3D=3D 0) { > time(&t); > printf("%s", ctime(&t)); > sleep(3); > time(&t); > printf("%s", ctime(&t)); > } > return (0); > }