[PATCH 1/3] ntdll: Reimplement NtQuerySystemInformation(SystemProcessInformation) using a single server call.

Zebediah Figura zfigura at codeweavers.com
Thu Jul 2 11:39:45 CDT 2020


On 7/2/20 11:24 AM, Rémi Bernon wrote:
> On 2020-07-02 05:18, Zebediah Figura wrote:
>> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
>> ---
>> This decreases CPU usage by wineserver from about 65% to about 45% for
>> me in
>> Street Fighter V, which for some reason calls this 15-20 times per
>> second.
>>
>>   dlls/ntdll/unix/system.c | 177 ++++++++++++++++-----------------------
>>   server/process.c         |  56 +++++++++++++
>>   server/protocol.def      |  30 +++++++
>>   server/trace.c           |  34 ++++++++
>>   4 files changed, 191 insertions(+), 106 deletions(-)
>>
>> diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
>> index 7045bc1550b..f89208997e2 100644
>> --- a/dlls/ntdll/unix/system.c
>> +++ b/dlls/ntdll/unix/system.c
>> @@ -2083,132 +2083,97 @@ NTSTATUS WINAPI NtQuerySystemInformation(
>> SYSTEM_INFORMATION_CLASS class,
>>         case SystemProcessInformation:
>>       {
>> -        SYSTEM_PROCESS_INFORMATION *spi = info;
>> -        SYSTEM_PROCESS_INFORMATION *last = NULL;
>> -        HANDLE handle = 0;
>> -        WCHAR procname[1024];
>> -        WCHAR* exename;
>> -        DWORD wlen = 0;
>> -        DWORD procstructlen = 0;
>> +        unsigned int process_count, i, j;
>> +        const struct process_info *server_process;
>> +        void *buffer = NULL;
>>   -        SERVER_START_REQ( create_snapshot )
>> +        if (size && !(buffer = RtlAllocateHeap( GetProcessHeap(), 0,
>> size )))
>>           {
>> -            req->flags = SNAP_PROCESS | SNAP_THREAD;
>> -            if (!(ret = wine_server_call( req ))) handle =
>> wine_server_ptr_handle( reply->handle );
>> +            ret = STATUS_NO_MEMORY;
>> +            break;
>>           }
>> -        SERVER_END_REQ;
>>   
> Shouldn't the allocated buffer size depend on the data to be read? If
> there's some very long paths there, the application buffer size may not
> be large enough, although it would have been enough to store the process
> infos with just their basename. 

Maybe, though I doubt it matters in practice. SystemProcessInformation
is by nature never going to have a stable length. In any case I wanted
to avoid having to make even two server calls where one would suffice.

> Or the server has to return only
> basenames, and assert that the client structures are larger than server
> request structures.

I guess stripping the rest of the path on the server side isn't a bad
idea anyway, though.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200702/96d410d2/attachment.sig>


More information about the wine-devel mailing list