Hello,
??? We have a requirement where we have to run the critical section in one of the processors,blocking the other processors in an SMP environment.
We are planning to use KeIpiGenericCall
http://msdn.microsoft.com/en-us/library/ff552198(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff550688(v=VS.85).aspx
Is it possible to block all other processors other than the calling processor, in the routine IpiGenericCall. i.e. only one processor should return, blocking the other processors in the routine IpiGenericCall, in an SMP environment.
Hello,
We have a requirement where we have to run the critical section in one of the processors,blocking the other processors in an SMP environment.
We are planning to use KeIpiGenericCall
http://msdn.microsoft.com/en-us/library/ff552198(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff550688(v=VS.85).aspx
Is it possible to block all other processors other than the calling processor, in the routine IpiGenericCall. i.e. only one processor should return, blocking the other processors in the routine IpiGenericCall, in an SMP environment.
Thanks & Regards
No, it’s not.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, February 28, 2011 2:09 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question on KeIpiGenericCall
Hello,
We have a requirement where we have to run the critical section in
one of the processors,blocking the other processors in an SMP environment.
We are planning to use KeIpiGenericCall
http://msdn.microsoft.com/en-us/library/ff552198(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff550688(v=VS.85).aspx
Is it possible to block all other processors other than the calling
processor, in the routine IpiGenericCall. i.e. only one processor should
return, blocking the other processors in the routine IpiGenericCall, in an
SMP environment.
Thanks & Regards
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Why do you think you need to corral all of the processors?
d
dent from a phine with no keynoard
From: sanketh shetty
Sent: Sunday, February 27, 2011 11:06 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question on KeIpiGenericCall
Hello,
We have a requirement where we have to run the critical section in one of the processors,blocking the other processors in an SMP environment.
We are planning to use KeIpiGenericCall
http://msdn.microsoft.com/en-us/library/ff552198(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff550688(v=VS.85).aspx
Is it possible to block all other processors other than the calling processor, in the routine IpiGenericCall. i.e. only one processor should return, blocking the other processors in the routine IpiGenericCall, in an SMP environment.
— NTDEV is sponsored by OSR For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Can anyone explain why processors can not be blocked within KeIpiGenericCall? and how does this function work?
Perhaps I misunderstood your question, but I thought you were asking if you
could use KeIpiGenericCall to have something run on ONE processor and have
the rest spin. If that’s correct, you can’t do that.
From the docs:
The KeIpiGenericCall routine causes the specified routine to run on all
processors simultaneously.
The whole point of the KeIpiGenericCall exercise is to get ONE thing
executing on ALL processors SYNCHRONOUSLY.
You (as I understand it) wish to coral all the processors, but have
something execute only on ONE processor, which is just not what
KeIpiGenericCall does.
If I misunderstood, my apologies.
As far as how KeIpiGenericCall() works, it’s not particularly complicated,
but you’ll need to disassemble it.
This still doesn’t answer Doron’s question, which is a good one - why do you
need to coral all processors?
Good luck,
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, February 28, 2011 3:43 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on KeIpiGenericCall
Can anyone explain why processors can not be blocked within
KeIpiGenericCall? and how does this function work?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
I am planning to use an atomic variable to block the processors in the routine IpiGenericCall.
About coralling the processors:
I have a requirement that the critical section I am running should be the only thread having access to the hardware devices.
Also no other thread with a higher priority should be able to preempt this thread untill the execution of the critical section.
>I have a requirement that the critical section I am running should be the
only thread having access to the hardware devices.
By this I assume that you mean ‘hardware devices’ as in hardware devices
that you don’t own? If not, then I’m confused as to why a spinlock won’t
do. If so, then this is likely a very problematic idea.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, February 28, 2011 5:18 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on KeIpiGenericCall
I am planning to use an atomic variable to block the processors in the
routine IpiGenericCall.
About coralling the processors:
I have a requirement that the critical section I am running should be the
only thread having access to the hardware devices.
Also no other thread with a higher priority should be able to preempt this
thread untill the execution of the critical section.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
I am sorry for the confusion, i will be accessing H/W which are not owned by me too, i want to aviod OS accessing those hardwares while I am accessing them, so i need exclusive access while doing the critical sections and no other execution should take place in the system (stop preemption and lock all the cores other than the current running core until i complete the critical section and then release them all). Please note that i need to lock for a very small period of time ![]()
>
Perhaps I misunderstood your question, but I thought you were asking
if you
could use KeIpiGenericCall to have something run on ONE processor and
have
the rest spin. If that’s correct, you can’t do that.
Are you sure?
The broadcast function just needs to spin on a lock (probably using
InterlockedExchange not kernel spinlock function) for CPU != 0 and then
do the work on CPU == 0. I do this under Xen (at HIGH_LEVEL though)
where all CPU’s except 0 spin and CPU 0 calls the suspend/migrate
function.
That doesn’t change the fact that what the OP wants to do might not be a
good idea though
James
>
I am sorry for the confusion, i will be accessing H/W which are not
owned by
me too, i want to aviod OS accessing those hardwares while I am
accessing
them, so i need exclusive access while doing the critical sections and
no
other execution should take place in the system (stop preemption and
lock all
the cores other than the current running core until i complete the
critical
section and then release them all). Please note that i need to lock
for a very
small period of time
How can you guarantee that the system wasn’t in the middle of an
operation using that hardware when your code started to run? If there is
no way to do that then you have a problem.
James
I wasn’t trying to say that you couldn’t roll your own; I thought he was
asking if there was some way to get KeIpiGenericCall() to just somehow run
the broadcast function only one processor.
I probably should have been clearer.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of James Harper
Sent: Monday, February 28, 2011 6:17 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Question on KeIpiGenericCall
Perhaps I misunderstood your question, but I thought you were asking
if you
could use KeIpiGenericCall to have something run on ONE processor and
have
the rest spin. If that’s correct, you can’t do that.
Are you sure?
The broadcast function just needs to spin on a lock (probably using
InterlockedExchange not kernel spinlock function) for CPU != 0 and then
do the work on CPU == 0. I do this under Xen (at HIGH_LEVEL though)
where all CPU’s except 0 spin and CPU 0 calls the suspend/migrate
function.
That doesn’t change the fact that what the OP wants to do might not be a
good idea though
James
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
This will not work since you cannot be sure that some other process is
not in the middle of accessing the hardware. If the hardware has more
than one register, you can have the situation of other process writes
register A, then you write registers A and B, then you let the other
process continue and it write B expecting its value in A.
I have seen people try this over the years, and the bottom line is
trying to take over a device you don’t own produces BSOD’s, and in at
least one case I know of a lawsuit that destroyed the company that tried
what you are doing.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“xxxxx@yahoo.com” wrote in message
news:xxxxx@ntdev:
> I am sorry for the confusion, i will be accessing H/W which are not owned by me too, i want to aviod OS accessing those hardwares while I am accessing them, so i need exclusive access while doing the critical sections and no other execution should take place in the system (stop preemption and lock all the cores other than the current running core until i complete the critical section and then release them all). Please note that i need to lock for a very small period of time ![]()
Hi Don,
I agree with you, it could over write the registers what the other process has configured, but i have some mechanism to handle this stuff and most of the case the device status/busy status are read before writing anything to it and stuff like that.
But what i am stuck is, or what i wanted to know is, by using keIpiGeneric call, can i implement some thing like,
the current running CPU will call keIpiGeneric call and this will cause all other processors other than the current running processor to spin on an atomic variable. The variable which will be controlled by the current processor such that it will be made available after the critical section of my application.
I know it is possible to do similar things in Linux, if not possible with KeIpiGenericCall, is there any other mechanism to do this?
There are also write only registers on some hardware.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, February 28, 2011 7:15 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on KeIpiGenericCall
Hi Don,
I agree with you, it could over write the registers what the other process
has configured, but i have some mechanism to handle this stuff and most of
the case the device status/busy status are read before writing anything to
it and stuff like that.
But what i am stuck is, or what i wanted to know is, by using keIpiGeneric
call, can i implement some thing like,
the current running CPU will call keIpiGeneric call and this will cause all
other processors other than the current running processor to spin on an
atomic variable. The variable which will be controlled by the current
processor such that it will be made available after the critical section of
my application.
I know it is possible to do similar things in Linux, if not possible with
KeIpiGenericCall, is there any other mechanism to do this?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
> Hi Don,
I agree with you, it could over write the registers what the other
process has
configured, but i have some mechanism to handle this stuff and most of
the
case the device status/busy status are read before writing anything to
it and
stuff like that.But what i am stuck is, or what i wanted to know is, by using
keIpiGeneric
call, can i implement some thing like,the current running CPU will call keIpiGeneric call and this will
cause all
other processors other than the current running processor to spin on
an atomic
variable. The variable which will be controlled by the current
processor such
that it will be made available after the critical section of my
application.I know it is possible to do similar things in Linux, if not possible
with
KeIpiGenericCall, is there any other mechanism to do this?
KeIpiGeneralCall will do this, you just need to roll your own exit
barrier. You should be able to do something like:
VOID
call_ipi_for_cpu_0()
{
ULONG barrier;
barrier = 1;
KeIpiGenericCall(broadcast_function, &barrier);
}
ULONG_PTR
broadcast_function(ULONG_PTR context)
{
PULONG barrier = (PULONG)context;
if (current_cpu == 0)
{
while (*barrier)
{
/* wait for CPU0 to release us */
do_sleep(); /* some power friendly spin function */
}
}
else
{
/* do_my_stuff_here */
*barrier = 0; /* release all the other CPU’s */
}
}
You need to make sure barrier is volatile etc but the essence of the
above should be correct.
James
Hi mm,
??? I am not accessing any H/W which has write only registers.
— On Mon, 28/2/11, Martin O’Brien wrote:
From: Martin O’Brien
Subject: RE: [ntdev] Question on KeIpiGenericCall
To: “Windows System Software Devs Interest List”
Date: Monday, 28 February, 2011, 5:51 PM
There are also write only registers on some hardware.
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Monday, February 28, 2011 7:15 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question on KeIpiGenericCall
Hi Don,
I agree with you, it could over write the registers what the other process
has configured, but i have some mechanism to handle this stuff and most of
the case the device status/busy status are read before writing anything to
it and stuff like that.
But what i am stuck is, or what i wanted to know is, by using keIpiGeneric
call, can i implement some thing like,
the current running CPU will call keIpiGeneric call and this will cause all
other processors other than the current running processor to spin on an
atomic variable. The variable which will be controlled by the current
processor such that it will be made available after the critical section of
my application.
I know it is possible to do similar things in Linux, if not possible with
KeIpiGenericCall, is there any other mechanism to do this?
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Yes of course you can corral the processors using ipi, but you have to
address the other issue - that you also need to guarantee that the
hardware itself will resume functioning correctly after you alter its
state. “Most of the cases”… if there is a window there is a way.
Mark Roddy
On Mon, Feb 28, 2011 at 7:15 AM, wrote:
> Hi Don,
>
> I agree with you, it could over write the registers what the other process has configured, but i have some mechanism to handle this stuff and most of the case the device status/busy status are read before writing anything to it and stuff like that.
>
> But what i am stuck is, or what i wanted to know is, by using keIpiGeneric call, can i implement some thing like,
>
> the current running CPU will call keIpiGeneric call and this will cause all other processors other than the current running processor to spin on an atomic variable. The variable which will be controlled by the current processor such that it will be made available after the critical section of my application.
>
> I know it is possible to do similar things in Linux, if not possible with KeIpiGenericCall, is there any other mechanism to do this?
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>
One of the big problems with KeIpiGenericCall is that it runs at
IPI_LEVEL and therefore does not respect locks, so not only are you
hitting the problems of my last post, you have the situation of if a
driver is using locking to protect the hardware your driver will ignore
that.
Please be sure to tell us what this CRAP is, since I want to be sure to
tell my clients not to buy it, and if they do who to sue when their
software misbehaves because you preempted the hardware.
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
“xxxxx@yahoo.com” wrote in message
news:xxxxx@ntdev:
> Hi Don,
>
> I agree with you, it could over write the registers what the other process has configured, but i have some mechanism to handle this stuff and most of the case the device status/busy status are read before writing anything to it and stuff like that.
>
> But what i am stuck is, or what i wanted to know is, by using keIpiGeneric call, can i implement some thing like,
>
> the current running CPU will call keIpiGeneric call and this will cause all other processors other than the current running processor to spin on an atomic variable. The variable which will be controlled by the current processor such that it will be made available after the critical section of my application.
>
> I know it is possible to do similar things in Linux, if not possible with KeIpiGenericCall, is there any other mechanism to do this?
Hmm … OK, it looks like the fundamental problem you’re trying to solve is that your HW doesn’t like to be touched unless it’s ready to be touched [smile] …
Rather than fiddle with the OS to try to halt any/ all accesses (which will cause all manner of other problems with the other parts of the OS and any other hardware that’s less sensitive than yours) I’d suggest instead seeing if there’s something to be done with your hardware, specifically using a kind of call gate approach …
For instance, suppose that there is a state engine in HW that runs that can’t handle any activity until the state engine completes. For a simple call gate mechanism, designate one register as Hardware, another register as Driver and a third register as OperationPending. These act as gates: when the HW is ready to do something then then HW sets H, D and OP low. When the driver (which is the only device capable of accessing the HW on the bus, yes?) wants to start the HW state engine then it checks to see if D and OP are low, if they are then it sets D and waits for the HW to set OP high and D low. Once the driver sees that OP is high then the driver touches the sensitive parts of the HW and things progress until the HW is back to it’s comfortable place and clears the OP register. The reverse is also true; when the HW wants to communicate with the driver then it sets the H register high and the driver sets OP high when it’s ready to talk to HW. Sensitive parts are touched, the driver sets H low and the HW then sets the OP register low …
This way HW is protected from multiple partners touching it, you don’t cripple the rest of the ecosystem and all is well …
As Doron mentioned, is this the problem you’re attempting to solve? If not, then what?
Cheers!