Discussion:
A generic function for (multicore) cache flush?
(too old to reply)
Nikolai Zhubr
2016-10-31 18:33:22 UTC
Permalink
Raw Message
Hello all,

Is there any good generic (portable) function to ensure memory cache
flush for a thread on a multicore system?

What I'm trying to do is essentially fetch some debugging counters from
multiple threads. They might happen to run on separate cores, thus
having something pending in local cache sometimes. I would like to avoid
EnterCriticalSection/ LeaveCriticalSection as such blocking would be a
huge overkill, however it is still desireable to fetch reasonably
current values. I'd like to avoid doing manual assembly as well (for
portability reasons etc.).


Thanks a lot!

Nikolai

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Jeppe Johansen
2016-10-31 19:44:38 UTC
Permalink
Raw Message
Post by Nikolai Zhubr
Hello all,
Is there any good generic (portable) function to ensure memory cache
flush for a thread on a multicore system?
What I'm trying to do is essentially fetch some debugging counters
from multiple threads. They might happen to run on separate cores,
thus having something pending in local cache sometimes. I would like
to avoid EnterCriticalSection/ LeaveCriticalSection as such blocking
would be a huge overkill, however it is still desireable to fetch
reasonably current values. I'd like to avoid doing manual assembly as
well (for portability reasons etc.).
Thanks a lot!
Nikolai
Have you found this to be a problem in real environments?
I can't imagine any of the mainstream processor architectures of FPC
where you wouldn't expect normal coherent bus operation when just
reading cached memory from other processors. If all you need is just
reasonably recent values that is..
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Gennady Agranov
2016-10-31 20:01:04 UTC
Permalink
Raw Message
Hi,

I have an issue with loading JNI library for Raspberry :(

I do compile with -Cg -WX and stack checking on (and also without).

But even this method is not called :(

function JNI_OnLoad(vm: PJavaVM; reserved: pointer): jint; {$ifdef
linux}cdecl{$else}stdcall{$endif};
begin
writeln('lll');
exit(0);
end;

Any suggestions?

Thanks,
Gennady

Java HotSpot(TM) Client VM warning: You have loaded library
/media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so
which might have disabled stack guard. The VM will try to fix the stack
guard now.

It's highly recommended that you fix the library with 'execstack -c
<libfile>', or link it with '-z noexecstack'.

[FORMS.PP] ExceptionOccurred

Sender=EStackOverflow

Exception=Stack overflow

Stack trace:

$62E6CF48 fpc_stackcheck, line 832 of
/home/pi/development/fpc/rtl/inc/system.inc

TApplication.HandleException Stack overflow

Stack trace:

$62E6CF48 fpc_stackcheck, line 832 of
/home/pi/development/fpc/rtl/inc/system.inc

Exception at 62E6CF48: EStackOverflow:

Stack overflow.


_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
w***@windstream.net
2016-10-31 20:42:51 UTC
Permalink
Raw Message
Post by Gennady Agranov
Hi,
I have an issue with loading JNI library for Raspberry :(
what does this have to do with the "A generic function for (multicore) cache
flush?" topic you attached it to by replying to that topic? you should use the
[write] or [post] button and then type in the name of the mailing list or news
group... then the subject and the post instead of trying to take shortcuts and
hijacking a topic...
--
NOTE: No off-list assistance is given without prior approval.
*Please keep mailing list traffic on the list* unless
private contact is specifically requested and granted.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Gennady Agranov
2016-10-31 21:10:23 UTC
Permalink
Raw Message
I thought that "reply" and changing the subject to a new one will do the
trick...

Is "topic" stored somewhere in the mail headers?

Sorry,
Gennady
Post by w***@windstream.net
Post by Gennady Agranov
Hi,
I have an issue with loading JNI library for Raspberry :(
what does this have to do with the "A generic function for (multicore)
cache flush?" topic you attached it to by replying to that topic? you
should use the [write] or [post] button and then type in the name of
the mailing list or news group... then the subject and the post
instead of trying to take shortcuts and hijacking a topic...
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Jonas Maebe
2016-10-31 21:15:54 UTC
Permalink
Raw Message
Post by Gennady Agranov
I thought that "reply" and changing the subject to a new one will do the
trick...
Is "topic" stored somewhere in the mail headers?
There is an "In-Reply-To" header, which states to which message your
message is a reply. All related replies are grouped into the same topic
by most mail clients.


Jonas
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Yury Sidorov
2016-10-31 21:12:39 UTC
Permalink
Raw Message
Post by Gennady Agranov
I have an issue with loading JNI library for Raspberry :(
I do compile with -Cg -WX and stack checking on (and also without).
But even this method is not called :(
function JNI_OnLoad(vm: PJavaVM; reserved: pointer): jint; {$ifdef
linux}cdecl{$else}stdcall{$endif};
begin
writeln('lll');
exit(0);
end;
Any suggestions?
Thanks,
Gennady
Java HotSpot(TM) Client VM warning: You have loaded library
/media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so
which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c
<libfile>', or link it with '-z noexecstack'.
[FORMS.PP] ExceptionOccurred
Why do you use LCL in your JNI library?
Try a simple library without LCL and check if it loads.
Also do not add any extra compiler switches.
In FPC 3.0 -Cg is broken for ARM.

Yury.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Nikolai Zhubr
2016-10-31 20:13:06 UTC
Permalink
Raw Message
Post by Jeppe Johansen
Post by Nikolai Zhubr
Is there any good generic (portable) function to ensure memory cache
flush for a thread on a multicore system?
What I'm trying to do is essentially fetch some debugging counters
from multiple threads. They might happen to run on separate cores,
thus having something pending in local cache sometimes. I would like
to avoid EnterCriticalSection/ LeaveCriticalSection as such blocking
would be a huge overkill, however it is still desireable to fetch
reasonably current values. I'd like to avoid doing manual assembly as
well (for portability reasons etc.).
Thanks a lot!
Nikolai
Have you found this to be a problem in real environments?
No.
Post by Jeppe Johansen
I can't imagine any of the mainstream processor architectures of FPC
where you wouldn't expect normal coherent bus operation when just
reading cached memory from other processors. If all you need is just
reasonably recent values that is..
Ok. Probably you are right.
Thanks!

Nikolai
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Vincent Snijders
2016-10-31 20:07:56 UTC
Permalink
Raw Message
Post by Nikolai Zhubr
Hello all,
Is there any good generic (portable) function to ensure memory cache flush
for a thread on a multicore system?
Maybe: http://www.freepascal.org/docs-html/rtl/system/readwritebarrier.html

Vincent
Nikolai Zhubr
2016-10-31 21:19:29 UTC
Permalink
Raw Message
Post by Nikolai Zhubr
Is there any good generic (portable) function to ensure memory cache
flush for a thread on a multicore system?
Maybe: http://www.freepascal.org/docs-html/rtl/system/readwritebarrier.html
Oh yes! That's the thing!
Thanks a lot!


Nikolai
Post by Nikolai Zhubr
Vincent
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Gennady Agranov
2016-11-01 01:42:29 UTC
Permalink
Raw Message
Post by Yury Sidorov
Why do you use LCL in your JNI library?
Try a simple library without LCL and check if it loads.
It works!

Great Thanks!

Does anyone know what to do about:

Java HotSpot(TM) Client VM warning: You have loaded library
/media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so
which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c
<libfile>', or link it with '-z noexecstack'.

Should I run execstack?

Should I run every time I build a shared object - or there is a better way?

Thanks!


_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Yury Sidorov
2016-11-01 10:27:22 UTC
Permalink
Raw Message
Post by Gennady Agranov
Post by Yury Sidorov
Why do you use LCL in your JNI library?
Try a simple library without LCL and check if it loads.
It works!
Great Thanks!
Java HotSpot(TM) Client VM warning: You have loaded library
/media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so
which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c
<libfile>', or link it with '-z noexecstack'.
Should I run execstack?
Should I run every time I build a shared object - or there is a better way?
Just pass this option the linker using the following FPC switch:
-k"-z noexecstack"

Yury.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Loading...