LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2009, 07:54 PM   #1
mohammednv
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Rep: Reputation: 18
check if the processor is 32/64bit?


Hi,

I have a question on finding the processor type. This topic seems to have discussed before, but I can't find the perfect answer.

My Questions are:
1) how can I find if the processor is 32bit or 64bit?
2) is there a way to find if mother board support 64bit?

What I know or heard about are:
1) uname can be used to find if the OS is 32bit or 64bit.
2) some articles tell that "lm" flag is set in /proc/cpuinfo means, you are on a 64bit processor
3) A few articles tell that "getconf LONG_BIT" will return 64 if your processor is 64bit. The return value 32 means, you have a 32bit processor.
4) yet some other articles tell that we can use "address sizes" field set on /proc/cpuinfo to understand if the processor is 32bit or 64bit.

address sizes : 36 bits physical, 48 bits virtual
If you find a line like above, it does mean that you have 64bit processor. The 32bit processors don't have that field set.

I just want to know which among the above option is correct. Are those option vendor dependent? If they are vendor independent, please don't tell me that they all should give same result. I am putting this post here as I have found different answers from different queries/commands.

The "getconf LONG_BIT" returned me 32 on a system where "lm" flag was set in /proc/cpuinfo. I couldn't find "address sizes" field for that machine in /proc/cpuinfo. The vendor was Intel Pentium.

When I dug a bit into detail, I could find that cpufeature.h can tell us what each flag/field means. Interestingly, I found "lm" under AMD and Intel defined features don't have such a flag. So, how come the "lm" flag set on my Intel based machine? Can we rely on "lm" flag to find the processor type? Is there any other methods to find it out? I just had a look at dmidecode output, but it didn't help me.

I appreciate your help.

Thanks,
Mohammed.
 
Old 07-21-2009, 07:56 PM   #2
mohammednv
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 18
The commands are their outputs as I mentioned before:

--------------------------------------
[root@LXS ~]# getconf LONG_BIT
32
[root@LXS ~]# grep -i lm /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl cid cx16 xtpr lahf_lm
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl cid cx16 xtpr lahf_lm
[root@LXS ~]#
--------------------------------------
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) D CPU 2.80GHz
stepping : 7
cpu MHz : 2793.267
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl cid cx16 xtpr lahf_lm
bogomips : 5590.11


processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Pentium(R) D CPU 2.80GHz
stepping : 7
cpu MHz : 2793.267
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl cid cx16 xtpr lahf_lm
bogomips : 5586.34
--------------------------------------
[root@LXS ~]# uname -a
Linux LXS 2.6.18-53.el5 #1 SMP Mon Nov 12 02:22:48 EST 2007 i686 i686 i386 GNU/Linux
[root@LXS ~]# cat /usr/src/kernels/2.6.18-53.el5-i686/include/asm-i386/cpufeature.h
/*
* cpufeature.h
*
* Defines x86 CPU feature bits
*/

#ifndef __ASM_I386_CPUFEATURE_H
#define __ASM_I386_CPUFEATURE_H

#include <linux/bitops.h>

#define NCAPINTS 7 /* N 32-bit words worth of info */

/* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */
#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
#define X86_FEATURE_DTES (0*32+21) /* Debug Trace Store */
#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
/* of FPU context), and CR4.OSFXSR available */
#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */

/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
/* Don't duplicate feature flags which are redundant with Intel! */
#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
#define X86_FEATURE_MP (1*32+19) /* MP Capable. */
#define X86_FEATURE_NX (1*32+20) /* Execute Disable */
#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
--------------------------------------
 
Old 07-22-2009, 06:30 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,842

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Quote:
Originally Posted by mohammednv View Post
What I know or heard about are:
1) uname can be used to find if the OS is 32bit or 64bit.
2) some articles tell that "lm" flag is set in /proc/cpuinfo means, you are on a 64bit processor
3) A few articles tell that "getconf LONG_BIT" will return 64 if your processor is 64bit. The return value 32 means, you have a 32bit processor.
4) yet some other articles tell that we can use "address sizes" field set on /proc/cpuinfo to understand if the processor is 32bit or 64bit.

address sizes : 36 bits physical, 48 bits virtual
If you find a line like above, it does mean that you have 64bit processor. The 32bit processors don't have that field set.
1) Might work - generally you would hope so.
2) True.
3) Nope. 32-bit kernel returns 32, even on 64-bit processor.
4) Not quite. Line(s) show up (1 per processor) on 64-bit kernels on 64-bit h/w. Don't appear for 32-bit kernel on same hardware.

Rely on the "lm" flag.
 
Old 07-22-2009, 07:06 AM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
++ Rely on the lm flag.

About the motherboard, just check the supported processor list on the manual. If you have lost it, you can usually get it from the web of the manufacturer.
 
Old 07-23-2009, 11:17 AM   #5
mohammednv
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 18
Thanks for your responses.

@syg00
Your answers to my questions look good and I agree with that.

Do you know why X86_FEATURE_LM flag is listed under AMD? (please see my first comment for more details). Also, note the following lines in that header file:


Quote:
/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
/* Don't duplicate feature flags which are redundant with Intel! */
So obviously, since Intel features are listed first, common flags should have been listed under Intel. As it's listed under AMD, I guess it's a AMD only feature. I'm not sure if the X86_FEATURE_IA64 flag listed under Intel is similar to X86_FEATURE_LM flag of AMD.

I can be wrong here, but please share your thoughts

Thanks again.

~mohammed
 
Old 07-23-2009, 11:33 AM   #6
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181Reputation: 1181
Quote:
Originally Posted by mohammednv View Post
1) how can I find if the processor is 32bit or 64bit?
The lm flag.

Quote:
2) is there a way to find if mother board support 64bit?
I don't think there is any general method.

Quote:
1) uname can be used to find if the OS is 32bit or 64bit.
True.

Quote:
2) some articles tell that "lm" flag is set in /proc/cpuinfo means, you are on a 64bit processor
True.

Quote:
3) A few articles tell that "getconf LONG_BIT" will return 64 if your processor is 64bit. The return value 32 means, you have a 32bit processor.
False. When that works at all it tells you whether the OS is 32 or 64, not the cpu.

Quote:
address sizes : 36 bits physical, 48 bits virtual
If you find a line like above, it does mean that you have 64bit processor. The 32bit processors don't have that field set.
I think having that line or not would be a software difference not a cpu difference. So lacking that line tells you nothing about the CPU. If you have the line, both 32 and 64 bit x86 CPUs vary by brand/model in the physical address size, but the virtual address size is 32 for 32 bit CPUs and 64 for current 64 bit CPUs. So maybe sometimes that line will tell you something.
 
Old 07-26-2009, 05:30 AM   #7
mohammednv
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 18
I agree with you johnsfine and I had got it clarified from syg00. What I still don't understand is whether FEATURE_LM is Intel specif or AMD specific flag.

Please see my previous comment (just before your comments) for the details.

Thanks,
Mohammed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to upgrade laptop to 64bit processor? ciden Linux - Hardware 11 03-01-2007 12:20 PM
Is this a 32bit or 64bit processor??? jiaming2k Linux - Hardware 3 08-11-2006 02:32 PM
Slackware and 64bit intel processor Teldon Slackware 2 11-16-2005 02:20 PM
can 64bit processor run both 64bit and 32bit computers? DJOtaku Linux - General 4 09-08-2005 09:14 PM
Is it worth the extra $ for a 64bit processor? tomj88 Linux - Hardware 8 06-15-2005 10:39 PM


All times are GMT -5. The time now is 10:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration