* Which process is associated with process ID 0 (swapper) @ 2006-04-20 14:58 Mikado 2006-04-20 15:30 ` linux-os (Dick Johnson) 0 siblings, 1 reply; 19+ messages in thread From: Mikado @ 2006-04-20 14:58 UTC (permalink / raw) To: linux-kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 When a process make a connection to one server, if the server doesn't respond, the swapper process (PID 0) will re-send SYN packet automatically. How can I know which socket/process that re-sent SYN packet belongs to. Thanks in advance, Mikado. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFER6GeNWc9T2Wr2JcRAsOMAJ9uQze/hsDkzMsXUurVFcbKg/XcUQCgi/1H c5HttDSP5AboaMe5N4FJPno= =S8U+ -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 14:58 Which process is associated with process ID 0 (swapper) Mikado @ 2006-04-20 15:30 ` linux-os (Dick Johnson) 2006-04-20 15:48 ` Mike Galbraith ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: linux-os (Dick Johnson) @ 2006-04-20 15:30 UTC (permalink / raw) To: Mikado; +Cc: Linux kernel On Thu, 20 Apr 2006, Mikado wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > When a process make a connection to one server, if the server doesn't > respond, the swapper process (PID 0) will re-send SYN packet > automatically. How can I know which socket/process that re-sent SYN > packet belongs to. > > Thanks in advance, > Mikado. This must be a trick question. Linux is not VAX/VMS. There is no swapper process. Check in /proc. Processes start at 1. Even kernel threads have PIDs greater than 1. Portions of the kernel networking code operate detached. The code gets the CPU from a timer queue or from an interrupt. When an connection is attempted, the process attempting the connection is either waiting, with its CPU time being used, or put to sleep, while the timer queue's CPU time is being used. The SYN/ACK handshake is handled during this time, therefore it is possible to find who is attempting that connection. Netstat gets that information from /proc/net and multiple socket calls. Cheers, Dick Johnson Penguin : Linux version 2.6.16.4 on an i686 machine (5592.89 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _ \x1a\x04 **************************************************************** The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them. Thank you. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 15:30 ` linux-os (Dick Johnson) @ 2006-04-20 15:48 ` Mike Galbraith 2006-04-20 16:04 ` Mikado 2006-04-20 22:06 ` Jan Engelhardt 2 siblings, 0 replies; 19+ messages in thread From: Mike Galbraith @ 2006-04-20 15:48 UTC (permalink / raw) To: linux-os (Dick Johnson); +Cc: Mikado, Linux kernel On Thu, 2006-04-20 at 11:30 -0400, linux-os (Dick Johnson) wrote: > This must be a trick question. Linux is not VAX/VMS. There is no > swapper process. Check in /proc. Processes start at 1. Even > kernel threads have PIDs greater than 1. include/linux/init_task.h .pgd = swapper_pg_dir, .comm = "swapper", You don't make enough nuclear powered kernels :) -Mike ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 15:30 ` linux-os (Dick Johnson) 2006-04-20 15:48 ` Mike Galbraith @ 2006-04-20 16:04 ` Mikado 2006-04-20 16:39 ` Joshua Hudson 2006-04-20 22:10 ` Jan Engelhardt 2006-04-20 22:06 ` Jan Engelhardt 2 siblings, 2 replies; 19+ messages in thread From: Mikado @ 2006-04-20 16:04 UTC (permalink / raw) To: linux-os (Dick Johnson); +Cc: Linux kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 linux-os (Dick Johnson) wrote: > This must be a trick question. Linux is not VAX/VMS. There is no > swapper process. Check in /proc. Processes start at 1. Even > kernel threads have PIDs greater than 1. Linux really has swapper process ;) > Portions of the kernel networking code operate detached. The code > gets the CPU from a timer queue or from an interrupt. When an > connection is attempted, the process attempting the connection > is either waiting, with its CPU time being used, or put to > sleep, while the timer queue's CPU time is being used. The > SYN/ACK handshake is handled during this time, therefore it > is possible to find who is attempting that connection. Netstat > gets that information from /proc/net and multiple socket > calls. I'm writing kernel module that hooks into netfilter code. I can catch packet's information and its owner process. The first SYN packet of handshaking belongs to real user-space socket/process. After timeout, several SYN packets are generated by kernel-space swapper process (PID 0) Is there anyway to find out the relationship between them in _kernel_space_ (module context). Thanks, Mikado. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFER7EQNWc9T2Wr2JcRAkHYAJ9HFfmHjzTRTIDhCPSI12wgWxKAjQCfXh1R UAeStFg9Wqk+rJJDGr+WI5c= =lbpv -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 16:04 ` Mikado @ 2006-04-20 16:39 ` Joshua Hudson 2006-04-20 22:10 ` Jan Engelhardt 1 sibling, 0 replies; 19+ messages in thread From: Joshua Hudson @ 2006-04-20 16:39 UTC (permalink / raw) To: linux-kernel On 4/20/06, Mikado <mikado4vn@gmail.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > linux-os (Dick Johnson) wrote: > > This must be a trick question. Linux is not VAX/VMS. There is no > > swapper process. Check in /proc. Processes start at 1. Even > > kernel threads have PIDs greater than 1. > > Linux really has swapper process ;) > > > Portions of the kernel networking code operate detached. The code > > gets the CPU from a timer queue or from an interrupt. When an > > connection is attempted, the process attempting the connection > > is either waiting, with its CPU time being used, or put to > > sleep, while the timer queue's CPU time is being used. The > > SYN/ACK handshake is handled during this time, therefore it > > is possible to find who is attempting that connection. Netstat > > gets that information from /proc/net and multiple socket > > calls. > > I'm writing kernel module that hooks into netfilter code. I can catch > packet's information and its owner process. The first SYN packet of > handshaking belongs to real user-space socket/process. After timeout, > several SYN packets are generated by kernel-space swapper process (PID > 0) Is there anyway to find out the relationship between them in > _kernel_space_ (module context). > I would recommend walking the list of sockets, and see what process(es) own the socket that is bound to that quad (host IP, port; foreigh IP, port). A better design might just be to hook connect(), but think hard on that one. If you do it, your module cannot be removed. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 16:04 ` Mikado 2006-04-20 16:39 ` Joshua Hudson @ 2006-04-20 22:10 ` Jan Engelhardt 2006-04-20 22:15 ` Hua Zhong ` (2 more replies) 1 sibling, 3 replies; 19+ messages in thread From: Jan Engelhardt @ 2006-04-20 22:10 UTC (permalink / raw) To: Mikado; +Cc: linux-os (Dick Johnson), Linux kernel >> This must be a trick question. Linux is not VAX/VMS. There is no >> swapper process. Check in /proc. Processes start at 1. Even >> kernel threads have PIDs greater than 1. > >Linux really has swapper process ;) > To be precise, it has more than one. When you hit an OOPS, the trace [1] might show: "Pid: 0, comm: swapper Not tainted 2.6.11.6" Plus you see one of these per CPU [ps aufwwx]: root 106 0.0 0.0 0 0 ? S Apr20 0:04 [kswapd0] So, a question to the public: what swapper swaps, and what's swapper(as in pid 0) in oops, if there's no PID 0? >I'm writing kernel module that hooks into netfilter code. I can catch >packet's information and its owner process. The first SYN packet of >handshaking belongs to real user-space socket/process. After timeout, >several SYN packets are generated by kernel-space swapper process (PID >0) Is there anyway to find out the relationship between them in >_kernel_space_ (module context). > Is your code doing it like ipt_owner does? [1] http://www.ussg.iu.edu/hypermail/linux/kernel/0504.0/0416.html Jan Engelhardt -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: Which process is associated with process ID 0 (swapper) 2006-04-20 22:10 ` Jan Engelhardt @ 2006-04-20 22:15 ` Hua Zhong 2006-04-20 22:19 ` Jan Engelhardt 2006-04-20 23:19 ` Mikado 2006-04-20 23:35 ` Mikado 2 siblings, 1 reply; 19+ messages in thread From: Hua Zhong @ 2006-04-20 22:15 UTC (permalink / raw) To: 'Jan Engelhardt', 'Mikado' Cc: 'linux-os (Dick Johnson)', 'Linux kernel' > >Linux really has swapper process ;) > > > To be precise, it has more than one. > > When you hit an OOPS, the trace [1] might show: > "Pid: 0, comm: swapper Not tainted 2.6.11.6" > > Plus you see one of these per CPU [ps aufwwx]: > root 106 0.0 0.0 0 0 ? S Apr20 > 0:04 [kswapd0] > > So, a question to the public: what swapper swaps, and what's > swapper(as in pid 0) in oops, if there's no PID 0? Swapper is the idle process, which swaps nothing. Its name is historic and it doesn't appear in /proc because for_each_process() skips it. Kswapd is totally different. ^ permalink raw reply [flat|nested] 19+ messages in thread
* RE: Which process is associated with process ID 0 (swapper) 2006-04-20 22:15 ` Hua Zhong @ 2006-04-20 22:19 ` Jan Engelhardt 2006-04-20 23:12 ` Mikado 0 siblings, 1 reply; 19+ messages in thread From: Jan Engelhardt @ 2006-04-20 22:19 UTC (permalink / raw) To: Hua Zhong Cc: 'Mikado', 'linux-os (Dick Johnson)', 'Linux kernel' > >Swapper is the idle process, which swaps nothing. Its name is historic and it doesn't appear in /proc because for_each_process() >skips it. > Anyone objecting to renaming it? Jan Engelhardt -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 22:19 ` Jan Engelhardt @ 2006-04-20 23:12 ` Mikado 2006-04-21 12:46 ` Jan Engelhardt 0 siblings, 1 reply; 19+ messages in thread From: Mikado @ 2006-04-20 23:12 UTC (permalink / raw) To: Jan Engelhardt Cc: 'Linux kernel', linux-os (Dick Johnson), Mike Galbraith, Hua Zhong -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jan Engelhardt wrote: >> Swapper is the idle process, which swaps nothing. Its name is historic and it doesn't appear in /proc because for_each_process() >> skips it. >> > Anyone objecting to renaming it? > > > Jan Engelhardt Please focus on my main question. Thank you! Mikado. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFESBVxNWc9T2Wr2JcRAseYAJ9Fd8/IN9pk/iAYQYc1MXHxt/T9WgCgmFpx j3wvQBiYBmDjPO1q4Rc8OB8= =eNTU -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 23:12 ` Mikado @ 2006-04-21 12:46 ` Jan Engelhardt 0 siblings, 0 replies; 19+ messages in thread From: Jan Engelhardt @ 2006-04-21 12:46 UTC (permalink / raw) To: Mikado Cc: 'Linux kernel', linux-os (Dick Johnson), Mike Galbraith, Hua Zhong >>> Swapper is the idle process, which swaps nothing. Its name is historic and it doesn't appear in /proc because for_each_process() >>> skips it. >>> >> Anyone objecting to renaming it? > >Please focus on my main question. Thank you! > Hey, you're not the only one on this list. Jan Engelhardt -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 22:10 ` Jan Engelhardt 2006-04-20 22:15 ` Hua Zhong @ 2006-04-20 23:19 ` Mikado 2006-04-20 23:35 ` Mikado 2 siblings, 0 replies; 19+ messages in thread From: Mikado @ 2006-04-20 23:19 UTC (permalink / raw) To: Jan Engelhardt; +Cc: Linux kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jan Engelhardt wrote: > Is your code doing it like ipt_owner does? Something like that. When I receive packet info, I'll take PID by attracting current->pid -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFESBcTNWc9T2Wr2JcRAuZcAJwKhY0vjUCxLGpqkkWOjBgnxj9MpQCgrxGu li8yXqS6hFTiRYW2MuCBwxI= =jfmh -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 22:10 ` Jan Engelhardt 2006-04-20 22:15 ` Hua Zhong 2006-04-20 23:19 ` Mikado @ 2006-04-20 23:35 ` Mikado 2006-04-21 0:37 ` Patrick McHardy 2 siblings, 1 reply; 19+ messages in thread From: Mikado @ 2006-04-20 23:35 UTC (permalink / raw) To: Jan Engelhardt; +Cc: Linux kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jan Engelhardt wrote: > Is your code doing it like ipt_owner does? It seems that ipt_owner does _not_ support PID match anymore: In /usr/src/linux/net/ipv4/netfilter/ipt_owner.c: ... if (info->match & (IPT_OWNER_PID|IPT_OWNER_SID|IPT_OWNER_COMM)) { printk("ipt_owner: pid, sid and command matching " "not supported anymore\n"); return 0; } ... My main objective simply works on single-processor machine, I haven't intend to do it on SMP one. Mikado. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFESBrONWc9T2Wr2JcRAnSiAJ9oAMtw0zZ0TcmnSXciuHmWry0sXACfT6M1 o86fk6onyQo/CVz9xIwZK1E= =e9qN -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 23:35 ` Mikado @ 2006-04-21 0:37 ` Patrick McHardy 2006-04-21 1:33 ` Mikado 2006-04-21 12:48 ` Jan Engelhardt 0 siblings, 2 replies; 19+ messages in thread From: Patrick McHardy @ 2006-04-21 0:37 UTC (permalink / raw) To: mikado4vn; +Cc: Jan Engelhardt, Linux kernel Mikado wrote: > Jan Engelhardt wrote: > >>>Is your code doing it like ipt_owner does? > > > It seems that ipt_owner does _not_ support PID match anymore: Yes, it was removed for two reasons: - it used tasklist_lock from bh-context, resulting in deadlocks - there is no 1:1 mapping between sockets (or packets) and processes. If you use corking even a single packet can be created in cooperation by multiple processes. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-21 0:37 ` Patrick McHardy @ 2006-04-21 1:33 ` Mikado 2006-04-21 3:16 ` Bernd Eckenfels 2006-04-21 12:48 ` Jan Engelhardt 1 sibling, 1 reply; 19+ messages in thread From: Mikado @ 2006-04-21 1:33 UTC (permalink / raw) To: Patrick McHardy; +Cc: Linux kernel -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Patrick McHardy wrote: > - there is no 1:1 mapping between sockets (or packets) and > processes. If you use corking even a single packet can be > created in cooperation by multiple processes. Single packet is created by multiple processes? Can you show me some examples? Mikado. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFESDZoNWc9T2Wr2JcRAp79AJ0eYjeA63dNZnRQ66eKVYhKU8NtRACfcONb wmo/IW+Yr7zuCXH09qDjq3I= =XChU -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-21 1:33 ` Mikado @ 2006-04-21 3:16 ` Bernd Eckenfels 0 siblings, 0 replies; 19+ messages in thread From: Bernd Eckenfels @ 2006-04-21 3:16 UTC (permalink / raw) To: linux-kernel Mikado <mikado4vn@gmail.com> wrote: > Single packet is created by multiple processes? Can you show me some > examples? cork to combine headers with sendfile content? Well, I dont think those cases are important :) Gruss Bernd ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-21 0:37 ` Patrick McHardy 2006-04-21 1:33 ` Mikado @ 2006-04-21 12:48 ` Jan Engelhardt 2006-04-21 12:52 ` Jan Engelhardt 1 sibling, 1 reply; 19+ messages in thread From: Jan Engelhardt @ 2006-04-21 12:48 UTC (permalink / raw) To: Patrick McHardy; +Cc: mikado4vn, Linux kernel >>>>Is your code doing it like ipt_owner does? >> >> It seems that ipt_owner does _not_ support PID match anymore: > >Yes, it was removed for two reasons: > >- it used tasklist_lock from bh-context, resulting in deadlocks >- there is no 1:1 mapping between sockets (or packets) and > processes. If you use corking even a single packet can be > created in cooperation by multiple processes. > Either way, I'd just be happy to match on "who created this socket" (don't need "who sends" ATM) without trying to set up SELinux... Jan Engelhardt -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-21 12:48 ` Jan Engelhardt @ 2006-04-21 12:52 ` Jan Engelhardt 2006-04-21 15:21 ` Mikado 0 siblings, 1 reply; 19+ messages in thread From: Jan Engelhardt @ 2006-04-21 12:52 UTC (permalink / raw) To: Patrick McHardy; +Cc: mikado4vn, Linux kernel >Either way, I'd just be happy to match on "who created this socket" (don't >need "who sends" ATM) without trying to set up SELinux... Which is... what seems remained in ipt_owner :D ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-21 12:52 ` Jan Engelhardt @ 2006-04-21 15:21 ` Mikado 0 siblings, 0 replies; 19+ messages in thread From: Mikado @ 2006-04-21 15:21 UTC (permalink / raw) To: Jan Engelhardt Cc: Linux kernel, linux-os (Dick Johnson), Mike Galbraith, Hua Zhong, Patrick McHardy, Michael Buesch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I found that "Fireflier" acts like ipt_owner. But I haven't tested it with this "swapper problem" [1] - http://edwintorok.googlepages.com/fireflier_kernel.html [2] - http://fireflier.isgeeky.com/wiki/What_is_fireflier [3] - http://fireflier.isgeeky.com/wiki/Kernel_module [4] - http://fireflier.isgeeky.com/wiki/Features -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFESPiQNWc9T2Wr2JcRAlPkAKCfZzgQAmWRBcmMJ3fcNQ2KkP2aEQCgu9q4 8gBeU287DTt17l4q+kSq1A4= =iyjA -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Which process is associated with process ID 0 (swapper) 2006-04-20 15:30 ` linux-os (Dick Johnson) 2006-04-20 15:48 ` Mike Galbraith 2006-04-20 16:04 ` Mikado @ 2006-04-20 22:06 ` Jan Engelhardt 2 siblings, 0 replies; 19+ messages in thread From: Jan Engelhardt @ 2006-04-20 22:06 UTC (permalink / raw) To: linux-os (Dick Johnson); +Cc: Mikado, Linux kernel >Subject: Re: Which process is associated with process ID 0 (swapper) > >This must be a trick question. Linux is not VAX/VMS. There is no >swapper process. Check in /proc. Processes start at 1. Even >kernel threads have PIDs greater than 1. > The initialization code which runs before the first userspace program is invoked (usually /sbin/init) could be termed 'process 0'. Jan Engelhardt -- ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2006-04-21 15:15 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-04-20 14:58 Which process is associated with process ID 0 (swapper) Mikado 2006-04-20 15:30 ` linux-os (Dick Johnson) 2006-04-20 15:48 ` Mike Galbraith 2006-04-20 16:04 ` Mikado 2006-04-20 16:39 ` Joshua Hudson 2006-04-20 22:10 ` Jan Engelhardt 2006-04-20 22:15 ` Hua Zhong 2006-04-20 22:19 ` Jan Engelhardt 2006-04-20 23:12 ` Mikado 2006-04-21 12:46 ` Jan Engelhardt 2006-04-20 23:19 ` Mikado 2006-04-20 23:35 ` Mikado 2006-04-21 0:37 ` Patrick McHardy 2006-04-21 1:33 ` Mikado 2006-04-21 3:16 ` Bernd Eckenfels 2006-04-21 12:48 ` Jan Engelhardt 2006-04-21 12:52 ` Jan Engelhardt 2006-04-21 15:21 ` Mikado 2006-04-20 22:06 ` Jan Engelhardt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox