MCPcopy Create free account
hub / github.com/F-Stack/f-stack / eventfd_write

Function eventfd_write

freebsd/kern/sys_eventfd.c:189–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189static int
190eventfd_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
191 int flags, struct thread *td)
192{
193 struct eventfd *efd;
194 eventfd_t count;
195 int error;
196
197 if (uio->uio_resid < sizeof(eventfd_t))
198 return (EINVAL);
199
200 error = uiomove(&count, sizeof(eventfd_t), uio);
201 if (error != 0)
202 return (error);
203 if (count == UINT64_MAX)
204 return (EINVAL);
205
206 efd = fp->f_data;
207 mtx_lock(&efd->efd_lock);
208retry:
209 if (UINT64_MAX - efd->efd_count <= count) {
210 if ((fp->f_flag & FNONBLOCK) != 0) {
211 mtx_unlock(&efd->efd_lock);
212 /* Do not not return the number of bytes written */
213 uio->uio_resid += sizeof(eventfd_t);
214 return (EAGAIN);
215 }
216 error = mtx_sleep(&efd->efd_count, &efd->efd_lock,
217 PCATCH, "efdwr", 0);
218 if (error == 0)
219 goto retry;
220 }
221 if (error == 0) {
222 MPASS(UINT64_MAX - efd->efd_count > count);
223 efd->efd_count += count;
224 KNOTE_LOCKED(&efd->efd_sel.si_note, 0);
225 selwakeup(&efd->efd_sel);
226 wakeup(&efd->efd_count);
227 }
228 mtx_unlock(&efd->efd_lock);
229
230 return (error);
231}
232
233static int
234eventfd_poll(struct file *fp, int events, struct ucred *active_cred,

Callers 4

vhost_user_inject_irqFunction · 0.85
mlx5_vdpa_queue_completeFunction · 0.85
mlx5_vdpa_virtq_setupFunction · 0.85
vhost_crypto_workerFunction · 0.85

Calls 5

selwakeupFunction · 0.85
uiomoveFunction · 0.70
mtx_lockFunction · 0.70
mtx_unlockFunction · 0.70
wakeupFunction · 0.70

Tested by

no test coverage detected