- Timestamp:
- 2011-01-26T14:52:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7fc092a, 9f0318c, ea6a824
- Parents:
- 192a0063 (diff), a0ce870 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel/generic
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/sysinfo/abi.h
r192a0063 r6265a2b 104 104 char name[TASK_NAME_BUFLEN]; /**< Task name (in kernel) */ 105 105 size_t virtmem; /**< Size of VAS (bytes) */ 106 size_t resmem; /**< Size of resident (used) memory (bytes) */ 106 107 size_t threads; /**< Number of threads */ 107 108 uint64_t ucycles; /**< Number of CPU cycles in user space */ -
kernel/generic/include/sysinfo/sysinfo.h
r192a0063 r6265a2b 148 148 extern sysarg_t sys_sysinfo_get_value(void *, size_t, void *); 149 149 extern sysarg_t sys_sysinfo_get_data_size(void *, size_t, void *); 150 extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t );150 extern sysarg_t sys_sysinfo_get_data(void *, size_t, void *, size_t, size_t *); 151 151 152 152 #endif -
kernel/generic/src/mm/backend_phys.c
r192a0063 r6265a2b 81 81 page_mapping_insert(AS, addr, base + (addr - area->base), 82 82 as_area_get_flags(area)); 83 if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1)) 84 panic("Cannot insert used space."); 83 84 if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1)) 85 panic("Cannot insert used space."); 85 86 86 87 return AS_PF_OK; -
kernel/generic/src/sysinfo/stats.c
r192a0063 r6265a2b 170 170 * Note that it may be infinitely better to let the address space 171 171 * management code compute these statistics as it proceeds instead of 172 * having them calculated hereover and over again here.172 * having them calculated over and over again here. 173 173 */ 174 174 … … 199 199 } 200 200 201 /** Get the resident (used) size of a virtual address space 202 * 203 * @param as Address space. 204 * 205 * @return Size of the resident (used) virtual address space (bytes). 206 * 207 */ 208 static size_t get_task_resmem(as_t *as) 209 { 210 size_t result = 0; 211 212 /* 213 * We are holding some spinlocks here and therefore are not allowed to 214 * block. Only attempt to lock the address space and address space area 215 * mutexes conditionally. If it is not possible to lock either object, 216 * allow the statistics to be inexact by skipping the respective object. 217 * 218 * Note that it may be infinitely better to let the address space 219 * management code compute these statistics as it proceeds instead of 220 * having them calculated over and over again here. 221 */ 222 223 if (SYNCH_FAILED(mutex_trylock(&as->lock))) 224 return result * PAGE_SIZE; 225 226 /* Walk the B+ tree of AS areas */ 227 link_t *cur; 228 for (cur = as->as_area_btree.leaf_head.next; 229 cur != &as->as_area_btree.leaf_head; cur = cur->next) { 230 btree_node_t *node = 231 list_get_instance(cur, btree_node_t, leaf_link); 232 233 unsigned int i; 234 for (i = 0; i < node->keys; i++) { 235 as_area_t *area = node->value[i]; 236 237 if (SYNCH_FAILED(mutex_trylock(&area->lock))) 238 continue; 239 240 /* Walk the B+ tree of resident pages */ 241 link_t *rcur; 242 for (rcur = area->used_space.leaf_head.next; 243 rcur != &area->used_space.leaf_head; rcur = rcur->next) { 244 btree_node_t *rnode = 245 list_get_instance(rcur, btree_node_t, leaf_link); 246 247 unsigned int j; 248 for (j = 0; j < rnode->keys; j++) 249 result += (size_t) rnode->value[i]; 250 } 251 252 mutex_unlock(&area->lock); 253 } 254 } 255 256 mutex_unlock(&as->lock); 257 258 return result * PAGE_SIZE; 259 } 260 201 261 /* Produce task statistics 202 262 * … … 215 275 str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name); 216 276 stats_task->virtmem = get_task_virtmem(task->as); 277 stats_task->resmem = get_task_resmem(task->as); 217 278 stats_task->threads = atomic_get(&task->refcount); 218 279 task_get_accounting(task, &(stats_task->ucycles), -
kernel/generic/src/sysinfo/sysinfo.c
r192a0063 r6265a2b 40 40 #include <arch/asm.h> 41 41 #include <errno.h> 42 #include <macros.h> 42 43 43 44 /** Maximal sysinfo path length */ … … 761 762 * character must be null). 762 763 * 763 * The user space buffer must be sized exactly according 764 * to the size of the binary data, otherwise the request 765 * fails. 764 * If the user space buffer size does not equal 765 * the actual size of the returned data, the data 766 * is truncated. Whether this is actually a fatal 767 * error or the data can be still interpreted as valid 768 * depends on the nature of the data and has to be 769 * decided by the user space. 770 * 771 * The actual size of data returned is stored to 772 * size_ptr. 766 773 * 767 774 * @param path_ptr Sysinfo path in the user address space. … … 770 777 * to store the binary data. 771 778 * @param buffer_size User space buffer size. 779 * @param size_ptr User space pointer where to store the 780 * binary data size. 772 781 * 773 782 * @return Error code (EOK in case of no error). … … 775 784 */ 776 785 sysarg_t sys_sysinfo_get_data(void *path_ptr, size_t path_size, 777 void *buffer_ptr, size_t buffer_size )786 void *buffer_ptr, size_t buffer_size, size_t *size_ptr) 778 787 { 779 788 int rc; 780 789 781 790 /* Get the item */ 782 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, false); 783 791 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, 792 false); 793 784 794 /* Only constant or generated binary data is considered */ 785 if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) { 786 /* Check destination buffer size */ 787 if (ret.data.size == buffer_size) 788 rc = copy_to_uspace(buffer_ptr, ret.data.data, 789 ret.data.size); 790 else 791 rc = ENOMEM; 795 if ((ret.tag == SYSINFO_VAL_DATA) || 796 (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) { 797 size_t size = min(ret.data.size, buffer_size); 798 rc = copy_to_uspace(buffer_ptr, ret.data.data, size); 799 if (rc == EOK) 800 rc = copy_to_uspace(size_ptr, &size, sizeof(size)); 792 801 } else 793 802 rc = EINVAL;
Note:
See TracChangeset
for help on using the changeset viewer.