Kernel module shows me 8 processors instead of 4 for Intel i5-2500K

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












My question mostly about hardware, specifically the Intel i5-2500K CPU which Intel describes as having




# of Cores 4

# of Threads 4




Linux shows me 4 processors:



$ cat /proc/cpuinfo | grep ^processor
processor : 0
processor : 1
processor : 2
processor : 3


Nevertheless, I've written a little kernel module that shows me 8 processors:



$ cat show_cpus_mod.c 
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/version.h>

#define CLASS_NAME "show_cpus_mod"

#define dbg( format, arg... ) do if ( debug ) pr_info( CLASS_NAME ": %s: " format , __FUNCTION__ , ## arg ); while ( 0 )
#define err( format, arg... ) pr_err( CLASS_NAME ": " format, ## arg )
#define info( format, arg... ) pr_info( CLASS_NAME ": " format, ## arg )
#define warn( format, arg... ) pr_warn( CLASS_NAME ": " format, ## arg )

MODULE_DESCRIPTION( "shows all cpus" );
MODULE_VERSION( "0.1" );
MODULE_LICENSE( "GPL" );
MODULE_AUTHOR( "author <e@mail.mail>" );

static int show_cpus_mod_init( void )
int cpu;
info( "Start loading module show_cpus_mod.n" );
for_each_possible_cpu( cpu )
info( "cpu = %dn", cpu );

return 0;


static void show_cpus_mod_exit( void )
info( "Module show_cpus_mod unloadedn" );


module_init( show_cpus_mod_init );
module_exit( show_cpus_mod_exit );


Building:



$ cat Makefile 
CURRENT = $(shell uname -r)
KDIR = /lib/modules/$(CURRENT)/build
PWD = $(shell pwd)
TARGET = show_cpus_mod
obj-m := $(TARGET).o

default:
$(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
@rm -f *.o .*.cmd .*.flags *.mod.c *.order
@rm -f .*.*.cmd *.symvers *~ *.*~ TODO.*
@rm -fR .tmp*
@rm -rf .tmp_versions


Inserting:



# make
# cp show_cpus_mod.ko /lib/modules/4.14.0-kali3-amd64/
# depmod
# modprobe show_cpus_mod


syslog:



localhost kernel: [67596.578805] show_cpus_mod: Start loading module show_cpus_mod.
localhost kernel: [67596.578808] show_cpus_mod: cpu = 0
localhost kernel: [67596.578809] show_cpus_mod: cpu = 1
localhost kernel: [67596.578810] show_cpus_mod: cpu = 2
localhost kernel: [67596.578811] show_cpus_mod: cpu = 3
localhost kernel: [67596.578811] show_cpus_mod: cpu = 4
localhost kernel: [67596.578812] show_cpus_mod: cpu = 5
localhost kernel: [67596.578812] show_cpus_mod: cpu = 6
localhost kernel: [67596.578813] show_cpus_mod: cpu = 7
localhost kernel: [67607.725738] show_cpus_mod: Module show_cpus_mod unloaded


What am I missing in Intel's description? Why 8? Or what is wrong with my kernel module?










share|improve this question









New contributor




wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    1
    down vote

    favorite












    My question mostly about hardware, specifically the Intel i5-2500K CPU which Intel describes as having




    # of Cores 4

    # of Threads 4




    Linux shows me 4 processors:



    $ cat /proc/cpuinfo | grep ^processor
    processor : 0
    processor : 1
    processor : 2
    processor : 3


    Nevertheless, I've written a little kernel module that shows me 8 processors:



    $ cat show_cpus_mod.c 
    #include <linux/module.h>
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/version.h>

    #define CLASS_NAME "show_cpus_mod"

    #define dbg( format, arg... ) do if ( debug ) pr_info( CLASS_NAME ": %s: " format , __FUNCTION__ , ## arg ); while ( 0 )
    #define err( format, arg... ) pr_err( CLASS_NAME ": " format, ## arg )
    #define info( format, arg... ) pr_info( CLASS_NAME ": " format, ## arg )
    #define warn( format, arg... ) pr_warn( CLASS_NAME ": " format, ## arg )

    MODULE_DESCRIPTION( "shows all cpus" );
    MODULE_VERSION( "0.1" );
    MODULE_LICENSE( "GPL" );
    MODULE_AUTHOR( "author <e@mail.mail>" );

    static int show_cpus_mod_init( void )
    int cpu;
    info( "Start loading module show_cpus_mod.n" );
    for_each_possible_cpu( cpu )
    info( "cpu = %dn", cpu );

    return 0;


    static void show_cpus_mod_exit( void )
    info( "Module show_cpus_mod unloadedn" );


    module_init( show_cpus_mod_init );
    module_exit( show_cpus_mod_exit );


    Building:



    $ cat Makefile 
    CURRENT = $(shell uname -r)
    KDIR = /lib/modules/$(CURRENT)/build
    PWD = $(shell pwd)
    TARGET = show_cpus_mod
    obj-m := $(TARGET).o

    default:
    $(MAKE) -C $(KDIR) M=$(PWD) modules

    clean:
    @rm -f *.o .*.cmd .*.flags *.mod.c *.order
    @rm -f .*.*.cmd *.symvers *~ *.*~ TODO.*
    @rm -fR .tmp*
    @rm -rf .tmp_versions


    Inserting:



    # make
    # cp show_cpus_mod.ko /lib/modules/4.14.0-kali3-amd64/
    # depmod
    # modprobe show_cpus_mod


    syslog:



    localhost kernel: [67596.578805] show_cpus_mod: Start loading module show_cpus_mod.
    localhost kernel: [67596.578808] show_cpus_mod: cpu = 0
    localhost kernel: [67596.578809] show_cpus_mod: cpu = 1
    localhost kernel: [67596.578810] show_cpus_mod: cpu = 2
    localhost kernel: [67596.578811] show_cpus_mod: cpu = 3
    localhost kernel: [67596.578811] show_cpus_mod: cpu = 4
    localhost kernel: [67596.578812] show_cpus_mod: cpu = 5
    localhost kernel: [67596.578812] show_cpus_mod: cpu = 6
    localhost kernel: [67596.578813] show_cpus_mod: cpu = 7
    localhost kernel: [67607.725738] show_cpus_mod: Module show_cpus_mod unloaded


    What am I missing in Intel's description? Why 8? Or what is wrong with my kernel module?










    share|improve this question









    New contributor




    wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      My question mostly about hardware, specifically the Intel i5-2500K CPU which Intel describes as having




      # of Cores 4

      # of Threads 4




      Linux shows me 4 processors:



      $ cat /proc/cpuinfo | grep ^processor
      processor : 0
      processor : 1
      processor : 2
      processor : 3


      Nevertheless, I've written a little kernel module that shows me 8 processors:



      $ cat show_cpus_mod.c 
      #include <linux/module.h>
      #include <linux/kernel.h>
      #include <linux/init.h>
      #include <linux/version.h>

      #define CLASS_NAME "show_cpus_mod"

      #define dbg( format, arg... ) do if ( debug ) pr_info( CLASS_NAME ": %s: " format , __FUNCTION__ , ## arg ); while ( 0 )
      #define err( format, arg... ) pr_err( CLASS_NAME ": " format, ## arg )
      #define info( format, arg... ) pr_info( CLASS_NAME ": " format, ## arg )
      #define warn( format, arg... ) pr_warn( CLASS_NAME ": " format, ## arg )

      MODULE_DESCRIPTION( "shows all cpus" );
      MODULE_VERSION( "0.1" );
      MODULE_LICENSE( "GPL" );
      MODULE_AUTHOR( "author <e@mail.mail>" );

      static int show_cpus_mod_init( void )
      int cpu;
      info( "Start loading module show_cpus_mod.n" );
      for_each_possible_cpu( cpu )
      info( "cpu = %dn", cpu );

      return 0;


      static void show_cpus_mod_exit( void )
      info( "Module show_cpus_mod unloadedn" );


      module_init( show_cpus_mod_init );
      module_exit( show_cpus_mod_exit );


      Building:



      $ cat Makefile 
      CURRENT = $(shell uname -r)
      KDIR = /lib/modules/$(CURRENT)/build
      PWD = $(shell pwd)
      TARGET = show_cpus_mod
      obj-m := $(TARGET).o

      default:
      $(MAKE) -C $(KDIR) M=$(PWD) modules

      clean:
      @rm -f *.o .*.cmd .*.flags *.mod.c *.order
      @rm -f .*.*.cmd *.symvers *~ *.*~ TODO.*
      @rm -fR .tmp*
      @rm -rf .tmp_versions


      Inserting:



      # make
      # cp show_cpus_mod.ko /lib/modules/4.14.0-kali3-amd64/
      # depmod
      # modprobe show_cpus_mod


      syslog:



      localhost kernel: [67596.578805] show_cpus_mod: Start loading module show_cpus_mod.
      localhost kernel: [67596.578808] show_cpus_mod: cpu = 0
      localhost kernel: [67596.578809] show_cpus_mod: cpu = 1
      localhost kernel: [67596.578810] show_cpus_mod: cpu = 2
      localhost kernel: [67596.578811] show_cpus_mod: cpu = 3
      localhost kernel: [67596.578811] show_cpus_mod: cpu = 4
      localhost kernel: [67596.578812] show_cpus_mod: cpu = 5
      localhost kernel: [67596.578812] show_cpus_mod: cpu = 6
      localhost kernel: [67596.578813] show_cpus_mod: cpu = 7
      localhost kernel: [67607.725738] show_cpus_mod: Module show_cpus_mod unloaded


      What am I missing in Intel's description? Why 8? Or what is wrong with my kernel module?










      share|improve this question









      New contributor




      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      My question mostly about hardware, specifically the Intel i5-2500K CPU which Intel describes as having




      # of Cores 4

      # of Threads 4




      Linux shows me 4 processors:



      $ cat /proc/cpuinfo | grep ^processor
      processor : 0
      processor : 1
      processor : 2
      processor : 3


      Nevertheless, I've written a little kernel module that shows me 8 processors:



      $ cat show_cpus_mod.c 
      #include <linux/module.h>
      #include <linux/kernel.h>
      #include <linux/init.h>
      #include <linux/version.h>

      #define CLASS_NAME "show_cpus_mod"

      #define dbg( format, arg... ) do if ( debug ) pr_info( CLASS_NAME ": %s: " format , __FUNCTION__ , ## arg ); while ( 0 )
      #define err( format, arg... ) pr_err( CLASS_NAME ": " format, ## arg )
      #define info( format, arg... ) pr_info( CLASS_NAME ": " format, ## arg )
      #define warn( format, arg... ) pr_warn( CLASS_NAME ": " format, ## arg )

      MODULE_DESCRIPTION( "shows all cpus" );
      MODULE_VERSION( "0.1" );
      MODULE_LICENSE( "GPL" );
      MODULE_AUTHOR( "author <e@mail.mail>" );

      static int show_cpus_mod_init( void )
      int cpu;
      info( "Start loading module show_cpus_mod.n" );
      for_each_possible_cpu( cpu )
      info( "cpu = %dn", cpu );

      return 0;


      static void show_cpus_mod_exit( void )
      info( "Module show_cpus_mod unloadedn" );


      module_init( show_cpus_mod_init );
      module_exit( show_cpus_mod_exit );


      Building:



      $ cat Makefile 
      CURRENT = $(shell uname -r)
      KDIR = /lib/modules/$(CURRENT)/build
      PWD = $(shell pwd)
      TARGET = show_cpus_mod
      obj-m := $(TARGET).o

      default:
      $(MAKE) -C $(KDIR) M=$(PWD) modules

      clean:
      @rm -f *.o .*.cmd .*.flags *.mod.c *.order
      @rm -f .*.*.cmd *.symvers *~ *.*~ TODO.*
      @rm -fR .tmp*
      @rm -rf .tmp_versions


      Inserting:



      # make
      # cp show_cpus_mod.ko /lib/modules/4.14.0-kali3-amd64/
      # depmod
      # modprobe show_cpus_mod


      syslog:



      localhost kernel: [67596.578805] show_cpus_mod: Start loading module show_cpus_mod.
      localhost kernel: [67596.578808] show_cpus_mod: cpu = 0
      localhost kernel: [67596.578809] show_cpus_mod: cpu = 1
      localhost kernel: [67596.578810] show_cpus_mod: cpu = 2
      localhost kernel: [67596.578811] show_cpus_mod: cpu = 3
      localhost kernel: [67596.578811] show_cpus_mod: cpu = 4
      localhost kernel: [67596.578812] show_cpus_mod: cpu = 5
      localhost kernel: [67596.578812] show_cpus_mod: cpu = 6
      localhost kernel: [67596.578813] show_cpus_mod: cpu = 7
      localhost kernel: [67607.725738] show_cpus_mod: Module show_cpus_mod unloaded


      What am I missing in Intel's description? Why 8? Or what is wrong with my kernel module?







      linux-kernel kernel-modules cpu hardware






      share|improve this question









      New contributor




      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited Oct 1 at 8:16









      Stephen Kitt

      149k23329396




      149k23329396






      New contributor




      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Oct 1 at 8:08









      wc1eBdb56TamM

      82




      82




      New contributor




      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      wc1eBdb56TamM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          You should use for_each_online_cpu or for_each_present_cpu instead of for_each_possible_cpu. That will limit the output to CPUs which are really online or present, respectively.






          share|improve this answer




















          • yeah, thanx. possible is something wrong...
            – wc1eBdb56TamM
            Oct 1 at 8:20











          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          wc1eBdb56TamM is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472525%2fkernel-module-shows-me-8-processors-instead-of-4-for-intel-i5-2500k%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          You should use for_each_online_cpu or for_each_present_cpu instead of for_each_possible_cpu. That will limit the output to CPUs which are really online or present, respectively.






          share|improve this answer




















          • yeah, thanx. possible is something wrong...
            – wc1eBdb56TamM
            Oct 1 at 8:20















          up vote
          3
          down vote



          accepted










          You should use for_each_online_cpu or for_each_present_cpu instead of for_each_possible_cpu. That will limit the output to CPUs which are really online or present, respectively.






          share|improve this answer




















          • yeah, thanx. possible is something wrong...
            – wc1eBdb56TamM
            Oct 1 at 8:20













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          You should use for_each_online_cpu or for_each_present_cpu instead of for_each_possible_cpu. That will limit the output to CPUs which are really online or present, respectively.






          share|improve this answer












          You should use for_each_online_cpu or for_each_present_cpu instead of for_each_possible_cpu. That will limit the output to CPUs which are really online or present, respectively.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 1 at 8:15









          Stephen Kitt

          149k23329396




          149k23329396











          • yeah, thanx. possible is something wrong...
            – wc1eBdb56TamM
            Oct 1 at 8:20

















          • yeah, thanx. possible is something wrong...
            – wc1eBdb56TamM
            Oct 1 at 8:20
















          yeah, thanx. possible is something wrong...
          – wc1eBdb56TamM
          Oct 1 at 8:20





          yeah, thanx. possible is something wrong...
          – wc1eBdb56TamM
          Oct 1 at 8:20











          wc1eBdb56TamM is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          wc1eBdb56TamM is a new contributor. Be nice, and check out our Code of Conduct.












          wc1eBdb56TamM is a new contributor. Be nice, and check out our Code of Conduct.











          wc1eBdb56TamM is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472525%2fkernel-module-shows-me-8-processors-instead-of-4-for-intel-i5-2500k%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?