[2/3] ntdll: Implement NtQuerySystemInformation/SystemLogicalProcessorInformation (try 5)

Rudolf Mayerhofer rm at eightyfive.net
Fri Oct 8 07:59:46 CDT 2010


>On Friday 08 October 2010 14:26:28 Alexandre Julliard wrote:
>> Rudolf Mayerhofer <rm at eightyfive.net> writes:
>> > +/***********************************************************************
>> > + * Several methods to retrieve data from SysFS (/sys)
>> > + * used to retrieve cached_lpi in fill_cpu_info()
>> > + */
>> > +static int sysfs_cpu_exists(int cpu)
>> > +{
>> > +    char buf[256];
>> > +
>> > +    sprintf(buf, "/sys/devices/system/cpu/cpu%d", cpu);
>> > +    return access(buf, F_OK) == 0;
>> > +}
>> > +
>> > +static int sysfs_cpucache_exists(int cpu, int cache)
>> > +{
>> > +    char buf[256];
>> > +
>> > +    sprintf(buf, "/sys/devices/system/cpu/cpu%d/cache/index%d", cpu,
>> > cache); +    return access(buf, F_OK) == 0;
>> > +}
>> > +
>> > +static int sysfs_numanode_exists(int node)
>> > +{
>> > +    char buf[256];
>> > +
>> > +    sprintf(buf, "/sys/devices/system/node/node%d", node);
>> > +    return access(buf, F_OK) == 0;
>> > +}
>> 
>> Don't do that sort of thing. You should handle failures to open the
>> files at the point where you need them instead of doing redundant
>> checks.

>That's not the case here, these checks are simply to find out if a cpu,cpu 
>cache or numa node index exists in SysFS. It just makes no sense to try to 
>parse all of the stuff for a specific cpu index if it does not exist in the first 
>place and this is the check for that (it's done the same way as lscpu from 
>util-linux-ng does it).
>
>All the parsing functions have their own error handling as well.

To clarify things a bit more, those checks are always on directories.

For CPU/Cache/Numa Node there is on directory containing files and 
subdirectories with all the data belonging to that CPU/Cache/Numa Node.
The indicies are always from 0 up to n (n=Max Number of Elements for 
each type).

An error at the point where the data is parsed is not enough to determine if
the CPU/Cache/Numa Node itself missing (which means we have already 
parsed all known elements) or the datafile is inaccessible/missing. 
Thus the additional check if the basedirectory for the CPU/Cache/Numa Node 
exists.



More information about the wine-devel mailing list