Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2013 19:19:57 +0800
From:      =?GB2312?B?u8bOxLvU?= <huanghwh@yahoo.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        "java@freebsd.org" <java@freebsd.org>
Subject:   Re: System.currentTimeMillis() is totally wrong after call JNA mlockall
Message-ID:  <F8871D76-C709-40C1-84C6-0F7EAB6445E9@yahoo.com>
In-Reply-To: <20130602051658.GZ3047@kib.kiev.ua>
References:  <1370140389.34142.YahooMailNeo@web15306.mail.cnb.yahoo.com> <20130602051658.GZ3047@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
2013-6-2=A3=AC13:16=A3=ACKonstantin Belousov <kostikbel@gmail.com> 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 <sys/types.h>
> #include <sys/mman.h>
> #include <sys/wait.h>
> #include <err.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> #include <unistd.h>
>=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);
> }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F8871D76-C709-40C1-84C6-0F7EAB6445E9>