• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-12-stable/contrib/processor-trace/libipt/src/

Lines Matching refs:section

59 	struct pt_section *section;
77 section = malloc(sizeof(*section));
78 if (!section)
81 memset(section, 0, sizeof(*section));
83 section->filename = dupstr(filename);
84 section->status = status;
85 section->offset = offset;
86 section->size = size;
87 section->ucount = 1;
91 errcode = mtx_init(&section->lock, mtx_plain);
93 free(section->filename);
94 free(section);
98 errcode = mtx_init(&section->alock, mtx_plain);
100 mtx_destroy(&section->lock);
101 free(section->filename);
102 free(section);
108 return section;
115 int pt_section_lock(struct pt_section *section)
117 if (!section)
124 errcode = mtx_lock(&section->lock);
133 int pt_section_unlock(struct pt_section *section)
135 if (!section)
142 errcode = mtx_unlock(&section->lock);
151 static void pt_section_free(struct pt_section *section)
153 if (!section)
158 mtx_destroy(&section->alock);
159 mtx_destroy(&section->lock);
163 free(section->filename);
164 free(section->status);
165 free(section);
168 int pt_section_get(struct pt_section *section)
173 if (!section)
176 errcode = pt_section_lock(section);
180 ucount = section->ucount + 1;
182 (void) pt_section_unlock(section);
186 section->ucount = ucount;
188 return pt_section_unlock(section);
191 int pt_section_put(struct pt_section *section)
196 if (!section)
199 errcode = pt_section_lock(section);
203 mcount = section->mcount;
204 ucount = section->ucount;
206 section->ucount = ucount - 1;
207 return pt_section_unlock(section);
210 errcode = pt_section_unlock(section);
217 pt_section_free(section);
221 static int pt_section_lock_attach(struct pt_section *section)
223 if (!section)
230 errcode = mtx_lock(&section->alock);
239 static int pt_section_unlock_attach(struct pt_section *section)
241 if (!section)
248 errcode = mtx_unlock(&section->alock);
257 int pt_section_attach(struct pt_section *section,
263 if (!section || !iscache)
266 errcode = pt_section_lock_attach(section);
270 ucount = section->ucount;
271 acount = section->acount;
273 if (section->iscache || !ucount)
276 section->iscache = iscache;
277 section->acount = 1;
279 return pt_section_unlock_attach(section);
284 (void) pt_section_unlock_attach(section);
291 if (section->iscache != iscache)
294 section->acount = acount;
296 return pt_section_unlock_attach(section);
299 (void) pt_section_unlock_attach(section);
303 int pt_section_detach(struct pt_section *section,
309 if (!section || !iscache)
312 errcode = pt_section_lock_attach(section);
316 if (section->iscache != iscache)
319 acount = section->acount;
324 ucount = section->ucount;
328 section->acount = acount;
330 section->iscache = NULL;
332 return pt_section_unlock_attach(section);
335 (void) pt_section_unlock_attach(section);
339 const char *pt_section_filename(const struct pt_section *section)
341 if (!section)
344 return section->filename;
347 uint64_t pt_section_size(const struct pt_section *section)
349 if (!section)
352 return section->size;
355 static int pt_section_bcache_memsize(const struct pt_section *section,
360 if (!section || !psize)
363 bcache = section->bcache;
375 static int pt_section_memsize_locked(const struct pt_section *section,
379 int (*memsize)(const struct pt_section *section, uint64_t *size);
382 if (!section || !psize)
385 memsize = section->memsize;
387 if (section->mcount)
394 errcode = memsize(section, &msize);
398 errcode = pt_section_bcache_memsize(section, &bcsize);
407 int pt_section_memsize(struct pt_section *section, uint64_t *size)
411 errcode = pt_section_lock(section);
415 status = pt_section_memsize_locked(section, size);
417 errcode = pt_section_unlock(section);
424 uint64_t pt_section_offset(const struct pt_section *section)
426 if (!section)
429 return section->offset;
432 int pt_section_alloc_bcache(struct pt_section *section)
440 if (!section)
443 if (!section->mcount)
446 ssize = pt_section_size(section);
454 /* We need to take both the attach and the section lock in order to pair
462 errcode = pt_section_lock_attach(section);
466 errcode = pt_section_lock(section);
470 bcache = pt_section_bcache(section);
488 section->bcache = bcache;
490 errcode = pt_section_memsize_locked(section, &memsize);
494 errcode = pt_section_unlock(section);
499 iscache = section->iscache;
501 errcode = pt_iscache_notify_resize(iscache, section,
508 return pt_section_unlock_attach(section);
512 (void) pt_section_unlock(section);
515 (void) pt_section_unlock_attach(section);
519 int pt_section_on_map_lock(struct pt_section *section)
524 if (!section)
527 errcode = pt_section_lock_attach(section);
531 iscache = section->iscache;
533 return pt_section_unlock_attach(section);
535 /* There is a potential deadlock when @section was unmapped again and
542 status = pt_iscache_notify_map(iscache, section);
544 errcode = pt_section_unlock_attach(section);
551 int pt_section_map_share(struct pt_section *section)
556 if (!section)
559 errcode = pt_section_lock(section);
563 mcount = section->mcount;
565 (void) pt_section_unlock(section);
571 (void) pt_section_unlock(section);
575 section->mcount = mcount;
577 return pt_section_unlock(section);
580 int pt_section_unmap(struct pt_section *section)
585 if (!section)
588 errcode = pt_section_lock(section);
592 mcount = section->mcount;
598 section->mcount = mcount -= 1;
600 return pt_section_unlock(section);
603 if (!section->unmap)
606 status = section->unmap(section);
608 pt_bcache_free(section->bcache);
609 section->bcache = NULL;
611 errcode = pt_section_unlock(section);
618 (void) pt_section_unlock(section);
622 int pt_section_read(const struct pt_section *section, uint8_t *buffer,
627 if (!section)
630 if (!section->read)
633 limit = section->size;
637 /* Truncate if we try to read past the end of the section. */
642 return section->read(section, buffer, size, offset);