CPU reservation and affinity using taskset and isolcpus kernel parameter with JVM?












1















We need for the JVM to reserve a set number of CPUs. Following my research we can use taskset along with the kernel parameter isolcpus=<CPU_ID> so that no other process uses this CPU.



A few questions arise:




  • does the process need to be started with taskset?

  • does the reservation means that the process can only run on that CPU and if there are resources problems it can expand to the other CPUs?










share|improve this question
















bumped to the homepage by Community 15 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1















    We need for the JVM to reserve a set number of CPUs. Following my research we can use taskset along with the kernel parameter isolcpus=<CPU_ID> so that no other process uses this CPU.



    A few questions arise:




    • does the process need to be started with taskset?

    • does the reservation means that the process can only run on that CPU and if there are resources problems it can expand to the other CPUs?










    share|improve this question
















    bumped to the homepage by Community 15 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1








      We need for the JVM to reserve a set number of CPUs. Following my research we can use taskset along with the kernel parameter isolcpus=<CPU_ID> so that no other process uses this CPU.



      A few questions arise:




      • does the process need to be started with taskset?

      • does the reservation means that the process can only run on that CPU and if there are resources problems it can expand to the other CPUs?










      share|improve this question
















      We need for the JVM to reserve a set number of CPUs. Following my research we can use taskset along with the kernel parameter isolcpus=<CPU_ID> so that no other process uses this CPU.



      A few questions arise:




      • does the process need to be started with taskset?

      • does the reservation means that the process can only run on that CPU and if there are resources problems it can expand to the other CPUs?







      cpu-usage taskset






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 25 '18 at 14:58









      Stephen Harris

      26.5k34980




      26.5k34980










      asked Jul 26 '18 at 15:52









      danidardanidar

      2113




      2113





      bumped to the homepage by Community 15 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 15 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You typically use taskset to restrict a process after it's been started. You could make use of the pidof java to determine what the PID is for your Java application and then pass that to taskset:



          $ taskset -p $(pidof java) --cpu-list 0-2,5


          NOTE: If you had 6 CPUs, 0,1,2,5 would assign an affinity to these CPUs for your JVM's PID.



          Keep in mind that affinity does not restrict other processes from using these CPUs, taskset if more a tool of restricting a specific process or processes to a specific set of CPUs, not in restricting exclusivity.



          excerpt taskset man page


          taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process
          to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU
          affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications.




          Alternatives



          This self answered U&L Q&A titled: How to use cgroups to limit all processes except whitelist to a single CPU? covers the topic of how to accomplish this using cgroups.



          References




          • Determining the particular processor on which a process is running






          share|improve this answer


























          • Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

            – danidar
            Jul 27 '18 at 8:49











          • It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

            – slm
            Jul 27 '18 at 8:54













          • I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

            – danidar
            Jul 27 '18 at 9:58













          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%2f458640%2fcpu-reservation-and-affinity-using-taskset-and-isolcpus-kernel-parameter-with-jv%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









          0














          You typically use taskset to restrict a process after it's been started. You could make use of the pidof java to determine what the PID is for your Java application and then pass that to taskset:



          $ taskset -p $(pidof java) --cpu-list 0-2,5


          NOTE: If you had 6 CPUs, 0,1,2,5 would assign an affinity to these CPUs for your JVM's PID.



          Keep in mind that affinity does not restrict other processes from using these CPUs, taskset if more a tool of restricting a specific process or processes to a specific set of CPUs, not in restricting exclusivity.



          excerpt taskset man page


          taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process
          to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU
          affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications.




          Alternatives



          This self answered U&L Q&A titled: How to use cgroups to limit all processes except whitelist to a single CPU? covers the topic of how to accomplish this using cgroups.



          References




          • Determining the particular processor on which a process is running






          share|improve this answer


























          • Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

            – danidar
            Jul 27 '18 at 8:49











          • It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

            – slm
            Jul 27 '18 at 8:54













          • I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

            – danidar
            Jul 27 '18 at 9:58


















          0














          You typically use taskset to restrict a process after it's been started. You could make use of the pidof java to determine what the PID is for your Java application and then pass that to taskset:



          $ taskset -p $(pidof java) --cpu-list 0-2,5


          NOTE: If you had 6 CPUs, 0,1,2,5 would assign an affinity to these CPUs for your JVM's PID.



          Keep in mind that affinity does not restrict other processes from using these CPUs, taskset if more a tool of restricting a specific process or processes to a specific set of CPUs, not in restricting exclusivity.



          excerpt taskset man page


          taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process
          to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU
          affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications.




          Alternatives



          This self answered U&L Q&A titled: How to use cgroups to limit all processes except whitelist to a single CPU? covers the topic of how to accomplish this using cgroups.



          References




          • Determining the particular processor on which a process is running






          share|improve this answer


























          • Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

            – danidar
            Jul 27 '18 at 8:49











          • It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

            – slm
            Jul 27 '18 at 8:54













          • I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

            – danidar
            Jul 27 '18 at 9:58
















          0












          0








          0







          You typically use taskset to restrict a process after it's been started. You could make use of the pidof java to determine what the PID is for your Java application and then pass that to taskset:



          $ taskset -p $(pidof java) --cpu-list 0-2,5


          NOTE: If you had 6 CPUs, 0,1,2,5 would assign an affinity to these CPUs for your JVM's PID.



          Keep in mind that affinity does not restrict other processes from using these CPUs, taskset if more a tool of restricting a specific process or processes to a specific set of CPUs, not in restricting exclusivity.



          excerpt taskset man page


          taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process
          to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU
          affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications.




          Alternatives



          This self answered U&L Q&A titled: How to use cgroups to limit all processes except whitelist to a single CPU? covers the topic of how to accomplish this using cgroups.



          References




          • Determining the particular processor on which a process is running






          share|improve this answer















          You typically use taskset to restrict a process after it's been started. You could make use of the pidof java to determine what the PID is for your Java application and then pass that to taskset:



          $ taskset -p $(pidof java) --cpu-list 0-2,5


          NOTE: If you had 6 CPUs, 0,1,2,5 would assign an affinity to these CPUs for your JVM's PID.



          Keep in mind that affinity does not restrict other processes from using these CPUs, taskset if more a tool of restricting a specific process or processes to a specific set of CPUs, not in restricting exclusivity.



          excerpt taskset man page


          taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. CPU affinity is a scheduler property that "bonds" a process
          to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU
          affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications.




          Alternatives



          This self answered U&L Q&A titled: How to use cgroups to limit all processes except whitelist to a single CPU? covers the topic of how to accomplish this using cgroups.



          References




          • Determining the particular processor on which a process is running







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 27 '18 at 8:56

























          answered Jul 27 '18 at 2:32









          slmslm

          254k71537687




          254k71537687













          • Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

            – danidar
            Jul 27 '18 at 8:49











          • It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

            – slm
            Jul 27 '18 at 8:54













          • I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

            – danidar
            Jul 27 '18 at 9:58





















          • Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

            – danidar
            Jul 27 '18 at 8:49











          • It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

            – slm
            Jul 27 '18 at 8:54













          • I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

            – danidar
            Jul 27 '18 at 9:58



















          Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

          – danidar
          Jul 27 '18 at 8:49





          Is it therefore not possible to reserve cpu exclusivly to some applications and nothing else uses these cpu?

          – danidar
          Jul 27 '18 at 8:49













          It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

          – slm
          Jul 27 '18 at 8:54







          It's possible using cgroups - unix.stackexchange.com/questions/247209/…. But not in the way you imagine.

          – slm
          Jul 27 '18 at 8:54















          I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

          – danidar
          Jul 27 '18 at 9:58







          I read on xmodulo that the kernel parameter "isolcpus=<CPU_ID>" to the boot loader during boot or GRUB configuration file. Then the Linux scheduler will not schedule any regular process on the reserved CPU core(s), unless specifically requested with taskset. For example, to reserve CPU cores 0 and 1, add "isolcpus=0,1" kernel parameter. Upon boot, then use taskset to safely assign the reserved CPU cores to your program.

          – danidar
          Jul 27 '18 at 9:58




















          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%2f458640%2fcpu-reservation-and-affinity-using-taskset-and-isolcpus-kernel-parameter-with-jv%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 rewrite equation of hyperbola in standard form

          No ethernet ip address in my vocore2