LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-05-2005, 09:36 PM   #1
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Rep: Reputation: 15
SMP configuration problems -- NR_CPUS undefined


I am trying to create a RAM image of Linux to run on a fairly bare platform. The chip I am using has 2 PPC cores and I am working on getting the SMP capabilities of Linux working. I am using MontaVista Linux (if that matters). I am able to successfully create an image when I don't enable the SMP option in the menuconfig (I forget what the option is exactly, something like: "Enable SMP support"). Then when I do enable it I get errors on the build that seems to say that the constant NR_CPUS isn't defined. I tracked that constant down to linux/threads.h. Now I need to know how/where to include that file and maybe why wasn't it included already since it seems to be necessary?

I am very new to Linux, so if any other details are needed, I would be happy to supply them. Any advice apprecitated!

Thanks,
Joey
 
Old 04-06-2005, 09:38 PM   #2
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
<bump>

Nobody? Need more details? Help!
 
Old 04-07-2005, 04:17 PM   #3
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
<bump>

If no one knows what I might try, can anyone point me somewhere else to ask/look? Any help greatly appreciated!
 
Old 04-07-2005, 07:19 PM   #4
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
You can try two things.

In the menuconfig, in the SMP option, it allows you to define the "maximum number of CPUS". Have you set a value here ?

Other thing you can try :
Try adding NR_CPUS=2 in the Makefile itself, at the beginning.
 
Old 04-07-2005, 08:22 PM   #5
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Thanks for the response, Ben. I am very slow with this Linux stuff, but here are the results of your suggestions:

Quote:
Originally posted by Ben2210
You can try two things.

In the menuconfig, in the SMP option, it allows you to define the "maximum number of CPUS". Have you set a value here ?
I don't see that option anywhere. The only mention of SMP is when I do `make menuconfig' under `Platform support' there is an option `Symmetric multi-processing support'. I checked that option and a sub-option appeared `Distribute interrupts on all CPUs by default'. I left that unchecked because it is unimportant at the moment.

Quote:

Other thing you can try :
Try adding NR_CPUS=2 in the Makefile itself, at the beginning.
I really am no sort of Linux expert, but I tried to put that line first in the file called `Makefile' and got the same sort of errors. It seemed to blow up when it was processing smp.h, again with the error that NR_CPUS is undefined. Did I put the line in the correct Makefile? Any more advice? Thanks again...
 
Old 04-07-2005, 08:44 PM   #6
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
OK, forget about editing the Makefile. That was silly. If you modified your makefile, revert your changes, and if you can't, re-extract your kernel sources.

Here we go :

in the menuconfig, go in "Processor type and features", then enable "Symmetric multi-processing support". It opens a new option "Maximum number of CPUs (2-255) (NEW)". Set that to 2. And you are done !

Note that the help for this option says "CONFIG_NR_CPUS", so that's exactly what we were looking for.

Important note :

As you're using a PPC architecture and I'm using a intel architecture, it might be that you have a different menu than I have. If this is the case, and you are not being proposed to change the NR_CPUS, either add a line to your .config :
Code:
CONFIG_NR_CPUS=2
then rerun make menuconfig, save your config, re-edit your .config and check that the line you added is still there.

Try compiling with that.
If it doesn't work, your last chance is to manually add the following line to the file include/linux/autoconf.h in your kernel sources directory :

Code:
#define NR_CPUS 2
Note that you have to do this *after* you run make menuconfig, but before the actual compilation.
 
Old 04-07-2005, 08:47 PM   #7
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
Hey, what kernel version are you using ? The NR_CPUS option says it's new, so that may explain why you don't have it!
 
Old 04-07-2005, 09:11 PM   #8
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Alright, Ben, you are awesome for helping me out. I am getting the feeling that some of these options have been disabled because the distro assumes a given platform (the platform they assume is the one I am trying to modify). There isn't a "Processor type and features" option. The "Symmetric multi-processing support" options lives under "Platform Support". So I couldn't try out that piece of advice. Your 2nd piece of advice concerning my .config file confused me a bit because I don't know where this file is (or what it is really). So I skipped that as well. So I went and modified that autoconfig.h file you suggested (last resort, I know).

When building based on this I got several warnings now that NR_CPUS gets redefined. Seems odd since it wasn't defined at all when I didn't have it in the autoconfig file. Anyway, finally I get an error form what looks like the entry.S file with an undefined reference to "hash_table_lock". Maybe this distro just didn't come complete and ready for this kind of modification? Is that possible? If that's the case, should I just look for some other distro? Would really like to get this one to work, though, so any further advice? If I am doing something silly please let me know! Thanks again...
 
Old 04-07-2005, 09:13 PM   #9
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Ben2210
Hey, what kernel version are you using ? The NR_CPUS option says it's new, so that may explain why you don't have it!
When I do "make menuconfig" it says "Linux Kernel v2.4.20_mvl31-ml300 Configuration".

So I guess v2.4.20?
 
Old 04-08-2005, 02:19 AM   #10
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
Hi.

When I said .config, I meant the (hidden) .config file in your kernel sources directory. To see it, do "ls -a". This is the kernel config file ; make menuconfig reads it to know what config to start with.

You don't have the same options as me because your Architecture is different from mine. You have PPC, I have intel. You could change that in some config file, but you do not want to do that, as you would get an Intel kernel, and you need a PPC kernel. Your distro is not at fault!

Forget about trying to tweak the source files : the error about the undefined reference to "hash_table_lock" seems impossible to work around.

So you are trying to compile a 2.4.20 kernel. This is totally antique! It must date back to 2002 or so. If you want to stay with a 2.4 kernel, the latest is 2.4.30. You can also try a 2.6 kernel (latest is 2.6.11.6). I think that compiling a newer kernel has a lot of chances of solving your problem.

You are not doing anything silly!
 
Old 04-08-2005, 06:32 AM   #11
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Alright Ben, thx again.

So here is a little more detail on my situation, to fish for a little more advice on where to proceed:

I have a fairly nice motherboard (lots of I/O built-in, 4 PCI slots, CompactFlash Reader, some RAM) with a Xilinx FPGA as the processor (Virtex II Pro, which has the 2 PPCs embedded within). As a demo of the board, it came with this MontaVista distro (which is why I have been trying to use that) and there are some tutorials on how to make a RAM image to run on a given configuration of the FPGA. This configuration only uses one of the PPCs. My goal is to get both going in an SMP fashion (I can get it going with both PPCs doing their own, independent thing, but that isn't as exciting). By the way, I am building the kernel on a separate PC and will ultimately be downloading Linux to the board's RAM. The FPGA gets configured and loaded with a simple bootloader program that starts Linux.

Given all of that, would it be possible to just download some newer version of Linux for PPC and configure it for 2 processors and make a RAM disk image of it? By now I think I understand how to go about configuring a kernel (given all the options are there!) as well as the process of making the image, the big thing is getting Linux to actually run on this board. If so, any advice on which one and where to get it? Ideally it would be easy to configure and free! But I think the "easy" is more important than the "free".

I just re-read this and it sounds a little muddled, but if it makes sense, can you offer any advice?

Thanks for the encouragement!
 
Old 04-08-2005, 07:08 AM   #12
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
First, if you are looking for a completely free distro that is very configurable, that will allow you to compile a custom kernel, and that handles PPC processors, one name comes to mind : Gentoo.

The problem is that your processor (Xilinx) looks so unusual, I'm not so sure that Gentoo will handle it. Perhaps this is why your system came with such an unusual distro as Montavista.

There's one thing that I don't understand : why don't you directly compile on your Xilinx system ? Compiling on another system and then putting the kernel on your Xilinx system is more complicated...
Is your other system a PPC too ?

I don't know how special the kernel provided by Montavista was. Perhaps your hardware is so unusual, that you can't use a standard kernel and have to get your kernel from Montavista. Perhaps you can find newer kernel sources at Montavista. Also perhaps Montavista provides kernel patches to adapt a standard kernel for your hardware. You should probably use google or go directly to Montavista's site to check.

In case your hardware is standard enough to use a standard kernel (given the proper kernel configuration), download 2.4.30 from www.kernel.org. Then take the kernel "config" file provided by Montavista (you can probably find it in /boot or in the kernel sources directory, where it will probably be called ".config").

Untar the 2.4.30 kernel sources, put the Montavista kernel "config" file here, rename it to ".config" and you're ready to make menuconfig.

If that still does not work, you can try a 2.6 kernel. 2.6 has better support for modern hardware, and yours seems to fall in that category.

If you think you need a 2.6 kernel, there's only one problem : you won't be able to reuse your Montavista config file. But if you think you're ready and you've read a good 2.6 HOWTO, why not!

Last edited by Ben2210; 04-08-2005 at 07:10 AM.
 
Old 04-08-2005, 07:12 AM   #13
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
And by the way 2.6 will give you better performance, especially for a SMP processor.

EDIT:
I just realized that the difference between your kernel compile options and mine were probably caused by the fact that you use 2.4 , and I use 2.6.

Last edited by Ben2210; 04-08-2005 at 07:26 AM.
 
Old 04-09-2005, 07:34 PM   #14
Alotau
Member
 
Registered: Jan 2005
Location: Fremont, CA
Distribution: Red Hat 9
Posts: 58

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Ben2210
First, if you are looking for a completely free distro that is very configurable, that will allow you to compile a custom kernel, and that handles PPC processors, one name comes to mind : Gentoo.
Thanks, I will look into it. Actually, that is the theme of this reply, I will have to do quite a bit more homework it seems to get to anything working.
Quote:

The problem is that your processor (Xilinx) looks so unusual, I'm not so sure that Gentoo will handle it. Perhaps this is why your system came with such an unusual distro as Montavista.
Ideally, my system will look like any other PPC405 system when it is working properly. At least that is the idea. The FPGA stuff around the PPC core is there to try new things. The only 'new' thing that I want to try is getting two PPCs on one chip working together.
Quote:

There's one thing that I don't understand : why don't you directly compile on your Xilinx system ? Compiling on another system and then putting the kernel on your Xilinx system is more complicated... Is your other system a PPC too ?
No, I was on an intel machine building the kernel. Another reason why I was trying to use the Montavista stuff provided. The target system (PPC) and host system (Intel (686?)) were assumed when the Montavista tools were provided. Thus saving me the worry of building a tool chain (I guess that is what I would have to do). Compiling directly on the Xilinx system is too hairy for me to think about, though maybe I should? There is a configuration provided that acts like a PPC 405 machine and can boot Linux. I got a HD connected once. There is 256M of RAM. If I went this route is Gentoo still a good choice?
Quote:
...find newer kernel sources at Montavista. Also perhaps Montavista provides kernel patches...
The Montavista stuff provided was a "preview" so you can work with it all you want, but if you want support or to sell something with Montavista in it, you need to register and stuff. So I am on my own in the Montavista realm!

As for the rest of your message, I think that I will go and figure out how to build myself the correct Linux for what I need. Now for some more questions to aid my understanding of SMP in Linux:

With linux configured perfectly and working on an SMP system, what steps does Linux go through to bring the system up? Is there a pointer to somewhere that I coiuld read about this?

Anyone know of PPC multiprocessors, architecturally speaking? Where I might find more info on that (I know it isn't a linux question, per se)?

Any other advice given everything you see on this thread?

Thanks again Ben, you helped quite a bit. And thanks in advance for any future advice (from Ben or anyone else!)...

Joey
 
Old 04-10-2005, 05:40 AM   #15
Ben2210
Member
 
Registered: Feb 2004
Location: Toronto
Distribution: Arch
Posts: 146

Rep: Reputation: 16
First, look what I found for you (I just Googled for "gentoo xilinx") :
http://www.klingauf.com/v2p/index.phtml

I don't have the knowledge to answer your last questions about Linux bootup and PPC architecture.

That's just my opinion, but I recommend that you get rid of Montavista as soon as possible. Even if you could afford MontaVista support, you would then deprive you of a good learning experience and of a lot of fun. I'm sure there's a way of configuring your system by hand, and I'm more and more sure that your system is 'standard enough' for standard linux kernel sources. I think that your CPU itself should be no problem to detect, the problem will more be about your motherboard. In this regard, the first thing to do is
Code:
lspci
(or /sbin/lspci). Please post here the output of this command.

Then, you have a choice.

Either you stick with MontaVista for now and you try to compile a vanilla kernel. Use the link I have found. Maybe the day will soon come, where you will see not one, but two little penguins on your bootup screen...

Or you switch directly to Gentoo. Probably the first thing for this would be to go to the gentoo.org forum, to explain precisely what is your hardware (including the lspci output) and ask whether Gentoo will handle it. To get an answer on a gentoo forum, use the famous vanity of Gentoo users. Don't ask "here's my hardware, can you help?", ask "I'm not sure Gentoo is able to handle this - what's your opinion?"

Last edited by Ben2210; 04-10-2005 at 05:45 AM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any reason to keep a non-smp kernel installed on a smp FC3 machine? jim-j Fedora 2 03-12-2006 08:06 AM
linking problems - 'undefined reference' errors back2morrie Programming 1 06-14-2005 09:02 AM
Mandrake 10 0fficial smp configuration agomes Mandriva 1 05-24-2004 11:11 AM
fedora smp configuration eazyridr Fedora 0 01-25-2004 12:19 PM
SMP problems Rodcl Linux - Software 2 04-17-2002 03:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:43 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