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

Rémi Bernon rbernon at codeweavers.com
Thu Jul 2 11:24:42 CDT 2020


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. Or the server has to return only 
basenames, and assert that the client structures are larger than server 
request structures.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list