[RFC] tcp: How does SACK or FACK determine the time to start fast retransmition?

2012-06-21 Thread 李易
HI all,
 When tcp uses reno as its congestion control algothim, it uses
tp-sacked_out as dup-ack. When the third dup-ack(under default
condition) comes, tcp will initiate its fast retransmition.
 But how about sack ?
 According to kernel source code comments, when sack or fack tcp option
is enabled, there is no dup-ack counter. See comments for function
tcp_dupack_heuristics():
http://lxr.linux.no/linux+v2.6.37/net/ipv4/tcp_input.c#L2300
 So , how does tcp know the current dup-ack is the last one which
triggers the fast retransmition?

 According to rfc3517 section 5:
 Upon the receipt of the first (DupThresh - 1) duplicate ACKs, the
scoreboard is to be updated as normal.
 When a TCP sender receives the duplicate ACK corresponding to
DupThresh ACKs,
the scoreboard MUST be updated with the new SACK information (via
Update ()). If no previous loss event has occurred
on the connection or the cumulative acknowledgment point is beyond
the last value of RecoveryPoint, a loss recovery phase SHOULD be
initiated, per the fast retransmit algorithm outlined in [RFC2581].

 But these sentences doesn't describe how tcp knows the current ack
is the dup-threshold dup-ack.

 Accorrding to rfc3517 seciton 4 and isLost(Seqnum) function:
 The routine returns true when either
DupThresh discontiguous SACKed sequences have arrived above
’SeqNum’ or (DupThresh * SMSS) bytes with sequence numbers greater
than ’SeqNum’ have been SACKed. Otherwise, the routine returns
false.
 I think this is just what I am searching for, but I still don't know
which line of code in Linux tcp protocol does this check.
 Can any one help me ? thks in advance.





___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Sysfs class attribute problem

2012-06-21 Thread Pranay Kumar Srivastava


 -Original Message-
 From: kernelnewbies-boun...@kernelnewbies.org [mailto:kernelnewbies-
 boun...@kernelnewbies.org] On Behalf Of kernelnewbies-
 requ...@kernelnewbies.org
 Sent: Wednesday, June 20, 2012 11:33 PM
 To: kernelnewbies@kernelnewbies.org
 Subject: Kernelnewbies Digest, Vol 19, Issue 39
 
 Send Kernelnewbies mailing list submissions to
   kernelnewbies@kernelnewbies.org
 
 To subscribe or unsubscribe via the World Wide Web, visit
   http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 or, via email, send a message with subject or body 'help' to
   kernelnewbies-requ...@kernelnewbies.org
 
 You can reach the person managing the list at
   kernelnewbies-ow...@kernelnewbies.org
 
 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Kernelnewbies digest...
 
 
 Today's Topics:
 
1. RE: A confusion about invoking my syscall (Jeff Haran)
2. Re: Sysfs class attribute problem (Jeshwanth Kumar N K Jeshu)
 
 
 --
 
 Message: 1
 Date: Wed, 20 Jun 2012 16:58:30 +
 From: Jeff Haran jha...@bytemobile.com
 Subject: RE: A confusion about invoking my syscall
 To: ?? wangzhe5...@gmail.com
 Cc: kernelnewbies kernelnewbies@kernelnewbies.org
 Message-ID:
   4ab110e2fa959f41ac8480e84516371105b...@hq-ex01.bytemobile.com
 Content-Type: text/plain; charset=iso-2022-jp
 
 
 
 From: ?? [mailto:wangzhe5...@gmail.com]
 Sent: Wednesday, June 20, 2012 1:16 AM
 To: Jeff Haran
 Cc: kernelnewbies
 Subject: Re: A confusion about invoking my syscall
 
 
 2012/6/20 Jeff Haran
 jha...@bytemobile.commailto:jha...@bytemobile.com
 
 
 From: ?? [mailto:wangzhe5...@gmail.commailto:wangzhe5...@gmail.com]
 Sent: Monday, June 18, 2012 9:32 PM
 To: Jeff Haran
 Cc: kernelnewbies
 Subject: Re: A confusion about invoking my syscall
 
 
 2012/6/19 Jeff Haran
 jha...@bytemobile.commailto:jha...@bytemobile.com
 
 
 From: kernelnewbies-boun...@kernelnewbies.orgmailto:kernelnewbies-
 boun...@kernelnewbies.org [mailto:kernelnewbies-
 boun...@kernelnewbies.orgmailto:kernelnewbies-
 boun...@kernelnewbies.org] On Behalf Of ??
 Sent: Monday, June 18, 2012 6:40 PM
 To: kernelnewbies
 Subject: A confusion about invoking my syscall
 
 Hello everyone:
 
  I append a simple syscall in kernel. and the function is as
 follows:
 
   asmlinkage  long sys_mysyscall(long data)
  {
   printk(This is my syscall!\n);
   return data;
   }
 
 and i test it sucessfully in user space . and the test program:
 
#include linux/unistd.h
#include syscall.h
#include sys/types.h
#include stdio.h
 
 
 
int main(void)
{
long n = 0,m = 0,pid1,pid2;
n = syscall(345,190);// #define __NR_mysyscall  345
printf(n = %ld\n,n);
pid1 = syscall(SYS_getpid);  //getpid
printf(pid = %ld\n,pid1);
pid2 = syscall(20);  //getpid
printf(pid = %ld\n,pid2);
return 0;
   }
 and the result:
 n = 190
 pid = 4097
 pid = 4097
 
 but if the test program is:
 #include linux/unistd.h
 #include syscall.h
 #include sys/types.h
 #include stdio.h
 
 
 
 int main(void)
 {
  long n = 0,m = 0,pid1,pid2;
  n = syscall(345,190);// #define __NR_mysyscall  345
  printf(n = %ld\n,n);
  m = syscall(SYS_mysyscall,190);
  printf(m = %ld\n,m);
  pid1 = syscall(SYS_getpid);  //getpid
  printf(pid = %ld\n,pid1);
  pid2 = syscall(20);  //getpid
  printf(pid = %ld\n,pid2);
  return 0;
 }
 and the result:
 wanny@wanny-C-Notebook-:~/syscall/src$ gcc test1.c
 test1.c: In function ?main?:
 test1.c:13:14: error: ?SYS_mysyscall? undeclared (first use in this
 function)
 test1.c:13:14: note: each undeclared identifier is reported only once
 for each function it appears in
 
 
 why i can't invoke my syscall with SYS_mysyscall?
 
 Thanks in advance!
 Because it appears you never defined the symbol SYS_mysyscall.
  I think so,but where shoud i defne the  symbol SYS_mysyscall ?
   and where is the symbol SYS_getpid defined?
 On my system /usr/include/bits/syscall.h, which is being included in
 your program because it includes syscall.h.
83 #define SYS_getpid __NR_getpid  ?so SYS_getpid is
 replaced by __NR_getpid. and __NR_getpid was defined in the
 kernel(arch/x86/include/asm/unistd_32.h). and my syscall was also
 defined there.#define SYS_mysyscall __NR_mysyscall, i don't kown why it
 doesn't works.
 
 My sources contain no reference to SYS_mysyscall nor __NR_mysyscall, so
 I assume you?ve added them to the Linux include files that you built
 your module from.
 
 User space programs like your main() program above generally aren?t
 going to include Linux source tree include files. When you include
 syscall.h from a user space program in a typical development
 environment, the compiler is by default going to look for syscall.h in
 /usr/include, not in the Linux source tree where presumably you?ve made
 your modifications. Of course you can always tell the compiler to look
 

Re: [RFC] tcp: How does SACK or FACK determine the time to start fast retransmition?

2012-06-21 Thread Vijay Subramanian
On 20 June 2012 23:33, 李易 lovelyl...@gmail.com wrote:
 HI all,
     When tcp uses reno as its congestion control algothim, it uses
 tp-sacked_out as dup-ack. When the third dup-ack(under default
 condition) comes, tcp will initiate its fast retransmition.
     But how about sack ?
     According to kernel source code comments, when sack or fack tcp option
 is enabled, there is no dup-ack counter. See comments for function
 tcp_dupack_heuristics():
 http://lxr.linux.no/linux+v2.6.37/net/ipv4/tcp_input.c#L2300
     So , how does tcp know the current dup-ack is the last one which
 triggers the fast retransmition?

With SACK, number of  dupacks does not have much meaning. What matters is
--how the SACK scoreboard looks like i.e. which packets are tagged
Lost/Sacked/Retransmitted
-- Whether FACK is in use (this assumes holes in between sacked
packets are lost and have left the network and so we can send out more
packets)

So, stack does not count the number of dupacks that have come in. Only
SACK blocks matter.
You can try to track the following path:
tcp_ack() deals with incoming acks and if it sees a dupack (does not
matter what number), or incoming packet contains SACK it calls
tcp_fastretrans_alert() which calls  tcp_xmit_retransmit_queue().

tcp_xmit_retransmit_queue() decides which packets to retransmit. The
first packet to start retransmitting from is tracked in
tp-retransmit_skb_hint.
Note that the dupThresh is actually tracked by tp-reordering which
measures  the reordering in the network and is not fixed at 3.  So, if
more than
tp-reordering packets have been acked above a given packet, this
packet is a candidate for retransmisson. See tcp_mark_head_lost() to
see how the
reordering metric is used to mark packets as lost. This corresponds to
the check you mentioned in the RFC.

So, window permitting, packets are sent as follows;
(a)-- Packets marked lost as per description above
(b)-- new packets (if any)
(c)-- Holes between sacked packets  which are not reliably lost.

choice between (b) and (c) is made in tcp_can_forward_retransmit().

Hope this helps.
Vijay

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: [RFC] tcp: How does SACK or FACK determine the time to start fast retransmition?

2012-06-21 Thread 李易
于 2012/6/21 16:42, Vijay Subramanian 写道:
 With SACK, number of  dupacks does not have much meaning. What matters is
 --how the SACK scoreboard looks like i.e. which packets are tagged
 Lost/Sacked/Retransmitted
 -- Whether FACK is in use (this assumes holes in between sacked
 packets are lost and have left the network and so we can send out more
 packets)

 So, stack does not count the number of dupacks that have come in. Only
 SACK blocks matter.
 You can try to track the following path:
 tcp_ack() deals with incoming acks and if it sees a dupack (does not
 matter what number), or incoming packet contains SACK it calls
 tcp_fastretrans_alert() which calls  tcp_xmit_retransmit_queue().

 tcp_xmit_retransmit_queue() decides which packets to retransmit. The
 first packet to start retransmitting from is tracked in
 tp-retransmit_skb_hint.
 Note that the dupThresh is actually tracked by tp-reordering which
 measures  the reordering in the network and is not fixed at 3.  So, if
 more than
 tp-reordering packets have been acked above a given packet, this
 packet is a candidate for retransmisson. See tcp_mark_head_lost() to
 see how the
 reordering metric is used to mark packets as lost. This corresponds to
 the check you mentioned in the RFC.

 So, window permitting, packets are sent as follows;
 (a)-- Packets marked lost as per description above
 (b)-- new packets (if any)
 (c)-- Holes between sacked packets  which are not reliably lost.

 choice between (b) and (c) is made in tcp_can_forward_retransmit().

 Hope this helps.
 Vijay

It is just I wanted! Thanks for your detailed explaination and kindness.


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


download the source code of some commands

2012-06-21 Thread 王哲
  Hi all:
   I want to see some source code of some commands,for
example,halt,reboot,uptime,and so on.

but i don't kown where to download?   can you give me some advice?

Thanks in advance!
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: download the source code of some commands

2012-06-21 Thread Denis Kirjanov
How does it related to the kernel?


On 6/21/12, 王哲 wangzhe5...@gmail.com wrote:
   Hi all:
I want to see some source code of some commands,for
 example,halt,reboot,uptime,and so on.

 but i don't kown where to download?   can you give me some advice?

 Thanks in advance!



-- 
Regards,
Denis

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel Memory

2012-06-21 Thread HowKernel StuffWorks
Hi,
  I am a kernel newbie too, Kernel memory is not pagable, because kernel
itself is responsible for paging. See this discussion,
http://kerneltrap.org/node/6404

  Paging happens for regular processes, i.e each process memory is divided
into a page of certain size(4kb in Linux), so it can swap for another page
that might be needed for that particular moment, it usually replaces an
page that have not been used for long time(see LRU,internal fragmentation).
Kernel is a process too, just like anyother process, but it differs from
others because it directly talks to the hardware and also it is the one
which takes care of paging and LRU algo's. So it does not make much sense,
for a kernel memory to be pageable, because, if it removes the page that
contains that has the paging algorithm, then there is  no way to come back,
you want to retrieve a page from disk_swap_area, but you cannot, because
the page that contains code to retrieve the instructions are paged :)...
This is not just for paging, since kernel controls everything, it is not
advisable to put its own code in swap area(see, virtual memory, virtual
memory = physical memory + swap space).

BTW, i am a kernel newbie too, this is my basic understanding, please feel
free to correct it, if I am wrong

On Thu, Jun 21, 2012 at 8:27 AM, Vijay Chauhan kernel.vi...@gmail.comwrote:

 Hello,

 I am newbie.
 It has been said kernel memory is not pageable
 What does it mean? There is no concept of kernel virtual address?

 Any simple explanation will help me to udnerstand.

 Thanks,
 Vijay

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel Memory

2012-06-21 Thread kishore sheik ahamed
Hey Vijay

I am a newbie too. Just sharing what I could go through.

It is said that Kernel or atleast a part of kernel needs to be non paged
for fast interrupt access etc as pinned memory
Wiki says
Pinned/Locked/Fixed pages

Operating systems have memory areas that are pinned (never swapped to
secondary storage). For example,
interrupthttp://en.wikipedia.org/wiki/Interruptmechanisms rely on an
array of pointers to their handlers, such as
I/O http://en.wikipedia.org/wiki/I/O completion and page
faulthttp://en.wikipedia.org/wiki/Page_fault.
If the pages containing these pointers or the code that they invoke were
pageable, interrupt-handling would become far more complex and
time-consuming, particularly in the case of page fault interrupts. Hence,
some part of the page table structures is not pageable.

Some pages may be pinned for short periods of time, others may be pinned
for long periods of time, and still others may need to be permanently
pinned. For example:

   - The paging supervisor code and drivers for secondary storage devices
   on which pages reside must be permanently pinned, as otherwise paging
   wouldn't even work because the necessary code wouldn't be available.
   - Timing-dependent components may be pinned to avoid variable paging
   delays.
   - Data buffers http://en.wikipedia.org/wiki/Data_buffer that are
   accessed directly by peripheral devices that use direct memory
accesshttp://en.wikipedia.org/wiki/Direct_memory_accessor I/O
   channels http://en.wikipedia.org/wiki/I/O_channel must reside in
   pinned pages while the I/O operation is in progress because such devices
   and the buses http://en.wikipedia.org/wiki/Bus_%28computing%29 to
   which they are attached expect to find data buffers located at physical
   memory addresses; regardless of whether the bus has a memory management
   unit for I/O http://en.wikipedia.org/wiki/IOMMU, transfers cannot be
   stopped if a page fault occurs and then restarted when the page fault has
   been processed.

There are other two discussion thread which say kernel is non-pageable and
now due to growing kernel Data structures it is allowed

http://kerneltrap.org/node/6404

http://kerneltrap.org/node/8206


Regards

Kishore


On Thu, Jun 21, 2012 at 5:57 PM, Vijay Chauhan kernel.vi...@gmail.comwrote:

 Hello,

 I am newbie.
 It has been said kernel memory is not pageable
 What does it mean? There is no concept of kernel virtual address?

 Any simple explanation will help me to udnerstand.

 Thanks,
 Vijay

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: download the source code of some commands

2012-06-21 Thread AFT
王哲 wangzhe5...@gmail.com writes:

   Hi all:
I want to see some source code of some commands,for
 example,halt,reboot,uptime,and so on.

 but i don't kown where to download?   can you give me some advice?


 Thanks in advance!

Hi,

Although this does not relate to kernel, you can still view the codes of
common linux/unix commands. ftp.gnu.org hosts most of commands in
different packaging. Like coreutils, findutils, netutils etc. And
standalone codes are there for grep, ed etc. 

You can also get a copy of freebsd dvd. Freebsd dvd's comes with full
source code of the core system.

cheers.

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel Memory

2012-06-21 Thread Arun KS
Hello Vijay,

On Thu, Jun 21, 2012 at 5:57 PM, Vijay Chauhan kernel.vi...@gmail.com wrote:
 Hello,

 I am newbie.
 It has been said kernel memory is not pageable
 What does it mean? There is no concept of kernel virtual address?
You might have heard about 3G/1G split. This 1GB is the virtual
address of the kernel. And whenever kernel try to access any address
in this range(for ARM architecture it is  0xC000 - 0x),
there should not be any page fault. That means MMU should be able to
convert your virtual address to physical. This 1GB contains your IO
address, RAM address.

Paging is a mechanism OS uses to pull the data(in pagesizes) to and
fro between system RAM and secondary memory.
Kernel memory is not pageable. This means memory allocated for the
kernel will not be pagged out. If you try to access any memory in
kernel with out creating page tables(this can be done by ioremap) you
will end up in OOPS. The main reason of kernel not being swapable or
pageable is as follows.
Think this way. What will happen if we have paged out that portion of
the logic which decides what to do when a page fault occurs? Who will
take care of the page fault then?

But if a user program hit a page fault(ie accessed address is not in
main memory), kernel will load the page from secondary memory if it is
a valid address. And if the address accesses is illegal, kernel kill
the user application(Segmentation fault).

Thanks,
Arun


 Any simple explanation will help me to udnerstand.

 Thanks,
 Vijay

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kernel Memory

2012-06-21 Thread AFT
Vijay Chauhan kernel.vi...@gmail.com writes:

 Hello,

 I am newbie.
 It has been said kernel memory is not pageable
 What does it mean? There is no concept of kernel virtual address?


Yes. Kernel works on static adress space.

 Any simple explanation will help me to udnerstand.


I'm not sure if you want to understand how kernel manages memory for
its internal DS. If its the case you should read the following
documents.

1) Read the chapter 8 of Linux Device driver 3rd edition.

http://lwn.net/Kernel/LDD3/

2) To understand slab allocator read the following papers by bonwick

   a) 94 paper describing slab allocator:
   
   
http://static.usenix.org/publications/library/proceedings/bos94/full_papers/bonwick.a

   b) Its followup in 2001
   
   
http://static.usenix.org/event/usenix01/full_papers/bonwick/bonwick_html/index.html

3) These should be enough. But if you want to know detailed architecture
of how virtual memory manager work you should read Gorman's book on
Linux virtual memory manager. Its a free pdf. can be found here:

http://ptgmedia.pearsoncmg.com/images/0131453483/downloads/gorman_book.pdf

Happy hacking.

Cheers
aft


 Thanks,
 Vijay

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



RE: download the source code of some commands

2012-06-21 Thread jeshwanth Kumar N K
Hello 

U can download coreutils from gnu.org.

Sent from my HTC

--

Send Kernelnewbies mailing list submissions to
kernelnewbies@kernelnewbies.org

To subscribe or unsubscribe via the World Wide Web, visit
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
or, via email, send a message with subject or body 'help' to
kernelnewbies-requ...@kernelnewbies.org

You can reach the person managing the list at
kernelnewbies-ow...@kernelnewbies.org

When replying, please edit your Subject line so it is more specific
than Re: Contents of Kernelnewbies digest...




Message: 1
Date: Thu, 21 Jun 2012 18:17:36 +0800
From: ?? lovelyl...@gmail.com
Subject: Re: [RFC] tcp: How does SACK or FACK determine the time to
start   fast retransmition?
To: Vijay Subramanian subramanian.vi...@gmail.com
Cc: netdev net...@vger.kernel.org, kernelnewbies@kernelnewbies.org
Message-ID: 4fe2f4c0.4020...@gmail.com
Content-Type: text/plain; charset=UTF-8; format=flowed

? 2012/6/21 16:42, Vijay Subramanian ??:
 With SACK, number of  dupacks does not have much meaning. What matters is
 --how the SACK scoreboard looks like i.e. which packets are tagged
 Lost/Sacked/Retransmitted
 -- Whether FACK is in use (this assumes holes in between sacked
 packets are lost and have left the network and so we can send out more
 packets)

 So, stack does not count the number of dupacks that have come in. Only
 SACK blocks matter.
 You can try to track the following path:
 tcp_ack() deals with incoming acks and if it sees a dupack (does not
 matter what number), or incoming packet contains SACK it calls
 tcp_fastretrans_alert() which calls  tcp_xmit_retransmit_queue().

 tcp_xmit_retransmit_queue() decides which packets to retransmit. The
 first packet to start retransmitting from is tracked in
 tp-retransmit_skb_hint.
 Note that the dupThresh is actually tracked by tp-reordering which
 measures  the reordering in the network and is not fixed at 3.  So, if
 more than
 tp-reordering packets have been acked above a given packet, this
 packet is a candidate for retransmisson. See tcp_mark_head_lost() to
 see how the
 reordering metric is used to mark packets as lost. This corresponds to
 the check you mentioned in the RFC.

 So, window permitting, packets are sent as follows;
 (a)-- Packets marked lost as per description above
 (b)-- new packets (if any)
 (c)-- Holes between sacked packets  which are not reliably lost.

 choice between (b) and (c) is made in tcp_can_forward_retransmit().

 Hope this helps.
 Vijay

It is just I wanted! Thanks for your detailed explaination and kindness.




--

Message: 2
Date: Thu, 21 Jun 2012 17:57:22 +0530
From: Vijay Chauhan kernel.vi...@gmail.com
Subject: Kernel Memory
To: kernelnewbies@kernelnewbies.org
Message-ID:
CAJ61zBA++CFmTHSb2cRr=ckjdtkvyssvs3_igesbbf21gwa...@mail.gmail.com
Content-Type: text/plain; charset=ISO-8859-1

Hello,

I am newbie.
It has been said kernel memory is not pageable
What does it mean? There is no concept of kernel virtual address?

Any simple explanation will help me to udnerstand.

Thanks,
Vijay



--

Message: 3
Date: Thu, 21 Jun 2012 20:48:48 +0800
From: ?? wangzhe5...@gmail.com
Subject: download the source code of some commands
To: kernelnewbies kernelnewbies@kernelnewbies.org
Message-ID:
cajrru3vhh719vzgccj3r8k842yemeo9d5_0swgqsgdnxe0v...@mail.gmail.com
Content-Type: text/plain; charset=iso-8859-1

  Hi all:
   I want to see some source code of some commands,for
example,halt,reboot,uptime,and so on.

but i don't kown where to download?   can you give me some advice?

Thanks in advance!
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120621/3a198ac7/attachment-0001.html
 

--

Message: 4
Date: Thu, 21 Jun 2012 05:53:00 -0700
From: ashish_bun...@dell.com
Subject: RE: download the source code of some commands
To: wangzhe5...@gmail.com, kernelnewbies@kernelnewbies.org
Message-ID:
a1a98fd909dc5248811a65c5d18e9c7635de8be...@blrx7mcdc202.amer.dell.com

Content-Type: text/plain; charset=iso-2022-jp

All commands are bin files. You should find the scripts for them in /usr/bin 
only.

Ashish Bunkar
Linux Engineering
Dell | BDC
office +91-80-28078131,  mobile +91-7259183696
ashish_bun...@dell.commailto:narayana...@dell.com



From: kernelnewbies-boun...@kernelnewbies.org 
[mailto:kernelnewbies-boun...@kernelnewbies.org] On Behalf Of ??
Sent: Thursday, June 21, 2012 6:19 PM
To: kernelnewbies
Subject: download the source code of some commands

  Hi all:
   I want to see some source code of some commands,for 
example,halt,reboot,uptime,and so on.

but i don't kown where to download?   can you give me some advice?

Thanks in advance!
-- next part --
An HTML attachment was scrubbed...
URL: 
http

could some current.h files be simplified?

2012-06-21 Thread Robert P. J. Day

  it *seems* as if a number of current.h files from various
architectures could be simplified.  here's asm-generic/current.h,
which gives any architecture a generic starting point in defining both
get_current() and current:

#ifndef __ASM_GENERIC_CURRENT_H
#define __ASM_GENERIC_CURRENT_H

#include linux/thread_info.h

#define get_current() (current_thread_info()-task)
#define current get_current()

#endif /* __ASM_GENERIC_CURRENT_H */

  and if that's acceptable, any architecture is welcome to simply
include it as, for instance, mips does in asm/current.h:

#include asm-generic/current.h

but here's the current.h file for parisc:

#ifndef _PARISC_CURRENT_H
#define _PARISC_CURRENT_H

#include linux/thread_info.h

struct task_struct;

static inline struct task_struct * get_current(void)
{
return current_thread_info()-task;
}

#define current get_current()

#endif /* !(_PARISC_CURRENT_H) */

  i'm not sure i see why the generic version wasn't adequate for
parisc (apart from the explicit pointer casting).  same thing with the
cris architecture and, i'm sure, others.

  is there any reason why some of those current.h files can't just
include the generic one?

rday

-- 


Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca

Twitter:   http://twitter.com/rpjday
LinkedIn:   http://ca.linkedin.com/in/rpjday


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: download the source code of some commands

2012-06-21 Thread Wang Lei
If you use Debian or other distribution with apt package system.

You can use whereis to locate this command.
[~]$ whereis halt
halt: /sbin/halt /usr/share/man/man5/halt.5.gz /usr/share/man/man8/halt.8.gz

Then, use dpkg -S to show which package it's included. This one is: sysvinit.
[~]$ dpkg -S /sbin/halt
sysvinit: /sbin/halt

Now, you can download the source from Debian source, use:
[~]$ apt-get source sysvinit

Or if you want the original source, use aptitude (or apt-cache) find
it's homepage.
[~]$ aptitude show sysvinit
Package: sysvinit
..
Homepage: http://savannah.nongnu.org/projects/sysvinit

At last, get it from there. As for other package systems, I think there
should be a way too. Or you can google.
 
On 2012-06-21 20:48:48 +0800, 王哲 wrote:
   Hi all:
I want to see some source code of some commands,for
 example,halt,reboot,uptime,and so on.

 but i don't kown where to download?   can you give me some advice?

 Thanks in advance!
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-- 
Regards,
Lei

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: download the source code of some commands

2012-06-21 Thread 王哲
2012/6/21 Wang Lei f3d...@gmail.com

 If you use Debian or other distribution with apt package system.

 You can use whereis to locate this command.
 [~]$ whereis halt
 halt: /sbin/halt /usr/share/man/man5/halt.5.gz
 /usr/share/man/man8/halt.8.gz

 Then, use dpkg -S to show which package it's included. This one is:
 sysvinit.
 [~]$ dpkg -S /sbin/halt
 sysvinit: /sbin/halt

 Now, you can download the source from Debian source, use:
 [~]$ apt-get source sysvinit

 Or if you want the original source, use aptitude (or apt-cache) find
 it's homepage.
 [~]$ aptitude show sysvinit
 Package: sysvinit
 ..
 Homepage: http://savannah.nongnu.org/projects/sysvinit

 At last, get it from there. As for other package systems, I think there
 should be a way too. Or you can google.


   Thank you very much !  i follow your steps, and download the source code
successfully.

On 2012-06-21 20:48:48 +0800, 王哲 wrote:
   Hi all:
I want to see some source code of some commands,for
 example,halt,reboot,uptime,and so on.

 but i don't kown where to download?   can you give me some advice?

 Thanks in advance!

  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

 --
 Regards,
 Lei

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Sysfs class attribute problem

2012-06-21 Thread Jeshwanth Kumar N K Jeshu
Hello Anish

Thank you for the changes. Ya now I understoor dealing with store function.
:)
And I did small change in ur code.

I have declared the show and store function as I declared before.

static ssize_t attr1_store(struct class *cls, struct class_attribute *attr,
const char *buf, size_t count);
static ssize_t attr1_show(struct class *cls, struct class_attribute *attr,
char *buf);

instead.

static ssize_t attr1_store(struct class *cls, const char *buf, size_t
count);
static ssize_t attr1_show(struct class *cls, char *buf);

After this its working fine.





On Thu, Jun 21, 2012 at 9:04 AM, anish singh anish198519851...@gmail.comwrote:

 On Wed, Jun 20, 2012 at 11:32 PM, Jeshwanth Kumar N K Jeshu
 jeshkumar...@gmail.com wrote:
  Hello
 
  Thank you anish for the reply, the code is I pasted below.
  [code-starts]
 
  #include linux/init.h
  #include linux/module.h
  #include linux/kernel.h
  #include linux/fs.h
  #include linux/device.h
  #include linux/sysdev.h
  #include linux/major.h
  #include asm/uaccess.h
  #include linux/slab.h
  #include linux/cdev.h
  #include linux/kdev_t.h
 
  static char *gvar = BeHonest;
  // Store and Show functions..
   static ssize_t attr1_store(struct class *cls, struct class_attribute
 *attr,
  const char *buf, size_t count);
   static ssize_t attr1_show(struct class *cls, struct class_attribute
 *attr,
  char *buf);
 
  static struct class_attribute pwm_class_attrs[] = {
  __ATTR(attr1, S_IRUGO | S_IWUSR , attr1_show, attr1_store),
  __ATTR_NULL
  };
 
  static struct class pwm_class =
  {
  .name = dev_jes,
  .owner = THIS_MODULE,
  .class_attrs = pwm_class_attrs
  };
 
 
  static int hello_init(void)
  {
  class_register(pwm_class);
  printk(In hello_init function \n);
 
  return 0;
  }
 
  static ssize_t attr1_show(struct class *cls, struct class_attribute
 *attr,
  char *buf)
  {
 
  printk(In attr1_show function\n);
  return sprintf(buf, %s\n, gvar);
  }
 
  static ssize_t attr1_store(struct class *cls, struct class_attribute
 *attr,
  const char *buf, size_t count)
  {
  printk(the string is : %s\n,buf);
  printk(In attr1_store function\n);
  return 1;
  //return sprintf(gvar, %s\n, buf);  --- If I put this line
 I
  am getting ERROR :(
  }
 
 
  static void  hello_exit(void)
  {
  class_unregister(pwm_class);
  printk(In hello_exit function \n);
  }
 
  module_init(hello_init);
  module_exit(hello_exit);
 
  MODULE_LICENSE(GPL);
  MODULE_AUTHOR(Jeshwanth);
  MODULE_DESCRIPTION(Learning sysfs);
 
  [code-ends]
 
  echo jeshu  /sys/class/dev_jes/attr1
 
  And If I pass the command to atttribute I got result below in dmesg.
 
  [ 3435.613057] the string is : jeshu
  [ 3435.613061]
  [ 3435.613066] In attr1_store function
  [ 3435.613072] the string is : eshu
  [ 3435.613074]
  [ 3435.613078] In attr1_store function
  [ 3435.613083] the string is : shu
  [ 3435.613085]
  [ 3435.613088] In attr1_store function
  [ 3435.613093] the string is : hu
  [ 3435.613095]
  [ 3435.613098] In attr1_store function
  [ 3435.613103] the string is : u
  [ 3435.613105]
  [ 3435.613108] In attr1_store function
  [ 3435.613113] the string is :
  [ 3435.613115]
  [ 3435.613118] In attr1_store function
 
 
  So please help me how to read the attribute in store function.. Thanks :)
 #include linux/init.h
 #include linux/module.h
 #include linux/kernel.h
 #include linux/fs.h
 #include linux/device.h
 #include linux/sysdev.h
 #include linux/major.h
 #include asm/uaccess.h
 #include linux/slab.h
 #include linux/cdev.h
 #include linux/kdev_t.h

 static char *gvar = NULL;
 static ssize_t attr1_store(struct class *cls, const char *buf, size_t
 count);
 static ssize_t attr1_show(struct class *cls, char *buf);

 static struct class_attribute pwm_class_attrs[] = {
 __ATTR(attr1, 0666, attr1_show, attr1_store), //use macro for
 permission
 __ATTR_NULL
 };

 static struct class pwm_class =
 {
.name = dev_jes,
.owner = THIS_MODULE,
.class_attrs = pwm_class_attrs
 };


 static int hello_init(void)
 {
 char string[] = nothing;
gvar = kmalloc(sizeof(char)*strlen(string), GFP_KERNEL);
class_register(pwm_class);
snprintf(gvar, sizeof(char)*strlen(string)+1, %s, string);
printk(anish In hello_init function \n);
return 0;
 }

 static ssize_t attr1_show(struct class *cls, char *buf)
 {

printk(In attr1_show function\n);
 printk(%s\n, gvar);
 printk(In attr1_show function\n);
 return sprintf(buf, %s, gvar);
 }

 static ssize_t attr1_store(struct class *cls, const char *buf, size_t
 count)
 {
printk(the string is : %s count %d\n, buf, count);
return snprintf(gvar, count, %s\n, buf);
 }


 static void  hello_exit(void)
 {
class_unregister(pwm_class);
printk(In hello_exit function \n);
 }

 module_init(hello_init);
 module_exit(hello_exit);

 

Re: Kernelnewbies Digest, Vol 19, Issue 43

2012-06-21 Thread zhaoqiao
 Debian source, use:
 [~]$ apt-get source sysvinit

 Or if you want the original source, use aptitude (or apt-cache) find
 it's homepage.
 [~]$ aptitude show sysvinit
 Package: sysvinit
 ..
 Homepage: http://savannah.nongnu.org/projects/sysvinit

 At last, get it from there. As for other package systems, I think there
 should be a way too. Or you can google.

 On 2012-06-21 20:48:48 +0800, ?? wrote:
Hi all:
 I want to see some source code of some commands,for
  example,halt,reboot,uptime,and so on.
 
  but i don't kown where to download?   can you give me some advice?
 
  Thanks in advance!
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

 --
 Regards,
 Lei



 --

 Message: 4
 Date: Thu, 21 Jun 2012 23:46:21 +0800
 From: ?? wangzhe5...@gmail.com
 Subject: Re: download the source code of some commands
 To: Wang Lei f3d...@gmail.com
 Cc: kernelnewbies kernelnewbies@kernelnewbies.org
 Message-ID:
cajrru3xdps620joe+q8w+siugvr3czzjohzg3e+pwssu5t0...@mail.gmail.com
 
 Content-Type: text/plain; charset=gb2312

 2012/6/21 Wang Lei f3d...@gmail.com

  If you use Debian or other distribution with apt package system.
 
  You can use whereis to locate this command.
  [~]$ whereis halt
  halt: /sbin/halt /usr/share/man/man5/halt.5.gz
  /usr/share/man/man8/halt.8.gz
 
  Then, use dpkg -S to show which package it's included. This one is:
  sysvinit.
  [~]$ dpkg -S /sbin/halt
  sysvinit: /sbin/halt
 
  Now, you can download the source from Debian source, use:
  [~]$ apt-get source sysvinit
 
  Or if you want the original source, use aptitude (or apt-cache) find
  it's homepage.
  [~]$ aptitude show sysvinit
  Package: sysvinit
  ..
  Homepage: http://savannah.nongnu.org/projects/sysvinit
 
  At last, get it from there. As for other package systems, I think there
  should be a way too. Or you can google.
 

   Thank you very much !  i follow your steps, and download the source code
 successfully.

 On 2012-06-21 20:48:48 +0800, ?? wrote:
Hi all:
 I want to see some source code of some commands,for
  example,halt,reboot,uptime,and so on.
 
  but i don't kown where to download?   can you give me some advice?
 
  Thanks in advance!

   ___
   Kernelnewbies mailing list
   Kernelnewbies@kernelnewbies.org
   http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 
  --
  Regards,
  Lei
 
 -- next part --
 An HTML attachment was scrubbed...
 URL:
 http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120621/6e586022/attachment-0001.html

 --

 Message: 5
 Date: Thu, 21 Jun 2012 17:48:25 +0200
 From: mic...@michaelblizek.twilightparadox.com
 Subject: Re: Kernel Memory
 To: Vijay Chauhan kernel.vi...@gmail.com
 Cc: kernelnewbies@kernelnewbies.org
 Message-ID: 20120621154824.GA2280@grml
 Content-Type: text/plain; charset=us-ascii

 Hi!

 On 17:57 Thu 21 Jun , Vijay Chauhan wrote:
  Hello,
 
  I am newbie.
  It has been said kernel memory is not pageable
  What does it mean? There is no concept of kernel virtual address?
 
  Any simple explanation will help me to udnerstand.

 The right term is actually kernel memory is not swappable. Swapping means
 writing inactive memory to disk and then using it for something else.
 Kernel
 memory not being swappable is a design decicion made in the early linux
 days.
 Operating systems which swap kernel memory need to isolate everything which
 should not be swappd out (e.g. things needed for swap-in, realtime stuff,
 security sensitive data, ...). This is quite a bit of work. I also guess
 it is
 pretty pointless nowadays. Installed memory and is getting so huge that
 virtual
 memory developers have a hard time trying to keep cpu-usage overhead for
 swapping user space memory low.

  There is no concept of kernel virtual address?

 Kernel memory uses virtual addresses as well. However, these the entire
 system
 memory is continuously mapped somewhere in the virtual address space. The
 drawback is that fragmentation turns allocation of large continuous memory
 regions into a game of luck.

 There is also an virtual address area (vmalloc) which is used to
 dynamically
 map multiple scattered pages to a continuous region. But this is rather
 slow
 and rarely used.

 You might want to take a look at: http://lwn.net/Kernel/LDD3/

-Michi
 --
 programing a layer 3+4 network protocol for mesh networks
 see http://michaelblizek.twilightparadox.com



 --

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


 End of Kernelnewbies Digest, Vol 19, Issue 43