On Mon, May 12, 2025 at 11:58 AM Song Liu song@kernel.org wrote:
On Mon, May 12, 2025 at 10:41 AM T.J. Mercier tjmercier@google.com wrote: [...]
+static int udmabuf;
static int udmabuf = -1;
+static const char udmabuf_test_buffer_name[DMA_BUF_NAME_LEN] = "udmabuf_test_buffer_for_iter"; +static size_t udmabuf_test_buffer_size; +static int sysheap_dmabuf;
static int sysheap_dmabuf = -1;
We don't really need the -1 since the rework in this version initializes them to -1 on failure, but I'll add it anyway.
+static const char sysheap_test_buffer_name[DMA_BUF_NAME_LEN] = "sysheap_test_buffer_for_iter"; +static size_t sysheap_test_buffer_size;
+static int create_udmabuf(void) +{
struct udmabuf_create create;
nit: zero initialize create to be future proof.
Ok, done.
int dev_udmabuf, memfd, local_udmabuf;
udmabuf_test_buffer_size = 10 * getpagesize();
[...]
+static void subtest_dmabuf_iter_check_default_iter(struct dmabuf_iter *skel) +{
bool found_test_sysheap_dmabuf = false;
bool found_test_udmabuf = false;
struct DmabufInfo bufinfo;
size_t linesize = 0;
char *line = NULL;
FILE *iter_file;
int iter_fd, f = INODE;
iter_fd = bpf_iter_create(bpf_link__fd(skel->links.dmabuf_collector));
ASSERT_OK_FD(iter_fd, "iter_create");
Should we check ASSERT_OK_FD() and exit early on failures?
We should fallthrough on error, but let's add the early out.
iter_file = fdopen(iter_fd, "r");
ASSERT_OK_PTR(iter_file, "fdopen");
Same here. [...]
+/*
- Fields output by this iterator are delimited by newlines. Convert any
- newlines in user-provided printed strings to spaces.
- */
+static void sanitize_string(char *src, size_t size) +{
for (char *c = src; c && (size_t)(c - src) < size; ++c)
Should this be:
for (char *c = src; *c && (size_t)(c - src) < size; ++c)
?
Yes! Thanks.
Thanks, Song
[...]