Re: How to alloc memory in kernel on a specific numa node

2018-08-27 Thread Rami Rosen
Hi, all,

@Krishna Actually, I believe that in sone cases, allocating memory on a
specified Numa node can be of interest, especiallly in terms of
performance. For example, each PCI device is associated with a Numa node.
Projects like DPDK are NUMA aware in the sense that memory is allocated on
a specified NUMA node. This contributes to boost performance.

Regards,
Rami Rosen



בתאריך יום ב׳, 27 באוג׳ 2018, 11:30, מאת s.v.krishna reddy ‏<
svkr...@gmail.com>:

> How does it matter to allocate on specific node?
>
> Thanks,
> Krishna.
>
> On Tue, Aug 21, 2018 at 5:59 PM bing zhu  wrote:
>
>> Dear Sir / Ma'am:
>> Greeting ,Thank you for your time,I'm trying to alloc some memory on a
>> specific numa node (like cpu 0) ,but i'm new to linux kernel ,can someone
>> help me with some information ?please .
>> Thanks anyway
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Networking Internals Question

2018-06-16 Thread Rami Rosen
Hi Ravi,
The path that a packet goes through, from being received by the
network driver and up to kernel Layer 3 (IPV4/IPV6) and from
there to kernel Layer 4 (UDP/TCP/SCTP/other sockets) and from there to
userspace sockets is quite complex. The logic is heavy, on that path
there are lookups in routing tables, netfilter hooks, sanity checks,
interaction with other subsystems, and more.

In order to try to simplify things, and not go into deep technical
details, we can say that generally the 5 tuple of the packet (SRC
address, DST address, SRC port, DST port and protocol) is what
determines to which socket it will go.

Regards,
Rami Rosen
http://ramirose.wixsite.com/ramirosen




On 16 June 2018 at 20:16, V.Ravikumar  wrote:
> Hi All,
>
> I wanted to know how a packet received will be handovered to a correct user
> process.
> Basically I want to understand what are the various header parameters in
> packet which will help to  find the open socket descriptor  of respective
> user process. I'm not able to find the exact  answers in the web.
>
> Thanks in advance
>
> Regards,
> Ravi
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

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


Re: Importance of kobject

2017-05-17 Thread Rami Rosen
Hi,
Also sysfs is tied inherently to the kobject infrastructure. So I
suggest that you will take a look also in
http://elixir.free-electrons.com/linux/latest/source/Documentation/filesystems/sysfs.txt

Chapter 14 of Linux Device Drivers, 3rd edition, was written in 2005,
so you should take in account that things change a bit since then in
terms of implementation details. The principles are for a large extent
quite the same, though.

Regards,
Rami Rosen




On 17 May 2017 at 10:21, Alexander Kapshuk <alexander.kaps...@gmail.com> wrote:
> -- Forwarded message --
> From: Alexander Kapshuk <alexander.kaps...@gmail.com>
> Date: Wed, May 17, 2017 at 10:20 AM
> Subject: Re: Importance of kobject
> To: Madhu K <madhu.s...@gmail.com>
>
>
> On Wed, May 17, 2017 at 10:08 AM, Madhu K <madhu.s...@gmail.com> wrote:
>> Hi All,
>>
>> I am kernel newbie, I want to know the importance of kobject, can anybody
>> explain the importance of kobject with an example.
>>
>> Thanks in advance.
>> Madhu
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
> Kobjects play an essential role in the Device Model.
> The documentation below may be a good starting point in learning about 
> kobjects:
>
> https://lwn.net/images/pdf/LDD3/ch14.pdf
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/kobject.txt?h=v4.12-rc1
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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


Re: pls help in veth

2016-12-06 Thread Rami Rosen
Hi Er,

First, the veth modules should be in your kernel,  as it does exist in 3.14:
http://lxr.free-electrons.com/source/drivers/net/veth.c?v=3.14

It could be that the iprotue1 package you have does not support veth.
What does the version of iproute2 you have on your machine ? what is
the output of "ip -V"?
Also do you have man page of "ip link" ? and in case you have, please
run "man ip link"  and post here what you see in the "TYPE :="
section, you have veth,
Also, assuming you have access to the source tree where the kernel was
built, what do you get when running, from the root of this tree:
more .config | grep VETH

And finally - which distro is running on this device ?

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On 6 December 2016 at 18:25, Er Krishna <erkris...@gmail.com> wrote:
> Hi Rami,
>
> Thanks, some how I am able to manage all the details you asked :
>
> root@krishna:~# lsmod | grep veth
> root@krishna:~#
> root@krishna:~#
> root@krishna:~# uname -a
> Linux  3.14.55- #1 SMP PREEMPT  i686 GNU/Linux
> root@krishna:~#
> root@krishna:~#
> root@krishna:~# modprobe -r veth
> modprobe: FATAL: Module veth is builtin.
> root@krishna:~#
>
> Any suggestion from your end to enable this is most welcome.
>
> BR/Krish
>
> On Tue, Dec 6, 2016 at 9:18 PM, Er Krishna <erkris...@gmail.com> wrote:
>>
>> Thanks Rami for all the help. Yes lsmod shows that veth is not there.
>> Perhaps the kernel has not been compiled with config_veth option enable in
>> .config. Exact kernel version I will let you know tomorrow but most of the
>> chances its 4.* kernel. Its customized kernel I got from different team,
>> they have build it via yocto and I had to setup one network topology on it.
>>
>> BR/Krish
>>
>> On Tue, Dec 6, 2016 at 8:18 PM, Rami Rosen <roszenr...@gmail.com> wrote:
>>>
>>> Hi Eri,
>>> The driver is the veth driver, but it should be loaded automatically
>>> when running this
>>> command.
>>>
>>> What do you get when running:
>>>
>>> modprobe veth
>>>
>>> And what do you have when running
>>> lsmod | grep veth ?
>>>
>>> Which kernel are you working with ? can you paste the output of
>>> "uname -a"? is it a kernel you built from source, or a kernel which is
>>> part of a distro?
>>>
>>> Regards,
>>> Rami Rosen
>>> http://ramirose.wix.com/ramirosen
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On 6 December 2016 at 15:15, Er Krishna <erkris...@gmail.com> wrote:
>>> > Hi All,
>>> >
>>> > Can some one pls let me know for below command to run on linux which
>>> > driver
>>> > and which package I need to install ? I see I have iproute package
>>> > installed
>>> > on my box, but still I am facing below error.
>>> >
>>> > root@krishna:~# ip link add ep1 type veth peer name ep2
>>> > RTNETLINK answers: Operation not supported
>>> >
>>> > BR/Krish
>>> >
>>> > ___
>>> > Kernelnewbies mailing list
>>> > Kernelnewbies@kernelnewbies.org
>>> > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>> >
>>
>>
>

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


Re: pls help in veth

2016-12-06 Thread Rami Rosen
Hi Eri,
The driver is the veth driver, but it should be loaded automatically
when running this
command.

What do you get when running:

modprobe veth

And what do you have when running
lsmod | grep veth ?

Which kernel are you working with ? can you paste the output of
"uname -a"? is it a kernel you built from source, or a kernel which is
part of a distro?

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen










On 6 December 2016 at 15:15, Er Krishna <erkris...@gmail.com> wrote:
> Hi All,
>
> Can some one pls let me know for below command to run on linux which driver
> and which package I need to install ? I see I have iproute package installed
> on my box, but still I am facing below error.
>
> root@krishna:~# ip link add ep1 type veth peer name ep2
> RTNETLINK answers: Operation not supported
>
> BR/Krish
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

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


Re: an advise how to start

2016-11-26 Thread Rami Rosen
Hi Limor,
Regarding your question about bugs:
The Linux kernel has a Bugzilla:
You can browse it by a subsystem.
https://bugzilla.kernel.org/describecomponents.cgi

Regards,
Rami Rosen
http://ramirose.wixsite.com/ramirosen

Hi all,
 i am a senior c,c++ engineer which is used to complex MT systems both in
user space and in layer 4. i have read some books on the kernel, wondered
around kernel code and understood parts of it subsystems. i am really
enthutiastic about writing something within the kernel but i dont know
where to start. a good start for me would be list of bugs and small
features missing but i dont know where to find such updated list. i have
heard about the outreachy project and liked it but next cycle is only at
may, and even than i need to dedicate 3 full months without working and it
also seems like a students kind of program so i m not sure i will fit.
Is any has any idea how can i find list of bugs and small features to begin
with ?
I m great at understanding code and in sync mechanisms. i truly love the
rcu. i also love smp and cpu in general and  vm. i have an experience with
file systems , some experience with embeded and allot of background in
networks but  the kernel network internals is not a subsystem i have dived
into seriously yet ( even implemented tcp stack from scratch though for
some company i worked in. and it worked smoothly with great performance )
Any guidance will be appreciated.
Thanks
Limor.

Sent from Yahoo Mail on Android

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


Re: ip_hdr vs ipip_hdr

2016-08-18 Thread Rami Rosen
Hi Ricky,

ipip in the linux semantics refers usually to IP tunnel, for example:
http://lxr.free-electrons.com/source/net/ipv4/ipip.c

Traffic of ip tunnels is composed from an inner IP header which is
encapsulated within a packet which as the external IP header,

>(1) what is differences between ip_hdr and ipip_hdr? Why we have them? No 
>?>documentation whatever to figure it out.

ip_hdr() is the IP header of layer 3, the network

 ipip_hdr() is the IP header of layer 4, the transport layer. So this
is the IP header of the internal IP header when you have a tunnel, not
the external IP header.

Hope this helps,

Regards,
Rami Rosen

http://ramirose.wix.com/ramirosen

On 18 August 2016 at 11:47, Ricky <zhangchaow...@gmail.com> wrote:
>
> In include/linux/ip.h,
>
> 23 static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
> 24 {
> 25 return (struct iphdr *)skb_network_header(skb);
> 26 }
> 27
> 28 static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
> 29 {
> 30 return (struct iphdr *)skb_inner_network_header(skb);
> 31 }
> 32
> 33 static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
> 34 {
> 35 return (struct iphdr *)skb_transport_header(skb);
> 36 }
> 37 #endif  /* _LINUX_IP_H */
>
> if I passed in sk_buff to ip_hdr and ipip_hdr
>
> struct iphdr *ip_hdr ip_hdr_net = ip_hdr(skb);
> struct iphdr *ip_hdr ip_hdr_trans = ipip_hdr(skb);
>
> Do ip_hdr_net->saddr and ip_hdr_trans->saddr point to the same thing? I
> tried it on code. It doesn't. It seems that only ip_hdr_net->saddr point to
> source IP address, which make sense. Because network layer has IP but not on
> transport layer.
>
> So questions:
>
> (1) what is differences between ip_hdr and ipip_hdr? Why we have them? No
> documentation whatever to figure it out.
>
> (2) should I use ntohX function to convert ip_hdr member data when accessing
> them? eg, ip_hdr_net->saddr.
>
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

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


Re: Is there a way to force probe to be called (etherned driver) ?

2016-07-24 Thread Rami Rosen
Hi, Ran,

Do you define the probe as a member is a platform_driver object ?
See for example,
http://lxr.free-electrons.com/source/drivers/net/ethernet/marvell/mvneta.c#L4219

In this case, maybe something is missing/wrong in
platform_device_register();

or do you use a platfom_driver object ?
http://lxr.free-electrons.com/source/include/linux/platform_device.h#L180

In this case, maybe something is missing/wrong in platform_driver_register().

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen





In case you do, probably something is missing in your
platform_device_register() method (which may be in arch/arm/plat-...)

On 24 July 2016 at 11:51, Ran Shalit <ransha...@gmail.com> wrote:
> Hello,
>
>
> I write ethernet driver (mac controller is implemented in fpga connected to 
> cpu)
>
> I see that the probe is not called on doing insmod.
>
> Is there a way to force the probe to be called on doing insmod ?
>
> I could not find in the board file (omap dart, kernel 3.4.0) any
> reference to ethernet.
>
>
> Best Regards,
>
> Ran
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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


Re: Are these books outdated?

2016-07-14 Thread Rami Rosen
Hi Andrey,

>Here is link to Jessica McKellar's (LDD4 co-author) repo with examples
>for the next book.
>https://github.com/jesstess/ldd4

Thanks for the link, I was not aware of it !

Rami Rosen

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


Re: Are these books outdated?

2016-07-14 Thread Rami Rosen
Hi,
Since  there was a concern about that theses books are outdated, I
want to mention here also
a book title "Professional Linux Kernel Architecture", by Wolfganag
Maurer, Wiley, 2008, 1368 pages.
(I read it partially)
And also I agree with Robert saying that he wouldn't count on that
publication date of LDD4 by Oreilly,, since indeed the publication
date was postponed in the past (at least once but maybe more, I am
unsure about that)

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On 14 July 2016 at 15:26, Robert P. J. Day <rpj...@crashcourse.ca> wrote:
> On Thu, 14 Jul 2016, François wrote:
>
>> On Thu, Jul 14, 2016 at 02:01:55PM +0300, Aleksander Alekseev wrote:
>>
>> Hello Aleksander,
>>
>> I only know LDD 3:
>> > * Linux Device Drivers, 3rd Edition (2005)
>>
>> Since this book is freely available in PDF, I would advise you to
>> read it. It is out-dated (in sense you won't compile snippets as is)
>> but it is well written, and pleasant to read.
>>
>> The version 4 was scheduled for dec 2015 iirc, but is now annonced
>> for nov 2017 on O'Reilly's website.
>
>   i wouldn't count on that publication date. according to sources,
> nothing has been finalized.
>
> 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
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

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


Re: OS Error: 105

2016-07-13 Thread Rami Rosen
Hi, Shilpa,
Can you send the code/put it in pastebin and send the link ?

Rami Rosen


On 13 July 2016 at 15:20, Shilpa Yellapragada <yshilpa.1...@gmail.com> wrote:
> Hi,
>
> Can someone explain me why I am encountering an OS error 105, while
> trying to write to a socket?
>
> Regards,
> Shilpa
>
> --
> Shilpa Yellapragada
> Software Engineer
> Infinera India Pvt Ltd
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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


Re: Is there any good literature explaining Linux's file system ?

2016-07-10 Thread Rami Rosen
Hi, Ruan,

AFAIK, there is no book which is dedicated to the Linux kernel
implementation of Linux filesystems.

In "Understanding the Linux Kernel, 3rd Edition"
By Daniel P. Bovet, Marco Cesati
rhere is one chapter (chapter 18) of about 40 pages about the
implementation of Ext2 and Ext3.
Please keep in mind that ext3 was removed:
https://lwn.net/Articles/651645/

There is also a chapter about Virtual File System (VFS), even though
you did not asked about it. I believe that learning about VFS is
important in ordet to understand how particular filesystems like
ext2/ext3/btrfs work.

See:http://shop.oreilly.com/product/9780596005658.do


Also in "Professional Linux Kernel Architecture" by Wolfgang Mauerer,
Wiley Publishing, Inc., there is a chapter about the "The Extended
Filesystem Family" (chapter 9), and also a chapter about VFS (Chapter
8).

here is also a book titled "Linux Filesystems Paperback"
by William Von Hagen. I did not read it. However, it is really old
(2002!); 14 years are significant in Linux development.

Good luck!

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

On 10 July 2016 at 15:23, Yubin Ruan <ablacktsh...@gmail.com> wrote:
>  Hi everybody,
>  I'm really curious about whether there is any literature that
> describe Linux's file systems(e.g. ext2{3,4}, btrfs) deeply?
>  I can't find much literature about Linux's filesystem. I have read
> some papers about Unix's file system. For example, **A Fast File System
> for UNIX**, which explain things in detail(though not so informative for
> me). I also read **Design and Implementation of the Second Extend
> Filesystem** by Remy, Theodore, et al. But those papers and blogs can't
> make thing clear for me, because there are so many things that they have
> not explained.
>  I wonder is there any book that explain one of the Linux
> filesystem(design, implementation) in detail, like what Mal Gorman
> explain about Linux Memory Management in his books **Understand The
> Linux Memory Manager** and **Code Commentary On The Linux Virtual Memory
> Manager** ?
>
> Thanks in advance,
> Ruan.
>
> ___
> 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: boot param to change tick

2016-06-21 Thread Rami Rosen
Hi,
>You have to rebuild the kernel to change the HZ value.
+1

Rami Rosen

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


Re: Adding new protocol to linux.

2016-03-28 Thread Rami Rosen
Hi,
Header files under include/net are for kernel internal use.
Header files under include/uapi are for exposure to userspace:
http://lxr.free-electrons.com/source/include/uapi/

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen
בתאריך 28 במרץ 2016 18:04, "Manoj Nayak" <manojnayak2...@gmail.com> כתב:

> > 1) Is it possible to write a new protocol for linux with an out of
> > tree module without modifing socket.h file?
>
> I think this has been already tried in the following code.
>
> http://lxr.free-electrons.com/source/include/net/bluetooth/bluetooth.h#L36
>
> http://lxr.free-electrons.com/source/include/linux/socket.h#L239
>
> The challenge is to expose this development specific header file to
> userspace.
> The following document talks about that.
>
> http://kernelnewbies.org/KernelHeaders
>
> Regards
> Manoj Nayak
>
>
> ___
> 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: Adding new protocol to linux.

2016-03-26 Thread Rami Rosen
Hi Daniel,

Following are answers for several of your questions:
Adding a protocol in Linux is done first by defining a protocol, and
then registering it with the proto_register() method:
http://lxr.free-electrons.com/source/net/core/sock.c#L2815
For that you need to define a proto object; for TCPv4 it is done thus,
for example:
http://lxr.free-electrons.com/source/net/ipv4/tcp_ipv4.c#L2315

Defining a protocol is not enough, you should also register a protocol
handler for this protocol.
Defining a protocol handler is done first by
defining a packet_type object
of this protocol and then defining a callback for this packet_type.
So for example, for IPv4, a packet_type object called ip_packet_type is
defined in http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1677

The protocol handler for this packet type is ip_rcv():
http://lxr.free-electrons.com/source/net/ipv4/ip_input.c#L378

This protocol is registered with dev_add_pack():
http://lxr.free-electrons.com/source/net/core/dev.c#L397

So, for example, for IPv4 it is done in inet_init():
http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1791

Apart from the protocol handler, a unique Ethernet type should be
defined for this protocol; for IPv4 we have  0x0800 (ETH_P_IP)
http://lxr.free-electrons.com/source/include/uapi/linux/if_ether.h#L46
and for the ARP protocol we have 0x0806 (ETH_P_ARP), and so on.

The Ethernet type in the Ethernet header represents the protocol
assigned to this packet.

The net_device_ops structure is not related, it merely represents the
interface of the of the kernel representation of network device (a
net_device object)  to userspace, for userspace operations like
setting the MTU, setting the MAC address, bringing the device up and
down, putting the device in promiscuous mode, and more.

Hope this helps!

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On 26 March 2016 at 05:00, Daniel. <danielhi...@gmail.com> wrote:
> Hi everybody,
>
> I'm planing to write a socket API for Nordic's nRF24L01+ and I was
> digging on socket code and find all supported protocols at
> include/linux/socket.h with all that #define AF_x y. So my questions
> are:
>
> 1) Is it possible to write a new protocol for linux with an out of
> tree module without modifing socket.h file?
> 2) Could netlink socket be used to solve this? .. and
> 3) I saw that there is net_device_ops and proto_ops. How they are tied 
> together?
>
> Thanks in advance and
> Best regards,
>
> --
> "Do or do not. There is no try"
>   Yoda Master
>
> ___
> 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: kexec not working

2016-03-05 Thread Rami Rosen
Hi Ronit,
Can you please tell what happens when you ran the "kexec -p" that you
mentioned ? Do you see any message on screen ? Does it hang immediately ?
Regards,
Rami Rosen
בתאריך 6 במרץ 2016 05:23, "Ronit Halder" <ronit.li...@gmail.com> כתב:

> When I am doing normal load of kernel using kexec, it works.
>
> #kexec -l /boot/vmlinuz-4.3.0-crash+
> --initrd=/boot/initramfs-4.3.0-crash+.img
> --append="root=/dev/mapper/fedora-root  1 irqpoll maxcpus=1
> reset_devices"
>
> #kexec -e
>
>
> But, when I am doing load on panic using kexec, it isn't working.
>
> #kexec -p /boot/vmlinuz-4.3.0-crash+
> --initrd=/boot/initramfs-4.3.0-crash+.img
> --append="root=/dev/mapper/fedora-root  1 irqpoll maxcpus=1
> reset_devices"
>
> #echo "1" >/proc/sys/kernel/sysrq
>
> #echo c > /proc/sysrq-trigger
>
>
> What am I doing wrong?
>
> ___
> 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: Reading network connections for processes in a separate net namespaces from /proc/[pid]/net/tcp|tcp6

2016-01-25 Thread Rami Rosen
Hi, Darek,

cat  /proc/[pid]/net/tcp
 is handled by
 http://lxr.free-electrons.com/source/net/ipv4/tcp_ipv4.c#L2230

and cat /proc/[pid]/net/tcp6
is handled by:
http://lxr.free-electrons.com/source/net/ipv6/tcp_ipv6.c#L1782

Hope it helps!

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

On 25 January 2016 at 15:00, dariusz ostolski
<dariusz.ostol...@gmail.com> wrote:
> Hello,
>
>
> 2016-01-22 10:21 GMT+01:00 Rami Rosen <roszenr...@gmail.com>:
>>>I've found
>>>functions for global files, maybe they are the same). I'd like to
>>>check when these files where introduced (from what kernel version they
>>>are available)
>>
>> Support for kernel network namesapces was added with kernel 2.6.29.
>> It is basically based on adding an object called "net_ns" to the
>> process descriptor, and instance of struct net, which represents a
>> network namesapce. You can think of such object as representing the
>> network state of a process, including all stats, sockets, devices,
>> tables, and so on. This net_ns is a member of an object called
>> nsproxy, which includes pointers to 4 other namesapces (uts, mnt, pid
>> and ipc).
>>
>>
>>>and there is no information about network
>>>namespaces at all (google, stackoverflow, man pages, kernel docs)
>>
>
> Thank You for your answer it gave me some clues so I was not
> completely blind when I checked kernel source code.
> Nevertheless, excuse me for not being precise enough, what I meant is
> that I couldn't find any docs about those 2 specific files:
> 1. /proc/[pid]/net/tcp
> 2. /proc/[pid]/net/tcp6
>
> And how is their content related to net namespaces?
>
> I want to read connections for a process that is in a separate net
> namespace but I'd like to avoid switching to that namespace,
> my experiments showed that reading /proc/[pid]/net/tcp|tcp6 should be
> enough, but I'd like to find confirmation of that
>  either in official docs (which I couldnt find) or in kernel source
> code (I failed there too).
>
> Again thank You in advance for your help.
>
> Regards,
> Darek

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


Re: How to statically build kernel module?

2016-01-22 Thread Rami Rosen
Hi,
Assuming that you are talking about a kernel module which is part of the
Kernel tree, you simply need to run make menuconfig, navigate to that
module, and instead "M" you should choose "Y". The build and install the
kernel image.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen
בתאריך 22 בינו 2016 21:44, "Kenneth Adam Miller" <
kennethadammil...@gmail.com> כתב:

> Is there a guidance anywhere? I know my question is simple and
> straightforward, but I've looked around a bit and I can't find a direct way
> to statically build a kernel module into the kernel.
>
> ___
> 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: Reading network connections for processes in a separate net namespaces from /proc/[pid]/net/tcp|tcp6

2016-01-22 Thread Rami Rosen
Hi,Darek,

>I've found
>functions for global files, maybe they are the same). I'd like to
>check when these files where introduced (from what kernel version they
>are available)

Support for kernel network namesapces was added with kernel 2.6.29.
It is basically based on adding an object called "net_ns" to the
process descriptor, and instance of struct net, which represents a
network namesapce. You can think of such object as representing the
network state of a process, including all stats, sockets, devices,
tables, and so on. This net_ns is a member of an object called
nsproxy, which includes pointers to 4 other namesapces (uts, mnt, pid
and ipc).


>and there is no information about network
>namespaces at all (google, stackoverflow, man pages, kernel docs)

This is not really so. Look for example in the following:

Namespaces and Cgroups – the basis of Linux Containers by Rami Rosen

http://files.meetup.com/18720713/Namespaces_Cgroups_Conatiners.pdf

"Resource management: Linux kernel Namespaces and cgroups by Rami Rosen
http://www.haifux.org/lectures/299/netLec7.pdf

Namespaces in operation, part 7: Network namespaces by Jake Edge
https://lwn.net/Articles/580893/

Introduction to Network Namepaces - David Mahler
https://www.youtube.com/watch?v=_WgUwUf1d34

(Shamless plug, I am the owner of the first two links...)

Hope this helps,

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen



On 22 January 2016 at 10:34, dariusz ostolski
<dariusz.ostol...@gmail.com> wrote:
> Hello,
>
> My name is Darek Ostolski, I'm computer enthusiast and hobbyst (also a
> developer).
> If this is incorrect mailing list excuse me and please point to
> the appropriate place to ask this kind of question. I couldn't find
> any other more
> appropriate place.
>
> I have a process that is in the separate net namespace (basically a
> container) and I want to check opened connections for that process. I
> have a kernel 4.3.3.
> My experiments showed that this information is available in
> /proc/[pid]/net/tcp|tcp6 files. For example for a global
> /proc/net/tcp6 shows following opened ports:
>
> root@host:~# cat /proc/net/tcp6
>   sl  local_address remote_address
>st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout
> inode
>0: :01BD
> : 0A : 00:
>  00 22882 1 88040de7b240 100 0 0 10 0
>1: :008B
> : 0A : 00:
>  00 22883 1 88040de7a9c0 100 0 0 10 0
>2: :0050
> : 0A : 00:
>  00 1214363 1 880077ed9340 100 0 0 10 0
>3: :0016
> : 0A : 00:
>  00 21933 1 880400a33140 100 0 0 10 0
>4: :445C
> : 0A : 00:
>   10000 29904 1 880400a32040 100 0 0 10 0
>
> And for a process running in container I have:
> root@host:~# cat /proc/30518/net/tcp6
>   sl  local_address remote_address
>st tx_queue rx_queue tr tm->when retrnsmt   uid  timeout
> inode
>0: 017F:1F45
> : 0A : 00:
>  00 1211206 1 880364fcb380 100 0 0 10 0
>1: :1F49
> : 0A : 00:
>  00 1215425 1 8802befd0200 100 0 0 10 0
>2: :1F90
> : 0A : 00:
>  00 1215421 1 880077ed8240 100 0 0 10 0
>
>
> So I see that there are opened ports that are not visible on host
> level but are visible at a container level for example 1F90 -> which
> is basically 8080.
>
>
> I'd like to ask following questions:
> 1. Where can I find documentation for /proc/[pid]/net/tcp|tcp6 files?
> All I could find was documentation about global file(i.e.
> /proc/net/tcp|tcp6) and there is no information about network
> namespaces at all (google, stackoverflow, man pages, kernel docs)
> 2. Could You confirm that in these files I'll see all connections that
> are specific for a given process even if this process is in separate
> network namespace? (so I dont have to enter target net/pid namespace
> to read their global /proc/net/tcp|tcp6 files)
> 3. I've grep k

Re: Preceding a method call with (void)

2015-09-18 Thread Rami Rosen
Hi,
Well, there are rare cases in the kernel when you add (void) before calling
the method. For example, if the method returns int or other type and you
want to emphasize that you are aware of that and deliberately not check the
return value.
See for example:
http://lxr.free-electrons.com/source/drivers/acpi/acpica/tbxfload.c#L156

Regards,
Rami Rosen
בתאריך 10 בספט 2015 09:39, <valdis.kletni...@vt.edu> כתב:

> On Thu, 10 Sep 2015 07:52:49 +0300, Kevin Wilson said:
>
> > (void) myFunc(param1);
> >
> > I did not encounter such cases in the kernel code that I read, thus far.
> >
> > On the other hand, I did not saw in the kernel coding style doc
> > anything which prohibits such usage.
> >
> > If I remember, using (void) before the method name is a way to tell
> > explicitly that this method does not return any value,
> > but I am not sure as for the exact reasons it is used (in userspace).
>
> Well, if the function actually returns nothing, in kernel code we usually
> declare it as:
>
> void myFunc( int param1)
> {
> /* yadda yadda yadda *.
> }
>
> Given that, what reason is there for casting the return value with (void)?
>
> (And if the function is actually   'int myFunc ( int param1) {...}',
> why are you calling it and then ignoring the return value?  That's a clue
> that you're abusing the API...)
>
> ___
> 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: When to use threaded interrupts?

2015-09-13 Thread Rami Rosen
Kosta,

This kernel and older ones include device drivers which use threaded IRQs
(call request_threaded_irq(), etc).
 For example, many of the driver under drivers/input/touchscreen are
using threaded IRQs:
Following link is from kernel 3.18:
http://lxr.free-electrons.com/source/drivers/input/touchscreen/ucb1400_ts.c?v=3.18

How did you came to the conclusion that this kernel does not support
threaded IRQs ? could it be that you simply do not use device drivers
that
use this mechanism ?

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen




On 13 September 2015 at 09:24, Kosta Zertsekel <zertse...@gmail.com> wrote:
>>> I think I get the pro of using threaded interrupts - to decrease the
>>> maximum
>>> interrupt latency on RT workloads and/or RT machines (servers, embedded,
>>> etc.).
>>> So, I'd like to ask:
>>>- Why not **all** of the drivers use the threaded interrupts?
>>>- What are the cons of the threaded interrupts?
>>>
>> Just a wild assumption: maybe the cost of incurring context switches ?
>> (comparing to tasklets)
>
> I get that threaded IRQ is better than softIrqs because threaded IRQ
> supports
> priorities. On the other hand, added context switches surely get system
> slower.
> But from the practical point of view - why on relatively new Intel PC there
> are
> no threaded irqs at all?
>
> ```
> $ uname -a
> Linux kostaz-OptiPlex-7010 3.19.0-26-generic #28-Ubuntu SMP Tue Aug 11
> 14:16:32 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> ```
>
> --- KostaZ
>
> On Thu, Sep 10, 2015 at 11:09 PM, Rami Rosen <roszenr...@gmail.com> wrote:
>>
>> Kosta,
>>
>> Just a wild assumption: maybe the cost of incurring context switches ?
>> (comparing to tasklets)
>>
>> Best Regards,
>> Rami Rosen
>> http://ramirose.wix.com/ramirosen
>>
>>
>>
>> On 10 September 2015 at 20:49, Kosta Zertsekel <zertse...@gmail.com>
>> wrote:
>> > Hi guys,
>> >
>> > I hope I'm on right mailing list. :-)
>> > I think I get the pro of using threaded interrupts - to decrease the
>> > maximum
>> > interrupt latency on RT workloads and/or RT machines (servers, embedded,
>> > etc.).
>> >
>> > Also, I see that in 4.2 there are only ~76 drivers that use threaded
>> > interrupt:
>> > ```
>> > $ git grep -l IRQ_WAKE_THREAD | sort | grep -v "\.h" | wc -l
>> > 76
>> > ```
>> >
>> > So, I'd like to ask:
>> >- Why not **all** of the drivers use the threaded interrupts?
>> >- What are the cons of the threaded interrupts?
>> >
>> > Thanks,
>> > --- KostaZ
>> >
>> > ___
>> > 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: When to use threaded interrupts?

2015-09-10 Thread Rami Rosen
Kosta,

Just a wild assumption: maybe the cost of incurring context switches ?
(comparing to tasklets)

Best Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen



On 10 September 2015 at 20:49, Kosta Zertsekel <zertse...@gmail.com> wrote:
> Hi guys,
>
> I hope I'm on right mailing list. :-)
> I think I get the pro of using threaded interrupts - to decrease the maximum
> interrupt latency on RT workloads and/or RT machines (servers, embedded,
> etc.).
>
> Also, I see that in 4.2 there are only ~76 drivers that use threaded
> interrupt:
> ```
> $ git grep -l IRQ_WAKE_THREAD | sort | grep -v "\.h" | wc -l
> 76
> ```
>
> So, I'd like to ask:
>- Why not **all** of the drivers use the threaded interrupts?
>- What are the cons of the threaded interrupts?
>
> Thanks,
> --- KostaZ
>
> ___
> 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: Questions on Netlink sockets

2015-08-19 Thread Rami Rosen
Hi, Bhaskar,

Thanks for posting the code.

PS: I am humbled to see a reply from you. I read Chapter 2 from your
book to understand netlink sockets.

I hope you enjoyed it and find it useful!

+ My code is not creating VLAN interface as executed by the 'ip link
...' command.

Can you elaborate a bit about this: which difference do you see between creating
a VLAN with
ip link add name eth2.200  link eth2 type vlan id 200

And running your program (let's call your executable vlan_nl)
in this way:
./vlan_nl eth1.100 eth1 100



Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

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


Re: Questions on Netlink sockets

2015-08-17 Thread Rami Rosen
Hi, Bhaskar,

Indeed the netdev mailing list is too advanced for this.

Do you get any error as a result of sending this netlink message ?
(I mean error in userspace or in kernel; if there is an error message
in the kernel it can be viewed by looking at the end of dmesg output)

Further more, I suggest that you will post the code here. The concept
itself is right, It should work, you either build the netlink message
incorrectly or send it incorrectly, so it seems.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On 18 August 2015 at 01:55, Bhaskar Upadhyayula bu.ker...@gmail.com wrote:
 Hello,

 I want to check with the group if this is right mailing list to post
 my question.

 Here is what I am doing.

 + From a user-space program, mimicking the behavior of creating a VLAN
 interface when we execute the following ip command:
 $ ip link add name vlan-intf-name link parent-intf-name type
 vlan id id

 Example: $ ip link add name dummy.110 link dummy type vlan id 110

 + My program open's a netlink socket and sends information to kernel
 (interface names, vlan tags etc). My code more or less follows the
 code in iproute2/ip/iplink.c

 + My code is not creating VLAN interface as executed by the 'ip link
 ...' command.

 I have a few questions around this and can post my code, if required.

 But please let me know if this is right mailing list or should I post
 on netdev list (which I feel is for advanced network questions).

 Thx.

 ___
 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: A flow path for ethernet kernel driver

2015-05-18 Thread Rami Rosen
Hi, Airton,

This is simply a matter of setting dmesg to work with
the level which you need in your setup.
You should set dmesg -n to work with the pr_info() level.
Pleas look in man dmesg, for the -n, --console-level level part.

If you are in a haste and looking for immediate solution, you can also
try pr_err() instead, as most distros do print such messages with
dmesg without need for any special setup.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

On 18 May 2015 at 22:23, Airton Ishimori nobumasa@gmail.com wrote:
 Hello, everybody,

 I'm trying to develop a new Ethernet driver (Realtek) for Linux kernel
 4.0.2.

 [3.612938] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded

 As part of my studies, I'm trying to trace the path for functions defined in
 drivers/net/ethernet/realtek/r8169.c, net/core/dev.c and
 net/core/dev_ioctl.c. I'm using printks for this purpose. For instance,
 something like:

 printk(TEST: __dev_set_promiscuity\n);

 However, I'm not getting what's going on. I can set/unset the promiscuity
 behaviour via ifconfig command.

 [  131.330091] device eth0 entered promiscuous mode
 [  170.619086] device eth0 left promiscuous mode

 By looking at the dmesg output above, I thought the function that deals with
 promiscuity was __dev_set_promiscuity() defined in net/core/dev.c, because
 this function calls a function to print the message above:

 pr_info(device %s %s promiscuous mode\n, dev-name, dev-flags 
 IFF_PROMISC ? entered : left);

 But, when I tried to look for my printk message with dmesg after compiling
 and running the kernel, I couldn't find it.

 $ cd linux-4.0.2/
 $ make net  make modules
 $ sudo make modules_install  sudo make install

 Can somebody help me to understand what's happening?

 Thanks in advance,

 --
 Airton Ishimori


 ___
 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: Lxc vs openvz

2014-06-16 Thread Rami Rosen
Hi,
In fact, the LXC project itself was not added to the kernel. It is the
underlying components, cgroups and namespaces, which were added to the
kernel. The work on cgroups started several years ago (by google), and
the work on namespaces started event before. The OpenVZ project, on
the other hand, is based on a proprietary project (Virtuozzo). The are
many
heavy features which OpenVZ added, and it will take probably years so
that the project will be fully in mainline.

If you want to learn more about this fascinating subject, you can read
two very detailed documents (pdf) with over 200 pages about
Linux Containers, LXC, OpenVZ, Docker, CRIU,
Namespaces and cgroups, in my website: http://ramirose.wix.com/ramirosen.


Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen





On Mon, Jun 16, 2014 at 5:10 PM, Grzegorz Dwornicki gd1...@gmail.com wrote:
 Hi

 Can anyone point me why lxc was added to the kernel instead of openvz? The
 point in time will be sufficient as I will look in the lkml archives.

 Grzegorz


 ___
 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: Problem with inserting nfs module in kernel

2014-05-12 Thread Rami Rosen
Hi, Sivakumar,
This should work. Are you sure all your printk are proper ?
Can you please pastebin the crash message  and send us a link ?

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen
בתאריך 12 במאי 2014 23:09, Sivakumar V sivakumar...@gmail.com כתב:




 Hi All,

 I am tried to compile and install (network file system)nfs module to
 kernel i.e. modified nfs code(inserted printk's in kernel nfs code) without
 compiling entire kernel .
 It is inserted but when configuring nfs the mount command crashes. i.e.
 mount -t nfs 172.16.10.44:/tmp /home/user/ddd

 can anyone know why it happens?

 Is there any way to do this

 Thanks in advance




 ___
 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: Regarding net_device_ops

2014-05-03 Thread Rami Rosen
Hi, Pranay,

First, let's assume that you are talking about IPv4, though you did not
mention it explicitly. (The principles in IPv6 are quite similar, though)

A packet is sent out in the usual case with the ip_queue_xmit() method.
The  ip_queue_xmit() method calls the ip_route_output_ports() method
in order to perform a lookup in the IPv4 routing tables.

see: http://lxr.free-electrons.com/source/net/ipv4/ip_output.c#L352

The results of this IPv4 routing lookup determines on which network device
(net_device) the packet will be sent. You should look at the code of
ip_route_output_ports() method in net/ipv4/route.c in order to
understand the IPv4 routing subsystem and the IPv4 routing lookup.

Packets can, under certain circumstances, be sent by the ip_send_skb()
method, but this happens when the flow (which consists also of the
net_device to be used) is known before.

Best Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sat, May 3, 2014 at 12:43 PM, Pranay Srivastava pran...@gmail.com wrote:
 Hi

 Referring to Documentation/networking/netdevices.txt

 a)

 ndo-ndo_start_xmit if written as is will be thread safe? [Correct?]
 NETIF_F_LLTX is not set only then this is true.

 But dev_queue_xmit(skb) doesn't seem to take any lock, neither does
 dev_hard_start_xmit. Please let me know if i'm wrong and where is this
 lock taken before calling dev_queue_xmit/dev_hard_start_xmit.


 b)

 Why and when would I want to use rtnl_lock/unlock? Is it like
 registering multiple device simultaneously?


 c)

 ndo-ndo_start_xmit is supposed to start the transmission of the skb.
 However I've a doubt

 --- Suppose that there's no room left for the incoming skb in the
 device buffer, so in that case it would be ideal to call
 netif_stop_queue. At this the the skb already with the ndo_start_xmit
 will not be retried again[Correct?]

  Is ndo_start_xmit required to wait in this case? However if the
 above spin_lock in a) was taken then this would be a waste. So is it
 possible that this skb is deffered to whenever there's room and
 return NETDEV_TX_OK? But if we do this we are telling the application
 that it's packet was delivered so in case there was a timeout set by
 the application on a reply it would again send us the same packet. So
 instead of deferring is it good to drop ?



 --
 ---P.K.S

 ___
 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: Regarding skb and net_device.

2014-05-03 Thread Rami Rosen
Hi, Pranay,

First, let's assume that you are talking about IPv4, though you did not
mention it explicitly. (The principles in IPv6 are quite similar, though)

A packet is sent out in the usual case with the ip_queue_xmit() method.
The  ip_queue_xmit() method calls the ip_route_output_ports() method
in order to perform a lookup in the IPv4 routing tables.

see: http://lxr.free-electrons.com/source/net/ipv4/ip_output.c#L352

The results of this IPv4 routing lookup determines on which network device
(net_device) the packet will be sent. You should look at the code of
ip_route_output_ports() method in net/ipv4/route.c in order to
understand the IPv4 routing subsystem and the IPv4 routing lookup.

Packets can, under certain circumstances, be sent by the ip_send_skb()
method, but this happens when the flow (which consists also of the
net_device to be used) is known before.

Best Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sat, May 3, 2014 at 11:33 AM, Pranay Srivastava pran...@gmail.com wrote:
 Hi,

 This is probably a stupid question, but i'm not able to find the
 answer. How does the networking subsystem decides which device to use
 for sending the skb. Can some one please guide me to the particular
 code. I seem to get lost in there :(

 --
 ---P.K.S

 ___
 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: Regarding net_device_ops

2014-05-03 Thread Rami Rosen
Hi,
Sorry, I of course discuss here your previous question about SKB
Regards,
Rami

On Sat, May 3, 2014 at 1:34 PM, Rami Rosen roszenr...@gmail.com wrote:
 Hi, Pranay,

 First, let's assume that you are talking about IPv4, though you did not
 mention it explicitly. (The principles in IPv6 are quite similar, though)

 A packet is sent out in the usual case with the ip_queue_xmit() method.
 The  ip_queue_xmit() method calls the ip_route_output_ports() method
 in order to perform a lookup in the IPv4 routing tables.

 see: http://lxr.free-electrons.com/source/net/ipv4/ip_output.c#L352

 The results of this IPv4 routing lookup determines on which network device
 (net_device) the packet will be sent. You should look at the code of
 ip_route_output_ports() method in net/ipv4/route.c in order to
 understand the IPv4 routing subsystem and the IPv4 routing lookup.

 Packets can, under certain circumstances, be sent by the ip_send_skb()
 method, but this happens when the flow (which consists also of the
 net_device to be used) is known before.

 Best Regards,
 Rami Rosen
 http://ramirose.wix.com/ramirosen


 On Sat, May 3, 2014 at 12:43 PM, Pranay Srivastava pran...@gmail.com wrote:
 Hi

 Referring to Documentation/networking/netdevices.txt

 a)

 ndo-ndo_start_xmit if written as is will be thread safe? [Correct?]
 NETIF_F_LLTX is not set only then this is true.

 But dev_queue_xmit(skb) doesn't seem to take any lock, neither does
 dev_hard_start_xmit. Please let me know if i'm wrong and where is this
 lock taken before calling dev_queue_xmit/dev_hard_start_xmit.


 b)

 Why and when would I want to use rtnl_lock/unlock? Is it like
 registering multiple device simultaneously?


 c)

 ndo-ndo_start_xmit is supposed to start the transmission of the skb.
 However I've a doubt

 --- Suppose that there's no room left for the incoming skb in the
 device buffer, so in that case it would be ideal to call
 netif_stop_queue. At this the the skb already with the ndo_start_xmit
 will not be retried again[Correct?]

  Is ndo_start_xmit required to wait in this case? However if the
 above spin_lock in a) was taken then this would be a waste. So is it
 possible that this skb is deffered to whenever there's room and
 return NETDEV_TX_OK? But if we do this we are telling the application
 that it's packet was delivered so in case there was a timeout set by
 the application on a reply it would again send us the same packet. So
 instead of deferring is it good to drop ?



 --
 ---P.K.S

 ___
 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: system call returns -1

2014-05-02 Thread Rami Rosen
Hi, Nada,
Return value of -1 could be EPERM,  Operation not permitted; see:
http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno-base.h

Can you paste the code in pastebin or some other public site?

regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Fri, May 2, 2014 at 9:23 AM, Nada Saif nada.sa...@gmail.com wrote:
 Hi,

 I added a new system call to kernel 2.6.32.61 - I used these commands for
 complication :

 make oldconfig
 make
 make modules install

 It went ok with few warning messages.

 When I tried to test the system call , the function _syscall  return -1,
 what that means?


 Thanks,
 Nada

 ___
 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: cgroups: cannot write on file memory.oom_control

2014-04-18 Thread Rami Rosen
Hi Hedi,
Well, you can use disabling oom in conjunction  with event handler. Thus,
you can free memory by changing memory setting of other cgroups when an oom
occurs in a specific cgroup, and avoid having an oops in that cgroup.
You can see an example of using event handler in conjunction with disabling
the oom killer in
Namespaces and cgroups in linux, in slides 101/102, see:
http://ramirose.wix.com/ramirosen

A shameless plug - I wrote this presentation of 121 slides about namespaces
and cgroups.

Regards,
Rami Rosen
 בתאריך 17 באפר 2014 11:24, Hedi Boufaied hedi.boufa...@amadeus.com כתב:

 Hi Rami,

 Thanks a lot for your sequence. I followed it and it does work.
 I now see my process paused in sleep state instead of getting killed when
 the cgroup reaches OoO.

 This being said:
 * I do not really understand why the use_hierarchy option needs to be
 disabled in order to allow disabling of the oom killer...
 * I'm not sure that disabling the OoO killer is safe/reliable enough: in
 some of the trials I made, I saw other processes (xterms) not part of the
 OoO cgroup getting completely stuck and I had to reboot my machine...

 Best Regards,
 Hedi



 From:Rami Rosen roszenr...@gmail.com
 To:Hedi Boufaied hedi.boufa...@amadeus.com,
 Cc:kernelnewbies kernelnewbies@kernelnewbies.org
 Date:15/04/2014 15:39
 Subject:Re: cgroups: cannot write on file memory.oom_control
 --



 Hi, Hedi,

 This sequence works for me:

 echo 0   /sys/fs/cgroup/memory/memory.use_hierarchy

 mkdir  /sys/fs/cgroup/memory/0

 Then, the following two commands changes the value of oom_kill_disable:

 echo 1/sys/fs/cgroup/memory/0/memory.oom_control

 echo 0/sys/fs/cgroup/memory/0/memory.oom_control


 For more info, please look for the text about enabling/disabling
 use_hierarchy in section 6,
 http://lxr.free-electrons.com/source/Documentation/cgroups/memory.txt.

 Regards,
 Rami Rosen
 http://ramirose.wix.com/ramirosen



 On Mon, Apr 14, 2014 at 12:22 PM, Hedi Boufaied
 hedi.boufa...@amadeus.com wrote:
  Hi everyone,
 
  I am working with cgroups on OpenSuse (over VirtualBox) and I cannot
 disable
  the OOM killer by writing to the file memory.oom_control:
 
  echo 1  memory.oom_control
  -bash: echo: write error: Invalid argument
 
  I can change the memory limit and several other settings by writing to
 the
  appropriate files (like memory.limit_in_bytes) but I could never write to
  file memory.oom_control although I am root.
 
  I saw someone posted a similar issue a few days ago but there was no
  reply...
 
  I have copied below the sequence of command I am using. Any idea what
 could
  be the issue ?
 
  Thanks in advance for your help!
 
  Hedi
 
 
  
 
  /sys/fs su - root
 
  /sys/fs cd cgroup
 
  /sys/fs/cgroup cgcreate -g memory:/mygroup
 
  /sys/fs/cgroup cd memory/mygroup
 
  /sys/fs/cgroup/memory/mygroup echo 32M  memory.limit_in_bytes
 
  /sys/fs/cgroup/memory/mygroup cat memory.limit_in_bytes
  33554432
 
  /sys/fs/cgroup/memory/mygroup echo 1  memory.oom_control
  -bash: echo: write error: Invalid argument
 
  /sys/fs/cgroup/memory/mygroup cat memory.oom_control
  oom_kill_disable 0
  under_oom 0
 
  ---
  ___
  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: cgroups: cannot write on file memory.oom_control

2014-04-15 Thread Rami Rosen
Hi, Hedi,

This sequence works for me:

echo 0   /sys/fs/cgroup/memory/memory.use_hierarchy

mkdir  /sys/fs/cgroup/memory/0

Then, the following two commands changes the value of oom_kill_disable:

echo 1/sys/fs/cgroup/memory/0/memory.oom_control

echo 0/sys/fs/cgroup/memory/0/memory.oom_control


For more info, please look for the text about enabling/disabling
use_hierarchy in section 6,
http://lxr.free-electrons.com/source/Documentation/cgroups/memory.txt.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen



On Mon, Apr 14, 2014 at 12:22 PM, Hedi Boufaied
hedi.boufa...@amadeus.com wrote:
 Hi everyone,

 I am working with cgroups on OpenSuse (over VirtualBox) and I cannot disable
 the OOM killer by writing to the file memory.oom_control:

 echo 1  memory.oom_control
 -bash: echo: write error: Invalid argument

 I can change the memory limit and several other settings by writing to the
 appropriate files (like memory.limit_in_bytes) but I could never write to
 file memory.oom_control although I am root.

 I saw someone posted a similar issue a few days ago but there was no
 reply...

 I have copied below the sequence of command I am using. Any idea what could
 be the issue ?

 Thanks in advance for your help!

 Hedi


 

 /sys/fs su - root

 /sys/fs cd cgroup

 /sys/fs/cgroup cgcreate -g memory:/mygroup

 /sys/fs/cgroup cd memory/mygroup

 /sys/fs/cgroup/memory/mygroup echo 32M  memory.limit_in_bytes

 /sys/fs/cgroup/memory/mygroup cat memory.limit_in_bytes
 33554432

 /sys/fs/cgroup/memory/mygroup echo 1  memory.oom_control
 -bash: echo: write error: Invalid argument

 /sys/fs/cgroup/memory/mygroup cat memory.oom_control
 oom_kill_disable 0
 under_oom 0

 ---
 ___
 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: Need help in enable configuration when compile Kernel module

2014-01-09 Thread Rami Rosen
Hi,
'y' is used for building the module as a built-in in the kernel image.
'm' stands for building the module as a stand alone object (*.ko),
which is not part of the kernel image, and should be insmoded or
modprobed in order to be used.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Fri, Jan 10, 2014 at 8:24 AM, m silverstri
michael.j.silvers...@gmail.com wrote:
 And please help me udnerstand what is the difference between 'y' and
 'm' in  'CONFIG_VIDEOBUF2_CORE=y instead of CONFIG_VIDEOBUF2_CORE=m'?

 On Thu, Jan 9, 2014 at 10:23 PM, m silverstri
 michael.j.silvers...@gmail.com wrote:
 Thanks. Can you please help me understand what you mean by 'make this
 to build into kernel instead of static'?


 On Thu, Jan 9, 2014 at 7:18 PM, Ashokkumar G
 ashok.sysprogram...@gmail.com wrote:
 Dear Silverstri,

 I am not sure for which platform you are compiling Kernel.

 But for X86(_64) and ARM, CONFIG_VIDEOBUF2_CORE will be selected as a module
 (will not build into kernel image static), this is the dependency
 VIDEOBUF2_DMA_CONTIG [=m]  MEDIA_SUPPORT [=m]  HAS_DMA [=y] ||
 VIDEOBUF2_VMALLOC [=m]  MEDIA_SUPPORT [=m] || VIDEOBUF2_DMA_SG [=n] 
 MEDIA_SUPPORT [=m] || SOC_CAMERA [=m]  MEDIA_SUPPORT [=m] 
 V4L_PLATFORM_DRIVERS [=y]  VIDEO_V4L2 [=m]  HAS_DMA [=y]  I2C [=y].

 select MEDIA_SUPPORT and SOC_CAMERA to build into kernel image static (when
 you select one of MEDIA_SUPPORT/SOC_CAMERA/VIDEO_V4L2 as build static into
 kernel, .config will have  CONFIG_VIDEOBUF2_CORE=y instead of
 CONFIG_VIDEOBUF2_CORE=m)

 For ARM board I used Device Drivers-Multimedia Support (make this to build
 into kernel instead of static)-V4L platform devices (make this to build
 into kernel instead of static)-Soc Camera Support(make this to build into
 kernel instead of static).

 --
 Best Regards
 Ashokkumar.G
 100 Things can not be taken back. 001. A lost opportunity. 010. A spoken
 word. 011. A sped arrow. 100. Time spent.


 On Thu, Jan 9, 2014 at 7:16 PM, m silverstri
 michael.j.silvers...@gmail.com wrote:

 I am using 3.10.x kernel tree. My kernel module needs config VIDEOBUF2.

 That is defined in drivers/media/v4l2-core/Kconfig:

 # Used by drivers that need Videobuf2 modules
 config VIDEOBUF2_CORE
 select DMA_SHARED_BUFFER
 tristate

 So I put 'CONFIG_VIDEOBUF2_CORE=y' in my Kernel config file and
 compile. From the Kconfig it has CONFIG_VIDEOBUF2_CORE has no
 dependency and I think adding CONFIG_VIDEOBUF2_CORE=y to my kernel
 config should work. I am modify the right kernel config file since I
 set other flags like CONFIG_VIDEO_DEV=y and that works.

 The generated .config does not contain 'CONFIG_VIDEOBUF2_CORE=y'

 and the compilation fails with  a bunch of

 undefined reference to `vb2_buffer_done'
 undefined reference to `vb2_buffer_done'
 undefined reference to `vb2_buffer_done'
 undefined reference to `vb2_buffer_done'

 I really appreciate if someone can help me with this.

 Thank you.

 ___
 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

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


Re: how to find kernel patch applied on existing build kernel

2013-12-23 Thread Rami Rosen
Hi, Vipul

If you want to know to which kernel release is a specified patch
related, you  can do it by git describe --contains:

git describe --contains e605b36575e896edd8161534550c9ea021b03bc0

v3.13-rc2~6^2

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sun, Dec 22, 2013 at 1:26 PM, Alexandru Juncu al...@rosedu.org wrote:
 On 22 December 2013 06:56, Vipul Jain vipu...@gmail.com wrote:
 Hi,

 If I would like to find out if any particular build kernel has a particular
 patch applied to that kernel how to go about it?

 Regards,
 Vipul.



 Hello!

 You can do a git log on the kernel's repo and see when it was applied.
 Or do a git blame if you need a particular line of a file.

 If you want to match it to a release, track the tags in the repo.

 You can use the webinterface:

 https://git.kernel.org/cgit/

 Just remember that because of the distributed nature of git and the
 kernel's development model, a particular patch is merged in many trees
 before reaching the de facto main linux repo (Linus' repo).

 ___
 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: create sysfs class attribute and sub directories

2013-12-15 Thread Rami Rosen
Hi,
You should use
sysfs_create_group() and  kobject_create_and_add() and DEVICE_ATTR() macro
see net/bridge/br_sysfs_br.c
and also see Documentation/kobject.txt and filesystems/sysfs.txt


Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sun, Dec 15, 2013 at 3:52 PM, Jeshwanth Kumar N K
jeshkumar...@gmail.com wrote:
 Hello List :),

 I have a small question about sysfs.
 I am creating a kernel module to print some versions in sysfs attributes. So
 the directory tree would be.
 /sys/class/versions/main/version
   /dev/version

 So, versions is my class directory, inside that two directories main and
 dev, both directory should contains version attribute. I am little familiar
 with creating with sysfs class attribute using struct class, but how to
 create the directory (like main/dev) and create attributes in both directory
 ?

 I have one more question, Is sysfs is right place to display version
 information ?

 Thanks in Advance :)

 --
 Regards
 Jeshwanth Kumar N K
 Bangalore, India

 ___
 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: A question about ip_options's option type

2013-12-14 Thread Rami Rosen
Hi, Guibin,

Your example with SO_LINGER is not relevant as this is the SO_LINGER
option and not the generic IP_OPTION.

Please take a look at the ping implementation:
http://www.linux-ipv6.org/gitweb/gitweb.cgi?p=gitroot/iputils.git;a=blob;f=ping.c;h=c0366cdacd626dde1669bf2d97588eb7c6ece3fd;hb=HEAD


You have there:

   if (options  F_TIMESTAMP) {
492 memset(rspace, 0, sizeof(rspace));
493 rspace[0] = IPOPT_TIMESTAMP;
494 rspace[1] = (ts_type==IPOPT_TS_TSONLY ? 40 : 36);
495 rspace[2] = 5;

So for the type, byte 0, you have  IPOPT_TIMESTAMP
and for the length, you have 40 or 36 (It depends on ts_type)

Best Regards,

Rami Rosen
http://ramirose.wix.com/ramirosen



On Sat, Dec 14, 2013 at 3:00 AM, Guibin(Bill) Tian gbt...@gmail.com wrote:
 Hi, maybe it's a naive question. But I am confused here.

 For the options field of an IP header, as for the data in this field,
 according to document and the code in the method of ip_options_compile,
 the first byte is  the options type data and the second byte is the length
 of the option. But I traced back the method of ip_options_get_from_user,
 there is no place that assign these two values to the __data field.

 I checked some example of socket API setsockopt, it also just converts the
 target options data pointer into a char * pointer and passes down to
 ip_options_get_from_user, still it doesn't set these two values.

 Can anyone help me on this? Because I am trying to add my own options to IP
 header at the IP layer for some experiment purposes.


 struct linger linger = { 0 };
 linger.l_onoff = 1;
 linger.l_linger = 30;
 status = setsockopt(serverSocket,
 SOL_SOCKET, SO_LINGER,
 (const char *) linger,
 sizeof(linger));


 ___
 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: Sending an ICMP packet with ip_local_out

2013-06-16 Thread Rami Rosen
Adel,
You say you have a  NULL pointer but you do not specify where.

can you please send the  log of the panic ?

Can you send the kernel module full code ?

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen









On Mon, Jun 17, 2013 at 6:18 AM, Adel Qodmani mpca...@gmail.com wrote:

 Hello everyone,


 I am trying to send an ICMP message in a kernel module; typically I'd
 build the skb, set up the net_device, the ethernet header and then use
 dev_queue_xmit.

 But right now I want my packet to follow the IP routing rules set in the
 system, so I thought I'll use ip_local_out function and let it handle the
 routing and setting the rest of the parameters in the skb.

 Yet, my code causes the kernel to panic due to a NULL pointer.

 The code is as follows:
 /* This function assumes source and dest are in NETWORK byte order */
 int sendICMPEcho(char *msg, unsigned int length, __be32 source, __be32
 dest)
 {
 struct iphdr *iph;
 struct icmphdr *icmph;
 struct sk_buff *newPacket;
  unsigned char *data;
 unsigned int skbSize = length + sizeof(struct icmphdr) * 2
 + sizeof(struct iphdr) * 2
  + sizeof(struct ethhdr) * 2;

 /* Allocate the skb */
 newPacket = alloc_skb(skbSize, GFP_ATOMIC);
  if(newPacket == NULL)
 return SEND_FAIL_MEMORY;

 /* Reserve the headers area */
  skb_reserve(newPacket, sizeof(struct icmphdr)
  + sizeof(struct iphdr)
 + sizeof(struct ethhdr));

 /* Extend the data area from 0 to the message length */
 data = skb_put(newPacket, length);
  /* Copy the data from the message buffer to the newPacket */
 memcpy(data, msg, length);

 /** ICMP HEADER***/
  /* skb_push - pushing the icmp header in the packet data */
 icmph = (struct icmphdr *) skb_push(newPacket,
  sizeof(struct icmphdr));
 /*set ICMP header here */
 icmph-type = ICMP_ECHO;
  icmph-code = 0;
 icmph-un.echo.id = 0;
 icmph-un.echo.sequence = htons(sendCounter);
  icmph-checksum= 0;
 icmph-checksum = in_cksum((unsigned short *)icmph,
 sizeof(struct icmphdr) + length);
  /** END ICMP HEADER**/
  /** IP HEADER ***/
  iph = (struct iphdr *) skb_push(newPacket,
 sizeof(struct iphdr));
 /* set IP header here */
  iph-ihl = 5;/* 5 * 32(bits) */
 iph-version = 4;
 iph-tos = 0; /* The recommended value by IANA for ICMP request */
  iph-tot_len = htons( sizeof(struct iphdr)
 + sizeof(struct icmphdr)
 + length);
  iph-id = 0;
 iph-frag_off = 0; /* No fragementation */
 iph-ttl = 65;
  iph-protocol =  IPPROTO_ICMP;
 iph-saddr = source;
 iph-daddr = dest;
  iph-check = 0;
 iph-check = in_cksum((unsigned short *)iph, sizeof(struct iphdr));
 /** END IP HEADER ***/


 // if(ip_local_out(newPacket)  0) THIS CRASHES WITH A NULL POINTER
 // return SEND_FAIL_SEND;
  ++sendCounter;
 return SEND_SUCCESS;
 }
 /* end sendICMPEcho */

 In my attempts when trying to solve this, I've tried to manually set the
 net_device in the skb and that didn't work either; I still had the same
 kernel panic.

 So I am sorry for the trouble, any hint where the error can be?


 Regards,
 Adel

 ___
 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: which function perform gso

2013-05-31 Thread Rami Rosen
Hi, Varun

look in dev_gso_segment():
http://lxr.free-electrons.com/source/net/core/dev.c#L2382

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen




On Fri, May 31, 2013 at 9:53 AM, Varun Sharma vsd...@gmail.com wrote:
 Hi,

 which function perform Generic segmentation offload in kernel.



 ___
 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: Device mapper api v/s block device driver api

2013-05-06 Thread Rami Rosen
Hi
Just of pure curiosity, can you please provide a link to the blog you had
mentioned?
Regards
Rami Rosen

http://ramirose.wix.com/ramirosen
On May 6, 2013 10:46 PM, neha naik nehanai...@gmail.com wrote:

 Hi,
Reading a blog on device mapper api got me confused about when one
 should use device mapper api and when to use block device driver api.
 I was under the impression that even for stackable device drivers (say a
 customized block device driver on top of lvm or such) we need to use the
 block device driver api. But,
 reading about the device mapper api i have started thinking that it may
 not be the case.
 May be for stackable device drivers device mapper is the solution.
 What do you think?  What are the pros and cons of device mapper v/s block
 device driver

 Regards,
 Neha

 ___
 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: Dynamic Sysfs Attribute Files

2013-04-24 Thread Rami Rosen
Hi,
Take a look in:
http://lxr.free-electrons.com/source/Documentation/filesystems/sysfs.txt

You should consider the sysfs API like
sysfs_create_dir(), sysfs_create_group(), sysfs_create_file()

Best Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

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


Re: open_softirq do?

2013-04-10 Thread Rami Rosen
Hi,
This is simply a registration of the software interrupt TX method
(net_tx_action).


The net_tx_action() is invoked in general when transmission was finished:
look in :
http://lxr.free-electrons.com/source/net/core/dev.c

void dev_kfree_skb_irq(struct sk_buff *skb)
...
raise_softirq_irqoff(NET_TX_SOFTIRQ);
...


whereas the dev_kfree_skb_irq() is called from the driver TX path for
freeing the skb.

There are other case; look in __netif_reschedule(), and in

dev_cpu_callback(), in net/core/dev.c


regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Wed, Apr 10, 2013 at 3:18 PM, Robert Clove cloverob...@gmail.com wrote:
 Hello All,

 I am clear all that the softirq is a software interrupt :
 Whenever a system call is about to return to the user space or h/w interrupt
 exit,ant s/w interrupt which are marked pending are run.

 Now in networking code i found

 open_softirq(NET_TX_SOFTIRQ, net_tx_action, NULL);

 What does this do?

 Thanks


 ___
 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: Interrupt Handler of Ethernet Device

2013-04-07 Thread Rami Rosen
Hi,
we have in :
 http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/e100.c

struct nic {
/* Begin: frequently used values: keep adjacent for cache effect */
u32 msg_enable  cacheline_aligned;
struct net_device *netdev;
 struct pci_dev *pdev;
 ...
 ...

And indeed  nic-netdev represents an Ethernet interface, which
is the struct net_device (see: include/linux/netdevice.h)

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sun, Apr 7, 2013 at 5:52 AM, ishare june.tune@gmail.com wrote:
 On Fri, Apr 05, 2013 at 03:06:37PM +0300, Rami Rosen wrote:
 Robert,
 You should look for the request_irq() method in the driver.
 This method registers an interrupt handler.
 For example, you can look in:
 http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/e100.c
 ...
 ...
 if ((err = request_irq(nic-pdev-irq, e100_intr, IRQF_SHARED,
  nic-netdev-name, nic-netdev)))

 ...

 This means that e100_intr is registered as an interrupt handler.

   Is this nic-netdev represent a  Ethernet interface ?



 Best,
 Rami Rosen
 http://ramirose.wix.com/ramirosen


 On Fri, Apr 5, 2013 at 11:50 AM, Robert Clove cloverob...@gmail.com wrote:
  Hello All,
 
 
  I am new here.
  I want to know the interrupt handler of the ethernet card and where can i
  find the definition of it so as i can clear the flow of packet reception.
 
  Thanks
  Robert
 
  ___
  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

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


Re: Interrupt Handler of Ethernet Device

2013-04-05 Thread Rami Rosen
Robert,
You should look for the request_irq() method in the driver.
This method registers an interrupt handler.
For example, you can look in:
http://lxr.free-electrons.com/source/drivers/net/ethernet/intel/e100.c
...
...
if ((err = request_irq(nic-pdev-irq, e100_intr, IRQF_SHARED,
 nic-netdev-name, nic-netdev)))

...

This means that e100_intr is registered as an interrupt handler.

Best,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Fri, Apr 5, 2013 at 11:50 AM, Robert Clove cloverob...@gmail.com wrote:
 Hello All,


 I am new here.
 I want to know the interrupt handler of the ethernet card and where can i
 find the definition of it so as i can clear the flow of packet reception.

 Thanks
 Robert

 ___
 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: cgroup.procs versus tasks (cgroups)

2013-04-02 Thread Rami Rosen
Hi,

BTW, for a given thread group with a specified TGID, you can view all the
threads PIDs in that thread group thus:
pstree -p TGID

and:
pstree TGID
 will give one line; It visually merges identical branches by putting
them in square brackets and prefixing them with the repetition count.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Tue, Apr 2, 2013 at 9:14 PM,  valdis.kletni...@vt.edu wrote:
 On Tue, 02 Apr 2013 16:46:24 +0300, Kevin Wilson said:
 Hi,
 Thanks  a lot Vlad. This explains it.
 - Does anybody know of a ps command (or a filter to  ps command)
 which will display only multithreaded
 processes (list processes by TGID) ?  (I know now about the option of
 displaying cgroup.procs , but is something parallel can be done with ps ? )

 Have you tried 'ps -m' and friends?  Though it doesn't do exactly
 what you wanted and *only* display multithreaded, you need to do some
 post-processing:

 $ ps max
 ...
928 ?-  0:00 /sbin/auditd -n
  - -Ssl   0:00 -
  - -Ssl   0:00 -
940 ?-  0:00 /sbin/audispd
  - -Ssl   0:00 -
  - -Ssl   0:00 -
951 ?-  0:00 /usr/sbin/abrtd -d -s
  - -Ss 0:00 -
960 ?-  0:00 /usr/bin/abrt-watch-log -F Backtrace 
 /var/log/Xorg.0.log -- /usr/bin/abrt-dump-xorg -xD
  - -Ss 0:00 -

 If there's 2 or more '- -' after the process entry, it's multi=threaded.

 Note however that as far as the kernel is concerned, a single-threaded
 process is handled by the code as a multi-threaded that happens to have
 only one thread at the moment.  In other words, thinking that single and
 multi threaded is different in some mystical way will probably end up
 causing trouble for  you...

 ___
 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: relationship between cpu_affinity and Packet RX Processing

2013-03-30 Thread Rami Rosen
Hi,
Stay tuned as I intend to put on the web an expanded document,
including documentations about kernel internals (besides networking).

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Fri, Mar 29, 2013 at 4:36 PM, Kumar amit mehta gmate.a...@gmail.com wrote:
 On Tue, Mar 26, 2013 at 09:31:01PM +0200, Rami Rosen wrote:
  Hi,
 
  1) You can be sure that it does not use more than one rx queue.
 
  You can find more info about RX queues in
  http://media.wix.com/ugd//295986_4ef6dbdf11fd0a7f74f09741b4b5b2ee.pdf
 

 Thank you so much for sharing this.

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


Re: what does the kernel does after it is being notified of incoming Frame

2013-03-26 Thread Rami Rosen
Hi,

 Can you give me more references even linked videos.

You might want to take a look in section 6, Receiving a packet,
in Linux Kernel Networking (free 189 pages doc).
see:
http://media.wix.com/ugd//295986_4ef6dbdf11fd0a7f74f09741b4b5b2ee.pdf

(A shameless plug as I wrote it...)

rgs,
Rami Rosen
http://ramirose.wix.com/ramirosen

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


Re: relationship between cpu_affinity and Packet RX Processing

2013-03-26 Thread Rami Rosen
Hi, Kumar,

1) Regarding rx queues: what does
ls /sys/class/net/eth0/queues
show ?

2) can you try setting affinity for working only with CPU3
and see what happens after some traffic is sent by
cat /proc/interrupts?

regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Tue, Mar 26, 2013 at 8:31 PM, Kumar amit mehta gmate.a...@gmail.com wrote:
 Hi All,

 I was reading some stuff on interrupts and irq lines today and I thought I'll
 expermient with the network rx path. To start with, I've a Virtual Machine
 running 3.8 linux kernel. My machine has 4 CPU cores, network (eth) interface
 is driven by pcnet_32 AMD driver and is tied to IRQ line #19. I started some
 network traffic and I notice that out of those 4 CPUs, only one of them is 
 being
 used and despite changing the CPU affinity, I still don't see the other cores
 being used for this network traffic. So based on this behavior(please see the
 logs below), I've these following queries:
 i) Does it mean that this network card do not have multiple Rx Queues ?
 ii) I think all the modern NICs must be implementing multiple Rx Queues and
 hence Can someone please point me to the simplest of such implemenation in any
 of the in-tree drivers ?
 iii) I'm just doing a simple 'ping' to google with of big size packets, As I 
 do
 not have a peer to use packetgen/netperf/iperf utilities.

 ref: Comments in double quotes.
 logs
 $ uname -r
 3.8.0-rc6-next-20130208

 $ cat /proc/cpuinfo |grep processor
 processor   : 0
 processor   : 1
 processor   : 2
 processor   : 3
 Total 4 cpu cores

 $ cat /proc/interrupts|egrep 'eth0|CPU'
 CPU0   CPU1   CPU2   CPU3
 19: 5103 74 33  5   IO-APIC-fasteoi eth0
 IRQ Line #19 for the network device

 $ lspci|grep -i ethernet
 02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 
 LANCE]
 (rev 10)

 AMD NIC
 $ lspci -s 02:01.0 -vvv|grep module
 Kernel modules: pcnet32

 $ lsmod|grep pcnet32
 pcnet3240671  0
 driver

 # whoami
 root

 # cat /proc/irq/19/smp_affinity
 03

 # cat /proc/irq/19/affinity_hint
 00

 I think smp_affinity is a bit map, therefore for all the four cores to be
 utilized, all 4 bits should be set to 1, which leads to 15(0xf), hence Chaning
 the cpu affinity
 # echo 15  /proc/irq/19/smp_affinity
 # cat /proc/irq/19/smp_affinity
 15

 started network traffic here and monitoring it
 # cat /proc/interrupts|grep eth0
 19:   5452 78 33  5   IO-APIC-fasteoi   eth0
 # cat /proc/interrupts|grep eth0
 19:   5488 78 35  5   IO-APIC-fasteoi   eth0
 # cat /proc/interrupts|grep eth0
 19:   5492 78 35  5   IO-APIC-fasteoi   eth0
 # cat /proc/interrupts|grep eth0
 19:   5500 78 35  5   IO-APIC-fasteoi   eth0
 .
 .after some time.
 # cat /proc/interrupts|grep eth0
 19:   6035 78 42  5   IO-APIC-fasteoi   eth0

 Most of the packets are still getting routed through CPU0 *Only*.
 logs

 -Amit

 ___
 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: relationship between cpu_affinity and Packet RX Processing

2013-03-26 Thread Rami Rosen
Hi,

1) You can be sure that it does not use more than one rx queue.

You can find more info about RX queues in
http://media.wix.com/ugd//295986_4ef6dbdf11fd0a7f74f09741b4b5b2ee.pdf

(I wrote it, a shameless plug...)

2) Does the irqbalance service, which is common in some distros, is
running ? can you try to disable it and run traffic again and check
/proc/interrupts afrer some time ?

3) regardless of 2 (meaning not stopping irqbalance if it was active)
can you please try taskset 02 ping www.google.com and tell us
whether interrupts were incremented on the second CPU ? (please send
/proc/interrupts | grep eth0 before and after sending, let's say, 5
pings)?

Rgs,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Tue, Mar 26, 2013 at 9:05 PM, Kumar amit mehta gmate.a...@gmail.com wrote:
 On Tue, Mar 26, 2013 at 08:35:56PM +0200, Rami Rosen wrote:
 1) Regarding rx queues: what does
 ls /sys/class/net/eth0/queues
 show ?


 $ ls /sys/class/net/eth0/queues
 rx-0  tx-0

 2) can you try setting affinity for working only with CPU3
 and see what happens after some traffic is sent by
 cat /proc/interrupts?

 # echo 8  /proc/irq/19/smp_affinity
 # cat /proc/irq/19/smp_affinity
 08

 $ cat /proc/interrupts |grep eth0
 19:  20635 78387   1857   IO-APIC-fasteoi   eth0
 $ cat /proc/interrupts |grep eth0
 19:  20635 78387   3041   IO-APIC-fasteoi   eth0

 Now only, CPU3 is processing the packets.
 So, i think, this driver(pcnet32) is not using multiple Rx Queue.

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


Re: Why we Use both mm_users and mm_count in struct mm_struct{ }

2013-03-25 Thread Rami Rosen
Hi,

Regarding your question about the previous thread:
Think of a context switch, let's say between a userspace process and a
kernel thread. A context switch is done between two processes
(processes are represented by struct task_struct). So when you look at
context_switch() prototype, you see:

context_switch(struct rq *rq, struct task_struct *prev,
...)

and prev is the process which ran in the run_queue of the scheduler
previously, before switching
to the new kernel thread. And we borrow memory descriptor from this process.

Rgs,
Rami Rosen
http://ramirose.wix.com/ramirosen






On Mon, Mar 25, 2013 at 8:02 AM, anish singh
anish198519851...@gmail.com wrote:
 On Mon, Mar 25, 2013 at 1:35 AM, Rami Rosen roszenr...@gmail.com wrote:
 Hi, Niroj,

 Please look at the following scenario:
 Suppose we create a kernel thread.
 With kernel threads, the mm member of the task_struct is NULL.
 (We are not permitted to access user space addresses from kernel thread,
 so we don't need mm).
 Kernel threads use (borrow) the active_mm of the previous thread.
 as we know that kernel threads are not associated with any user space
 process then why this overheads of active_mm or why we borrow the
 active_mm of the previous thread.
 Can you explain: what is previous thread here?
 But in order to avoid freeing the active_mm if the previous threads 
 terminates
 before the kernel thread terminates, we increment mm_count of the
 active_mm of the previous thread
 when we create a kernel thread (which borrows the active_mm of the
 previous thread).
 In such a case, even if the mm_users is 0, mm_count is not 0, and
 we do not free that mm_active.
 (remember that mm_users is initialized to 1).

 To be more specific:
 when that previous thread terminates, we call
 the mmput() (see exit_mm(), in kernel/exit.c)
 mmput() decrements mm_users and calls mmdrop().
 Since in mmdrop(), after decrements mm_count it is not 0,
 we do not free the mm_struct.

 Here are the code snippets:

 /*
  * Decrement the use count and release all resources for an mm.
  */
 void mmput(struct mm_struct *mm)
 {
 might_sleep();

 if (atomic_dec_and_test(mm-mm_users)) {
 uprobe_clear_state(mm);
 exit_aio(mm);
 ksm_exit(mm);
 khugepaged_exit(mm); /* must run before exit_mmap */
 exit_mmap(mm);
 set_mm_exe_file(mm, NULL);
 if (!list_empty(mm-mmlist)) {
 spin_lock(mmlist_lock);
 list_del(mm-mmlist);
 spin_unlock(mmlist_lock);
 }
 if (mm-binfmt)
 module_put(mm-binfmt-module);
 mmdrop(mm);
 }
 }



 mmdrop() is for freeing a memory descriptor:

 static inline void mmdrop(struct mm_struct * mm)
 {
 if (unlikely(atomic_dec_and_test(mm-mm_count)))
 __mmdrop(mm);
 }


 When the condition if (!mm) is true, this means this is a kernel thread:

 static inline void
 context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
 {
 struct mm_struct *mm, *oldmm;

 prepare_task_switch(rq, prev, next);

 mm = next-mm;
 oldmm = prev-active_mm;
 /*
  * For paravirt, this is coupled with an exit in switch_to to
  * combine the page table reload and the switch backend into
  * one hypercall.
  */
 arch_start_context_switch(prev);

 if (!mm) {
 next-active_mm = oldmm;
 atomic_inc(oldmm-mm_count);
 enter_lazy_tlb(oldmm, next);
 } else
 ...

 Regards,
 Rami Rosen
 http://ramirose.wix.com/ramirosen




 On Sat, Mar 23, 2013 at 7:02 AM, Niroj Pokhrel nirojpokh...@gmail.com 
 wrote:
 Hi all,
 I have been going through the Address Space in the linux and came across two
 variables in the struct mm_struct and I'm a bit confused about the two:
 struct mm_struct
 {
   ..
   atomic_t   mm_users;
   atomic_t   mm_count;
   
 }
 Basically, after reading through I came to understand that mm_users are used
 to store the number of processes or threads using the memory so depending
 upon the number of users it is going to be set.
 But, I am confused with mm_count, it is said the mm_count is increment by
 one for all the mm_users and when all the mm_users value is reduced to zero
 then mm_count is reduced. So, my question is can the value of mm_count be
 ever greater than one because all the mm_users are equivalent to mm_count .
 So, if not then why are we using the mm_count as we can simply remove the
 memory areas whenever the mm_users count reduce to zero.
 May be the explanation is simple but I'm lost. Thanking all of you in
 advance.


 Regards,
 Niroj Pokhrel

 ___
 Kernelnewbies mailing list
 Kernelnewbies

Re: question about

2013-03-25 Thread Rami Rosen
Hi,
In init_clocksource_sysfs() method,
device_register() adds the folder:
/sys/devices/system/clocksource/clocksource0,
whereas subsys_system_register() adds the parent folder
(/sys/devices/system/clocksource)
see:
http://lxr.free-electrons.com/source/kernel/time/clocksource.c#L902


rgs,
Rami Rosen
http://ramirose.wix.com/ramirosen

On Mon, Mar 25, 2013 at 4:57 AM, Moritz Fischer
moritz.fisc...@ettus.com wrote:
 On Sun, Mar 24, 2013 at 1:29 PM, Kevin Wilson wkev...@gmail.com wrote:

 Kevin,

 Any idea which methods adds the following entries:
 /sys/devices/system/clocksource/clocksource0
 /sys/devices/system/clocksource/clocksource0/available_clocksource

 I'm not an expert, but a quick grep for 'available_clocksource' led me
 to the kernel/time/clocksource.c file.

 Hope that helps you out,

 - Moritz

 ___
 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: Why we Use both mm_users and mm_count in struct mm_struct{ }

2013-03-24 Thread Rami Rosen
Hi, Niroj,

Please look at the following scenario:
Suppose we create a kernel thread.
With kernel threads, the mm member of the task_struct is NULL.
(We are not permitted to access user space addresses from kernel thread,
so we don't need mm).
Kernel threads use (borrow) the active_mm of the previous thread.
But in order to avoid freeing the active_mm if the previous threads terminates
before the kernel thread terminates, we increment mm_count of the
active_mm of the previous thread
when we create a kernel thread (which borrows the active_mm of the
previous thread).
In such a case, even if the mm_users is 0, mm_count is not 0, and
we do not free that mm_active.
(remember that mm_users is initialized to 1).

To be more specific:
when that previous thread terminates, we call
the mmput() (see exit_mm(), in kernel/exit.c)
mmput() decrements mm_users and calls mmdrop().
Since in mmdrop(), after decrements mm_count it is not 0,
we do not free the mm_struct.

Here are the code snippets:

/*
 * Decrement the use count and release all resources for an mm.
 */
void mmput(struct mm_struct *mm)
{
might_sleep();

if (atomic_dec_and_test(mm-mm_users)) {
uprobe_clear_state(mm);
exit_aio(mm);
ksm_exit(mm);
khugepaged_exit(mm); /* must run before exit_mmap */
exit_mmap(mm);
set_mm_exe_file(mm, NULL);
if (!list_empty(mm-mmlist)) {
spin_lock(mmlist_lock);
list_del(mm-mmlist);
spin_unlock(mmlist_lock);
}
if (mm-binfmt)
module_put(mm-binfmt-module);
mmdrop(mm);
}
}



mmdrop() is for freeing a memory descriptor:

static inline void mmdrop(struct mm_struct * mm)
{
if (unlikely(atomic_dec_and_test(mm-mm_count)))
__mmdrop(mm);
}


When the condition if (!mm) is true, this means this is a kernel thread:

static inline void
context_switch(struct rq *rq, struct task_struct *prev,
   struct task_struct *next)
{
struct mm_struct *mm, *oldmm;

prepare_task_switch(rq, prev, next);

mm = next-mm;
oldmm = prev-active_mm;
/*
 * For paravirt, this is coupled with an exit in switch_to to
 * combine the page table reload and the switch backend into
 * one hypercall.
 */
arch_start_context_switch(prev);

if (!mm) {
next-active_mm = oldmm;
atomic_inc(oldmm-mm_count);
enter_lazy_tlb(oldmm, next);
} else
...

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen




On Sat, Mar 23, 2013 at 7:02 AM, Niroj Pokhrel nirojpokh...@gmail.com wrote:
 Hi all,
 I have been going through the Address Space in the linux and came across two
 variables in the struct mm_struct and I'm a bit confused about the two:
 struct mm_struct
 {
   ..
   atomic_t   mm_users;
   atomic_t   mm_count;
   
 }
 Basically, after reading through I came to understand that mm_users are used
 to store the number of processes or threads using the memory so depending
 upon the number of users it is going to be set.
 But, I am confused with mm_count, it is said the mm_count is increment by
 one for all the mm_users and when all the mm_users value is reduced to zero
 then mm_count is reduced. So, my question is can the value of mm_count be
 ever greater than one because all the mm_users are equivalent to mm_count .
 So, if not then why are we using the mm_count as we can simply remove the
 memory areas whenever the mm_users count reduce to zero.
 May be the explanation is simple but I'm lost. Thanking all of you in
 advance.


 Regards,
 Niroj Pokhrel

 ___
 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: networking question

2013-03-14 Thread Rami Rosen
Hi,

Can you post your client and server code?

rgs,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Thu, Mar 14, 2013 at 12:55 PM, devendra.aaru devendra.a...@gmail.com wrote:
 Hey all,

 I have got a strange bug(?) while testing the multicasting server and client.

 I have done only the INADDR_ANY bind in server and client adds its
 IP_MULTICAST_IF to 224.0.0.1 ,

 surprisingly i recvd pkts from the client with out joining using
 IP_ADD_MEMBERSHIP.

 Is that a bug? or as we listening on INADDR_ANY will make us recv all
 the mcast/bcast pkts?

 while if i do tx on 224.0.0.3 , the server is not able to recv the packets.

 any ideas?

 ___
 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: Sending an IP packet

2013-02-22 Thread Rami Rosen
Hi, Adel,

You should use
ip_route_output_flow().
For this you should construct a
 flowi4 instance.
ip_route_output_flow() is exported via EXPORT_SYMBOL_GPL.

See for example how this is done in udp_sendmsg().

Good luck!

Rami Rosen
http://ramirose.wix.com/ramirosen

On Fri, Feb 22, 2013 at 2:36 PM, Adel Qodmani mpca...@gmail.com wrote:
 Hey,

 My question is quite simple, I have an sk_buff that I want to transmit, the
 sk_buff is an ICMP message and so far, I've built the headers and set up
 everything.

 The problem is, when I want to do such a thing, I typically use a function
 called:
 dev_queue_xmit which takes the skb and transmits the packet using the
 net_device specified in the skb; but time time I can't set the net_device, I
 need the packet to go through the routing code and get it sent normally; so
 what function can I use to that?

 Some notes:
 *The kernel I am working on is 3.2.0-37
 *I am working using Modules, so symbols that are not exported are
 unreachable for me
 *I set the IP header using htons, so my header data is already in network
 byte-order.

 Regards,
 Adel

 ___
 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: Sending an IP packet

2013-02-22 Thread Rami Rosen
Hi, Adel,
ip_route_output_flow() calls
__ip_route_output_key().

The return value is the routing entry, rtable.

the parameters for __ip_route_output_key() do not
include sock; only net and flow (flp4).
And the __ip_route_output_key() is exported.

There is
a call for xfrm_lookup() which does need a sock
in ip_route_output_flow()

The xfrm_lookup() is empty when building without IPsec.

So in you case, if you know that your solution does not require
IPSec traffic, you can use __ip_route_output_key().

rgs.
Rami Rosen
http://ramirose.wix.com/ramirosen


On Fri, Feb 22, 2013 at 3:53 PM, Adel Qodmani mpca...@gmail.com wrote:
 On Fri, Feb 22, 2013 at 3:47 PM, Rami Rosen roszenr...@gmail.com wrote:

 Hi, Adel,

 You should use
 ip_route_output_flow().
 For this you should construct a
  flowi4 instance.
 ip_route_output_flow() is exported via EXPORT_SYMBOL_GPL.

 See for example how this is done in udp_sendmsg().

 Good luck!

 Rami Rosen
 http://ramirose.wix.com/ramirosen

 On Fri, Feb 22, 2013 at 2:36 PM, Adel Qodmani mpca...@gmail.com wrote:
  Hey,
 
  My question is quite simple, I have an sk_buff that I want to transmit,
  the
  sk_buff is an ICMP message and so far, I've built the headers and set up
  everything.
 
  The problem is, when I want to do such a thing, I typically use a
  function
  called:
  dev_queue_xmit which takes the skb and transmits the packet using the
  net_device specified in the skb; but time time I can't set the
  net_device, I
  need the packet to go through the routing code and get it sent normally;
  so
  what function can I use to that?
 
  Some notes:
  *The kernel I am working on is 3.2.0-37
  *I am working using Modules, so symbols that are not exported are
  unreachable for me
  *I set the IP header using htons, so my header data is already in
  network
  byte-order.
 
  Regards,
  Adel
 
  ___
  Kernelnewbies mailing list
  Kernelnewbies@kernelnewbies.org
  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
 

 Hi Rami,

 Using ip_route_output_flow() or using udp_sendmsg() would require not only
 constructing a flowi4 but also a sock; I am intentionally trying to avoid
 building a sock at the time being.
 Is there a way I can deliver my sk_buff to the routing code so that it'd set
 the net_device in there or at least tell me which interface to use and then
 I'd set it up myself?

 Thankful,
 Adel

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


Re: Sending an IP packet

2013-02-22 Thread Rami Rosen
Hi, Adel,
  - In your first message you said you are using kernel modules.
  - In case you intend to add code in ICMP for your special
requirements from the control protocol,  then this seems not a good
idea (because this means patching the kernel for using your module;
and probably such patches will not go to mainline)
I don't know of any usage of ICMP for  purposes beyond what is
declared in the ICMP RFC.

regards,
Rami Rosen
http://ramirose.wix.com/ramirosen

On Fri, Feb 22, 2013 at 5:15 PM, Adel Qodmani mpca...@gmail.com wrote:

 On Fri, Feb 22, 2013 at 4:54 PM, valdis.kletni...@vt.edu wrote:

 On Fri, 22 Feb 2013 14:36:17 +0200, Adel Qodmani said:


 Others have given some details on how.  A better question is why.


 Well, the why is the following:

 I am trying to implement a new protocol that we've designed which works on
 top of the IP layer, so I am using ICMP messages to carry control
 information for the protocol.
 Why using ICMP, it seemed natural since our protocol is a Network-layer
 protocol and ICMP is a control messages protocol.

 Does that make sense?

 Regards,
 Adel

 ___
 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 source code tree

2013-02-09 Thread Rami Rosen
Hi,
You can pick a kernel to download from:
http://www.kernel.org/pub/linux/kernel/v3.x/
The latest stable kernel is

Regarding configuration, you can take the config file of Ubuntu
in order to avoid risk of errors in configuration.


Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Sat, Feb 9, 2013 at 5:48 PM, sunil sunil.slvp...@gmail.com wrote:
 Hi all,

 need help, I am trying to write simple device driver. But before that
 i need to download kernel source code tree
 someone please explain how to download  this and configure. I am very
 new to this. I am using ubuntu 12.04


 thanks  regards
 sunil A S

 ___
 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: Linux Kernel Networking document (free, 178 pages doc)

2013-01-31 Thread Rami Rosen
Hi,
Have you considered to start with ext4?
it seems that ext3, ext2 are a bit out of fashion,

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Thu, Jan 31, 2013 at 8:58 PM, shubham kernel.shub...@gmail.com wrote:
 Thanks Rami,

 I am also trying to understand ext3 and write some document for the same.

 Regards
 Shubham


 On 31-Jan-13 12:51 AM, Rami Rosen wrote:

 HI,
 I will try to write something for Linux Filesystems  (and maybe for
 other subsystems) but this will probably take a lot of time.

 Regards,
 Rami Rosen
 http://ramirose.wix.com/ramirosen


 On Wed, Jan 30, 2013 at 5:44 PM, shubham kernel.shub...@gmail.com wrote:

 Thanks for sharing the document.

 I hope we could have such documents for other subsystems as well.

 Regards
 Shubham


 On 28-Jan-13 10:23 PM, Rami Rosen wrote:

 Hi everyone,
 You can find here an up to date and detailed document in pdf (178
 pages) about Linux Kernel Networking; going deep into design and
 implementation details as well as the theory behind it:
 http://media.wix.com/ugd//295986_931b8bcf34d93419d46e05b5aa5d0216.pdf

 I believe that developers/sysadmins/researchers/students may find help
 with it.


 regards,
 Rami Rosen

 http://ramirose.wix.com/ramirosen

 ___
 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: Linux Kernel Networking document (free, 178 pages doc)

2013-01-30 Thread Rami Rosen
HI,
I will try to write something for Linux Filesystems  (and maybe for
other subsystems) but this will probably take a lot of time.

Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen


On Wed, Jan 30, 2013 at 5:44 PM, shubham kernel.shub...@gmail.com wrote:
 Thanks for sharing the document.

 I hope we could have such documents for other subsystems as well.

 Regards
 Shubham


 On 28-Jan-13 10:23 PM, Rami Rosen wrote:

 Hi everyone,
 You can find here an up to date and detailed document in pdf (178
 pages) about Linux Kernel Networking; going deep into design and
 implementation details as well as the theory behind it:
 http://media.wix.com/ugd//295986_931b8bcf34d93419d46e05b5aa5d0216.pdf

 I believe that developers/sysadmins/researchers/students may find help
 with it.


 regards,
 Rami Rosen

 http://ramirose.wix.com/ramirosen

 ___
 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


Linux Kernel Networking document (free, 178 pages doc)

2013-01-28 Thread Rami Rosen
Hi everyone,
You can find here an up to date and detailed document in pdf (178
pages) about Linux Kernel Networking; going deep into design and
implementation details as well as the theory behind it:
http://media.wix.com/ugd//295986_931b8bcf34d93419d46e05b5aa5d0216.pdf

I believe that developers/sysadmins/researchers/students may find help with it.


regards,
Rami Rosen

http://ramirose.wix.com/ramirosen

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


Re: sys fs interface

2012-12-30 Thread Rami Rosen
Hi,
This is done via:
kobject_create_and_add(), which
eventually calls sysfs_create_file(), or sysfs_create_group().

Look in Documentation/kobject.txt

regards,
Rami Rosen
http://ramirose.wix.com/ramirosen




On Fri, Dec 28, 2012 at 1:22 PM, Rahul Bedarkar rpal...@gmail.com wrote:
 Hi,

 When driver provides sys fs interface for user space programs, how we
 specify name of file to be created ?


 Thanks,
 Rahul B.

 ___
 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: what is tty* in /edv file folder?

2012-11-28 Thread Rami Rosen
Hi,

These are character devices for I/O.

/dev/tty0 is a special device, representing the current terminal.
/dev/tty1 is the  first virtual terminal,  /dev/tty1 is second virtual terminal
(usually there are 6 virtual terminals).

The other /dev/tty* are for other purposes.

Regards,
Rami Rosen

http://ramirose.wix.com/ramirosen


On Wed, Nov 28, 2012 at 12:11 PM, horse_rivers horse_riv...@126.com wrote:
 hi:


I find in /dev/ file folder ,there are many tty* , which is like  
 tty0,ty1,tty7,tty9,and son on.

   I do not know what is this ?

my computer may not have so many device

 thanks!

 ___
 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