And peering in to implementation, be it inlined or not, and coming to conclusions based on it vs interface documentation is not a good habit to create. Jan, please file a feedback item on the lookaside msdn documentation page asking for clarity on smp safety.
Thx
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@flounder.com
Sent: Thursday, August 9, 2012 12:22 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Is ExAllocateFromNPagedLookasideList SMP safe?
You can use lookasides without additional locking, they are MP safe.
As you see, the statistics can be a bit off, but they are not the only
field used to trim the list if the system is under memory pressure so
it is OK for them to be slightly off
OK, so the count is just a hint. But they are “off” not just during a small window of potential inconsistency, but forever, because of MP race conditions. Based on the information available, but not the knowledge of the implementation of lookaside lists, I would have concluded (as I did) that they are not MP safe.
Hints are a useful technique, and in some sense the examination of the code produced an erroneous conclusion, because there was nothing to suggest that the value was a hint rather than a valid accounting mechanism. So this is an indication that sometimes too much superficial knowledge is dangerous (the plural of “anecdote” is not “data”; data is not information; information is not knowledge; knowledge is not understanding).
joe
d
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Jan Bottorff
Sent: Thursday, August 09, 2012 12:01 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Is ExAllocateFromNPagedLookasideList SMP safe?
I was writing some code that used non-paged lookaside lists and forgot
if they were SMP/thread safe. The docs don’t seem to give a clue if I
need to wrap a lock around access to the same NPAGED_LOOKASIDE_LIST
from multiple threads, so I looked at the macros in the header file.
Now I’m even less sure. This is in the Win 8 RC WDK headers.
Looking at the macro that defines ExAllocateFromNPagedLookasideList is
says:
Lookaside->L.TotalAllocates += 1;
As this is not an interlocked increment, I’d say no it’s not SMP safe.
But then a few lines down it says:
Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
As it uses the interlocked Slist function, this will be SMP safe.
It seems like the list operations will be thread safe, but the
statistical counts may be off due to the lack of interlocked
operations. I supposed these might work ok with, approximate values.
Is it late and I’m just missing something, or yes lookaside lists are
designed to operate with potential anomalies in the counts? Or, am I
really supposed to wrap these in spinlocks, even though the list operations are interlocked?
Jan
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
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