Changeset 5634

Show
Ignore:
Timestamp:
10/30/09 12:40:10 (3 weeks ago)
Author:
jayesh
Message:

Handling the case where we don't have info about logical procs on windows - eg: Win2K systems. If info about logical procs is not available we don't set proc affinity and allow these systems to continue working. See tickets 832,776

Location:
mpich2/trunk/src/pm/smpd
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/src/pm/smpd/smpd.h

    r5117 r5634  
    981981DWORD_PTR smpd_get_next_process_affinity_mask(void ); 
    982982DWORD_PTR smpd_get_processor_affinity_mask(int proc_num); 
    983 void smpd_init_affinity_table(void ); 
     983BOOL smpd_init_affinity_table(void ); 
    984984#endif 
    985985 
  • mpich2/trunk/src/pm/smpd/smpd_affinitize.c

    r4983 r5634  
    4040{ 
    4141    DWORD_PTR Mask; 
    42     if (s_affinity_max == 0) 
     42    if (s_affinity_max == 0){ 
     43        smpd_dbg_printf("Affinity table not initialized. Returning invalid mask\n"); 
    4344        return 0; 
     45    } 
    4446 
    4547    Mask = s_affinity_table[s_affinity_idx % s_affinity_max]; 
     
    246248    are distributed so as to balance the use of system resources. 
    247249*/ 
    248 void smpd_init_affinity_table() 
     250typedef BOOL (WINAPI *LPFN_GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); 
     251BOOL smpd_init_affinity_table() 
    249252{ 
    250253    /* 
     
    252255    */ 
    253256    int count, nTableEntries; 
    254     BOOL fSucc; 
     257    BOOL fSucc, retval = TRUE; 
    255258    DWORD Length; 
    256259    DWORD_PTR SystemMask, ReserveMask, PrimaryMask; 
     
    258261    SYSTEM_LOGICAL_PROCESSOR_INFORMATION* pInfo = NULL; 
    259262    ResourceTableEntry* pTable = NULL; 
     263    LPFN_GetLogicalProcessorInformation lpfn_get_logical_proc_info; 
    260264 
    261265    fSucc = GetProcessAffinityMask(GetCurrentProcess(), &UsableProcessorMask, &SystemMask); 
    262     if(!fSucc) 
    263         return; 
    264  
     266    if(!fSucc){ 
     267        return FALSE; 
     268    } 
     269 
     270    /* Check if GetLogicalProcessorInformation() is available */ 
     271    lpfn_get_logical_proc_info = 
     272        (LPFN_GetLogicalProcessorInformation ) GetProcAddress(GetModuleHandle(TEXT("kernel32")), 
     273                                                    "GetLogicalProcessorInformation"); 
     274    if(lpfn_get_logical_proc_info == NULL){ 
     275        smpd_dbg_printf("GetLogicalProcessorInformation() not available\n");  
     276        return FALSE; 
     277    } 
    265278    /* 
    266279        Retrieve the length required to store the processor information data 
    267280    */ 
    268281    Length = 0; 
    269     /* FIXME: Check return val */ 
    270     GetLogicalProcessorInformation(NULL, &Length); 
    271     if(Length == 0) 
    272         return; 
     282    /* This call will fail - however it will return the length reqd to store proc info*/ 
     283    fSucc = lpfn_get_logical_proc_info(NULL, &Length); 
     284    if(Length == 0){ 
     285        smpd_dbg_printf("GetLogicalProcessorInformation() returned invalid (0 bytes) length to store proc info\n"); 
     286        return FALSE; 
     287    } 
    273288 
    274289    /* 
     
    276291    */ 
    277292    pInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION*) malloc(Length); 
    278     if(pInfo == NULL) 
    279         return; 
     293    if(pInfo == NULL){ 
     294        smpd_err_printf("Allocating memory for system logical proc info failed\n"); 
     295        return FALSE; 
     296    } 
    280297 
    281298    /* 
    282299        Query for the processors information 
    283300    */ 
    284     fSucc = GetLogicalProcessorInformation(pInfo, &Length); 
    285     if(!fSucc) 
    286         goto fn_exit; 
     301    fSucc = lpfn_get_logical_proc_info(pInfo, &Length); 
     302    if(!fSucc){ 
     303        smpd_err_printf("GetLogicalProcessorInformation() failed (error = %d)\n", GetLastError()); 
     304        goto fn_fail; 
     305    } 
    287306     
    288307    count = Length / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); 
     
    294313 
    295314    pTable = (ResourceTableEntry*) malloc(count * sizeof(ResourceTableEntry)); 
    296     if (pTable == NULL) 
    297         goto fn_exit; 
     315    if (pTable == NULL){ 
     316        smpd_err_printf("Allocating memory for Resourcetableentry failed\n"); 
     317        goto fn_fail; 
     318    } 
    298319 
    299320    /* 
     
    326347 
    327348    free(pTable); 
    328 fn_exit: 
     349 fn_exit: 
    329350    free(pInfo); 
     351    return retval; 
     352fn_fail: 
     353    retval = FALSE; 
     354    goto fn_exit; 
    330355} 
    331356 
  • mpich2/trunk/src/pm/smpd/smpd_cmd_args.c

    r5462 r5634  
    446446        } 
    447447#ifdef HAVE_WINDOWS_H 
    448     /* FIXME: smpd_init_affinity_table() Does not return error codes if it fails */ 
    449     smpd_init_affinity_table(); 
     448    { 
     449        BOOL ret; 
     450        ret = smpd_init_affinity_table(); 
     451        if(!ret){ 
     452            smpd_dbg_printf("Initializing smpd affinity table failed\n"); 
     453        } 
     454    } 
    450455#endif 
    451456