Lines Matching refs:data
328 * data. So even if the DSO is represented by 'krava.xz' module,
492 list_add_tail(&dso->data.open_entry, &dso__data_open);
498 list_del_init(&dso->data.open_entry);
500 "DSO data fd counter out of bounds.");
591 * dso_close - Open DSO data file
594 * Open @dso's data file descriptor and updates
625 if (dso->data.fd >= 0) {
626 close(dso->data.fd);
627 dso->data.fd = -1;
628 dso->data.file_size = 0;
634 * dso_close - Close DSO data file
637 * Close @dso's data file descriptor and updates
649 dso = list_first_entry(&dso__data_open, struct dso, data.open_entry);
675 * Used only by tests/dso-data.c to reset the environment
709 * dso__data_close - Close DSO data file
712 * External interface to close @dso's data file descriptor.
730 if (dso->data.fd >= 0)
734 dso->data.fd = open_dso(dso, machine);
741 dso->data.fd = open_dso(dso, machine);
742 if (dso->data.fd >= 0)
747 if (dso->data.fd >= 0)
748 dso->data.status = DSO_DATA_STATUS_OK;
750 dso->data.status = DSO_DATA_STATUS_ERROR;
754 * dso__data_get_fd - Get dso's data file descriptor
764 if (dso->data.status == DSO_DATA_STATUS_ERROR)
772 if (dso->data.fd < 0)
775 return dso->data.fd;
787 if (dso->data.status_seen & flag)
790 dso->data.status_seen |= flag;
796 static ssize_t bpf_read(struct dso *dso, u64 offset, char *data)
805 dso->data.status = DSO_DATA_STATUS_ERROR;
816 memcpy(data, buf + offset, size);
826 dso->data.status = DSO_DATA_STATUS_ERROR;
830 dso->data.file_size = node->info_linear->info.jited_prog_len;
838 struct rb_root *root = &dso->data.cache;
855 const struct rb_root *root = &dso->data.cache;
881 struct rb_root *root = &dso->data.cache;
912 static ssize_t dso_cache__memcpy(struct dso_cache *cache, u64 offset, u8 *data,
919 memcpy(data, cache->data + cache_offset, cache_size);
921 memcpy(cache->data + cache_offset, data, cache_size);
926 u64 offset, char *data)
933 * dso->data.fd might be closed if other thread opened another
938 if (dso->data.fd < 0) {
939 dso->data.status = DSO_DATA_STATUS_ERROR;
944 ret = pread(dso->data.fd, data, DSO__DATA_CACHE_SIZE, offset);
965 *ret = bpf_read(dso, cache_offset, cache->data);
971 *ret = file_read(dso, machine, cache_offset, cache->data);
1002 u64 offset, u8 *data, ssize_t size, bool out)
1011 return dso_cache__memcpy(cache, offset, data, size, out);
1015 * Reads and caches dso data DSO__DATA_CACHE_SIZE size chunks
1016 * in the rb_tree. Any read to already cached data is served
1017 * by cached data. Writes update the cache only, not the backing file.
1020 u64 offset, u8 *data, ssize_t size, bool out)
1023 u8 *p = data;
1057 * dso->data.fd might be closed if other thread opened another
1062 if (dso->data.fd < 0) {
1064 dso->data.status = DSO_DATA_STATUS_ERROR;
1068 if (fstat(dso->data.fd, &st) < 0) {
1072 dso->data.status = DSO_DATA_STATUS_ERROR;
1075 dso->data.file_size = st.st_size;
1084 if (dso->data.file_size)
1087 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1097 * dso__data_size - Return dso data size
1101 * Return: dso data size
1108 /* For now just estimate dso data size is close to file size */
1109 return dso->data.file_size;
1113 u64 offset, u8 *data, ssize_t size,
1120 if (offset > dso->data.file_size)
1126 return cached_io(dso, machine, offset, data, size, out);
1130 * dso__data_read_offset - Read data from dso file offset
1134 * @data: buffer to store data
1135 * @size: size of the @data buffer
1137 * External interface to read data from dso file offset. Open
1138 * dso data file and use cached_read to get the data.
1141 u64 offset, u8 *data, ssize_t size)
1143 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1146 return data_read_write_offset(dso, machine, offset, data, size, true);
1150 * dso__data_read_addr - Read data from dso address
1154 * @data: buffer to store data
1155 * @size: size of the @data buffer
1157 * External interface to read data from dso address.
1161 u8 *data, ssize_t size)
1165 return dso__data_read_offset(dso, machine, offset, data, size);
1169 * dso__data_write_cache_offs - Write data to dso data cache at file offset
1173 * @data: buffer to write
1174 * @size: size of the @data buffer
1176 * Write into the dso file data cache, but do not change the file itself.
1181 u8 *data = (u8 *)data_in; /* cast away const to use same fns for r/w */
1183 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1186 return data_read_write_offset(dso, machine, offset, data, size, false);
1190 * dso__data_write_cache_addr - Write data to dso data cache at dso address
1194 * @data: buffer to write
1195 * @size: size of the @data buffer
1197 * External interface to write into the dso file data cache, but do not change
1202 const u8 *data, ssize_t size)
1206 return dso__data_write_cache_offs(dso, machine, offset, data, size);
1326 dso->data.cache = RB_ROOT;
1329 dso->data.fd = -1;
1330 dso->data.status = DSO_DATA_STATUS_UNKNOWN;
1346 INIT_LIST_HEAD(&dso->data.open_entry);
1417 return !memcmp(dso->bid.data, bid->data, bid->size) &&
1418 !memchr_inv(&dso->bid.data[bid->size], 0,
1423 memcmp(dso->bid.data, bid->data, dso->bid.size) == 0;