How should we interpret the phrase “asynchronous requests” in cfq-iosched.txt?












0















The old cfq-iosched.txt mentions "asynchronous" or "async" requests in several places.




CFQ maintains the per process queue for the processes which request I/O
operation(synchronous requests). In case of asynchronous requests, all the
requests from all the processes are batched together according to their
process's I/O priority.




How exactly should we understand the distinction in this doc, from a userspace point of view? I am unclear because there are several distinctions that are named sync/async:




  1. Normal read()/write() calls, v.s. Linux AIO (io_submit()/io_getevents).

  2. The O_SYNC flag, which can be set when you open() a file.


(Note, as I understand it, the quote above about IO priority does not apply to simple buffered writes. IO priority has no effect on such requests.)










share|improve this question





























    0















    The old cfq-iosched.txt mentions "asynchronous" or "async" requests in several places.




    CFQ maintains the per process queue for the processes which request I/O
    operation(synchronous requests). In case of asynchronous requests, all the
    requests from all the processes are batched together according to their
    process's I/O priority.




    How exactly should we understand the distinction in this doc, from a userspace point of view? I am unclear because there are several distinctions that are named sync/async:




    1. Normal read()/write() calls, v.s. Linux AIO (io_submit()/io_getevents).

    2. The O_SYNC flag, which can be set when you open() a file.


    (Note, as I understand it, the quote above about IO priority does not apply to simple buffered writes. IO priority has no effect on such requests.)










    share|improve this question



























      0












      0








      0








      The old cfq-iosched.txt mentions "asynchronous" or "async" requests in several places.




      CFQ maintains the per process queue for the processes which request I/O
      operation(synchronous requests). In case of asynchronous requests, all the
      requests from all the processes are batched together according to their
      process's I/O priority.




      How exactly should we understand the distinction in this doc, from a userspace point of view? I am unclear because there are several distinctions that are named sync/async:




      1. Normal read()/write() calls, v.s. Linux AIO (io_submit()/io_getevents).

      2. The O_SYNC flag, which can be set when you open() a file.


      (Note, as I understand it, the quote above about IO priority does not apply to simple buffered writes. IO priority has no effect on such requests.)










      share|improve this question
















      The old cfq-iosched.txt mentions "asynchronous" or "async" requests in several places.




      CFQ maintains the per process queue for the processes which request I/O
      operation(synchronous requests). In case of asynchronous requests, all the
      requests from all the processes are batched together according to their
      process's I/O priority.




      How exactly should we understand the distinction in this doc, from a userspace point of view? I am unclear because there are several distinctions that are named sync/async:




      1. Normal read()/write() calls, v.s. Linux AIO (io_submit()/io_getevents).

      2. The O_SYNC flag, which can be set when you open() a file.


      (Note, as I understand it, the quote above about IO priority does not apply to simple buffered writes. IO priority has no effect on such requests.)







      linux-kernel io






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 26 at 14:45







      sourcejedi

















      asked Jan 26 at 11:09









      sourcejedisourcejedi

      24k439106




      24k439106






















          1 Answer
          1






          active

          oldest

          votes


















          1














          The form of requests processed by the Linux IO schedulers, have various "hints" set on them. One of them is the "sync" hint.




          All IO is handled async in Linux. This is fine for background
          writes, but for reads or writes that someone waits for completion
          on, we want to notify the block layer and IO scheduler so that they
          know about it. That allows them to make better scheduling
          decisions. So when the below references 'sync' and 'async', it
          is referencing this priority hint.



          -- include/linux/fs.h (2016-11-01)




          Read requests are always treated as synchronous.




          block: don't use REQ_SYNC in the READ_SYNC definition (2016-11-01)



          Reads are synchronous per definition, don't add another flag for it.




          Both O_DIRECT and O_SYNC writes are treated as synchronous.



          #define READ_SYNC       0
          #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
          #define WRITE_ODIRECT REQ_SYNC


          IO requests initiated by fsync() use the same hint as O_SYNC writes. Although if the IO request has already been initiated and fsync() must wait for the existing request, I see no mechanism to adjust the request.




          Re: trying to understand READ_META, READ_SYNC, WRITE_SYNC & co (2010)





          But that leaves the question why disabling the idling logical for
          data integrity ->writepage is fine? This gets called from ->fsync
          or O_SYNC writes and will have the same impact as O_DIRECT writes.




          We have never enabled idling for those. O_SYNC should get a nice
          boost too, it just needs to be benchmarked and tested and then
          there would be no reason not to add it.




          We've only started using any kind of sync tag last year in ->writepage
          in commit a64c8610bd3b
          "block_write_full_page: Use synchronous writes for WBC_SYNC_ALL
          writebacks"




          "disabling idling" is a different hint flag, which is a bit harder to explain. But the commit linked in the above quote confirms the use of the WRITE_SYNC hint for fsync().



          The code quoted above has since been moved or replaced, but the use of the "sync" hint should still be the same in 2018 as it was in 2016.



          So I don't believe it really matters whether the requests are made using Linux AIO or not.



          (I notice AIO is only supported for O_DIRECT, therefore all AIO should be "synchronous" from the IO scheduler's point of view :-). At least as of v4.20. The proposed new AIO interface supports buffered (non-O_DIRECT) IO. That will go through the same code above, so then the hint will still be set according to whether O_SYNC is used).






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496855%2fhow-should-we-interpret-the-phrase-asynchronous-requests-in-cfq-iosched-txt%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The form of requests processed by the Linux IO schedulers, have various "hints" set on them. One of them is the "sync" hint.




            All IO is handled async in Linux. This is fine for background
            writes, but for reads or writes that someone waits for completion
            on, we want to notify the block layer and IO scheduler so that they
            know about it. That allows them to make better scheduling
            decisions. So when the below references 'sync' and 'async', it
            is referencing this priority hint.



            -- include/linux/fs.h (2016-11-01)




            Read requests are always treated as synchronous.




            block: don't use REQ_SYNC in the READ_SYNC definition (2016-11-01)



            Reads are synchronous per definition, don't add another flag for it.




            Both O_DIRECT and O_SYNC writes are treated as synchronous.



            #define READ_SYNC       0
            #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
            #define WRITE_ODIRECT REQ_SYNC


            IO requests initiated by fsync() use the same hint as O_SYNC writes. Although if the IO request has already been initiated and fsync() must wait for the existing request, I see no mechanism to adjust the request.




            Re: trying to understand READ_META, READ_SYNC, WRITE_SYNC & co (2010)





            But that leaves the question why disabling the idling logical for
            data integrity ->writepage is fine? This gets called from ->fsync
            or O_SYNC writes and will have the same impact as O_DIRECT writes.




            We have never enabled idling for those. O_SYNC should get a nice
            boost too, it just needs to be benchmarked and tested and then
            there would be no reason not to add it.




            We've only started using any kind of sync tag last year in ->writepage
            in commit a64c8610bd3b
            "block_write_full_page: Use synchronous writes for WBC_SYNC_ALL
            writebacks"




            "disabling idling" is a different hint flag, which is a bit harder to explain. But the commit linked in the above quote confirms the use of the WRITE_SYNC hint for fsync().



            The code quoted above has since been moved or replaced, but the use of the "sync" hint should still be the same in 2018 as it was in 2016.



            So I don't believe it really matters whether the requests are made using Linux AIO or not.



            (I notice AIO is only supported for O_DIRECT, therefore all AIO should be "synchronous" from the IO scheduler's point of view :-). At least as of v4.20. The proposed new AIO interface supports buffered (non-O_DIRECT) IO. That will go through the same code above, so then the hint will still be set according to whether O_SYNC is used).






            share|improve this answer






























              1














              The form of requests processed by the Linux IO schedulers, have various "hints" set on them. One of them is the "sync" hint.




              All IO is handled async in Linux. This is fine for background
              writes, but for reads or writes that someone waits for completion
              on, we want to notify the block layer and IO scheduler so that they
              know about it. That allows them to make better scheduling
              decisions. So when the below references 'sync' and 'async', it
              is referencing this priority hint.



              -- include/linux/fs.h (2016-11-01)




              Read requests are always treated as synchronous.




              block: don't use REQ_SYNC in the READ_SYNC definition (2016-11-01)



              Reads are synchronous per definition, don't add another flag for it.




              Both O_DIRECT and O_SYNC writes are treated as synchronous.



              #define READ_SYNC       0
              #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
              #define WRITE_ODIRECT REQ_SYNC


              IO requests initiated by fsync() use the same hint as O_SYNC writes. Although if the IO request has already been initiated and fsync() must wait for the existing request, I see no mechanism to adjust the request.




              Re: trying to understand READ_META, READ_SYNC, WRITE_SYNC & co (2010)





              But that leaves the question why disabling the idling logical for
              data integrity ->writepage is fine? This gets called from ->fsync
              or O_SYNC writes and will have the same impact as O_DIRECT writes.




              We have never enabled idling for those. O_SYNC should get a nice
              boost too, it just needs to be benchmarked and tested and then
              there would be no reason not to add it.




              We've only started using any kind of sync tag last year in ->writepage
              in commit a64c8610bd3b
              "block_write_full_page: Use synchronous writes for WBC_SYNC_ALL
              writebacks"




              "disabling idling" is a different hint flag, which is a bit harder to explain. But the commit linked in the above quote confirms the use of the WRITE_SYNC hint for fsync().



              The code quoted above has since been moved or replaced, but the use of the "sync" hint should still be the same in 2018 as it was in 2016.



              So I don't believe it really matters whether the requests are made using Linux AIO or not.



              (I notice AIO is only supported for O_DIRECT, therefore all AIO should be "synchronous" from the IO scheduler's point of view :-). At least as of v4.20. The proposed new AIO interface supports buffered (non-O_DIRECT) IO. That will go through the same code above, so then the hint will still be set according to whether O_SYNC is used).






              share|improve this answer




























                1












                1








                1







                The form of requests processed by the Linux IO schedulers, have various "hints" set on them. One of them is the "sync" hint.




                All IO is handled async in Linux. This is fine for background
                writes, but for reads or writes that someone waits for completion
                on, we want to notify the block layer and IO scheduler so that they
                know about it. That allows them to make better scheduling
                decisions. So when the below references 'sync' and 'async', it
                is referencing this priority hint.



                -- include/linux/fs.h (2016-11-01)




                Read requests are always treated as synchronous.




                block: don't use REQ_SYNC in the READ_SYNC definition (2016-11-01)



                Reads are synchronous per definition, don't add another flag for it.




                Both O_DIRECT and O_SYNC writes are treated as synchronous.



                #define READ_SYNC       0
                #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
                #define WRITE_ODIRECT REQ_SYNC


                IO requests initiated by fsync() use the same hint as O_SYNC writes. Although if the IO request has already been initiated and fsync() must wait for the existing request, I see no mechanism to adjust the request.




                Re: trying to understand READ_META, READ_SYNC, WRITE_SYNC & co (2010)





                But that leaves the question why disabling the idling logical for
                data integrity ->writepage is fine? This gets called from ->fsync
                or O_SYNC writes and will have the same impact as O_DIRECT writes.




                We have never enabled idling for those. O_SYNC should get a nice
                boost too, it just needs to be benchmarked and tested and then
                there would be no reason not to add it.




                We've only started using any kind of sync tag last year in ->writepage
                in commit a64c8610bd3b
                "block_write_full_page: Use synchronous writes for WBC_SYNC_ALL
                writebacks"




                "disabling idling" is a different hint flag, which is a bit harder to explain. But the commit linked in the above quote confirms the use of the WRITE_SYNC hint for fsync().



                The code quoted above has since been moved or replaced, but the use of the "sync" hint should still be the same in 2018 as it was in 2016.



                So I don't believe it really matters whether the requests are made using Linux AIO or not.



                (I notice AIO is only supported for O_DIRECT, therefore all AIO should be "synchronous" from the IO scheduler's point of view :-). At least as of v4.20. The proposed new AIO interface supports buffered (non-O_DIRECT) IO. That will go through the same code above, so then the hint will still be set according to whether O_SYNC is used).






                share|improve this answer















                The form of requests processed by the Linux IO schedulers, have various "hints" set on them. One of them is the "sync" hint.




                All IO is handled async in Linux. This is fine for background
                writes, but for reads or writes that someone waits for completion
                on, we want to notify the block layer and IO scheduler so that they
                know about it. That allows them to make better scheduling
                decisions. So when the below references 'sync' and 'async', it
                is referencing this priority hint.



                -- include/linux/fs.h (2016-11-01)




                Read requests are always treated as synchronous.




                block: don't use REQ_SYNC in the READ_SYNC definition (2016-11-01)



                Reads are synchronous per definition, don't add another flag for it.




                Both O_DIRECT and O_SYNC writes are treated as synchronous.



                #define READ_SYNC       0
                #define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
                #define WRITE_ODIRECT REQ_SYNC


                IO requests initiated by fsync() use the same hint as O_SYNC writes. Although if the IO request has already been initiated and fsync() must wait for the existing request, I see no mechanism to adjust the request.




                Re: trying to understand READ_META, READ_SYNC, WRITE_SYNC & co (2010)





                But that leaves the question why disabling the idling logical for
                data integrity ->writepage is fine? This gets called from ->fsync
                or O_SYNC writes and will have the same impact as O_DIRECT writes.




                We have never enabled idling for those. O_SYNC should get a nice
                boost too, it just needs to be benchmarked and tested and then
                there would be no reason not to add it.




                We've only started using any kind of sync tag last year in ->writepage
                in commit a64c8610bd3b
                "block_write_full_page: Use synchronous writes for WBC_SYNC_ALL
                writebacks"




                "disabling idling" is a different hint flag, which is a bit harder to explain. But the commit linked in the above quote confirms the use of the WRITE_SYNC hint for fsync().



                The code quoted above has since been moved or replaced, but the use of the "sync" hint should still be the same in 2018 as it was in 2016.



                So I don't believe it really matters whether the requests are made using Linux AIO or not.



                (I notice AIO is only supported for O_DIRECT, therefore all AIO should be "synchronous" from the IO scheduler's point of view :-). At least as of v4.20. The proposed new AIO interface supports buffered (non-O_DIRECT) IO. That will go through the same code above, so then the hint will still be set according to whether O_SYNC is used).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 26 at 16:01

























                answered Jan 26 at 14:38









                sourcejedisourcejedi

                24k439106




                24k439106






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496855%2fhow-should-we-interpret-the-phrase-asynchronous-requests-in-cfq-iosched-txt%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    19世紀