Skip to content
Snippets Groups Projects
Select Git revision
  • a8205e310011f09cc73cd577d7b0074c57b9bb54
  • openEuler-1.0-LTS default protected
  • openEuler-22.09
  • OLK-5.10
  • openEuler-22.03-LTS-Ascend
  • openEuler-22.03-LTS
  • master
  • openEuler-22.03-LTS-LoongArch-NW
  • openEuler-22.09-HCK
  • openEuler-20.03-LTS-SP3
  • openEuler-21.09
  • openEuler-21.03
  • openEuler-20.09
  • 4.19.90-2210.4.0
  • 5.10.0-121.0.0
  • 5.10.0-60.61.0
  • 4.19.90-2210.3.0
  • 5.10.0-60.60.0
  • 5.10.0-120.0.0
  • 5.10.0-60.59.0
  • 5.10.0-119.0.0
  • 4.19.90-2210.2.0
  • 4.19.90-2210.1.0
  • 5.10.0-118.0.0
  • 5.10.0-106.19.0
  • 5.10.0-60.58.0
  • 4.19.90-2209.6.0
  • 5.10.0-106.18.0
  • 5.10.0-106.17.0
  • 5.10.0-106.16.0
  • 5.10.0-106.15.0
  • 5.10.0-117.0.0
  • 5.10.0-60.57.0
33 results

io_uring.c

Blame
  • io_uring.c 212.55 KiB
    // SPDX-License-Identifier: GPL-2.0
    /*
     * Shared application/kernel submission and completion ring pairs, for
     * supporting fast/efficient IO.
     *
     * A note on the read/write ordering memory barriers that are matched between
     * the application and kernel side.
     *
     * After the application reads the CQ ring tail, it must use an
     * appropriate smp_rmb() to pair with the smp_wmb() the kernel uses
     * before writing the tail (using smp_load_acquire to read the tail will
     * do). It also needs a smp_mb() before updating CQ head (ordering the
     * entry load(s) with the head store), pairing with an implicit barrier
     * through a control-dependency in io_get_cqring (smp_store_release to
     * store head will do). Failure to do so could lead to reading invalid
     * CQ entries.
     *
     * Likewise, the application must use an appropriate smp_wmb() before
     * writing the SQ tail (ordering SQ entry stores with the tail store),
     * which pairs with smp_load_acquire in io_get_sqring (smp_store_release
     * to store the tail will do). And it needs a barrier ordering the SQ
     * head load before writing new SQ entries (smp_load_acquire to read
     * head will do).
     *
     * When using the SQ poll thread (IORING_SETUP_SQPOLL), the application
     * needs to check the SQ flags for IORING_SQ_NEED_WAKEUP *after*
     * updating the SQ tail; a full memory barrier smp_mb() is needed
     * between.
     *
     * Also see the examples in the liburing library:
     *
     *	git://git.kernel.dk/liburing
     *
     * io_uring also uses READ/WRITE_ONCE() for _any_ store or load that happens
     * from data shared between the kernel and application. This is done both
     * for ordering purposes, but also to ensure that once a value is loaded from
     * data that the application could potentially modify, it remains stable.
     *
     * Copyright (C) 2018-2019 Jens Axboe
     * Copyright (c) 2018-2019 Christoph Hellwig
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/errno.h>
    #include <linux/syscalls.h>
    #include <linux/compat.h>
    #include <net/compat.h>
    #include <linux/refcount.h>
    #include <linux/uio.h>
    #include <linux/bits.h>
    
    #include <linux/sched/signal.h>
    #include <linux/fs.h>
    #include <linux/file.h>
    #include <linux/fdtable.h>
    #include <linux/mm.h>
    #include <linux/mman.h>
    #include <linux/percpu.h>
    #include <linux/slab.h>
    #include <linux/kthread.h>
    #include <linux/blkdev.h>
    #include <linux/bvec.h>
    #include <linux/net.h>
    #include <net/sock.h>
    #include <net/af_unix.h>
    #include <net/scm.h>
    #include <linux/anon_inodes.h>
    #include <linux/sched/mm.h>
    #include <linux/uaccess.h>
    #include <linux/nospec.h>