Print this page
patch as-lock-macro-simplification


 173         val_array = kmem_alloc(val_size, KM_SLEEP);
 174 
 175         if ((req_array[0] & MEMINFO_MASK) == MEMINFO_PLGRP) {
 176                 /* find the corresponding lgroup for each physical address */
 177                 for (i = 0; i < addr_count; i++) {
 178                         paddr = in_array[i];
 179                         pfn = btop(paddr);
 180                         lgrp = lgrp_pfn_to_lgrp(pfn);
 181                         if (lgrp) {
 182                                 out_array[i] = lgrp->lgrp_id;
 183                                 val_array[i] = VALID_ADDR | VALID_REQ;
 184                         } else {
 185                                 out_array[i] = NULL;
 186                                 val_array[i] = 0;
 187                         }
 188                 }
 189         } else {
 190                 /* get the corresponding memory info for each virtual address */
 191                 as = curproc->p_as;
 192 
 193                 AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 194                 hat = as->a_hat;
 195                 for (i = out_idx = 0; i < addr_count; i++, out_idx +=
 196                     info_count) {
 197                         addr = in_array[i];
 198                         vaddr = (uintptr_t)(addr & ~PAGEOFFSET);
 199                         if (!as_segat(as, (caddr_t)vaddr)) {
 200                                 val_array[i] = 0;
 201                                 continue;
 202                         }
 203                         val_array[i] = VALID_ADDR;
 204                         pfn = hat_getpfnum(hat, (caddr_t)vaddr);
 205                         if (pfn != PFN_INVALID) {
 206                                 paddr = (uint64_t)((pfn << PAGESHIFT) |
 207                                     (addr & PAGEOFFSET));
 208                                 for (j = 0; j < info_count; j++) {
 209                                         switch (req_array[j] & MEMINFO_MASK) {
 210                                         case MEMINFO_VPHYSICAL:
 211                                                 /*
 212                                                  * return the physical address
 213                                                  * corresponding to the input


 269                                                 /*
 270                                                  * for future use:-
 271                                                  * return the lgroup of nth
 272                                                  * physical replica of the
 273                                                  * specified virtual address
 274                                                  */
 275                                                 break;
 276                                         case MEMINFO_PLGRP:
 277                                                 /*
 278                                                  * this is for physical address
 279                                                  * only, shouldn't mix with
 280                                                  * virtual address
 281                                                  */
 282                                                 break;
 283                                         default:
 284                                                 break;
 285                                         }
 286                                 }
 287                         }
 288                 }
 289                 AS_LOCK_EXIT(as, &as->a_lock);
 290         }
 291 
 292         /* copy out the results and validity bits and free the buffers */
 293         if ((copyout(out_array, minfo.mi_outdata, out_size) != 0) ||
 294             (copyout(val_array, minfo.mi_validity, val_size) != 0))
 295                 ret = set_errno(EFAULT);
 296 
 297         kmem_free(in_array, in_size);
 298         kmem_free(out_array, out_size);
 299         kmem_free(req_array, req_size);
 300         kmem_free(val_array, val_size);
 301 
 302         return (ret);
 303 }
 304 
 305 
 306 /*
 307  * Initialize lgroup affinities for thread
 308  */
 309 void




 173         val_array = kmem_alloc(val_size, KM_SLEEP);
 174 
 175         if ((req_array[0] & MEMINFO_MASK) == MEMINFO_PLGRP) {
 176                 /* find the corresponding lgroup for each physical address */
 177                 for (i = 0; i < addr_count; i++) {
 178                         paddr = in_array[i];
 179                         pfn = btop(paddr);
 180                         lgrp = lgrp_pfn_to_lgrp(pfn);
 181                         if (lgrp) {
 182                                 out_array[i] = lgrp->lgrp_id;
 183                                 val_array[i] = VALID_ADDR | VALID_REQ;
 184                         } else {
 185                                 out_array[i] = NULL;
 186                                 val_array[i] = 0;
 187                         }
 188                 }
 189         } else {
 190                 /* get the corresponding memory info for each virtual address */
 191                 as = curproc->p_as;
 192 
 193                 AS_LOCK_ENTER(as, RW_READER);
 194                 hat = as->a_hat;
 195                 for (i = out_idx = 0; i < addr_count; i++, out_idx +=
 196                     info_count) {
 197                         addr = in_array[i];
 198                         vaddr = (uintptr_t)(addr & ~PAGEOFFSET);
 199                         if (!as_segat(as, (caddr_t)vaddr)) {
 200                                 val_array[i] = 0;
 201                                 continue;
 202                         }
 203                         val_array[i] = VALID_ADDR;
 204                         pfn = hat_getpfnum(hat, (caddr_t)vaddr);
 205                         if (pfn != PFN_INVALID) {
 206                                 paddr = (uint64_t)((pfn << PAGESHIFT) |
 207                                     (addr & PAGEOFFSET));
 208                                 for (j = 0; j < info_count; j++) {
 209                                         switch (req_array[j] & MEMINFO_MASK) {
 210                                         case MEMINFO_VPHYSICAL:
 211                                                 /*
 212                                                  * return the physical address
 213                                                  * corresponding to the input


 269                                                 /*
 270                                                  * for future use:-
 271                                                  * return the lgroup of nth
 272                                                  * physical replica of the
 273                                                  * specified virtual address
 274                                                  */
 275                                                 break;
 276                                         case MEMINFO_PLGRP:
 277                                                 /*
 278                                                  * this is for physical address
 279                                                  * only, shouldn't mix with
 280                                                  * virtual address
 281                                                  */
 282                                                 break;
 283                                         default:
 284                                                 break;
 285                                         }
 286                                 }
 287                         }
 288                 }
 289                 AS_LOCK_EXIT(as);
 290         }
 291 
 292         /* copy out the results and validity bits and free the buffers */
 293         if ((copyout(out_array, minfo.mi_outdata, out_size) != 0) ||
 294             (copyout(val_array, minfo.mi_validity, val_size) != 0))
 295                 ret = set_errno(EFAULT);
 296 
 297         kmem_free(in_array, in_size);
 298         kmem_free(out_array, out_size);
 299         kmem_free(req_array, req_size);
 300         kmem_free(val_array, val_size);
 301 
 302         return (ret);
 303 }
 304 
 305 
 306 /*
 307  * Initialize lgroup affinities for thread
 308  */
 309 void