Lines Matching +full:close +full:- +full:range
1 // SPDX-License-Identifier: GPL-2.0
7 * Copyright (C) 2019-2022 Google LLC
29 int uffd = reader_args->uffd; in uffd_handler_thread_fn()
46 TEST_ASSERT(!epoll_ctl(epollfd, EPOLL_CTL_ADD, reader_args->pipe, &evt), in uffd_handler_thread_fn()
54 r = epoll_wait(epollfd, &evt, 1, -1); in uffd_handler_thread_fn()
64 r = read(reader_args->pipe, &tmp_chr, 1); in uffd_handler_thread_fn()
74 if (r == -1) { in uffd_handler_thread_fn()
86 if (reader_args->delay) in uffd_handler_thread_fn()
87 usleep(reader_args->delay); in uffd_handler_thread_fn()
88 r = reader_args->handler(reader_args->uffd_mode, uffd, &msg); in uffd_handler_thread_fn()
122 uffd_desc->pipefds = calloc(sizeof(int), num_readers); in uffd_setup_demand_paging()
123 TEST_ASSERT(uffd_desc->pipefds, "Failed to alloc pipes"); in uffd_setup_demand_paging()
125 uffd_desc->readers = calloc(sizeof(pthread_t), num_readers); in uffd_setup_demand_paging()
126 TEST_ASSERT(uffd_desc->readers, "Failed to alloc reader threads"); in uffd_setup_demand_paging()
128 uffd_desc->reader_args = calloc(sizeof(struct uffd_reader_args), num_readers); in uffd_setup_demand_paging()
129 TEST_ASSERT(uffd_desc->reader_args, "Failed to alloc reader_args"); in uffd_setup_demand_paging()
131 uffd_desc->num_readers = num_readers; in uffd_setup_demand_paging()
142 TEST_ASSERT(ioctl(uffd, UFFDIO_API, &uffdio_api) != -1, in uffd_setup_demand_paging()
146 uffdio_register.range.start = (uint64_t)hva; in uffd_setup_demand_paging()
147 uffdio_register.range.len = len; in uffd_setup_demand_paging()
149 TEST_ASSERT(ioctl(uffd, UFFDIO_REGISTER, &uffdio_register) != -1, in uffd_setup_demand_paging()
154 uffd_desc->uffd = uffd; in uffd_setup_demand_paging()
155 for (i = 0; i < uffd_desc->num_readers; ++i) { in uffd_setup_demand_paging()
162 uffd_desc->pipefds[i] = pipes[1]; in uffd_setup_demand_paging()
164 uffd_desc->reader_args[i].uffd_mode = uffd_mode; in uffd_setup_demand_paging()
165 uffd_desc->reader_args[i].uffd = uffd; in uffd_setup_demand_paging()
166 uffd_desc->reader_args[i].delay = delay; in uffd_setup_demand_paging()
167 uffd_desc->reader_args[i].handler = handler; in uffd_setup_demand_paging()
168 uffd_desc->reader_args[i].pipe = pipes[0]; in uffd_setup_demand_paging()
170 pthread_create(&uffd_desc->readers[i], NULL, uffd_handler_thread_fn, in uffd_setup_demand_paging()
171 &uffd_desc->reader_args[i]); in uffd_setup_demand_paging()
173 PER_VCPU_DEBUG("Created uffd thread %i for HVA range [%p, %p)\n", in uffd_setup_demand_paging()
185 for (i = 0; i < uffd->num_readers; ++i) in uffd_stop_demand_paging()
186 TEST_ASSERT(write(uffd->pipefds[i], &c, 1) == 1, in uffd_stop_demand_paging()
189 for (i = 0; i < uffd->num_readers; ++i) in uffd_stop_demand_paging()
190 TEST_ASSERT(!pthread_join(uffd->readers[i], NULL), in uffd_stop_demand_paging()
193 close(uffd->uffd); in uffd_stop_demand_paging()
195 for (i = 0; i < uffd->num_readers; ++i) { in uffd_stop_demand_paging()
196 close(uffd->pipefds[i]); in uffd_stop_demand_paging()
197 close(uffd->reader_args[i].pipe); in uffd_stop_demand_paging()
200 free(uffd->pipefds); in uffd_stop_demand_paging()
201 free(uffd->readers); in uffd_stop_demand_paging()
202 free(uffd->reader_args); in uffd_stop_demand_paging()