Why is kswapd0 running on a computer with no swap?












15















I have a cloud server with ~14G of RAM and no swap. However, I occasionally see kswapd0 taking up some CPU when I run top. Why would kswapd0 be running at all if there's no swap space for it to manage?










share|improve this question



























    15















    I have a cloud server with ~14G of RAM and no swap. However, I occasionally see kswapd0 taking up some CPU when I run top. Why would kswapd0 be running at all if there's no swap space for it to manage?










    share|improve this question

























      15












      15








      15


      1






      I have a cloud server with ~14G of RAM and no swap. However, I occasionally see kswapd0 taking up some CPU when I run top. Why would kswapd0 be running at all if there's no swap space for it to manage?










      share|improve this question














      I have a cloud server with ~14G of RAM and no swap. However, I occasionally see kswapd0 taking up some CPU when I run top. Why would kswapd0 be running at all if there's no swap space for it to manage?







      swap






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 11 '14 at 16:33









      Thomas JohnsonThomas Johnson

      226149




      226149






















          3 Answers
          3






          active

          oldest

          votes


















          6














          It still has a process to check if there's any swap. To reduce it, you'll need to set your swappiness -



          edit "/etc/sysctl.conf" as root, then change (or add)



          vm.swappiness = 0





          share|improve this answer



















          • 3





            Ok, but why is it using 1% of my cpu?

            – portforwardpodcast
            Jun 10 '15 at 23:00











          • if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

            – Mikko Rantalainen
            Feb 15 '18 at 13:12











          • If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

            – Mikko Rantalainen
            Feb 15 '18 at 13:15



















          17














          Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk ( such as executable programs ) is still swapped to their respective files even if you don't have a swap device.






          share|improve this answer



















          • 3





            For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

            – Mikko Rantalainen
            Feb 15 '18 at 13:08



















          0














          If you have no swap and kswapd0 is running, your system is actually using nearly all of the RAM at that moment. It's time to get better tools to monitor memory usage (or free/available memory in the system).



          The real fix is to reduce memory usage (run processes with less memory leaks, run less processes, skip running some processes at all, limit number of children/worker processes of some server software) or to get more RAM. If the need for RAM is caused by memory leaks, you may opt to use swap instead. Linux should be pretty smart getting the leaked parts to swap given enough time. Having swap is better than nothing but that is not a real substitute for having adequate amount of RAM.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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%2faskubuntu.com%2fquestions%2f432809%2fwhy-is-kswapd0-running-on-a-computer-with-no-swap%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            6














            It still has a process to check if there's any swap. To reduce it, you'll need to set your swappiness -



            edit "/etc/sysctl.conf" as root, then change (or add)



            vm.swappiness = 0





            share|improve this answer



















            • 3





              Ok, but why is it using 1% of my cpu?

              – portforwardpodcast
              Jun 10 '15 at 23:00











            • if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

              – Mikko Rantalainen
              Feb 15 '18 at 13:12











            • If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

              – Mikko Rantalainen
              Feb 15 '18 at 13:15
















            6














            It still has a process to check if there's any swap. To reduce it, you'll need to set your swappiness -



            edit "/etc/sysctl.conf" as root, then change (or add)



            vm.swappiness = 0





            share|improve this answer



















            • 3





              Ok, but why is it using 1% of my cpu?

              – portforwardpodcast
              Jun 10 '15 at 23:00











            • if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

              – Mikko Rantalainen
              Feb 15 '18 at 13:12











            • If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

              – Mikko Rantalainen
              Feb 15 '18 at 13:15














            6












            6








            6







            It still has a process to check if there's any swap. To reduce it, you'll need to set your swappiness -



            edit "/etc/sysctl.conf" as root, then change (or add)



            vm.swappiness = 0





            share|improve this answer













            It still has a process to check if there's any swap. To reduce it, you'll need to set your swappiness -



            edit "/etc/sysctl.conf" as root, then change (or add)



            vm.swappiness = 0






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 11 '14 at 16:44









            Elliott FrischElliott Frisch

            2,17311117




            2,17311117








            • 3





              Ok, but why is it using 1% of my cpu?

              – portforwardpodcast
              Jun 10 '15 at 23:00











            • if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

              – Mikko Rantalainen
              Feb 15 '18 at 13:12











            • If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

              – Mikko Rantalainen
              Feb 15 '18 at 13:15














            • 3





              Ok, but why is it using 1% of my cpu?

              – portforwardpodcast
              Jun 10 '15 at 23:00











            • if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

              – Mikko Rantalainen
              Feb 15 '18 at 13:12











            • If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

              – Mikko Rantalainen
              Feb 15 '18 at 13:15








            3




            3





            Ok, but why is it using 1% of my cpu?

            – portforwardpodcast
            Jun 10 '15 at 23:00





            Ok, but why is it using 1% of my cpu?

            – portforwardpodcast
            Jun 10 '15 at 23:00













            if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

            – Mikko Rantalainen
            Feb 15 '18 at 13:12





            if kswapd0 is taking any CPU and you do not have swap, the system is nearly out of RAM and is trying to deal with the situation by (in practise) swapping pages from executables. The correct fix is to reduce workload, add swap or (preferably) install more RAM. Adding swap will improve performance because kernel will have more options about what to swap to disk. Without swap the kernel is practically forced to swap application code.

            – Mikko Rantalainen
            Feb 15 '18 at 13:12













            If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

            – Mikko Rantalainen
            Feb 15 '18 at 13:15





            If you have swap enabled and kswapd0 is using some CPU and you do not want that, lower the swappiness setting. However, unless your swap is backed by SSD that suffers from writing (e.g. bad wear leveling algorithm), lowering the swappiness reduces the system overall performance. The idea is to keep a copy of RAM in the swap in case more RAM is needed - in that case the copy in RAM is thrown away immediately instead of starting to swap that out before the RAM can be used. This optimistic swapping is only done while system is idle enough so it should never slow down your system.

            – Mikko Rantalainen
            Feb 15 '18 at 13:15













            17














            Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk ( such as executable programs ) is still swapped to their respective files even if you don't have a swap device.






            share|improve this answer



















            • 3





              For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

              – Mikko Rantalainen
              Feb 15 '18 at 13:08
















            17














            Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk ( such as executable programs ) is still swapped to their respective files even if you don't have a swap device.






            share|improve this answer



















            • 3





              For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

              – Mikko Rantalainen
              Feb 15 '18 at 13:08














            17












            17








            17







            Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk ( such as executable programs ) is still swapped to their respective files even if you don't have a swap device.






            share|improve this answer













            Swap space is only used for data that is not backed by any other file. Data that is mapped from other files on disk ( such as executable programs ) is still swapped to their respective files even if you don't have a swap device.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 11 '14 at 17:15









            psusipsusi

            31.2k15088




            31.2k15088








            • 3





              For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

              – Mikko Rantalainen
              Feb 15 '18 at 13:08














            • 3





              For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

              – Mikko Rantalainen
              Feb 15 '18 at 13:08








            3




            3





            For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

            – Mikko Rantalainen
            Feb 15 '18 at 13:08





            For example, consider a case where you have zero swap and system is nearly running out of RAM. The kernel will take memory from e.g. Firefox (it can do this because Firefox is running executable code that has been loaded from disk - the code can be loaded from disk again if needed). If Firefox then needs to access that RAM again N seconds later, the CPU generates "hard fault" which forces Linux to free some RAM (e.g. take some RAM from another process), load the missing data from disk and then allow Firefox to continue as usual. This is pretty similar to normal swapping and kswapd0 does it.

            – Mikko Rantalainen
            Feb 15 '18 at 13:08











            0














            If you have no swap and kswapd0 is running, your system is actually using nearly all of the RAM at that moment. It's time to get better tools to monitor memory usage (or free/available memory in the system).



            The real fix is to reduce memory usage (run processes with less memory leaks, run less processes, skip running some processes at all, limit number of children/worker processes of some server software) or to get more RAM. If the need for RAM is caused by memory leaks, you may opt to use swap instead. Linux should be pretty smart getting the leaked parts to swap given enough time. Having swap is better than nothing but that is not a real substitute for having adequate amount of RAM.






            share|improve this answer




























              0














              If you have no swap and kswapd0 is running, your system is actually using nearly all of the RAM at that moment. It's time to get better tools to monitor memory usage (or free/available memory in the system).



              The real fix is to reduce memory usage (run processes with less memory leaks, run less processes, skip running some processes at all, limit number of children/worker processes of some server software) or to get more RAM. If the need for RAM is caused by memory leaks, you may opt to use swap instead. Linux should be pretty smart getting the leaked parts to swap given enough time. Having swap is better than nothing but that is not a real substitute for having adequate amount of RAM.






              share|improve this answer


























                0












                0








                0







                If you have no swap and kswapd0 is running, your system is actually using nearly all of the RAM at that moment. It's time to get better tools to monitor memory usage (or free/available memory in the system).



                The real fix is to reduce memory usage (run processes with less memory leaks, run less processes, skip running some processes at all, limit number of children/worker processes of some server software) or to get more RAM. If the need for RAM is caused by memory leaks, you may opt to use swap instead. Linux should be pretty smart getting the leaked parts to swap given enough time. Having swap is better than nothing but that is not a real substitute for having adequate amount of RAM.






                share|improve this answer













                If you have no swap and kswapd0 is running, your system is actually using nearly all of the RAM at that moment. It's time to get better tools to monitor memory usage (or free/available memory in the system).



                The real fix is to reduce memory usage (run processes with less memory leaks, run less processes, skip running some processes at all, limit number of children/worker processes of some server software) or to get more RAM. If the need for RAM is caused by memory leaks, you may opt to use swap instead. Linux should be pretty smart getting the leaked parts to swap given enough time. Having swap is better than nothing but that is not a real substitute for having adequate amount of RAM.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 8 at 13:14









                Mikko RantalainenMikko Rantalainen

                574515




                574515






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • 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%2faskubuntu.com%2fquestions%2f432809%2fwhy-is-kswapd0-running-on-a-computer-with-no-swap%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 change which sound is reproduced for terminal bell?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?