Lines Matching refs:data
298 * data. So even if the DSO is represented by 'krava.xz' module,
449 list_add_tail(&dso->data.open_entry, &dso__data_open);
455 list_del_init(&dso->data.open_entry);
457 "DSO data fd counter out of bounds.");
530 * dso_close - Open DSO data file
533 * Open @dso's data file descriptor and updates
561 if (dso->data.fd >= 0) {
562 close(dso->data.fd);
563 dso->data.fd = -1;
564 dso->data.file_size = 0;
570 * dso_close - Close DSO data file
573 * Close @dso's data file descriptor and updates
585 dso = list_first_entry(&dso__data_open, struct dso, data.open_entry);
611 * Used only by tests/dso-data.c to reset the environment
645 * dso__data_close - Close DSO data file
648 * External interface to close @dso's data file descriptor.
666 if (dso->data.fd >= 0)
670 dso->data.fd = open_dso(dso, machine);
677 dso->data.fd = open_dso(dso, machine);
678 if (dso->data.fd >= 0)
683 if (dso->data.fd >= 0)
684 dso->data.status = DSO_DATA_STATUS_OK;
686 dso->data.status = DSO_DATA_STATUS_ERROR;
690 * dso__data_get_fd - Get dso's data file descriptor
700 if (dso->data.status == DSO_DATA_STATUS_ERROR)
708 if (dso->data.fd < 0)
711 return dso->data.fd;
723 if (dso->data.status_seen & flag)
726 dso->data.status_seen |= flag;
731 static ssize_t bpf_read(struct dso *dso, u64 offset, char *data)
740 dso->data.status = DSO_DATA_STATUS_ERROR;
751 memcpy(data, buf + offset, size);
761 dso->data.status = DSO_DATA_STATUS_ERROR;
765 dso->data.file_size = node->info_linear->info.jited_prog_len;
772 struct rb_root *root = &dso->data.cache;
789 const struct rb_root *root = &dso->data.cache;
815 struct rb_root *root = &dso->data.cache;
846 static ssize_t dso_cache__memcpy(struct dso_cache *cache, u64 offset, u8 *data,
853 memcpy(data, cache->data + cache_offset, cache_size);
855 memcpy(cache->data + cache_offset, data, cache_size);
860 u64 offset, char *data)
867 * dso->data.fd might be closed if other thread opened another
872 if (dso->data.fd < 0) {
873 dso->data.status = DSO_DATA_STATUS_ERROR;
878 ret = pread(dso->data.fd, data, DSO__DATA_CACHE_SIZE, offset);
899 *ret = bpf_read(dso, cache_offset, cache->data);
903 *ret = file_read(dso, machine, cache_offset, cache->data);
934 u64 offset, u8 *data, ssize_t size, bool out)
943 return dso_cache__memcpy(cache, offset, data, size, out);
947 * Reads and caches dso data DSO__DATA_CACHE_SIZE size chunks
948 * in the rb_tree. Any read to already cached data is served
949 * by cached data. Writes update the cache only, not the backing file.
952 u64 offset, u8 *data, ssize_t size, bool out)
955 u8 *p = data;
989 * dso->data.fd might be closed if other thread opened another
994 if (dso->data.fd < 0) {
996 dso->data.status = DSO_DATA_STATUS_ERROR;
1000 if (fstat(dso->data.fd, &st) < 0) {
1004 dso->data.status = DSO_DATA_STATUS_ERROR;
1007 dso->data.file_size = st.st_size;
1016 if (dso->data.file_size)
1019 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1029 * dso__data_size - Return dso data size
1033 * Return: dso data size
1040 /* For now just estimate dso data size is close to file size */
1041 return dso->data.file_size;
1045 u64 offset, u8 *data, ssize_t size,
1052 if (offset > dso->data.file_size)
1058 return cached_io(dso, machine, offset, data, size, out);
1062 * dso__data_read_offset - Read data from dso file offset
1066 * @data: buffer to store data
1067 * @size: size of the @data buffer
1069 * External interface to read data from dso file offset. Open
1070 * dso data file and use cached_read to get the data.
1073 u64 offset, u8 *data, ssize_t size)
1075 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1078 return data_read_write_offset(dso, machine, offset, data, size, true);
1082 * dso__data_read_addr - Read data from dso address
1086 * @data: buffer to store data
1087 * @size: size of the @data buffer
1089 * External interface to read data from dso address.
1093 u8 *data, ssize_t size)
1096 return dso__data_read_offset(dso, machine, offset, data, size);
1100 * dso__data_write_cache_offs - Write data to dso data cache at file offset
1104 * @data: buffer to write
1105 * @size: size of the @data buffer
1107 * Write into the dso file data cache, but do not change the file itself.
1112 u8 *data = (u8 *)data_in; /* cast away const to use same fns for r/w */
1114 if (dso->data.status == DSO_DATA_STATUS_ERROR)
1117 return data_read_write_offset(dso, machine, offset, data, size, false);
1121 * dso__data_write_cache_addr - Write data to dso data cache at dso address
1125 * @data: buffer to write
1126 * @size: size of the @data buffer
1128 * External interface to write into the dso file data cache, but do not change
1133 const u8 *data, ssize_t size)
1136 return dso__data_write_cache_offs(dso, machine, offset, data, size);
1254 dso->data.cache = RB_ROOT;
1257 dso->data.fd = -1;
1258 dso->data.status = DSO_DATA_STATUS_UNKNOWN;
1274 INIT_LIST_HEAD(&dso->data.open_entry);
1344 return !memcmp(dso->bid.data, bid->data, bid->size) &&
1345 !memchr_inv(&dso->bid.data[bid->size], 0,
1350 memcmp(dso->bid.data, bid->data, dso->bid.size) == 0;