Linux-Development-Sys Digest #664, Volume #8     Mon, 23 Apr 01 10:13:15 EDT

Contents:
  Disk sector access with Int or C-syscall (pmode) (Peter Wiehe)
  Re: A Linux emulator for Linux, does this exist? (Jonathan Buzzard)
  Re: How to get a number of processors (Roberto Nibali)
  Re: Packet dropped in IN_DEV_FORWARD in ip_route_input_slow (Roberto Nibali)
  where is the source of the function of printk() ??? ("hushui")
  Re: How to get a number of processors (Chris)
  SIGSEGV signal handler and pthread (Sang-Kwon Lee)
  Re: where is the source of the function of printk() ??? (Josef Moellers)
  [help] TCP rate control and Linux? (Paolo Castagna)
  Re: How do I initiate Gnome? (Kasper Dupont)
  Re: Disk sector access with Int or C-syscall (pmode) (Kasper Dupont)
  what is __init in At&t ??? ("hushui")
  Re: what is __init in At&t ??? (Alexander Viro)
  pty handling (Manousaridis Aggelos)

----------------------------------------------------------------------------

From: Peter Wiehe <[EMAIL PROTECTED]>
Subject: Disk sector access with Int or C-syscall (pmode)
Date: Mon, 23 Apr 2001 07:39:43 GMT

How can I access the disk "raw" (=by sector) in Linux without ports?
And without going to real mode or VM86 mode?
Is there a C-call or an interrupt ?

[ Peter Wiehe wiehepeter<at>web.de ]

------------------------------

From: [EMAIL PROTECTED] (Jonathan Buzzard)
Subject: Re: A Linux emulator for Linux, does this exist?
Date: Mon, 23 Apr 2001 09:54:06 +0100

In article <9bv9eo$1pt$[EMAIL PROTECTED]>,
        [EMAIL PROTECTED] (Philip Armstrong) writes:
> In article <[EMAIL PROTECTED]>,
> Jonathan Buzzard <[EMAIL PROTECTED]> wrote:
>>> Besides I said lower than the old ones (which certainly did need three
>>> phase power :)  ), not low in absolute terms!
>>
>>Aparantly they do use three phase power supplies though.
> 
> yeah? Hmm wonder why then. Maybe you can get cleaner DC power more
> easily off 3-phase?
> 

Probably a large part of it is that a three phase supply runs at 415V
as opposed to 230V of a normal supply. This basically means that the
current draw for a 13kW load is 31A as opposed to 56A. If you have ever
wired in a shower with 40A cable you will understand why you might want
to avoid having to wire up something drawing 56A.

JAB.

-- 
Jonathan A. Buzzard                 Email: [EMAIL PROTECTED]
Northumberland, United Kingdom.       Tel: +44(0)1661-832195

------------------------------

From: Roberto Nibali <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to get a number of processors
Date: Mon, 23 Apr 2001 12:23:37 +0200

> > > sysconf(2); /usr/include/bits/confname.h
> >
> > > i.e.
> >
> > >        printf("%d\n", sysconf(_SC_NPROCESSORS_CONF));
> >
> > A better bet would be to have your program look at /proc/cpuinfo
> 
> No it wouldn't.

:)

BTW: It's sysconf(3) over here and <bits/confname.h> is not wise, use
     <unistd.h> instead [and nitpicking: it's long sysconf(int name);].

#include <stdio.h>
#include <unistd.h>

int main(void){
        printf("Processors: %ld\n", sysconf(_SC_NPROCESSORS_CONF));
        return(0);
}

But thank you for this information. I was looking recently into how I
could exactly do this and I forgot to check out the macros defined in
unistd.h. I took the /proc/cpuinfo way. Now I can change it :)

Best regards,
Roberto Nibali, ratz

-- 
mailto: `echo [EMAIL PROTECTED] | sed 's/[NOSPAM]//g'`

------------------------------

From: Roberto Nibali <[EMAIL PROTECTED]>
Subject: Re: Packet dropped in IN_DEV_FORWARD in ip_route_input_slow
Date: Mon, 23 Apr 2001 12:29:46 +0200

Snehal Khandkar wrote:
> 
> Hi,
> 
> My packets are getting dropped in route.c in ip_route_input_slow in
> the following check
> 
>  if (!IN_DEV_FORWARD (in_dev))
>         return -EINVAL;
> 
> In brief the stuff I am trying to do:
> 
> Trying to make a host act as a load balancer. I have 3 servers. Client
> sends the request to my host with my IP addr in its dest addr. In
> ip_input.c in ip_rcv, I change src addr of packet to my ip addr, and the
> dest addr to the server's ip addr and assign it a source port. This
> should now reach the server. The server then should respond to me and I
> will forward the packet to the client again by changing the src and dest
> addr and ports as needed.

You need to extend the routing code to support this routing stuff. Have
you tried your tests with CONFIG_IP_TRANSPARENT_PROXY=y? If it doesn't
work, check out the page I mention below and if you still want to have
your solution I might as well first having a look at the code myself.
 
> The problem is that when I try to change the packet I get from client, it
> gets dropped in the above mentioned check. Can someone please tell me what
> that macro does and why its failing.
> 
> Thank you,
> Snehal

You might check out our LVS project at [http://www.linux-vs.org]. And if
you subscribe to the mailinglist and post the question there after having
tried our load balancing solution you certainly might get the best and correct 
answer if you still need it.

HTH,
Roberto Nibali, ratz

-- 
mailto: `echo [EMAIL PROTECTED] | sed 's/[NOSPAM]//g'`

------------------------------

From: "hushui" <[EMAIL PROTECTED]>
Subject: where is the source of the function of printk() ???
Date: Mon, 23 Apr 2001 18:42:43 +0800

where is the source of printk???
I read linux source from booting and meet it first in init/mani.c .
I am curious about it .



------------------------------

From: Chris <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: How to get a number of processors
Date: Mon, 23 Apr 2001 11:41:54 +0000

Roberto Nibali wrote:
> 
> > > > sysconf(2); /usr/include/bits/confname.h
> > >
> > > > i.e.
> > >
> > > >        printf("%d\n", sysconf(_SC_NPROCESSORS_CONF));
> > >
> > > A better bet would be to have your program look at /proc/cpuinfo
> >
> > No it wouldn't.
> 
> :)
> 
> 
> and <bits/confname.h> is not wise, use

Indeed. However, if you want to find out the name of the
symbol to use, it's in there, not unistd.h.

-- 
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
 Television is a medium, so called
 because it is neither rare nor well done.

------------------------------

From: Sang-Kwon Lee <[EMAIL PROTECTED]>
Subject: SIGSEGV signal handler and pthread
Date: Mon, 23 Apr 2001 21:22:37 +0900

I want to capture the SIGSEGV signal.
So, I registered a SIGSEGV signal handler.
It works. It captures correct fault address.
But, when I link this code to pthread library, the fault address is not
correct.
The same source code puts different result according to linkage of
pthread library.
Can anybody help me solve this problem?
I wil really appreciate any kind of comments or help.
Thanks in advance.

My system is Intel P-III dual CPU, Linux 2.2.13-7mdksmp.
The following is my source code for test:

// main.c
// test SIGSEGV signal and pthread

#include <pthread.h>
#include <signal.h>
#include <stdio.h>

// SIGSEGV signal handler
void SigSegvHandler(int signo, struct sigcontext_struct sigctx)
{
  unsigned addr; // fault address
  unsigned error;

  addr  = sigctx.cr2; // fault address
  error = (sigctx.err & 2);
  printf("fault address = 0x%X\n", addr);
  printf("error = 0x%X\n", error);
  fflush(stdout);
  exit(1);
}

// install SIGSEGV signal handler
void InstallSigSegvHandler()
{
  struct sigaction act;

  act.sa_handler = (void (*)()) SigSegvHandler;
  sigemptyset(&act.sa_mask);
  act.sa_flags = 0;
  if (sigaction(SIGSEGV, &act, NULL))
  {
    printf("segv sigaction problem\n");
    fflush(stdout);
    exit(1);
  }
}

char *ptr;

main()
{
  char temp;

  InstallSigSegvHandler();

  ptr = NULL;
  temp = *ptr;

  return 0;
}

The following result is when I don't link pthread library. It is correct
result:

fault address = 0x0
error = 0x0

The following result is when I link pthread library. It is incorrect
result:

fault address = 0x23
error = 0x0



------------------------------

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: where is the source of the function of printk() ???
Date: Mon, 23 Apr 2001 15:17:05 +0200

hushui wrote:
> =

> where is the source of printk???
> I read linux source from booting and meet it first in init/mani.c .
> I am curious about it .

It's probably where one would look for it:
        kernel/printk.c

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

------------------------------

From: Paolo Castagna <[EMAIL PROTECTED]>
Subject: [help] TCP rate control and Linux?
Date: Mon, 23 Apr 2001 14:40:33 +0200

Hi,
I'm an Italian student and I'm doing a Master Thesis on TCP rate 
control.

TCP rate control is a new technique for transparently augmenting 
end-to-end TCP performance by controlling the sending rate of a TCP 
source. The sending rate of a TCP source is determined by its window
size, the round trip time and the rate of acknowledgments. 
TCP rate control affects these aspects by modifying the ack number 
and receiver window fields in acknowledgments and by modulating the 
acknowledgment rate. From a performance viewpoint a key benefit of 
TCP rate control is to avoid adverse performance effects due to 
packet losses such as reduced goodput and unfairness or large spread
in per-user goodputs. Further, TCP rate control positively affects
performance even if the bottleneck is non-local and the end-host
TCP implementations are non-conforming. [see article below]

I would like to know your opinions about that, and if there is 
already something similar in the Linux world. I've already see 
the kernel sources but I didn't find something like that.

I'll appreciate suggestion about how to implement such ideas on
Linux, specifically in the kernel 2.4.3.
There are two algorithms in the TCP rate control technique, as 
describe in the paper below, may be usefull for you to have the
algorithms:

=====================================================================

Algorithm 1 - Rate Allocation Algorithm

The goal of this algorithm is to allocate max-min fair rates to 
competing TCP flows. Initially, equal rate allocations are given to 
all competing flows. Then sending rates of flows are estimated by 
maintaining an exponential average over a rate sampling interval.
When a flow does not to utilize its allocation, it is labeled as 
bottlenecked. Excess allocation is stripped off from all such 
bottlenecked flows and allocated to non-bottlenecked or hungry flows. 
This step is repeated until there is no residual bandwidth to 
allocate or all flows are bottlenecked. This algorithm is invoked 
every time a new flow begins, a flow terminates or when the rate 
sampling interval expires. The resulting rate allocations are 
stored into a table. 

=====================================================================

1. For each flow i, let Ri be the measured rate 
   and Ai be the allocated rate.

2. If N is the total number of flows and B is the bottleneck
   capacity, the initial allocation for each flow i is

     Ai = B / N                                      (2)

3. If Ri < (p * Ai) for some satisfaction percentage p 
   (a statically chosen parameter), then mark flow i as 
   bottlenecked, else mark it as hungry.

4. Let U be the aggregate residual bandwidth i.e the
   bandwidth which remains unutilized by the bottlenecked
   flows.

5. Distribute this residual bandwidth evenly over all the
   hungry flows. If H is the total number of hungry flows, 
   the new allocation for a hungry flow j is given by

     Aj = Aj + (U / H)                               (3)

6. For each bottlenecked flow k the new allocation is
   given by

     Ak = (Ak + Rk) / 2                              (4)

   So for bottlenecked flows, the allocation approaches
   the measured rate over successive iterations of the
   algorithm.

=====================================================================

About this algorithm, I've a problem... how can I measure the rate
Ri for each TCP flow? I've found NeTraMet on this URL:
http://www.auckland.ac.nz/net/Accounting/ntm.Release.note.html
... and I've also read the discussion about that on linux-kernel 
mailing list. Where is the best place to make a such thing? 
I've thought in /net/core/dev.c in function dev_queue_xmit. 
And, again, how can I associate the rate Ri to each TCP flow?

=====================================================================

Algorithm 2 - Rate Enforcement Algorithm

This algorithm enforces the rate allocation by converting the rate 
to a window value. Additionally, it spaces out the acknowledgments 
of a flow, so that they are evenly distributed over its RTT.

=====================================================================

1. For each flow i let

     wi = the calculated window size in units of packets.
     Di = the inter-ack spacing in seconds.
     RTTi = the round trip time (RTT) of flow i, ideally
     not including queuing delays, in seconds.
     MSSi = the maximum segment size of flow i, in bytes.
     Ai = the rate allocation in bytes/s.

2. Observe that for each flow i, we have:

     wi * MSSi = Ai * RTTi                           (5)

   So the window value can be calculated as, 
   
     wi = (Ai * RTTi) / MSSi                         (6)

3. The inter-ack spacing time (RTTi/wi) can also be
   obtained from equation (5):

     Di = RTTi / wi = MSSi / Ai                      (7)

4. For each flow i, acks (if available) are clocked out
   at intervals of Di with the receiver window field set
   to Wi. 

5. The receiver window field of the ack of flow i is set as:

     Wi = min(wi * MSSi , actual receiver window)    (8)

6. The ack number field in the header is determined based
   upon two variables (max and min sequence number) used to 
   denote the ack queue. In the common case, the ack number 
   would be chosen to progress by one MSSi.
   
=====================================================================

About this algorithm, where is, for you, the best place
where to do a such thing? In general I'd like to do only minor
changes possible in the kernel sources, and I would like to 
implement a module for TCP rate control.
I've also found an usefull paper by Glenn Herrin, I've try the
example with the kernel v2.4.3 but I've some problem with it: 
when I export a symbol from the kernel, using EXPORT_SYMBOL and I 
try to use it from a module I have the error: "undefined symbol in 
mymodule" even if it's listed in /boot/System.map 

=====================================================================

Papers:

o Shrikrishna Karandikar, Shivkumar Kalyanaraman, 
  Prasad Bagal, Bob Packer, 
  "TCP Rate Control",
  Computer Communication Review, a publication of ACM SIGCOMM, 
  volume 30, number 1, January 2000. ISSN # 0146-4833. 
  URL: http://www.acm.org/sigcomm/ccr/archive/2000/jan00/ccr-200001-kara.html

o Glenn Herrin,
  Linux IP Networking, 
  A Guide to the Implementation and 
  Modification of the Linux Protocol Stack 
  TR 00-04, May 31, 2000 
  URL: http://kernelnewbies.org/documents/ipnetworking/

o Others interesting papers:
  URL: http://www.ecse.rpi.edu/Homepages/shivkuma/research/papers-rpi.html#tcp

=====================================================================

Commercial products based on idea of TCP Rate Control:

o Packeteer - http://www.packeteer.com/ [nasdaq: PKTR]
o Allot - http://www.allot.com/

=====================================================================

I beg your pardon for the lenght of this message, and also for my
bad english :/ I hope this is the right place for a such discussion, 
if not, please, excuse me, and if you know send me some references.

Greetings,
Paolo Castagna.


------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: How do I initiate Gnome?
Date: Mon, 23 Apr 2001 13:13:04 +0000

ray wrote:
> 
> Dear Lee
> 
> > >
> > I think you're looking at the problem the wrong way round (provided I've
> read
> > you right).
> >
> > If you want to have Gnome running with FVWM, load up Gnome and then get
> Gnome
> > to load up FVWM as its WM of choice:
> >
> Yes, I want Gnome running with FVWM
> 
> > Edit .Xclients (and make sure it's executable afterwards!) to have:
> >
> > exec gnome-session
> >
> 
> I have done this part, but the startx command fails. It says command not
> found. I suspect that it could be the path but when I search around in the
> whole directory for gnome-session file, I could not find it.
> 
> > Then, when Gnome has loaded up (probably with Sawmill or E), open up the
> > Control Centre and specify FVWM as the WM in the Window Managers section
> (you
> > may have to add it to the list first).
> >
> > Is that what you were after or have I missed the plot?
> >
> > Lee.

If gnome-session is missing it will do no good trying
to execute it. On my system it is installed in /usr/bin,
so it is very unlikely that the problem is a wrong path.

If you do not have a file named /usr/bin/gnome-session
it means that gnome is not properly installed on your
system. BTW which distribution are you using?

-- 
Kasper Dupont

------------------------------

From: Kasper Dupont <[EMAIL PROTECTED]>
Subject: Re: Disk sector access with Int or C-syscall (pmode)
Date: Mon, 23 Apr 2001 13:25:41 +0000

Peter Wiehe wrote:
> 
> How can I access the disk "raw" (=by sector) in Linux without ports?
> And without going to real mode or VM86 mode?
> Is there a C-call or an interrupt ?
> 
> [ Peter Wiehe wiehepeter<at>web.de ]

You can open the block device special file and
use lseek, read and write. There are also some
ioctls to do special stuff like reading geomtery.

The name of the file to open depends on which
kind of disk you try to access:

/dev/fd0   for the first floppy drive.
/dev/hda   master device on first IDE controller
/dev/hdb   slave device on first IDE controller
/dev/hdc   master device on second IDE controller
and so on.

-- 
Kasper Dupont

------------------------------

From: "hushui" <[EMAIL PROTECTED]>
Subject: what is __init in At&t ???
Date: Mon, 23 Apr 2001 20:57:21 +0800

In many function of kernel ,many of them are declared as a profix __init??
Waht is this means??
Thank you .



------------------------------

From: [EMAIL PROTECTED] (Alexander Viro)
Subject: Re: what is __init in At&t ???
Date: 23 Apr 2001 09:33:46 -0400

In article <9c18qg$[EMAIL PROTECTED]>,
hushui <[EMAIL PROTECTED]> wrote:
>In many function of kernel ,many of them are declared as a profix __init??

        WTF does it have to AT&T? __init expands to
__attribute__((__section__ (".text.init"))), which is a gcc extension.
It puts the compiled function into section .text.init instead of normal .text.
After the kernel is done with the bootstrap it frees the memory used by
that section.

-- 
"You're one of those condescending Unix computer users!"
"Here's a nickel, kid.  Get yourself a better computer" - Dilbert.

------------------------------

From: [EMAIL PROTECTED] (Manousaridis Aggelos)
Subject: pty handling
Date: 23 Apr 2001 14:05:06 GMT
Reply-To: [EMAIL PROTECTED]

I am developing a programm that sniffs a serial port.
My idea was to create e pty pair, bound my application to the master side,
and to my serial device (/dev/ttySX), and copy data from one side to another
and vice-versa (while doing some editing on the fly).
Up until now, I had a success, i am able to connect using pppd (the device is
an NT, which acts like a modem - async PPP).

the problem I am facing now is this.
an application connects to the slave side ( open(/dev/ttyXX ), does some
reads/writes and closes.
when the application closes, my read() call on the master side fails with
Input/Output error, which is a bad thing (TM) because my infinite read/write
loop floods the other side.

Apparently during the close() call on the slave side, something happens to the
master side also. What system call shall i use to avoid this?

I open the master side with:

fd = open(dev, O_RDWR);

and then call the following code:

int set_ptymaster(int fd)
{
 struct termios setme;

 if ( tcgetattr(fd,&setme)<0 )
        return -1;

 setme.c_iflag = 0;
 setme.c_oflag = 0;
 setme.c_cflag &= ~(CSIZE | PARENB | CSTOPB);
 setme.c_cflag |= CS8 | CREAD | HUPCL;
 setme.c_lflag &= ~(ICANON | ECHO | ECHONL);
 setme.c_cc[VTIME] = 0;
 setme.c_cc[VMIN] = 1;

 return tcsetattr(fd,TCSANOW,&setme);
}

-- 
Aggelos Manousarides

------------------------------


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.system newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-System Digest
******************************

Reply via email to