LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 11-04-2003, 08:57 PM   #1
astroboy5714
LQ Newbie
 
Registered: Nov 2003
Posts: 9

Rep: Reputation: 0
Dual Xeon - Spread 99.9 to 2 Procs?


I have a Dual Xeon machine, RH9... 4 processors list because of the hyperthreading, but I have a problem... I've got some powerful software that uses 99.9% of one of these 4 processors.

Is there a way (software?) to spread that out to take 50% of 2 of the 4? I can't find any documentation or help on this anywhere... I actually have a feeling the software would like to use more, lets say 60% on each of 2... to make 120% of one processor, which is causing some slowness.


Thanks!
 
Old 11-04-2003, 09:06 PM   #2
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
If the program does not take advantage of threading
or use fork() to distribute load then no there's not
really anything you can do.
 
Old 11-04-2003, 11:31 PM   #3
astroboy5714
LQ Newbie
 
Registered: Nov 2003
Posts: 9

Original Poster
Rep: Reputation: 0
I found this. How would it work for me?


affinity.c :

/*
* Simple command-line tool to set affinity
* Robert Love, 20020311
*/
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include "affinity.h"

int main(int argc, char * argv[])
{
unsigned long new_mask;
unsigned long cur_mask;
unsigned int len = sizeof(new_mask);
pid_t pid;
if (argc != 3) {
printf(" usage: %s <pid> <cpu_mask>\n", argv[0]);
return -1;
}
pid = atol(argv[1]);
sscanf(argv[2], "%08lx", &new_mask);
if (sched_getaffinity(pid, len, &cur_mask) < 0) {
printf("error: could not get pid %d's affinity.\n", pid);
return -1;
}
printf(" pid %d's old affinity: %08lx\n", pid, cur_mask);
if (sched_setaffinity(pid, len, &new_mask)) {
printf("error: could not set pid %d's affinity.\n", pid);
return -1;
}
if (sched_getaffinity(pid, len, &cur_mask) < 0) {
printf("error: could not get pid %d's affinity.\n", pid);
return -1;
}
printf(" pid %d's new affinity: %08lx\n", pid, cur_mask);
return 0;
}

affinity.h :

#define _AFFINITY_H
#include <sched.h>
#include <unistd.h>
#include <linux/unistd.h>
/*
* provide the proper syscall information if our libc is not yet updated.
* It is suggested you check your kernel to make sure these are right for
* your architecture.
*/
#if defined(__i386__)
#define __NR_sched_setaffinity241
#define __NR_sched_getaffinity242
#endif
_syscall3(int, sched_setaffinity, pid_t, pid, unsigned int, len,
unsigned long *, user_mask_ptr)
_syscall3(int, sched_getaffinity, pid_t, pid, unsigned int, len,
unsigned long *, user_mask_ptr)

Compile this program:

gcc affinity.c -o affinity

Then run it like so:

affinity PID 1 (stick to CPU 0)
affinity PID 2 (stick to CPU 1)
affinity PID 3 (stick to both cpu)

EG: affinity 14932 1

If you have more processors, like 4, then affinity PID 5 would assign it to all processors (let the linux scheduler do its work) ...

I'm using this with kernel 2.5, and I believe it only works with 2.5, unless you patch your 2.4 kernel..
 
Old 11-05-2003, 10:34 AM   #4
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
It really wouldn't do anything for you.
It lets you choose which process runs
on which processor. This doesn't help
you unless there are a lot of processes
running on that one CPU and for some
reason not using the others.

The speed of SMP systems aren't equal to
the sum of their clocks they can only run
processes in parallel and there-by appear
faster by taking advantage of concurrency.
No process can run faster than the clock
speed of of the processors in the system.
e.g. I have 2 1.2GHz processors the fastest
any process can run is at the performance
of a 1.2GHz processor. My computer *seems*
like it is faster because I can be running two
processes at once.

Also if you are running a 2.5.x kernel
upgrade to 2.6-test-9 or what ever the
latest is.
 
Old 11-05-2003, 04:12 PM   #5
Gill Bates
Member
 
Registered: Aug 2003
Location: the far side
Distribution: OpenSuSe 10.2, Mac OS X Tiger
Posts: 380

Rep: Reputation: 30
shot in the dark

is smp processing enabled in the kernel?
 
  


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
Multiprocessor Kernel for my Dual Xeon Randvegeta Linux - Hardware 3 07-21-2005 05:10 PM
Debian with Dual Xeon processor. r_akarach Debian 7 12-22-2004 09:16 AM
Best motherboard for Dual Xeon 3.06GHz CPUs? Teaboy Linux - Hardware 4 11-02-2003 12:19 PM
dual xeon c0c0deuz Linux - Hardware 1 08-09-2003 02:07 AM
pthreads on dual Intel Xeon system coxtonyj Linux - General 0 07-25-2003 03:49 AM


All times are GMT -5. The time now is 10:32 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration