示例#1
0
/* update the per fs  blocknr hint default value. */
void
update_blocknr_hint_default(const struct super_block *s,
			    const reiser4_block_nr * block)
{
	reiser4_super_info_data *sbinfo = get_super_private(s);

	assert("nikita-3342", !reiser4_blocknr_is_fake(block));

	spin_lock_reiser4_super(sbinfo);
	if (*block < sbinfo->block_count) {
		sbinfo->blocknr_hint_default = *block;
	} else {
		warning("zam-676",
			"block number %llu is too large to be used in a blocknr hint\n",
			(unsigned long long)*block);
		dump_stack();
		DEBUGON(1);
	}
	spin_unlock_reiser4_super(sbinfo);
}
示例#2
0
int
read_hardware_config(SYS_CONF_TYP * scfg, unsigned int tot_cpus, unsigned int pvr)  {

    int i, j = 0;
    int bind_to_cpu , rc, pir;
	int node, chip , proc;
    char msg[4096];
	SYS_CONF_TYP physical_scfg ;
	int num_nodes = 0, chips_per_node = 0;

    for(i = 0; i < MAX_CPUS ; i++) {
        l_p[i] = NO_CPU_DEFINED;
    }
#ifndef __HTX_LINUX__
    for(i = 0 ; i < tot_cpus ; i++ ) {
        bind_to_cpu = i ;
       	rc = bindprocessor(BINDPROCESS, getpid(), bind_to_cpu);
        if(rc == -1) {
            sprintf(msg, "\n bindprocessor failed with rc = %d, i = %d, errno = %d", rc, i, errno);
			hxfmsg(&htx_d, 0, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }

        pir = getPir();
        l_p[i] = pir ;

       	rc = bindprocessor(BINDPROCESS, getpid(), PROCESSOR_CLASS_ANY);
        if(rc == -1) {
            sprintf( msg, "\n%d: bindprocessor failed with %d while unbinding, rc = %d, i = %d ",__LINE__,  errno, rc, i);
			hxfmsg(&htx_d, 0, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }
    }
#else
	FILE *fp;
	char command[200],fname[256];
	int rad, lcpu, nrads, num_procs;

	strcpy(fname,htx_d.htx_exer_log_dir);
	sprintf(fname,"%s/node_details.%d",fname,getpid());
    /*sprintf(command,"/usr/lpp/htx/etc/scripts/get_node_details.sh "
            "> %s\n",fname);*/
    strcpy(command,getenv("HTXSCRIPTS"));
    sprintf(command, "%s/get_node_details.sh > %s\n", command, fname);

    if ( (rc = system(command)) == -1 ) {
            sprintf(msg, "sytem command to get_node_details failed with %d",rc);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
        	return(-1);
    }
    if ((fp=fopen(fname,"r"))==NULL){
            sprintf(msg, "fopen of file %s failed with errno=%d",fname,errno);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
        	return(-1);
    }

    /* Get total number of chips */
    rc = fscanf(fp,"num_nodes=%d\n",&nrads);
    if (rc == 0 || rc == EOF) {
            sprintf(msg, "fscanf of num_nodes on file %s failed with errno =%d",fname,errno);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
            return(-1);
    }
    for (rad = 0; rad < nrads; rad++) {
            int cpu_index = 0;
            int cur_chip = -1; /* Current chip */
            /* Fetch the current chip and the num procs in the chip */
            rc = fscanf(fp,"node=%d,cpus_in_node=%d,cpus",&cur_chip,&num_procs);
            if (rc == 0 || rc == EOF) {
                 sprintf(msg, "fscanf: chip =%d,Fetching of cpus in chip error from"
                        " file %s failed with errno =%d",rad,fname,errno);
                 hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
                 return(-1);
            }

            if ( num_procs > tot_cpus ) {
                sprintf(msg, "num_procs %d in this chip cannot be more than max procs %d "
                        ,num_procs,tot_cpus);
                hxfmsg(&htx_d,0,HTX_HE_HARD_ERROR, msg);
                return(-1);
            }

           /*
            * To find the actual processors (logical cpu Ids that can be
            * specified in an rset):
            */
            cpu_index = 0 ;

            while ( cpu_index < num_procs) {
                rc = fscanf(fp,":%d",&lcpu);
                if ( rc == 0 || rc == EOF) {
                    sprintf(msg, "fscanf: cpu fetch for chip=%d caused error from "
                                 " file %s failed with errno =%d",rad,fname,errno);
                    hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
                    return(-1);
                }
				/* Bind to lcpu and get the PIR value for it */
				rc = htx_bind_process(BIND_THE_PROCESS, lcpu);
				if(rc == -1) {
		            sprintf(msg, "\n bindprocessor failed with %d, binding cpu=%d", errno, lcpu);
            		hxfmsg(&htx_d, errno, HTX_HE_HARD_ERROR, msg);
             		return(-1);
        		}

                l_p[lcpu] = get_cpu_id(lcpu);
				rc = htx_unbind_process();
				if(rc == -1) {
					sprintf(msg, "\n bindprocessor failed with %d, unbinding th=%d, cpu=%d", errno, lcpu);
					hxfmsg(&htx_d, errno, HTX_HE_HARD_ERROR, msg);
					return(-1);
				}

				DEBUGON("l_p[%d]=%d\n",lcpu, l_p[lcpu]);
                cpu_index++;
            }
            rc = fscanf(fp,"\n");
            if (rc == EOF) {
                   sprintf(msg, "fscanf: expecting new line character at the end of"
                                " node %d data reading from file %s failed with errno =%d",\
                                rad,fname,errno);
                   hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
                   return(-1);
            }
     }

#endif
	/* Intialize the sysconf data structure */
	for(node = 0; node < MAX_NODES; node++) {
		for(chip = 0; chip < MAX_CHIPS_PER_NODE; chip ++) {
			for(proc = 0; proc < MAX_CPUS_PER_CHIP; proc ++) {
				physical_scfg.node[node].chip[chip].lprocs[proc] = -1;
			}
			physical_scfg.node[node].chip[chip].num_procs = 0;
		}
		physical_scfg.node[node].num_chips = 0;
	}
	physical_scfg.num_nodes = 0 ;

    i = 0 ;
   	while(i < MAX_CPUS) {
		if(l_p[i] == NO_CPU_DEFINED)  {
			i++;
			continue;
		}
        if(pvr == PVR_POWER9_NIMBUS){
            node = P9_NIMBUS_GET_NODE(l_p[i]);
            chip = P9_NIMBUS_GET_CHIP(l_p[i]);
        } else if(pvr == PVR_POWER9_CUMULUS){
            node = P9_CUMULUS_GET_NODE(l_p[i]);
            chip = P9_CUMULUS_GET_CHIP(l_p[i]);
        } else if(pvr == PVR_POWER8_MURANO || pvr == PVR_POWER8_VENICE || pvr == PVR_POWERP8P_GARRISION) {
			node = P8_GET_NODE(l_p[i]);
			chip = P8_GET_CHIP(l_p[i]);
    	} else if(pvr == PVR_POWER7 || pvr == PVR_POWER7PLUS) {
        	node = P7_GET_NODE(l_p[i]);
        	chip = P7_GET_CHIP(l_p[i]);
    	} else if(pvr == PVR_POWER6) {
			node = P6_GET_NODE(l_p[i]);
			chip = P6_GET_CHIP(l_p[i]);
		} else {
			sprintf(msg, "\n We shldnt have been here pvr = %x,  PVR mismatch. Exiting !!\n", pvr);
            hxfmsg(&htx_d, 0, HTX_HE_HARD_ERROR, msg);
            return(-1);
		}
		DEBUGON("Node=%d,Chip%d,proc=%d\n",node,chip,i);
       	physical_scfg.node[node].chip[chip].lprocs[physical_scfg.node[node].chip[chip].num_procs++] = i ;
       	i++;
    }

	for(i = 0; i < MAX_NODES; i ++) {
		for( j = 0; j < MAX_CHIPS_PER_NODE; j++) {
			if(physical_scfg.node[i].chip[j].num_procs > 0) {
				physical_scfg.node[i].num_chips ++;
			}
		}
		if(physical_scfg.node[i].num_chips > 0) {
			physical_scfg.num_nodes ++;
		}
	}

	/* Copy the system configuration to scfg */
	for(node = 0; node < MAX_NODES; node++) {
		if(physical_scfg.node[node].num_chips == 0)
			continue;
		chips_per_node = 0;
		for(chip = 0; chip < MAX_CHIPS_PER_NODE; chip ++) {

			if(physical_scfg.node[node].chip[chip].num_procs == 0)
				continue;
			memcpy(&scfg->node[num_nodes].chip[chips_per_node], &physical_scfg.node[node].chip[chip], sizeof(CHIP));
			chips_per_node++;
		}
		if(chips_per_node != physical_scfg.node[node].num_chips) {
			sprintf(msg, "%s: Something Wrong !!! Node = %d, chips_per_node = %d, physical_scfg_chip = %d \n",
													 __FUNCTION__,node, chips_per_node, physical_scfg.node[node].num_chips) ;
			hxfmsg(&htx_d, 0, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }
		scfg->node[num_nodes].num_chips = physical_scfg.node[node].num_chips;
		num_nodes++;
	}
	if(num_nodes != physical_scfg.num_nodes) {
		sprintf(msg, "%s: Something Wrong !!! Num_nodes = %d, physical_num_nodes = %d \n",
										__FUNCTION__, num_nodes, physical_scfg.num_nodes);
		hxfmsg(&htx_d, 0, HTX_HE_HARD_ERROR, msg);
        return(-1);
    }

	scfg->num_nodes = physical_scfg.num_nodes;

    return 0 ;
}
示例#3
0
int
fill_random_buffer(unsigned long long size, unsigned long long ** seg_addr, MEMORY_SET * mem)  {


    size_t shm_size;
    char msg[4096];
    int shm_id, rc = 0;
    unsigned int memflg;
    unsigned long long *addr_8, *end_addr, *addr;
	unsigned long long i , j ;

#ifndef __HTX_LINUX__ /* AIX Specific */ 

   	psize_t psize = 16*M;
    struct shmid_ds shm_buf = { 0 };
	
	memflg = (IPC_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
	if(SET_PAGESIZE) { 
		memflg |= (SHM_LGPAGE | SHM_PIN);
    	psize = 16*M;
	} else { 
		psize = 4 * K; 
	} 
#else	/* Linux Specific */ 
	unsigned long long psize;

    memflg = (IPC_CREAT | IPC_EXCL |SHM_R | SHM_W);
	if(SET_PAGESIZE) { 
		memflg |= (SHM_HUGETLB);
		psize = 16*M;
	} else { 
		psize = 4 * K; 
	} 
#endif 

    shm_size = size;


    shm_id = shmget(IPC_PRIVATE, shm_size , memflg);
    if(shm_id == -1) {
          sprintf(msg,"shmget failed with %d !\n", errno);
          hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
          return(-1);
    }

#ifndef __HTX_LINUX__
	if( SET_PAGESIZE) {  
	    if ( shm_size > 256*M) {
    	  if ((rc = shmctl(shm_id, SHM_GETLBA, &shm_buf)) == -1)   {
        	    sprintf(msg,"\n shmctl failed to get minimum alignment requirement - %d", errno);
            	hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
            	return(-1);
       		}
    	}
    	shm_buf.shm_pagesize = psize;
    	if( (rc = shmctl(shm_id, SHM_PAGESIZE, &shm_buf)) == -1) {
         	sprintf(msg,"\n shmctl failed with %d while setting page size.",errno);
         	hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
         	return(-1);
    	}
	} 	
#endif
    addr = (unsigned long long *) shmat(shm_id, 0, 0);
    if(-1 == (int)addr) {
        sprintf(msg,"\n shmat failed with %d",errno);
        hxfmsg(&htx_d, -1,HTX_HE_HARD_ERROR, msg);
        memory_set_cleanup();
        return(-1);
    }
    addr_8 = (unsigned long long *)addr;
    end_addr = (unsigned long long *) ((char *)addr + shm_size);
	DEBUGON("%s: addr_8 = %llx , end_addr = %llx \n",__FUNCTION__, addr_8, end_addr);
    for(; addr_8 < end_addr; ) {
        *addr_8 = get_random_number();
        addr_8++;
    }

	/* Lock the new shared memory, so that its always memory resident */
	rc = mlock(addr, shm_size);
	if(rc == -1) {
		sprintf(msg,"\n mlock failed with %d", errno);
		hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
		memory_set_cleanup();
		return(-1);
	}

	mem->seg_addr = (char *)addr ;
	mem->shm_id = shm_id ;
	mem->memory_set_size = size;
	*seg_addr = (unsigned long long *)addr ;
    return 0;
}
示例#4
0
int
get_cont_phy_mem(unsigned int num_cpus_mapped, unsigned int memory_mapping[][2], long long size, MEMORY_SET mem[]) {

    char *p, *addr, msg[4096];
    int i=0, ii, rc, host_cpu , j;
    size_t shm_size;
    unsigned int cpu, bind_to_cpu;
    unsigned int memflg;

#ifndef __HTX_LINUX__ /* AIX Specific */

    psize_t psize = 16*M;
    struct shmid_ds shm_buf = { 0 };
	struct vminfo_psize vminfo_64k = { 0 }; 

    memflg = (IPC_CREAT | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
    if(SET_PAGESIZE) {
        psize = 16*M;
    } else {
        psize = 4 * K;
    }
#else   /* Linux Specific */
    unsigned long long psize;

    memflg = (IPC_CREAT | IPC_EXCL |SHM_R | SHM_W);
    if(SET_PAGESIZE) {
        memflg |= (SHM_HUGETLB);
        psize = 16*M;
    } else {
        psize = 4 * K;
    }

    /* shmmax controls the maximum amount of memory to be allocated for shared memory */
    rc = system ("echo 268435456 > /proc/sys/kernel/shmmax");
    if (rc < 0){
        sprintf(msg,"unable to change the /proc/sys/kernel/shmmax variable\n");
        hxfmsg(&htx_d, 0, HTX_HE_INFO, msg);
    }

    /* The maximum amount of shared memory that can be allocated. */
    rc = system ("echo 268435456 > /proc/sys/kernel/shmall");
    if (rc < 0) {
        sprintf(msg,"unable to change the /proc/sys/kernel/shmall");
        hxfmsg(&htx_d, 0, HTX_HE_INFO, msg);
    }
#endif


    DEBUGON("\n Need %llx physically contiguous memory \n", size);

    shm_size = (size < PG_SZ_16M ? PG_SZ_16M : size);

    for(cpu = 0; cpu < num_cpus_mapped; cpu ++) {

    	if(memory_mapping[cpu][DEST_CPU] != NO_CPU_DEFINED) {
            host_cpu = memory_mapping[cpu][HOST_CPU];
            bind_to_cpu = memory_mapping[cpu][DEST_CPU];
        } else {
            continue;
        }
#ifdef __HTX_LINUX__
	    rc = htx_bind_process(BIND_THE_PROCESS, bind_to_cpu);
#else
   		rc = bindprocessor(BINDPROCESS, getpid(), bind_to_cpu);
#endif
        if(rc == -1) {
            sprintf(msg, "\n bindprocessor failed with %d, binding th=%d, cpu=%d", errno, cpu,bind_to_cpu);
            hxfmsg(&htx_d, errno, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }

        mem[host_cpu].shm_id = shmget(IPC_PRIVATE, shm_size, memflg);
        if(mem[host_cpu].shm_id == -1) {
            memory_set_cleanup();
            sprintf(msg,"shmget failed with %d !\n", errno);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }

#ifndef __HTX_LINUX__
	if(SET_PAGESIZE) {  
        if ( shm_size > 256*M) {
            if ((rc = shmctl(mem[host_cpu].shm_id, SHM_GETLBA, &shm_buf)) == -1)   {
                memory_set_cleanup();
                sprintf(msg,"\n shmctl failed to get minimum alignment requirement - %d", errno);
                hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
                return(-1);
            }
        }
        shm_buf.shm_pagesize = psize;
        if( (rc = shmctl(mem[host_cpu].shm_id, SHM_PAGESIZE, &shm_buf)) == -1) {
            memory_set_cleanup();
            sprintf(msg,"\n shmctl failed with %d while setting page size.",errno);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }
	}
#endif
        addr = (char *) shmat(mem[host_cpu].shm_id, 0, 0);
        if(-1 == (int)addr) {
            sprintf(msg,"\n shmat failed with %d",errno);
            hxfmsg(&htx_d, -1,HTX_HE_HARD_ERROR, msg);
            memory_set_cleanup();
            return(-1);
        }

        /* to be on safer side write touch the remote memory obtained */
        char * mem_addr = addr;
        for(i=0; i < (shm_size/psize); i++) {
            *(unsigned long long *)mem_addr = 0xFFFFffffFFFFffff ; 
            mem_addr += psize;
        }

        sprintf(msg, "%s: cpu %d, bound to cpu %d, seg_addr = 0x%llx of size = 0x%llx\n",
									__FUNCTION__, host_cpu, bind_to_cpu, (unsigned long long *)addr, shm_size);
        hxfmsg(&htx_d, 0, HTX_HE_INFO, msg);

		/* Lock the new shared memory, so that its always memory resident */ 
        rc = mlock(addr, shm_size);
        if(rc == -1) {
            sprintf(msg,"\n mlock failed with %d", errno);
            hxfmsg(&htx_d, rc, HTX_HE_HARD_ERROR, msg);
            memory_set_cleanup();
            return(-1);
        }

        mem[host_cpu].seg_addr = addr;
		mem[host_cpu].memory_set_size = shm_size; 

#ifdef __HTX_LINUX__
	   	rc = htx_unbind_process();
#else
    	rc = bindprocessor(BINDPROCESS, getpid(), PROCESSOR_CLASS_ANY);
#endif
        if(rc == -1) {
            sprintf(msg, "\n%d: bindprocessor failed with %d while unbinding",__LINE__,  errno);
            hxfmsg(&htx_d, errno, HTX_HE_HARD_ERROR, msg);
            return(-1);
        }
    } /* Off num_cpus_mapped loop */
    return(0);
}