Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 29310 invoked from network); 11 Jan 2007 12:00:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jan 2007 12:00:47 -0000 Received: (qmail 40465 invoked by uid 500); 11 Jan 2007 12:00:50 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 40431 invoked by uid 500); 11 Jan 2007 12:00:50 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 40418 invoked by uid 99); 11 Jan 2007 12:00:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jan 2007 04:00:50 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of gcjhd-harmony-dev@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from [80.91.229.2] (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jan 2007 04:00:39 -0800 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1H4ybC-0001C4-5F for dev@harmony.apache.org; Thu, 11 Jan 2007 13:00:02 +0100 Received: from msfwpr01.ims.intel.com ([62.118.80.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Jan 2007 13:00:02 +0100 Received: from egor.pasko by msfwpr01.ims.intel.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 11 Jan 2007 13:00:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@harmony.apache.org From: Egor Pasko Subject: Re: Remove VM statistics or make it thread safe? Date: 11 Jan 2007 17:58:32 +0600 Lines: 103 Message-ID: References: <300B70C65DCD59468957941A60716EBC486DBD@mssmsx411> <5836de490701110313y6bb4bfe5ma0d55a23c320696@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: msfwpr01.ims.intel.com User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Sender: news X-Virus-Checked: Checked by ClamAV on apache.org On the 0x25B day of Apache Harmony Aleksey Ignatenko wrote: > What I see in the code beyond is that there is no crash possibility and it > could lead only to fault stat values. But it could be important if it adds > additional noise of measuring to Thread Checker tool then it should be fixed > to move next and find really importent hidden race conditions. is there any possibility to filter out something in Thread Checker? > Aleksey. > > > On 11 Jan 2007 17:06:37 +0600, Egor Pasko wrote: > > > > On the 0x25B day of Apache Harmony Ilia A. Leviev wrote: > > > Hi, > > > Recently I have started to use Thread Checker tool for finding unsafe > > > thread access places in VM. > > > First I have tried to check VM that run simple application such HWA. > > > The tool shows that there is thread unsafe access to some of > > > VM_Statistics fields that result in race condition. > > > > JIT profilers and Jitrino.OPT instruction profiler are thread-unsafe > > too. But this is a *feature*. We do not need precise data here at a > > cost of extra synchronisations. > > > > Same arguments may be applied to vm stats... > > > > > \vm\vmcore\include\ vm_stats.h > > > > > > class VM_Statistics > > > { > > > public: > > > > > > uint64 num_free_local_called; > > > uint64 num_jni_handles_wasted_refs; > > > uint64 num_free_local_called_free; > > > uint64 num_local_jni_handles; > > > uint64 num_jni_handles_freed; > > > > > > ~~~~~~~~~~~~~~~~~~~~~ > > > > > > The problem occurred during execution of free_local_object_handles2 > > > function > > > from \vm\vmcore\src\object\object_handles.cpp. > > > The function increment fields of type uint64. > > > > > > //////////////////////////////////////////////////////// > > > void free_local_object_handles2(ObjectHandles* head) > > > { > > > ObjectHandlesNew* h = (ObjectHandlesNew*)head; > > > assert(h); > > > #ifdef VM_STATS > > > VM_Statistics::get_vm_stats().num_free_local_called++;// race > > > condition > > > if(h->next != NULL) > > > VM_Statistics::get_vm_stats().num_free_local_called_free++;// > > > race condition > > > #endif //VM_STATS > > > while(h->next) { > > > #ifdef VM_STATS > > > unsigned size = h->size; > > > VM_Statistics::get_vm_stats().num_local_jni_handles += size; // > > > race condition > > > VM_Statistics::get_vm_stats().num_jni_handles_freed++; // race > > > condition > > > VM_Statistics::get_vm_stats().num_jni_handles_wasted_refs += > > > (h->capacity - size);// race condition > > > #endif //VM_STATS > > > ObjectHandlesNew* next = h->next; > > > STD_FREE(h); > > > h = next; > > > } > > > #ifdef VM_STATS > > > VM_Statistics::get_vm_stats().num_jni_handles_wasted_refs += > > > (h->capacity - h->size); // race condition > > > #endif //VM_STATS > > > } > > > //////////////////////////////////////////////////////// > > > > > > There are several solutions: > > > 1) remove and do not use statistics at all, if anybody not needs it. > > > 2) make this function synchronized using lock-unlock functions from > > > lock_manager, > > > 3) make increment by atomic APR function such apr_atomic_inc32( > > > volatile apr_uint32_t * mem ), > > > but to use it we need to change the type of the fields from uint64 > > > to volatile uint32. > > > > > > What solution will be more acceptable? > > > > > > > > > Best regards, > > > Leviev Ilya > > > Intel Java & XML Engineering > > > > > > > -- > > Egor Pasko > > > > -- Egor Pasko