From owner-freebsd-java@freebsd.org Sat Feb 13 08:09:55 2016 Return-Path: Delivered-To: freebsd-java@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3BCA9AA632B for ; Sat, 13 Feb 2016 08:09:55 +0000 (UTC) (envelope-from glewis@eyesbeyond.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 24F921F94 for ; Sat, 13 Feb 2016 08:09:55 +0000 (UTC) (envelope-from glewis@eyesbeyond.com) Received: by mailman.ysv.freebsd.org (Postfix) id 24AE9AA632A; Sat, 13 Feb 2016 08:09:55 +0000 (UTC) Delivered-To: java@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 242F1AA6329 for ; Sat, 13 Feb 2016 08:09:55 +0000 (UTC) (envelope-from glewis@eyesbeyond.com) Received: from misty.eyesbeyond.com (gerbercreations.com [71.39.140.16]) by mx1.freebsd.org (Postfix) with ESMTP id AC9FB1F93 for ; Sat, 13 Feb 2016 08:09:53 +0000 (UTC) (envelope-from glewis@eyesbeyond.com) Received: from misty.eyesbeyond.com (localhost.eyesbeyond.com [127.0.0.1]) by misty.eyesbeyond.com (8.15.2/8.15.2) with ESMTP id u1D89pYV070933; Sat, 13 Feb 2016 00:09:51 -0800 (PST) (envelope-from glewis@eyesbeyond.com) Received: (from glewis@localhost) by misty.eyesbeyond.com (8.15.2/8.15.2/Submit) id u1D89jjk070932; Sat, 13 Feb 2016 00:09:45 -0800 (PST) (envelope-from glewis@eyesbeyond.com) X-Authentication-Warning: misty.eyesbeyond.com: glewis set sender to glewis@eyesbeyond.com using -f Date: Sat, 13 Feb 2016 00:09:45 -0800 From: Greg Lewis To: Brian Gardner Cc: Magnus Ihse Bursie , java@freebsd.org Subject: Re: Helping out with JDK 9 on BSD Message-ID: <20160213080945.GC56357@misty.eyesbeyond.com> References: <56ADE7D4.8020107@oracle.com> <56ADE943.6020103@oracle.com> <8B9ACABA-F9B2-4288-9DB5-CA843DE48C34@getsnappy.com> <20160203034053.GA36170@misty.eyesbeyond.com> <56B45453.9020006@oracle.com> <1C39812E-E596-47E6-AB45-0A591A017FFB@getsnappy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Feb 2016 08:09:55 -0000 On Fri, Feb 12, 2016 at 10:54:29AM -0800, Brian Gardner wrote: > After giving it some thought, I???ve created an alternate patch for the c= lear_current_thread issue. I like this solution better because it is isola= ted to java_start function in os_bsd.cpp, and it makes java_start responsib= le for cleaning up the current_thread since it also initializes it. Sounds good! What can I do to help get all the changes up for review? -- Greg > > On Feb 10, 2016, at 10:45 PM, Brian Gardner wro= te: > >=20 > > Hello again Greg and Magnus, > > I finished up researching the leftover thread-specific data after 4 des= tructor iterations issue. It looks like it???s currently functioning on Fr= eebsd the same way it does on Linux, the only difference is that Freebsd ou= tput that warning were Linux silently stops after it???s forth try. I look= ed into how openjdk8 was working and it looks like there were calls to TLS:= :set_thread(NULL) scattered throughout the code base at the end of some ::r= un methods. I???ve mimicked that behavior in the necessary spots with the = following patch. I can???t help but think there must be a better way to ge= t these Thread???s destructors called, and I tried that in place of making = clear_thread_current public and calling it directly, but it resulted in dea= dlock. > >=20 > > > >=20 > >> On Feb 9, 2016, at 2:36 PM, Brian Gardner > wrote: > >>=20 > >> Hi Greg and Magnus, > >> I???ve attached the patches needed to build and compile on Freebsd. I= ???ve reverted my changes to TLS, and done more debugging there. There app= ears to be two separate issues. One issue was that the implementation of O= S::bad::gettid() was somehow clearing the current thread previously set wit= h pthread_setspecific. I was able to fix this by porting logic from bad-po= rt/jdk8, see hotspot__os_bd_cpp__getthreadid.patch. The second issue seems= to be related to certain types of threads never getting their destructor c= alled and therefor not clearing pthread_setspecific and resulting in Thread= 803c59000 has exited with leftover thread-specific data after 4 destructor= iterations, errors. This one I haven???t tracked down yet and will contin= ue looking into. While I can compile and execute HelloWorld, I???m getting= a ton of these benign yet annoying messages from ConcurrentGC and Worker t= hreads. I???ll continue looking into that next week. > >>=20 > >>=20 > >>> On Feb 4, 2016, at 11:50 PM, Magnus Ihse Bursie > wrote: > >>>=20 > >>> On 2016-02-04 01:29, Brian Gardner wrote: > >>>> Hi Greg, > >>>> Great to hear from you, it???s been a while since I took on one of t= hese projects, but I do follow the java@freebsd mailing list and see all th= e work you put in. I must tell you how greatly your work is appreciated by = me and I???m sure the rest of the community. I have good news, with fairly= minimal changes I have it compiling, building HelloWorld, and running Hell= oWorld all without errors. > >>>>=20 > >>>> I think it???ll break down into 4 change sets, > >>>> NM - I ported some code from bsd-port/jdk8/hotspot/make/bsd/makefile= s/build_vm_def.sh that fixes a compile error=20 > >>>> SUPPORT_RESERVED_STACK_AREA - define SUPPORT_RESERVED_STACK_AREA for= _ALLBSD_SOURCE > >>>> Serviceability Agent - ported from bad-port/jdk8, currently compiles= but hasn???t been tested > >>>> TLS - there is problems with the TLS in jdk9 used for Thread::curren= t(). This caused several issues for me and while the fix was relatively st= raight forward in using THREAD_LOCAL_DECL completely in place of TLS comple= tely, I???d imagine there was a reason it was implemented in sort of a Hybr= id fashion alongside TLS. > >>>=20 > >>> There is a reason. It is very well described in this comment: > >>> https://bugs.openjdk.java.net/browse/JDK-8132510?focusedCommentId=3D1= 3866505 > > >>>=20 > >>> The TL;DR: in some circumstances the JVM can crash if we do not set u= p an initial TLS. On the other hand, this was for glibc, so maybe this situ= ation does not arise for FreeBSD. > >>>=20 > >>>>=20 > >>>> It would be great if I could post these as web reviews for others to= review. Greg, would getting access to bsd-port/jdk9 allow us to collabora= te through web reviews? =20 > >>>=20 > >>>=20 > >>>> Magnus, do you think using bsd-port/jdk9 for this purpose be a step = towards getting these basic changes into the jdk9 mainline, or would your c= olleagues think "if they have bsd-port/jdk9, why bother with integrating th= em into the jdk9 mainline???? > >>>=20 > >>> I think putting these changes in bsd-port/jdk9 is very reasonable, an= d I do not believe it will in any way hinder their acceptance into jdk9 mai= nline. The only thing to be careful about there, though, is that all contri= butors have signed the OCA (Oracle contributor agreement). Mixing in "legal= ly bad" code can present a real problem for adoption into mainline. > >>>=20 > >>> /Magnus > >>>=20 > >>>>=20 > >>>> Brian Gardner > >>>>=20 > >>>>> On Feb 2, 2016, at 7:40 PM, Greg Lewis < >glewis@eyesbeyond.com >>= wrote: > >>>>>=20 > >>>>> On Sun, Jan 31, 2016 at 06:57:26AM -0800, Brian Gardner wrote: > >>>>>> I???m interested in helping. I ported openjdk6 to freebsd and als= o helped out with openjdk8. > >>>>>>=20 > >>>>>> Brian Gardner > >>>>>=20 > >>>>> I'd love to see as much of these changes get into the jdk9 mainline= =2E My time > >>>>> is really limited for the next couple of weeks though. If it would= help you > >>>>> or Magnus to use the bsd-port repo to stage changes then that would= be > >>>>> great too. Let me do a merge to make sure it is up to date with ma= inline. > >>>>> Notionally we'd have to do a vote to get you both access I think? = But I > >>>>> can shepherd changes in if that will help with sharing them. > >>>>>=20 > >>>>> FWIW, in terms of taking responsibility, I've been regularly updati= ng the > >>>>> repos for jdk8 and jdk7 for a couple of years. I'm happy to keep j= dk9 > >>>>> building if that is what is being looked for there and also port mo= re of > >>>>> the BSD changes for jdk8 as appropriate. > >>>>>=20 > >>>>> - Greg > >>>>>=20 > >>>>>>> On Jan 31, 2016, at 3:00 AM, Magnus Ihse Bursie >> wrote: > >>>>>>>=20 > >>>>>>> On 2016-01-31 11:54, Magnus Ihse Bursie wrote: > >>>>>>>> Hi, > >>>>>>>>=20 > >>>>>>>> [TL;DR: I'm offering patches to compile JDK 9 on FreeBSD, but it= 's not clear where to put them, or how.] > >>>>>>>>=20 > >>>>>>>> I'm working at Oracle on the OpenJDK build team and is responsib= le for large parts of the build system of OpenJDK. Lately, I've been playin= g around with FreeBSD (and other BSDs) in my free time, and I've written a = patch that will add build system support for FreeBSD, OpenBSD and NetBSD in= JDK 9 (tracked in >https://bugs.openjdk.java.net= /browse/JDK-8147795 >). > >>>>>>>>=20 > >>>>>>>> I started writing this when I realized that the jdk9 branch in t= he OpenJDK bsd-port repository did not contain any BSD-specific changes at = all, and the old JDK 8 changes will not readily be portable, due to major c= hanges in the build system between JDK 8 and JDK 9. > >>>>>>>>=20 > >>>>>>>> I thought it would be a no-brainer to integrate these changes in= to the JDK 9 mainline, so they would be in place for whenever you guys woul= d start to attack porting the code base. However, some of my collegues thou= ght otherwise. The end result, I think, is that they wanted to see someone = (not necessarily a company, the FreeBSD organisation for instance seemed to= be okay), to step forward and say "we take responsibility for the BSD port= ", and give some kind of commitment to actually use these build changes in = producing a viable port. You can read the mail conversation here: >http://m= ail.openjdk.java.net/pipermail/build-dev/2016-January/016421.html > > >>>>>>>=20 > >>>>>>> I forgot to add that I'm willing to help with build issues for th= e BSD port, as far as my (like everybode else's) limited free time allows m= e. Unfortunately, I'm still a noob at BSD internals and can't really help w= ith much apart from that. > >>>>>>>=20 > >>>>>>> /Magnus > >>>>>>>=20 > >>>>>>>=20 > >>>>>>>>=20 > >>>>>>>> An alternative to pushing this code into the JDK 9 mainline is o= f course to push it to the bsd-port/jdk9 repo (given that the owners of tha= t repo approves), but that seems like a less favourable solution. Having th= e code in the mainline does not mean that it gets tested automatically, but= it means that it will be part of e.g. refactoring, that would otherwise br= eak a downstream patchset. > >>>>>>>>=20 > >>>>>>>> I cc:ed this conversation to the >bsd-port-dev@openjdk.java.ne= t > mailing list, but never got any= kind of official response there. Since this list seems more active, I'm tr= ying here instead. :) > >>>>>>>>=20 > >>>>>>>> So, I'm offering two patches here, one that applies to the build= system, is nice and clean, and possible to integrate into JDK 9 mainline, = if my collegues are convinced that someone is backing up the BSD port. And = there's a second patch, which fixes broken C/C++/Java code and results in a= product that can at least run "javac HelloWorld", but this is not yet clea= n enough for integration anywere, at least not the JDK 9 mainline. (I don't= know enough of the BSD internals to fix all problems, so there's some "#if= 0" code here and there.) > >>>>>>>>=20 > >>>>>>>> /Magnus > >>>>>>>>=20 > >>>>>>>> _______________________________________________ > >>>>>>>> freebsd-java@freebsd.org > mailing list > >>>>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java > > >>>>>>>> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freeb= sd.org " > > >>>>>>>=20 > >>>>>>> _______________________________________________ > >>>>>>> freebsd-java@freebsd.org > >> mailing list > >>>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java > >> > >>>>>>> To unsubscribe, send any mail to " >freebsd-java-u= nsubscribe@freebsd.org > < >mailto:freebsd-java-unsubscribe@freebsd.org >>" > >>>>>>=20 > >>>>>> _______________________________________________ > >>>>>> freebsd-java@freebsd.org > mailing list > >>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java > > >>>>>> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd= =2Eorg " > > >>>>>=20 > >>>>> --=20 > >>>>> Greg Lewis Email : >glewis@eyesbeyond.com > > >>>>> Eyes Beyond Web : >http://www.eyesbeyond.com > > >>>>> Information Technology FreeBSD : >glewis@FreeBSD.org > > >>>>> _______________________________________________ > >>>>> freebsd-java@freebsd.org > mailing list > >>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java > > >>>>> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.= org >" > >>>>=20 > >>>=20 > >>>=20 > >>=20 > >> _______________________________________________ > >> freebsd-java@freebsd.org mailing list > >> https://lists.freebsd.org/mailman/listinfo/freebsd-java > >> To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org= " > >=20 >=20 --=20 Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org