Re: PCI Issues

2009-09-14 Thread Pei Lin
2009/9/15 Greg KH :
> On Tue, Sep 15, 2009 at 09:19:52AM +0800, Pei Lin wrote:
>> 2009/9/15 Greg KH :
>> > On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
>> >> Hello,
>> >> 1. Can several drivers can handle the same PCI device?
>> >
>> > Officially, No.  Unofficially, there are ways to do this, but you have
>> > to be _very_ careful.
>> >
>> > What type of PCI device do you want to control?  Is there already a
>> > driver bound to it?
>> >
>> >> 2. How can I know which driver currently handles my PCI devices? (lsmod 
>> >> show
>> >> few drivers that can show a few candidate but I want to know the actual
>> >> driver that register to that PCI).
>> >
>> > lspci -k
>> >
>> hi, grep,
>
> The name is "Greg" :)
>

Oh~ sorry, maybe these days i type too much command "grep". LOL ,^_^.

>> what is your lspci's version? and in my fc8 ,lspci version
>> is 2.2.6 which has no parameter about -k.
>
> fc8 is very old, please use a newer version.  I'm running 3.1.4 here.
>
>> So lspci just can tell me a not very clear info about pci device if
>> there is no device driver attach it.
>
> Not true, use a newer lspci version.
>
> Or just use the proper symlink in sysfs, it will tell you if a driver is
> bound to a device, which is what lspci uses.
ok, that is very useful for me. Thanks a lot.

BRs

Lin

>
> good luck,
>
> greg k-h
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread raz ben yehuda
i would i have used netconsole. 

On Tue, 2009-09-15 at 11:45 +0530, Leonidas . wrote:
> 
> 
> On Mon, Sep 14, 2009 at 7:00 PM, Pei Lin  wrote:
> 2009/9/14 Leonidas . :
> >
> >
> 
> 
> > On Mon, Sep 14, 2009 at 4:01 PM, Leonidas .
>  wrote:
> >>
> >>
> >> On Mon, Sep 14, 2009 at 3:32 PM, Leonidas .
>  wrote:
> >>>
> >>>
> >>> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas .
> 
> >>> wrote:
> 
> 
>  On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao
>   wrote:
> >
> > hi leo
> > maintain circular buffer in module, so that if user
> doesn't access for
> > days its going to be automatically discarded.I think
> printk also use same
> > kind of mechanism which dumps data into cirbuffer.
> >
> > thanks,
> > karuna.
> >
> > On Mon, Sep 14, 2009 at 2:41 PM, Leonidas .
> 
> > wrote:
> >>
> >>
> >> On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao
> >>  wrote:
> >>>
> >>> hi leo
> >>> you can maintain buffer in your module to log
> errors.When user tries
> >>> to access /proc you can print all those from your
> buffer.
> >>>
> >>> Thanks,
> >>> karuna.
> >>>
> >>> On Mon, Sep 14, 2009 at 1:22 PM, Leonidas .
> 
> >>> wrote:
> 
> 
>  Hi List
> 
>  I have written a kernel module which implements a
> char device. An
>  userspace app
>  is supposed to get data from my module and then dump
> it into a file
>  for further processing.
> 
>  The kind of data which kernel module is going to pass
> to userspace
>  is going to be a 4K buffer,
>  and the data traffic is not going to be really heavy,
> meaning may be
>  a 4K buffer every 1 min or so.
>  I am not very sure though, but certainly not heavy
> traffic the way
>  they describe for network traffic etc.
> 
>  And this data needs to be logged to a file either
> from kernel or
>  userspace and an userspace all will work
>  on that data. This data needs to be logged as soon as
> it arrives
>  meaning, I might not be able to write it to
>  /proc since from module I can update /proc only when
> user actually
>  accesses it. This data needs to be
>  static in nature, meaning I get one error and I write
> it to a file
>  somehow and user can see it anytime.
> 
>  I hope I have described the situation clearly. I have
> explored some
>  mechanism like ioctls, mmaping the
>  kernel buffer etc but all these would require the
> user module to
>  poll or notified somehow by kernel that
>  the data is available. I dont want the user module to
> poll.
> 
> 
>  -Leo.
> 
> >>>
> >>
> >> Pei Lin,
> >>
> >> I am not limiting my solution by using a law or what
> someone says. But
> >> I think it is very important to
> >> follow the spirit of environment/OS/arch you are
> working on and come
> >> up with the best possible solution.
> 
> 
> hi , i didn't receive these messages. (^-^)
> yeah,u can choose the way u wanna go,no matter a wide road or
> some
> private alleys.
> which one is convenient for different guys.
> 
> >> As you correctly mention we can hack around and achieve
> the same
> >> functionality but I would rather do these
> >> kind of experiments for fun or to show my friends that
> the kernel can
> >> be hacked these ways, but certainly not
> >> in a system which is supposed to be a production
> system. I appreciate
> >> your thoughts and I am sure many times
> >> one stumbles upon real cool things which change course
> of nature and
> >> are reasons for radical changes in
> >> various subsystems. But I think this is not one of
> them, this has been
> >> discussed over and over again and there
> >> are stan

Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 7:00 PM, Pei Lin  wrote:

> 2009/9/14 Leonidas . :
> >
> >
> > On Mon, Sep 14, 2009 at 4:01 PM, Leonidas . 
> wrote:
> >>
> >>
> >> On Mon, Sep 14, 2009 at 3:32 PM, Leonidas . 
> wrote:
> >>>
> >>>
> >>> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas . 
> >>> wrote:
> 
> 
>  On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao
>   wrote:
> >
> > hi leo
> > maintain circular buffer in module, so that if user doesn't access
> for
> > days its going to be automatically discarded.I think printk also use
> same
> > kind of mechanism which dumps data into cirbuffer.
> >
> > thanks,
> > karuna.
> >
> > On Mon, Sep 14, 2009 at 2:41 PM, Leonidas . 
> > wrote:
> >>
> >>
> >> On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao
> >>  wrote:
> >>>
> >>> hi leo
> >>> you can maintain buffer in your module to log errors.When user
> tries
> >>> to access /proc you can print all those from your buffer.
> >>>
> >>> Thanks,
> >>> karuna.
> >>>
> >>> On Mon, Sep 14, 2009 at 1:22 PM, Leonidas .  >
> >>> wrote:
> 
> 
>  Hi List
> 
>  I have written a kernel module which implements a char device. An
>  userspace app
>  is supposed to get data from my module and then dump it into a
> file
>  for further processing.
> 
>  The kind of data which kernel module is going to pass to userspace
>  is going to be a 4K buffer,
>  and the data traffic is not going to be really heavy, meaning may
> be
>  a 4K buffer every 1 min or so.
>  I am not very sure though, but certainly not heavy traffic the way
>  they describe for network traffic etc.
> 
>  And this data needs to be logged to a file either from kernel or
>  userspace and an userspace all will work
>  on that data. This data needs to be logged as soon as it arrives
>  meaning, I might not be able to write it to
>  /proc since from module I can update /proc only when user actually
>  accesses it. This data needs to be
>  static in nature, meaning I get one error and I write it to a file
>  somehow and user can see it anytime.
> 
>  I hope I have described the situation clearly. I have explored
> some
>  mechanism like ioctls, mmaping the
>  kernel buffer etc but all these would require the user module to
>  poll or notified somehow by kernel that
>  the data is available. I dont want the user module to poll.
> 
> 
>  -Leo.
> 
> >>>
> >>
> >> Pei Lin,
> >>
> >> I am not limiting my solution by using a law or what someone says.
> But
> >> I think it is very important to
> >> follow the spirit of environment/OS/arch you are working on and come
> >> up with the best possible solution.
>
> hi , i didn't receive these messages. (^-^)
> yeah,u can choose the way u wanna go,no matter a wide road or some
> private alleys.
> which one is convenient for different guys.
>
> >> As you correctly mention we can hack around and achieve the same
> >> functionality but I would rather do these
> >> kind of experiments for fun or to show my friends that the kernel
> can
> >> be hacked these ways, but certainly not
> >> in a system which is supposed to be a production system. I
> appreciate
> >> your thoughts and I am sure many times
> >> one stumbles upon real cool things which change course of nature and
> >> are reasons for radical changes in
> >> various subsystems. But I think this is not one of them, this has
> been
> >> discussed over and over again and there
> >> are standard interfaces defined. My questions is more about the
> design
> >> part not about how I can hack and get
> >> the stuff done.
>
> yeah,i agree. If it is a commercial software, it need a pretty and
> clean interface to support future updating and maintenance.
>
> >>
> >> Karuna,
> >> I had thought about this solution i.e. maintain a buffer in module
> and
> >> dump it whenever user wants, only
> >> issue is my module will keep consuming memory here. I msg buffers
> can
> >> be freed once logged but how about
> >> a case where user does not request for few days? The amount of
> memory
> >> my module is going to consume will be
> >> unacceptable.
> >>
> >> -Leo
> >
> 
>  Sorry I did not mention it earlier, I can not discard any error
> message
>  logged, meaning these are error messages
>  and might crash my system after a long time. I need to to be able to
> see
>  all these messages till I restart my module.
> 
>  _Leo.
> >>>
> >>>
> >>> Basically, I am quite tight on memory and I would like to convery error
> >>> messages to user as soon as any
> >>> error condition is hit. So my m

Re: spinlocks and copy_to_user()

2009-09-14 Thread Peter Teoh
On Mon, Sep 14, 2009 at 11:43 PM, Daniel Baluta  wrote:
> On Mon, Sep 14, 2009 at 6:32 PM, Peter Teoh  wrote:
>> On Mon, Sep 14, 2009 at 11:11 PM, Peter Teoh  wrote:
>>> sounds like u need TWO variables.   reason goes like this:
>>
>
> Huh?
>
>>
>> sorryI also forgotten to mention that since there are two variable
>> now...the interrupt sensitive one should be using spinlock and the one
>> that need to be able to sleep() should be a mutex or semaphore
>
> Can you be more explicit :).
>
> Daniel.
>

I tried to be abstract and vague, because even the simple statement
"two variable" have multiple implementation possible, so it is up to
your design.

For eg (a specific design)since top half have to be quick
(http://www.linuxjournal.com/article/6916), just update ONE flag
(called flagA), perhaps just a 4 bytes or less variable.NO spin
lock is needed, and then in work queue (is is scheduled from inside
the interrupt), and work queue can sleep, just mutex lock all the
necessary structures fields (called structB), and modify it, and then
unlock it, before calling copy_to_user().   since u are not using
copy_from_user(), there is no way it can be modified from userspace,
and so no need to keep the mutex lock opened.

so long as nobody can acquire the mutex lock, all the fields will stay
consistent among itself.   whenever u modify one field, all the
necessary field get modified within the same lock - for
consistency/integrity reason.

but of course interrupt can always comes in and modify the flagA, just
go ahead and modify it.it will not affect the value of structB
now, but perhaps later, until when the next scheduled workqueue to
update the structB gets triggered again.

so on the whole everything is logically consistentany bugs in my
logic?   (this is just one implementation of the two variable concept)

-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: NEWBIE in kernel

2009-09-14 Thread Bian Jiang
> > On Fri, Sep 11, 2009 at 1:52 PM, Gaurav Soni  wrote:
> >>
> >> Hi Dear All,
> >>
> >> I m new in kernel programming,I have gone through beginning linux
> >> programming by matthew and stones, wrox publicaiton. Any one can
> >> please suggest me what will be the best way to start linux kernel
> >> programming.
> >>
>
> You might want to read these.
>
> 1. Linux kernel development, Rober Love.
> 2. Linux device drivers - Greg-KH
> 3. Linux kernel programming - Michal beck and others.
> 4. Advanced unix programming - Richard Stevens
>
> Going ahead you might want to read:
>
> UTLK - bovet and cesati
> Linux Virtual memory - Mel gorman.
>
> You need to refer to the sources in parallel. try lxr.linux.no or you
> can download the same from kernel.org
>
> >> With Regards
> >> Gaurav Soni
>


 I think the best way to start linux kernel programming is come from Greg
Kroah-Hartman  is Linux Kernel in a
Nutshell.

This book help you into the Linux kernel development.

-- 
Bian Jiang
Blog: http://www.wifihack.net


Re: PCI Issues

2009-09-14 Thread Greg KH
On Tue, Sep 15, 2009 at 09:19:52AM +0800, Pei Lin wrote:
> 2009/9/15 Greg KH :
> > On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
> >> Hello,
> >> 1. Can several drivers can handle the same PCI device?
> >
> > Officially, No.  Unofficially, there are ways to do this, but you have
> > to be _very_ careful.
> >
> > What type of PCI device do you want to control?  Is there already a
> > driver bound to it?
> >
> >> 2. How can I know which driver currently handles my PCI devices? (lsmod 
> >> show
> >> few drivers that can show a few candidate but I want to know the actual
> >> driver that register to that PCI).
> >
> > lspci -k
> >
> hi, grep,

The name is "Greg" :)

> what is your lspci's version? and in my fc8 ,lspci version
> is 2.2.6 which has no parameter about -k.

fc8 is very old, please use a newer version.  I'm running 3.1.4 here.

> So lspci just can tell me a not very clear info about pci device if
> there is no device driver attach it.

Not true, use a newer lspci version.

Or just use the proper symlink in sysfs, it will tell you if a driver is
bound to a device, which is what lspci uses.

good luck,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: DEVFS permissions

2009-09-14 Thread shankarGanesh

Greg KH wrote:

On Mon, Sep 14, 2009 at 08:38:48AM -0400, Shankar Ganesh wrote:

Hi ,

When we create a node under devfs ,


There is no such thing as devfs anymore.


hwcdev_class = class_create(THIS_MODULE, DRVNAME);
device_create(hwcdev_class, NULL, MKDEV(dev_major, 0), dev,
DEVNAME);

 the  node is created with default permission of 600 (root=rw, others nil) ,

crw   root root252  , 

How do i make permission setting automatically while creating node ? (i need
666 and don't want to execute chmod 666 /dev/mydev )


Create a udev rule to provide the proper permission for this device.


Thanks for your inputs


thanks,

greg k-h




--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: About Webcam module

2009-09-14 Thread Niamathullah sharief
Yes thank you..Now i am not getting my modules exactly. I compiled all the
required modules...ie gspca_main, gspca_zc3xx, v4l1-compat. But i am not
getting this "videodev" module..I dont know why...

My Makefile

*obj-m += gspca_main.o**
> *

*obj-m += gspca_zc3xx.o**
> *

*obj-m += v4l1-compat.o**
> *

*obj-m += v4l2-dev.o**
> *

*obj-m += v4l2-ioctl.o**
> *

*obj-m += v4l2-device.o*



> *gspca_main-objs := gspca.o**
> *

*gspca_zc3xx-objs := zc3xx.o**
> *

*videodev-objs := v4l2-dev.o v4l2-ioctl.o v4l2-device.o**
> *

*
> *

*all:**
> *

* make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules**
> *

*
> *

*clean:**
> *

* make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean*



if i compile i am getting the the modules as


* **shar...@sharief-desktop:~/Desktop/video/gspca$ make**
> *

*make -C /lib/modules/2.6.30/build M=/home/sharief/Desktop/video/gspca
> modules**
> *

*make[1]: Entering directory `/home/sharief/Desktop/kernelroot/linux-2.6.30'
> **
> *

* CC [M] /home/sharief/Desktop/video/gspca/gspca.o**
> *

* CC [M] /home/sharief/Desktop/video/gspca/zc3xx.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/gspca_main.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/gspca_zc3xx.o**
> *

* CC [M] /home/sharief/Desktop/video/gspca/v4l1-compat.o**
> *

* CC [M] /home/sharief/Desktop/video/gspca/v4l2-dev.o**
> *

* CC [M] /home/sharief/Desktop/video/gspca/v4l2-ioctl.o**
> *

* CC [M] /home/sharief/Desktop/video/gspca/v4l2-device.o**
> *

* Building modules, stage 2.**
> *

* MODPOST 6 modules**
> *

* CC /home/sharief/Desktop/video/gspca/gspca_main.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/gspca_main.ko**
> *

* CC /home/sharief/Desktop/video/gspca/gspca_zc3xx.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/gspca_zc3xx.ko**
> *

* CC /home/sharief/Desktop/video/gspca/v4l1-compat.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/v4l1-compat.ko**
> *

* CC /home/sharief/Desktop/video/gspca/v4l2-dev.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/v4l2-dev.ko**
> *

* CC /home/sharief/Desktop/video/gspca/v4l2-device.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/v4l2-device.ko**
> *

* CC /home/sharief/Desktop/video/gspca/v4l2-ioctl.mod.o**
> *

* LD [M] /home/sharief/Desktop/video/gspca/v4l2-ioctl.ko*


  I dont know why i am getting like this...?Please help me


Re: PCI Issues

2009-09-14 Thread Pei Lin
2009/9/15 Greg KH :
> On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
>> Hello,
>> 1. Can several drivers can handle the same PCI device?
>
> Officially, No.  Unofficially, there are ways to do this, but you have
> to be _very_ careful.
>
> What type of PCI device do you want to control?  Is there already a
> driver bound to it?
>
>> 2. How can I know which driver currently handles my PCI devices? (lsmod show
>> few drivers that can show a few candidate but I want to know the actual
>> driver that register to that PCI).
>
> lspci -k
>
hi, grep, what is your lspci's version? and in my fc8 ,lspci version
is 2.2.6 which has no parameter about -k.
So lspci just can tell me a not very clear info about pci device if
there is no device driver attach it.
like this:
00:1f.2 SATA controller: Intel Corporation Unknown device 3a02 (rev
02) (prog-if 01 [AHCI 1.0])
Subsystem: Hewlett-Packard Company Unknown device 3035
Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 221
I/O ports at 2250 [size=8]
I/O ports at 2268 [size=4]
I/O ports at 2258 [size=8]
I/O ports at 226c [size=4]
I/O ports at 21e0 [size=32]
Memory at f0526000 (32-bit, non-prefetchable) [size=2K]
Capabilities: [80] Message Signalled Interrupts: Mask- 64bit- Queue=0

BRs
Lin

>
> thanks,
>
> greg k-h
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecar...@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: ext4 extents: How to determine if an extent points to a hole.

2009-09-14 Thread Peter Teoh
just to share what i have read, based on "lwn.net surfing":

>From the article that started it all:

http://lwn.net/Articles/260795/

>From the specs, if u used ioctl() with FIEMAP_EXTENT_HOLE it will keep
returning u the next hole.

http://lwn.net/Articles/297696/
http://lwn.net/Articles/260803/
http://lwn.net/Articles/332610/
http://lwn.net/Articles/275722/

a few of the articles above have userspace program that shows how to
use the primitive FIEMAP_EXTENT_HOLE to identify holes.

have fun!!

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: any example of CONFIG_GENERIC_HARDIRQS=n?

2009-09-14 Thread Robert P. J. Day
On Mon, 14 Sep 2009, Robert P. J. Day wrote:

>   doing some research into a future newbie column on interrupts, and
> i noticed that every single config file default for the Kconfig
> variable CONFIG_GENERIC_HARDIRQS is "y", and every Kconfig file
> defines that variable as a bool and defaults it to y with no way to
> be user-selectable.  so the obvious question is, under what
> circumstances will that ever be "n"?
>
>   more to the point, what does that variable mean, anyway?  :-)

  never mind, i just realized my mistake -- that variable is tested
via an "#ifdef", so any arch that doesn't define it means implicitly
no.  duh.  i should have noticed that.  (that includes both 32-bit
sparc and m68k.)

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



any example of CONFIG_GENERIC_HARDIRQS=n?

2009-09-14 Thread Robert P. J. Day

  doing some research into a future newbie column on interrupts, and i
noticed that every single config file default for the Kconfig
variable CONFIG_GENERIC_HARDIRQS is "y", and every Kconfig file
defines that variable as a bool and defaults it to y with no way to be
user-selectable.  so the obvious question is, under what circumstances
will that ever be "n"?

  more to the point, what does that variable mean, anyway?  :-)

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: About Webcam module

2009-09-14 Thread Niamathullah sharief
Here i am facing a new problem. I tried to compile and install the
gspca_main and gspca_zc3xx modules separately. I compiled them successfully.
but i am getting error when inserting that modules


r...@sharief-desktop:/home/sharief/Desktop/video/gspca# insmod
> gspca_zc3xx.ko
>
insmod: error inserting 'gspca_zc3xx.ko': -1 Unknown symbol in module
>
r...@sharief-desktop:/home/sharief/Desktop/video/gspca# insmod gspca_main.ko
>
>
insmod: error inserting 'gspca_main.ko': -1 Unknown symbol in module
>

I think this both modules what some other modules to get insert in to
kernel...But i am sure about that modules. Can anyone help me?





On Sat, Sep 12, 2009 at 11:54 AM, Jean-Francois Moine wrote:

> On Fri, 11 Sep 2009 17:37:19 +0530
> Niamathullah sharief  wrote:
>
>[snip]
> > shar...@sharief-desktop:~$ modinfo -d gspca_zc3xx
> > >
> > GSPCA ZC03xx/VC3xx USB Camera Driver
> > >
> > shar...@sharief-desktop:~$ modinfo -d gspca_main
> > >
> > GSPCA USB Camera Driver
> > >
> > shar...@sharief-desktop:~$ modinfo -d videodev
> > >
> > Device registrar for Video4Linux drivers v2
> > >
> > shar...@sharief-desktop:~$ modinfo -d v4l1_compat
> > >
> > v4l(1) compatibility layer for v4l2 drivers.
> > >
> > shar...@sharief-desktop:~$
> > >
> >
> > So first two things are showing as camera driver. bur how it is
> > possible. kindly help me
>
> Hi,
>
> The driver of a USB device is easily found looking at
>/lib/modules/`uname -r`/modules.usbmap
>
> So, your driver is gspca_zc3xx. Then, this module uses the gspca
> framework, i.e it calls functions of the module gspca_main. This last
> one calls functions of the common video module videodev. Then again, if
> v4l1 compatibility is enabled, videodev calls functions of v4l1_compat.
>
> lsmod shows all that directly:
>
> Module  Size   Used by
> gspca_zc3xx55936   0
> gspca_main 29312   1   gspca_zc3xx
> videodev   41344   1   gspca_main
> v4l1_compat22404   1   videodev
>
> Regards.
>
> --
> Ken ar c'hentań | ** Breizh ha Linux atav! **
> Jef |   http://moinejf.free.fr/
>


Re: About Webcam module

2009-09-14 Thread Jean-Francois Moine
On Mon, 14 Sep 2009 23:30:27 +0530
Niamathullah sharief  wrote:

> Here i am facing a new problem. I tried to compile and install the
> gspca_main and gspca_zc3xx modules separately. I compiled them
> successfully. but i am getting error when inserting that modules
> 
> 
> r...@sharief-desktop:/home/sharief/Desktop/video/gspca# insmod
> > gspca_zc3xx.ko
> >
> insmod: error inserting 'gspca_zc3xx.ko': -1 Unknown symbol in module
> >
> r...@sharief-desktop:/home/sharief/Desktop/video/gspca# insmod
> gspca_main.ko
> >
> >
> insmod: error inserting 'gspca_main.ko': -1 Unknown symbol in module
> >
> 
> I think this both modules what some other modules to get insert in to
> kernel...But i am sure about that modules. Can anyone help me?

Indeed, the 2 modules videodev and v4l1_compat must be loaded prior to
load first gspca_main and then gspca_zc3xx, as shown by lsmod (below).

Usually, insmod is not directly used. You must use modprobe which looks
at the symbols and loads the required modules.

> On Sat, Sep 12, 2009 at 11:54 AM, Jean-Francois Moine
> wrote:
> > 
> > So, your driver is gspca_zc3xx. Then, this module uses the gspca
> > framework, i.e it calls functions of the module gspca_main. This
> > last one calls functions of the common video module videodev. Then
> > again, if v4l1 compatibility is enabled, videodev calls functions
> > of v4l1_compat.
> >
> > lsmod shows all that directly:
> >
> > Module  Size   Used by
> > gspca_zc3xx55936   0
> > gspca_main 29312   1   gspca_zc3xx
> > videodev   41344   1   gspca_main
> > v4l1_compat22404   1   videodev


-- 
Ken ar c'hentañ | ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: multiple barrier bios to make_request_fn ?

2009-09-14 Thread Jens Axboe

On 14/09/2009, at 17.08, Ed Cashin  wrote:


On Mon Sep 14 05:38:23 EDT 2009, jens.ax...@oracle.com wrote:

On Fri, Sep 11 2009, Ed Cashin wrote:

The Documentation/block/barrier.txt information seems geared toward
block device drivers that handle I/O requests from the  
request_queue,

and not drivers that handle bios directly by providing their own
make_request_fn via blk_queue_make_request.

So I think the section quoted below does not apply to such a
bio-handling driver.

 * Currently, no matter which ordered mode is used, there can be  
only

 one barrier request in progress.  All I/O barriers are held off by
 block layer until the previous I/O barrier is complete.


Right, that synchronization does not exist at the bio level.


The implication is that when a bio_barrier(bio) is seen by the
make_request_fn, it should sleep until any in-progress barrier bio  
has

been completed.  Is that correct?


Yes, that is correct.


Thanks.

It looks like interested parties like filesystems use
blkdev_issue_flush to generate a barrier, but a bio generated by
blkdev_issue_flush will always be "empty", with no associated I/O to
do.

Can a make_request_fn-style driver count on barrier bios always being
I/O operation free?


No, they usually carry data too.




--
Jens Axboe

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: DEVFS permissions

2009-09-14 Thread Greg KH
On Mon, Sep 14, 2009 at 08:38:48AM -0400, Shankar Ganesh wrote:
> Hi ,
> 
> When we create a node under devfs ,

There is no such thing as devfs anymore.

> 
> hwcdev_class = class_create(THIS_MODULE, DRVNAME);
> device_create(hwcdev_class, NULL, MKDEV(dev_major, 0), dev,
> DEVNAME);
> 
>  the  node is created with default permission of 600 (root=rw, others nil) ,
> 
> crw   root root252  , 
> 
> How do i make permission setting automatically while creating node ? (i need
> 666 and don't want to execute chmod 666 /dev/mydev )

Create a udev rule to provide the proper permission for this device.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: PCI Issues

2009-09-14 Thread Greg KH
On Sun, Sep 13, 2009 at 05:12:11PM +0300, Mena Soliko wrote:
> Hello,
> 1. Can several drivers can handle the same PCI device?

Officially, No.  Unofficially, there are ways to do this, but you have
to be _very_ careful.

What type of PCI device do you want to control?  Is there already a
driver bound to it?

> 2. How can I know which driver currently handles my PCI devices? (lsmod show
> few drivers that can show a few candidate but I want to know the actual
> driver that register to that PCI).

lspci -k


thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



user/init with kernel 2.6?

2009-09-14 Thread Stephane Lambert
Hello all,
I've seen that the compilation of certain programs (such as user/mount)
fails with kernel 2.6 because they are suitable for kernel 2.0.
A solution is to use Busybox which provides a large set of functionalities.
Should I use 'Busybox/init' instead of 'user/init'?
Does 'user/init' and 'user/sh' entirely compatible with kernel 2.6?
Thanks in advance for your answers.
Regards.

-- 
Cortus S.A., Montpellier
email: stephane.lamb...@cortus.com
http://www.cortus.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: spinlocks and copy_to_user()

2009-09-14 Thread Peter Teoh
On Mon, Sep 14, 2009 at 11:11 PM, Peter Teoh  wrote:
> sounds like u need TWO variables.   reason goes like this:


sorryI also forgotten to mention that since there are two variable
now...the interrupt sensitive one should be using spinlock and the one
that need to be able to sleep() should be a mutex or semaphore.


-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: multiple barrier bios to make_request_fn ?

2009-09-14 Thread Ed Cashin
On Mon Sep 14 05:38:23 EDT 2009, jens.ax...@oracle.com wrote:
> On Fri, Sep 11 2009, Ed Cashin wrote:
> > The Documentation/block/barrier.txt information seems geared toward
> > block device drivers that handle I/O requests from the request_queue,
> > and not drivers that handle bios directly by providing their own
> > make_request_fn via blk_queue_make_request.
> > 
> > So I think the section quoted below does not apply to such a
> > bio-handling driver.
> > 
> >   * Currently, no matter which ordered mode is used, there can be only
> >   one barrier request in progress.  All I/O barriers are held off by
> >   block layer until the previous I/O barrier is complete.
> 
> Right, that synchronization does not exist at the bio level.
> 
> > The implication is that when a bio_barrier(bio) is seen by the
> > make_request_fn, it should sleep until any in-progress barrier bio has
> > been completed.  Is that correct?
> 
> Yes, that is correct.

Thanks.

It looks like interested parties like filesystems use
blkdev_issue_flush to generate a barrier, but a bio generated by
blkdev_issue_flush will always be "empty", with no associated I/O to
do.

Can a make_request_fn-style driver count on barrier bios always being
I/O operation free?

-- 
  Ed

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: kernel boot delay

2009-09-14 Thread Pei Lin
hi, do u enable the DHCP in the boot time?
if dhcp fails, it will attempt after the timer overtime.This process
will take nearly 30 seconds.

BRs
Lin

2009/9/12 Denis Kirjanov :
> Back to my problem. I am not very clear what is still reason for the delay.
> Here is the part of the boot log:
> [    5.576643] initcall scsi_complete_async_scans+0x0/0x150 returned 0 after
> 1 usecs
> [    5.582773] calling  memmap_init+0x0/0xaa @ 1
> [    5.588856] initcall memmap_init+0x0/0xaa returned 0 after 40 usecs
> [    5.594885] calling  pci_mmcfg_late_insert_resources+0x0/0x136 @ 1
> [    5.600961] initcall pci_mmcfg_late_insert_resources+0x0/0x136 returned 1
> after 1 usecs
> [    5.607129] initcall pci_mmcfg_late_insert_resources+0x0/0x136 returned
> with error code 1
> [    5.613186] calling  tcp_congestion_default+0x0/0xf @ 1
> [    5.619274] initcall tcp_congestion_default+0x0/0xf returned 0 after 1
> usecs
> [    5.625355] calling  ip_auto_config+0x0/0xfbb @ 1
> [    5.631459] initcall ip_auto_config+0x0/0xfbb returned 0 after 8 usecs
> [    5.637526] calling  initialize_hashrnd+0x0/0x16 @ 1
> [    5.643611] initcall initialize_hashrnd+0x0/0x16 returned 0 after 5 usecs
> [   36.264990] IBM TrackPoint firmware: 0x0e, buttons: 3/3
> [   37.585287] input: TPPS/2 IBM TrackPoint as
> /devices/platform/i8042/serio1/serio2/input/input7
> [   37.958178] async_waiting @ 1
> [   37.964297] async_continuing @ 1 after 1 usec
> [   38.357116] kjournald starting.  Commit interval 5 seconds
> [   38.363273] EXT3-fs: mounted filesystem with writeback data mode.
> [   38.369493] VFS: Mounted root (ext3 filesystem) readonly on device 8:3.
> In so far as I remember I also compile kernel without ibm trackpoint stuff.
> Behavior after this did not change. It's not clear what happens after
> calling initialize_hashrnd().
>
>
> On Fri, Sep 11, 2009 at 8:33 PM, Peter Teoh  wrote:
>>
>> oh...just found it:
>>
>> https://linuxlink.timesys.com/3/podcast
>>
>> Episode 40:  Overview of 2.6.28 Linux Kernel and Talk About the Newly
>> Introduced Boot Tracer
>> February 13, 2009 (23MB)
>>    MP3 Download
>>
>> (https://linuxlink.timesys.com/files/podcasts/mp3/Episode_040_LinuxLink_Radio.mp3)
>>    OGG Vorbis Download
>>
>>
>>
>> On Fri, Sep 11, 2009 at 12:29 PM, Denis Kirjanov 
>> wrote:
>> > Interesting resource. Thanks for sharing)
>> >
>> > On Fri, Sep 11, 2009 at 8:16 PM, Peter Teoh 
>> > wrote:
>> >>
>> >> On Fri, Sep 11, 2009 at 11:59 PM, Denis Kirjanov 
>> >> wrote:
>> >> > Did not know about this feature :/ But thx!,  I'll try it
>> >> >
>> >>
>> >> believe it or noti was just listening to Timesys linux podcast No
>> >> 40, and it specifically introduced CONFIG_BOOT_TRACER, just minutes
>> >> before I read your question.
>> >>
>> >> so this is new to me too!!!   i am recompiling now.
>> >>
>> >> --
>> >> Regards,
>> >> Peter Teoh
>> >
>> >
>> >
>> > --
>> > Regards,
>> > Denis
>> >
>>
>>
>>
>> --
>> Regards,
>> Peter Teoh
>
>
>
> --
> Regards,
> Denis
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: making a global structure

2009-09-14 Thread SandeepKsinha
Hi Krushnaal,

On Mon, Sep 14, 2009 at 5:54 PM, krushnaal pai  wrote:
> hello
> i am a newbie, i know about exporting variables between modules,
> but what i am trying right now is to export a structure( i want to make a
> global structure)
> i wrote this in one module.
> Code:
>
> struct abc{
> int y;
> int a[10];
>
> int *z[10];
> };
> struct abc *x;
> EXPORT_SYMBOL(x);
>

Once you declare X as exported it will be accessed by any other module.
The symbol X is reserved now and any other module cannot use X.

> then i tried to use it in another module like this
>
> Code:
>

Try this:

struct abc *y;
y=x;

Since, x is globally exported. This should work.
>
> but it didnt work,derefrencing errors 
>
> are the above codes correct?
>
> can sumone plz correct me. any help appreciated. ty



-- 
Regards,
Sandeep.






“To learn is to change. Education is a process that changes the learner.”

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread Pei Lin
2009/9/14 Leonidas . :
>
>
> On Mon, Sep 14, 2009 at 4:01 PM, Leonidas .  wrote:
>>
>>
>> On Mon, Sep 14, 2009 at 3:32 PM, Leonidas .  wrote:
>>>
>>>
>>> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas . 
>>> wrote:


 On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao
  wrote:
>
> hi leo
> maintain circular buffer in module, so that if user doesn't access for
> days its going to be automatically discarded.I think printk also use same
> kind of mechanism which dumps data into cirbuffer.
>
> thanks,
> karuna.
>
> On Mon, Sep 14, 2009 at 2:41 PM, Leonidas . 
> wrote:
>>
>>
>> On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao
>>  wrote:
>>>
>>> hi leo
>>> you can maintain buffer in your module to log errors.When user tries
>>> to access /proc you can print all those from your buffer.
>>>
>>> Thanks,
>>> karuna.
>>>
>>> On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
>>> wrote:


 Hi List

 I have written a kernel module which implements a char device. An
 userspace app
 is supposed to get data from my module and then dump it into a file
 for further processing.

 The kind of data which kernel module is going to pass to userspace
 is going to be a 4K buffer,
 and the data traffic is not going to be really heavy, meaning may be
 a 4K buffer every 1 min or so.
 I am not very sure though, but certainly not heavy traffic the way
 they describe for network traffic etc.

 And this data needs to be logged to a file either from kernel or
 userspace and an userspace all will work
 on that data. This data needs to be logged as soon as it arrives
 meaning, I might not be able to write it to
 /proc since from module I can update /proc only when user actually
 accesses it. This data needs to be
 static in nature, meaning I get one error and I write it to a file
 somehow and user can see it anytime.

 I hope I have described the situation clearly. I have explored some
 mechanism like ioctls, mmaping the
 kernel buffer etc but all these would require the user module to
 poll or notified somehow by kernel that
 the data is available. I dont want the user module to poll.


 -Leo.

>>>
>>
>> Pei Lin,
>>
>> I am not limiting my solution by using a law or what someone says. But
>> I think it is very important to
>> follow the spirit of environment/OS/arch you are working on and come
>> up with the best possible solution.

hi , i didn't receive these messages. (^-^)
yeah,u can choose the way u wanna go,no matter a wide road or some
private alleys.
which one is convenient for different guys.

>> As you correctly mention we can hack around and achieve the same
>> functionality but I would rather do these
>> kind of experiments for fun or to show my friends that the kernel can
>> be hacked these ways, but certainly not
>> in a system which is supposed to be a production system. I appreciate
>> your thoughts and I am sure many times
>> one stumbles upon real cool things which change course of nature and
>> are reasons for radical changes in
>> various subsystems. But I think this is not one of them, this has been
>> discussed over and over again and there
>> are standard interfaces defined. My questions is more about the design
>> part not about how I can hack and get
>> the stuff done.

yeah,i agree. If it is a commercial software, it need a pretty and
clean interface to support future updating and maintenance.

>>
>> Karuna,
>> I had thought about this solution i.e. maintain a buffer in module and
>> dump it whenever user wants, only
>> issue is my module will keep consuming memory here. I msg buffers can
>> be freed once logged but how about
>> a case where user does not request for few days? The amount of memory
>> my module is going to consume will be
>> unacceptable.
>>
>> -Leo
>

 Sorry I did not mention it earlier, I can not discard any error message
 logged, meaning these are error messages
 and might crash my system after a long time. I need to to be able to see
 all these messages till I restart my module.

 _Leo.
>>>
>>>
>>> Basically, I am quite tight on memory and I would like to convery error
>>> messages to user as soon as any
>>> error condition is hit. So my module cant keep even 10 error msg which
>>> will eat up 10 pages.
>>>
>>> _Leo
>>>
>>>
>>
>> Looks like some of the replys didn't get delivered to the list. Please
>> refer the thread for someof the interactions.
>>
>> Isn't debugfs the right thing to use here? Anyone? Please enlighten.
>>
>> _Leo
>>
>
>
> After some analysis, I have decide

Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 5:44 PM, Leonidas .  wrote:

>
>
> On Mon, Sep 14, 2009 at 4:01 PM, Leonidas .  wrote:
>
>>
>>
>> On Mon, Sep 14, 2009 at 3:32 PM, Leonidas . wrote:
>>
>>>
>>>
>>> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas . wrote:
>>>


 On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao <
 karunakar.san...@gmail.com> wrote:

> hi leo
> maintain circular buffer in module, so that if user doesn't access for
> days its going to be automatically discarded.I think printk also use same
> kind of mechanism which dumps data into cirbuffer.
>
> thanks,
> karuna.
>
> On Mon, Sep 14, 2009 at 2:41 PM, Leonidas . wrote:
>
>>
>>
>>   On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao <
>> karunakar.san...@gmail.com> wrote:
>>
>>> hi leo
>>> you can maintain buffer in your module to log errors.When user tries
>>> to access /proc you can print all those from your buffer.
>>>
>>> Thanks,
>>> karuna.
>>>
>>>  On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
>>> wrote:
>>>


 Hi List

 I have written a kernel module which implements a char device. An
 userspace app
 is supposed to get data from my module and then dump it into a file
 for further processing.

 The kind of data which kernel module is going to pass to userspace
 is going to be a 4K buffer,
 and the data traffic is not going to be really heavy, meaning may be
 a 4K buffer every 1 min or so.
 I am not very sure though, but certainly not heavy traffic the way
 they describe for network traffic etc.

 And this data needs to be logged to a file either from kernel or
 userspace and an userspace all will work
 on that data. This data needs to be logged as soon as it arrives
 meaning, I might not be able to write it to
 /proc since from module I can update /proc only when user actually
 accesses it. This data needs to be
 static in nature, meaning I get one error and I write it to a file
 somehow and user can see it anytime.

 I hope I have described the situation clearly. I have explored some
 mechanism like ioctls, mmaping the
 kernel buffer etc but all these would require the user module to
 poll or notified somehow by kernel that
 the data is available. I dont want the user module to poll.


 -Leo.


>>>
>> Pei Lin,
>>
>> I am not limiting my solution by using a law or what someone says. But
>> I think it is very important to
>> follow the spirit of environment/OS/arch you are working on and come
>> up with the best possible solution.
>> As you correctly mention we can hack around and achieve the same
>> functionality but I would rather do these
>> kind of experiments for fun or to show my friends that the kernel can
>> be hacked these ways, but certainly not
>> in a system which is supposed to be a production system. I appreciate
>> your thoughts and I am sure many times
>> one stumbles upon real cool things which change course of nature and
>> are reasons for radical changes in
>> various subsystems. But I think this is not one of them, this has been
>> discussed over and over again and there
>> are standard interfaces defined. My questions is more about the design
>> part not about how I can hack and get
>> the stuff done.
>>
>> Karuna,
>> I had thought about this solution i.e. maintain a buffer in module and
>> dump it whenever user wants, only
>> issue is my module will keep consuming memory here. I msg buffers can
>> be freed once logged but how about
>> a case where user does not request for few days? The amount of memory
>> my module is going to consume will be
>> unacceptable.
>>
>> -Leo
>>
>
>
 Sorry I did not mention it earlier, I can not discard any error message
 logged, meaning these are error messages
 and might crash my system after a long time. I need to to be able to see
 all these messages till I restart my module.

 _Leo.

>>>
>>>
>>> Basically, I am quite tight on memory and I would like to convery error
>>> messages to user as soon as any
>>> error condition is hit. So my module cant keep even 10 error msg which
>>> will eat up 10 pages.
>>>
>>> _Leo
>>>
>>>
>>>
>> Looks like some of the replys didn't get delivered to the list. Please
>> refer the thread for someof the interactions.
>>
>> Isn't debugfs the right thing to use here? Anyone? Please enlighten.
>>
>> _Leo
>>
>>
>
> After some analysis, I have decided to use netlink sockets for my use case.
> Some queries regarding the same:
>
> 1. Are netlink sockets an overkill for not so heavy data transfer ?
> 2. Do I have to recompile kernel et

Viewing page cache content

2009-09-14 Thread Krzysztof Poc
HelloIs it possible to view the page cache content.I don't mean printing out the content of the whole page cache.I rather expect something that allows querying the page cache for a specific file.It would be great to know exactly what parts (regions) of a specific file are currently cached in the page cache.Are there any console tools that allow to do that ?Thanks for help.Kibicuj z nami w Łodzi!Miasteczko kibica w ManufakturzeKonkursy, zabawa i wielkie emocjeSprawdź: http://klik.wp.pl/?adr=http://corto.www.wp.pl/as/miasteczko.html&sid=859



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



DEVFS permissions

2009-09-14 Thread Shankar Ganesh
Hi ,

When we create a node under devfs ,


hwcdev_class = class_create(THIS_MODULE, DRVNAME);
device_create(hwcdev_class, NULL, MKDEV(dev_major, 0), dev,
DEVNAME);

 the  node is created with default permission of 600 (root=rw, others nil) ,

crw   root root252  , 

How do i make permission setting automatically while creating node ? (i need
666 and don't want to execute chmod 666 /dev/mydev )


-- 
With Regards,
ShankarGanesh K .


making a global structure

2009-09-14 Thread krushnaal pai
hello
i am a newbie, i know about exporting variables between modules,
but what i am trying right now is to export a structure( i want to make a
global structure)
i wrote this in one module.
 Code:

struct abc{
int y;
int a[10];
int *z[10];
};
struct abc *x;
EXPORT_SYMBOL(x);

then i tried to use it in another module like this

 Code:

extern struct abc *x;

but it didnt work,derefrencing errors 

are the above codes correct?

can sumone plz correct me. any help appreciated. ty


Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 4:01 PM, Leonidas .  wrote:

>
>
> On Mon, Sep 14, 2009 at 3:32 PM, Leonidas .  wrote:
>
>>
>>
>> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas . wrote:
>>
>>>
>>>
>>> On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao <
>>> karunakar.san...@gmail.com> wrote:
>>>
 hi leo
 maintain circular buffer in module, so that if user doesn't access for
 days its going to be automatically discarded.I think printk also use same
 kind of mechanism which dumps data into cirbuffer.

 thanks,
 karuna.

 On Mon, Sep 14, 2009 at 2:41 PM, Leonidas . wrote:

>
>
>   On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao <
> karunakar.san...@gmail.com> wrote:
>
>> hi leo
>> you can maintain buffer in your module to log errors.When user tries
>> to access /proc you can print all those from your buffer.
>>
>> Thanks,
>> karuna.
>>
>>  On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
>> wrote:
>>
>>>
>>>
>>> Hi List
>>>
>>> I have written a kernel module which implements a char device. An
>>> userspace app
>>> is supposed to get data from my module and then dump it into a file
>>> for further processing.
>>>
>>> The kind of data which kernel module is going to pass to userspace is
>>> going to be a 4K buffer,
>>> and the data traffic is not going to be really heavy, meaning may be
>>> a 4K buffer every 1 min or so.
>>> I am not very sure though, but certainly not heavy traffic the way
>>> they describe for network traffic etc.
>>>
>>> And this data needs to be logged to a file either from kernel or
>>> userspace and an userspace all will work
>>> on that data. This data needs to be logged as soon as it arrives
>>> meaning, I might not be able to write it to
>>> /proc since from module I can update /proc only when user actually
>>> accesses it. This data needs to be
>>> static in nature, meaning I get one error and I write it to a file
>>> somehow and user can see it anytime.
>>>
>>> I hope I have described the situation clearly. I have explored some
>>> mechanism like ioctls, mmaping the
>>> kernel buffer etc but all these would require the user module to poll
>>> or notified somehow by kernel that
>>> the data is available. I dont want the user module to poll.
>>>
>>>
>>> -Leo.
>>>
>>>
>>
> Pei Lin,
>
> I am not limiting my solution by using a law or what someone says. But
> I think it is very important to
> follow the spirit of environment/OS/arch you are working on and come up
> with the best possible solution.
> As you correctly mention we can hack around and achieve the same
> functionality but I would rather do these
> kind of experiments for fun or to show my friends that the kernel can
> be hacked these ways, but certainly not
> in a system which is supposed to be a production system. I appreciate
> your thoughts and I am sure many times
> one stumbles upon real cool things which change course of nature and
> are reasons for radical changes in
> various subsystems. But I think this is not one of them, this has been
> discussed over and over again and there
> are standard interfaces defined. My questions is more about the design
> part not about how I can hack and get
> the stuff done.
>
> Karuna,
> I had thought about this solution i.e. maintain a buffer in module and
> dump it whenever user wants, only
> issue is my module will keep consuming memory here. I msg buffers can
> be freed once logged but how about
> a case where user does not request for few days? The amount of memory
> my module is going to consume will be
> unacceptable.
>
> -Leo
>


>>> Sorry I did not mention it earlier, I can not discard any error message
>>> logged, meaning these are error messages
>>> and might crash my system after a long time. I need to to be able to see
>>> all these messages till I restart my module.
>>>
>>> _Leo.
>>>
>>
>>
>> Basically, I am quite tight on memory and I would like to convery error
>> messages to user as soon as any
>> error condition is hit. So my module cant keep even 10 error msg which
>> will eat up 10 pages.
>>
>> _Leo
>>
>>
>>
> Looks like some of the replys didn't get delivered to the list. Please
> refer the thread for someof the interactions.
>
> Isn't debugfs the right thing to use here? Anyone? Please enlighten.
>
> _Leo
>
>

After some analysis, I have decided to use netlink sockets for my use case.
Some queries regarding the same:

1. Are netlink sockets an overkill for not so heavy data transfer ?
2. Do I have to recompile kernel etc for loading my module which usages
netlink sockets?
3. Are they widely available everywhere? Meaning 2.4 and 2.6 kernles as
well?
4. Any idea whether these are available on BSD kernel as well? I think

Re: multiple barrier bios to make_request_fn ?

2009-09-14 Thread Jens Axboe
On Fri, Sep 11 2009, Ed Cashin wrote:
> The Documentation/block/barrier.txt information seems geared toward
> block device drivers that handle I/O requests from the request_queue,
> and not drivers that handle bios directly by providing their own
> make_request_fn via blk_queue_make_request.
> 
> So I think the section quoted below does not apply to such a
> bio-handling driver.
> 
>   * Currently, no matter which ordered mode is used, there can be only
>   one barrier request in progress.  All I/O barriers are held off by
>   block layer until the previous I/O barrier is complete.

Right, that synchronization does not exist at the bio level.

> The implication is that when a bio_barrier(bio) is seen by the
> make_request_fn, it should sleep until any in-progress barrier bio has
> been completed.  Is that correct?

Yes, that is correct.

-- 
Jens Axboe


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 3:32 PM, Leonidas .  wrote:

>
>
> On Mon, Sep 14, 2009 at 3:28 PM, Leonidas .  wrote:
>
>>
>>
>> On Mon, Sep 14, 2009 at 2:46 PM, karunakar rao <
>> karunakar.san...@gmail.com> wrote:
>>
>>> hi leo
>>> maintain circular buffer in module, so that if user doesn't access for
>>> days its going to be automatically discarded.I think printk also use same
>>> kind of mechanism which dumps data into cirbuffer.
>>>
>>> thanks,
>>> karuna.
>>>
>>> On Mon, Sep 14, 2009 at 2:41 PM, Leonidas . wrote:
>>>


   On Mon, Sep 14, 2009 at 2:30 PM, karunakar rao <
 karunakar.san...@gmail.com> wrote:

> hi leo
> you can maintain buffer in your module to log errors.When user tries to
> access /proc you can print all those from your buffer.
>
> Thanks,
> karuna.
>
>  On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . wrote:
>
>>
>>
>> Hi List
>>
>> I have written a kernel module which implements a char device. An
>> userspace app
>> is supposed to get data from my module and then dump it into a file
>> for further processing.
>>
>> The kind of data which kernel module is going to pass to userspace is
>> going to be a 4K buffer,
>> and the data traffic is not going to be really heavy, meaning may be a
>> 4K buffer every 1 min or so.
>> I am not very sure though, but certainly not heavy traffic the way
>> they describe for network traffic etc.
>>
>> And this data needs to be logged to a file either from kernel or
>> userspace and an userspace all will work
>> on that data. This data needs to be logged as soon as it arrives
>> meaning, I might not be able to write it to
>> /proc since from module I can update /proc only when user actually
>> accesses it. This data needs to be
>> static in nature, meaning I get one error and I write it to a file
>> somehow and user can see it anytime.
>>
>> I hope I have described the situation clearly. I have explored some
>> mechanism like ioctls, mmaping the
>> kernel buffer etc but all these would require the user module to poll
>> or notified somehow by kernel that
>> the data is available. I dont want the user module to poll.
>>
>>
>> -Leo.
>>
>>
>
 Pei Lin,

 I am not limiting my solution by using a law or what someone says. But I
 think it is very important to
 follow the spirit of environment/OS/arch you are working on and come up
 with the best possible solution.
 As you correctly mention we can hack around and achieve the same
 functionality but I would rather do these
 kind of experiments for fun or to show my friends that the kernel can be
 hacked these ways, but certainly not
 in a system which is supposed to be a production system. I appreciate
 your thoughts and I am sure many times
 one stumbles upon real cool things which change course of nature and are
 reasons for radical changes in
 various subsystems. But I think this is not one of them, this has been
 discussed over and over again and there
 are standard interfaces defined. My questions is more about the design
 part not about how I can hack and get
 the stuff done.

 Karuna,
 I had thought about this solution i.e. maintain a buffer in module and
 dump it whenever user wants, only
 issue is my module will keep consuming memory here. I msg buffers can be
 freed once logged but how about
 a case where user does not request for few days? The amount of memory my
 module is going to consume will be
 unacceptable.

 -Leo

>>>
>>>
>> Sorry I did not mention it earlier, I can not discard any error message
>> logged, meaning these are error messages
>> and might crash my system after a long time. I need to to be able to see
>> all these messages till I restart my module.
>>
>> _Leo.
>>
>
>
> Basically, I am quite tight on memory and I would like to convery error
> messages to user as soon as any
> error condition is hit. So my module cant keep even 10 error msg which will
> eat up 10 pages.
>
> _Leo
>
>
>
Looks like some of the replys didn't get delivered to the list. Please refer
the thread for someof the interactions.

Isn't debugfs the right thing to use here? Anyone? Please enlighten.

_Leo


Re: Copying kernel module error messages to userspace

2009-09-14 Thread Loránd Jakab
On Monday, September 14, 2009 10:07:58 Leonidas . wrote:
> When we do a printk it writes to kernel log buffer, correct? This is
>  real in time operation i.e. as soon as we do a
> printk the messages get logged. Now this log file can be accesses
>  from /var/log/messages right? How is this done?
> 
> I want to so something similar, so I can log my messages to a seprate
>  file which is going to stay around so user can
> see at across reboots as well.

You could set up a new logging facility for your kernel module, and use 
the system logger to log everything from that facility to a separate 
file. Why wouldn't this work for you?

Regards,
Lori


signature.asc
Description: This is a digitally signed message part.


Re: ext4 extents: How to determine if an extent points to a hole.

2009-09-14 Thread SandeepKsinha
Hi Manish,


On Mon, Sep 14, 2009 at 3:12 PM, Manish Katiyar  wrote:
> On Mon, Sep 14, 2009 at 3:09 PM, SandeepKsinha  
> wrote:
>> Hi Manish,
>>
>> On Mon, Sep 14, 2009 at 2:57 PM, Manish Katiyar  wrote:
>>> On Mon, Sep 14, 2009 at 11:59 AM, SandeepKsinha  
>>> wrote:
 Hi Greg,

 Thanks a lot for such nice explanation. But I still have the same
 query lingering...


 On Mon, Sep 14, 2009 at 9:36 AM, Greg Freemyer  
 wrote:
> On Sun, Sep 13, 2009 at 1:49 PM, SandeepKsinha  
> wrote:
>> On Sun, Sep 13, 2009 at 11:08 PM, Manish Katiyar  
>> wrote:
>>> On Sun, Sep 13, 2009 at 10:12 PM, SandeepKsinha 
>>>  wrote:
 Hi,


 On Sun, Sep 13, 2009 at 10:07 PM, Manish Katiyar  
 wrote:
> On Sun, Sep 13, 2009 at 5:44 PM, SandeepKsinha 
>  wrote:
>> Hi all,
>>
>> Looking at the flags in the extent info,  Is there any specifc flags
>> which indicates an extent to be a HOLE??
>
> I am not sure if I understand the question correctly .. why would
> you need that ? Can you give an example where it should be used ??
>

 Look at e4defrag.c,
 it checks the file size and allocates the same number of blocks for
 donor inode. Which will eventually make a holey file into a normal
 one.
 Any tool/application should make sure that they leave a sparse file as 
 sparse.

 I think, as suggested by Greg Freemyer, we can use BMAP ioctl to get
 such information.
>>>
>>> Yes, but I think bmap would be costly if the file is large and is not
>>> holey :-(  but that would be probably same calling fiemap if the
>>> file is completely fragmented such that each extent size is 1.
>>>
>>
>> Since, ext2/ext3 did not have mutli block allocation thats why this is
>> the  only way that we might have.
>> But generally most of the new features work on with extent based files 
>> on ext4.
>>
>> I am still wondering that how to we represent a hole using extents in
>> a extent based file.
>> Just like we had a convention of having the block number 0 in case of 
>> holes.
>>
>> Similarly, what do we look at to figure out if its a hole or not. BMAP
>> is one way. But since, in a extent based file, we have only extents,
>> there should be some flag to indicate the same.
>
> Sandeep,
>
> If you look at e4defrag, it first gets a list of all the extents.  I'm
> pretty sure extents only exist for allocated extents.  Holes do not
> have any associated extents.
>>>
>>> I did a extent dump of a holey file.
>>>
>>> Inode: 12   Type: regular    Mode:  0644   Flags: 0x8
>>> Generation: 4284390079    Version: 0x0001
>>> User:  5572   Group:  5573   Size: 20877312000
>>> File ACL: 0    Directory ACL: 0
>>> Links: 1   Blockcount: 16000
>>> Fragment:  Address: 0    Number: 0    Size: 0
>>> ctime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
>>> atime: 0x4aad34e9 -- Sun Sep 13 23:37:37 2009
>>> mtime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
>>> EXTENTS:
>>> (0-3999): 10241-14240, (20384000-20387999): 14337-18336
>>>
>>> Level Entries             Logical        Physical Length Flags
>>>  0/ 0   1/  2        0 -     3999  10241 -  14240   4000
>>>  0/ 0   2/  2 20384000 - 20387999  14337 -  18336   4000
>>>
>>> I am looking at the source, but as you can see it is not printing the
>>> extents for the hole part.
>>>
>>
>> I suspect the debugfs code masking that out for the output.
>
> yes... and that is the flag/method that we are looking for ... isn't it :-) 
> ???
>

read the above conversation, this answers all the question.


me: How does ext4 represent holes ?  Do we have a extent (unitialized
for holes)  ??

Kalpak: physical block no = 0

me: But we keep an extent for the same.  If I do a FIEMAP

Kalpak: yup

 me: I will also get an extent for the holes

Kalpak: FIEMAP wont return hole extents

 me: ok

Kalpak: but u can find out that if there was hole by FIEMAP output
if last block != this block there was a hole in between

Hope this helps everyone. Also, now we do not bother much about holes.




>> If you remember, for a normal block based file also, it does something
>> similar, it does not prints the values for holes.
>>
>> It can be a case here as well.
>>>
>

 This is what my actual question is, think of this situation...

 |-|-|-|--|
 0              500          700            1200               3000
 [Logical block numbers for an inode]


 In this situation you will have four extents for sure.
 ext_1 -> 0 -- 500
 ext_2 -> 501 --700 [ This will be an initialized extent]
 ext_3 -> 701 -- 1200
 ext_4 -> 1200 -- 3000

 After looking at the sources and some comments in the ext4 source
 code, 

Re: ext4 extents: How to determine if an extent points to a hole.

2009-09-14 Thread Manish Katiyar
On Mon, Sep 14, 2009 at 3:09 PM, SandeepKsinha  wrote:
> Hi Manish,
>
> On Mon, Sep 14, 2009 at 2:57 PM, Manish Katiyar  wrote:
>> On Mon, Sep 14, 2009 at 11:59 AM, SandeepKsinha  
>> wrote:
>>> Hi Greg,
>>>
>>> Thanks a lot for such nice explanation. But I still have the same
>>> query lingering...
>>>
>>>
>>> On Mon, Sep 14, 2009 at 9:36 AM, Greg Freemyer  
>>> wrote:
 On Sun, Sep 13, 2009 at 1:49 PM, SandeepKsinha  
 wrote:
> On Sun, Sep 13, 2009 at 11:08 PM, Manish Katiyar  
> wrote:
>> On Sun, Sep 13, 2009 at 10:12 PM, SandeepKsinha 
>>  wrote:
>>> Hi,
>>>
>>>
>>> On Sun, Sep 13, 2009 at 10:07 PM, Manish Katiyar  
>>> wrote:
 On Sun, Sep 13, 2009 at 5:44 PM, SandeepKsinha 
  wrote:
> Hi all,
>
> Looking at the flags in the extent info,  Is there any specifc flags
> which indicates an extent to be a HOLE??

 I am not sure if I understand the question correctly .. why would
 you need that ? Can you give an example where it should be used ??

>>>
>>> Look at e4defrag.c,
>>> it checks the file size and allocates the same number of blocks for
>>> donor inode. Which will eventually make a holey file into a normal
>>> one.
>>> Any tool/application should make sure that they leave a sparse file as 
>>> sparse.
>>>
>>> I think, as suggested by Greg Freemyer, we can use BMAP ioctl to get
>>> such information.
>>
>> Yes, but I think bmap would be costly if the file is large and is not
>> holey :-(  but that would be probably same calling fiemap if the
>> file is completely fragmented such that each extent size is 1.
>>
>
> Since, ext2/ext3 did not have mutli block allocation thats why this is
> the  only way that we might have.
> But generally most of the new features work on with extent based files on 
> ext4.
>
> I am still wondering that how to we represent a hole using extents in
> a extent based file.
> Just like we had a convention of having the block number 0 in case of 
> holes.
>
> Similarly, what do we look at to figure out if its a hole or not. BMAP
> is one way. But since, in a extent based file, we have only extents,
> there should be some flag to indicate the same.

 Sandeep,

 If you look at e4defrag, it first gets a list of all the extents.  I'm
 pretty sure extents only exist for allocated extents.  Holes do not
 have any associated extents.
>>
>> I did a extent dump of a holey file.
>>
>> Inode: 12   Type: regular    Mode:  0644   Flags: 0x8
>> Generation: 4284390079    Version: 0x0001
>> User:  5572   Group:  5573   Size: 20877312000
>> File ACL: 0    Directory ACL: 0
>> Links: 1   Blockcount: 16000
>> Fragment:  Address: 0    Number: 0    Size: 0
>> ctime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
>> atime: 0x4aad34e9 -- Sun Sep 13 23:37:37 2009
>> mtime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
>> EXTENTS:
>> (0-3999): 10241-14240, (20384000-20387999): 14337-18336
>>
>> Level Entries             Logical        Physical Length Flags
>>  0/ 0   1/  2        0 -     3999  10241 -  14240   4000
>>  0/ 0   2/  2 20384000 - 20387999  14337 -  18336   4000
>>
>> I am looking at the source, but as you can see it is not printing the
>> extents for the hole part.
>>
>
> I suspect the debugfs code masking that out for the output.

yes... and that is the flag/method that we are looking for ... isn't it :-) ???

> If you remember, for a normal block based file also, it does something
> similar, it does not prints the values for holes.
>
> It can be a case here as well.
>>

>>>
>>> This is what my actual question is, think of this situation...
>>>
>>> |-|-|-|--|
>>> 0              500          700            1200               3000
>>> [Logical block numbers for an inode]
>>>
>>>
>>> In this situation you will have four extents for sure.
>>> ext_1 -> 0 -- 500
>>> ext_2 -> 501 --700 [ This will be an initialized extent]
>>> ext_3 -> 701 -- 1200
>>> ext_4 -> 1200 -- 3000
>>>
>>> After looking at the sources and some comments in the ext4 source
>>> code, I could figure out that holes would be having an initialized
>>> extent.
>>> Reference: http://lxr.linux.no/#linux+v2.6.31/fs/ext4/extents.c#L2843
>>>
>>> I think we cannot have a mixture of both a BMAP and an EMAP, it will be 
>>> either.
>>>
 Then it calls merge_extents to create extent groups.  In e4defrag
 terminology, an extent group is a collection of all the logically
 contiguous extents.  I don't know if the kernel uses that terminology
 or not.

>>>
>>> Hope they are not merging together any initialized and uninitialized
>>> extents together, since they can be logically contiguous. Or rather
>>> they will be.
>>>
>>>
 In other words in e4defrag terminology a sparse file is a series of:

 exten

Re: ext4 extents: How to determine if an extent points to a hole.

2009-09-14 Thread SandeepKsinha
Hi Manish,

On Mon, Sep 14, 2009 at 2:57 PM, Manish Katiyar  wrote:
> On Mon, Sep 14, 2009 at 11:59 AM, SandeepKsinha  
> wrote:
>> Hi Greg,
>>
>> Thanks a lot for such nice explanation. But I still have the same
>> query lingering...
>>
>>
>> On Mon, Sep 14, 2009 at 9:36 AM, Greg Freemyer  
>> wrote:
>>> On Sun, Sep 13, 2009 at 1:49 PM, SandeepKsinha  
>>> wrote:
 On Sun, Sep 13, 2009 at 11:08 PM, Manish Katiyar  
 wrote:
> On Sun, Sep 13, 2009 at 10:12 PM, SandeepKsinha  
> wrote:
>> Hi,
>>
>>
>> On Sun, Sep 13, 2009 at 10:07 PM, Manish Katiyar  
>> wrote:
>>> On Sun, Sep 13, 2009 at 5:44 PM, SandeepKsinha 
>>>  wrote:
 Hi all,

 Looking at the flags in the extent info,  Is there any specifc flags
 which indicates an extent to be a HOLE??
>>>
>>> I am not sure if I understand the question correctly .. why would
>>> you need that ? Can you give an example where it should be used ??
>>>
>>
>> Look at e4defrag.c,
>> it checks the file size and allocates the same number of blocks for
>> donor inode. Which will eventually make a holey file into a normal
>> one.
>> Any tool/application should make sure that they leave a sparse file as 
>> sparse.
>>
>> I think, as suggested by Greg Freemyer, we can use BMAP ioctl to get
>> such information.
>
> Yes, but I think bmap would be costly if the file is large and is not
> holey :-(  but that would be probably same calling fiemap if the
> file is completely fragmented such that each extent size is 1.
>

 Since, ext2/ext3 did not have mutli block allocation thats why this is
 the  only way that we might have.
 But generally most of the new features work on with extent based files on 
 ext4.

 I am still wondering that how to we represent a hole using extents in
 a extent based file.
 Just like we had a convention of having the block number 0 in case of 
 holes.

 Similarly, what do we look at to figure out if its a hole or not. BMAP
 is one way. But since, in a extent based file, we have only extents,
 there should be some flag to indicate the same.
>>>
>>> Sandeep,
>>>
>>> If you look at e4defrag, it first gets a list of all the extents.  I'm
>>> pretty sure extents only exist for allocated extents.  Holes do not
>>> have any associated extents.
>
> I did a extent dump of a holey file.
>
> Inode: 12   Type: regular    Mode:  0644   Flags: 0x8
> Generation: 4284390079    Version: 0x0001
> User:  5572   Group:  5573   Size: 20877312000
> File ACL: 0    Directory ACL: 0
> Links: 1   Blockcount: 16000
> Fragment:  Address: 0    Number: 0    Size: 0
> ctime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
> atime: 0x4aad34e9 -- Sun Sep 13 23:37:37 2009
> mtime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
> EXTENTS:
> (0-3999): 10241-14240, (20384000-20387999): 14337-18336
>
> Level Entries             Logical        Physical Length Flags
>  0/ 0   1/  2        0 -     3999  10241 -  14240   4000
>  0/ 0   2/  2 20384000 - 20387999  14337 -  18336   4000
>
> I am looking at the source, but as you can see it is not printing the
> extents for the hole part.
>

I suspect the debugfs code masking that out for the output.
If you remember, for a normal block based file also, it does something
similar, it does not prints the values for holes.

It can be a case here as well.
>
>>>
>>
>> This is what my actual question is, think of this situation...
>>
>> |-|-|-|--|
>> 0              500          700            1200               3000
>> [Logical block numbers for an inode]
>>
>>
>> In this situation you will have four extents for sure.
>> ext_1 -> 0 -- 500
>> ext_2 -> 501 --700 [ This will be an initialized extent]
>> ext_3 -> 701 -- 1200
>> ext_4 -> 1200 -- 3000
>>
>> After looking at the sources and some comments in the ext4 source
>> code, I could figure out that holes would be having an initialized
>> extent.
>> Reference: http://lxr.linux.no/#linux+v2.6.31/fs/ext4/extents.c#L2843
>>
>> I think we cannot have a mixture of both a BMAP and an EMAP, it will be 
>> either.
>>
>>> Then it calls merge_extents to create extent groups.  In e4defrag
>>> terminology, an extent group is a collection of all the logically
>>> contiguous extents.  I don't know if the kernel uses that terminology
>>> or not.
>>>
>>
>> Hope they are not merging together any initialized and uninitialized
>> extents together, since they can be logically contiguous. Or rather
>> they will be.
>>
>>
>>> In other words in e4defrag terminology a sparse file is a series of:
>>>
>>> extent group - hole - extent group - hole - extent group - etc.
>>>
>>> Then e4defrag creates a donor file with exactly the same allocated
>>> block areas by calling fallocate on the donor file for each extent
>>> group with the same starting offset and length as the extent group.
>

Re: Copying kernel module error messages to userspace

2009-09-14 Thread Pei Lin
And i also think it even can use this method, prink your error
message, and use a shell " sleep 100; dmesg | grep xxx >> savefile" to
do this job and no need to write an application.
It is simple and no need for a minute to realize it if it is used just
for a trace tool for u.

BRs

Lin

2009/9/14 Pei Lin :
> why u must use a law to limit your solution?
> And u can hack kernel and dig the hole and do what u want..
>
> Lin
>
> 2009/9/14 Leonidas . :
>>
>>
>> On Mon, Sep 14, 2009 at 2:19 PM, Leonidas .  wrote:
>>>
>>>
>>> On Mon, Sep 14, 2009 at 1:57 PM, Pei Lin  wrote:

 SO u can use the first method,write files from the kernel space.
 See the hyperlink i give.

 Lin

 2009/9/14 Leonidas . :
 >
 >
 > On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
 > wrote:
 >>
 >>
 >> Hi List
 >>
 >> I have written a kernel module which implements a char device. An
 >> userspace app
 >> is supposed to get data from my module and then dump it into a file
 >> for
 >> further processing.
 >>
 >> The kind of data which kernel module is going to pass to userspace is
 >> going to be a 4K buffer,
 >> and the data traffic is not going to be really heavy, meaning may be a
 >> 4K
 >> buffer every 1 min or so.
 >> I am not very sure though, but certainly not heavy traffic the way
 >> they
 >> describe for network traffic etc.
 >>
 >> And this data needs to be logged to a file either from kernel or
 >> userspace
 >> and an userspace all will work
 >> on that data. This data needs to be logged as soon as it arrives
 >> meaning,
 >> I might not be able to write it to
 >> /proc since from module I can update /proc only when user actually
 >> accesses it. This data needs to be
 >> static in nature, meaning I get one error and I write it to a file
 >> somehow
 >> and user can see it anytime.
 >>
 >> I hope I have described the situation clearly. I have explored some
 >> mechanism like ioctls, mmaping the
 >> kernel buffer etc but all these would require the user module to poll
 >> or
 >> notified somehow by kernel that
 >> the data is available. I dont want the user module to poll.
 >>
 >>
 >> -Leo.
 >>
 >
 > When we do a printk it writes to kernel log buffer, correct? This is
 > real in
 > time operation i.e. as soon as we do a
 > printk the messages get logged. Now this log file can be accesses from
 > /var/log/messages right? How is this done?
 >
 > I want to so something similar, so I can log my messages to a seprate
 > file
 > which is going to stay around so user can
 > see at across reboots as well.
 >
 >
 >
 > -Leo.
 >
 >
>>>
>>>
>>> No, Greg KH mentions that is should not be done!
>>> And I have been reading that 'It is a bad..bad thing to access files from
>>> kernel space'
>>> since I started doing Linux stuff.
>>>
>>> _Leo.
>>
>>
>> I am aware of other legitimate mechanisms as I have described on my origianl
>> post.
>> It is just that I have certain constraints under which I cant use many of
>> the methods
>> since I dont want to user space entity to do polling or get signal from
>> kernel.
>>
>> -Leo.
>>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: ext4 extents: How to determine if an extent points to a hole.

2009-09-14 Thread Manish Katiyar
On Mon, Sep 14, 2009 at 11:59 AM, SandeepKsinha  wrote:
> Hi Greg,
>
> Thanks a lot for such nice explanation. But I still have the same
> query lingering...
>
>
> On Mon, Sep 14, 2009 at 9:36 AM, Greg Freemyer  
> wrote:
>> On Sun, Sep 13, 2009 at 1:49 PM, SandeepKsinha  
>> wrote:
>>> On Sun, Sep 13, 2009 at 11:08 PM, Manish Katiyar  wrote:
 On Sun, Sep 13, 2009 at 10:12 PM, SandeepKsinha  
 wrote:
> Hi,
>
>
> On Sun, Sep 13, 2009 at 10:07 PM, Manish Katiyar  
> wrote:
>> On Sun, Sep 13, 2009 at 5:44 PM, SandeepKsinha  
>> wrote:
>>> Hi all,
>>>
>>> Looking at the flags in the extent info,  Is there any specifc flags
>>> which indicates an extent to be a HOLE??
>>
>> I am not sure if I understand the question correctly .. why would
>> you need that ? Can you give an example where it should be used ??
>>
>
> Look at e4defrag.c,
> it checks the file size and allocates the same number of blocks for
> donor inode. Which will eventually make a holey file into a normal
> one.
> Any tool/application should make sure that they leave a sparse file as 
> sparse.
>
> I think, as suggested by Greg Freemyer, we can use BMAP ioctl to get
> such information.

 Yes, but I think bmap would be costly if the file is large and is not
 holey :-(  but that would be probably same calling fiemap if the
 file is completely fragmented such that each extent size is 1.

>>>
>>> Since, ext2/ext3 did not have mutli block allocation thats why this is
>>> the  only way that we might have.
>>> But generally most of the new features work on with extent based files on 
>>> ext4.
>>>
>>> I am still wondering that how to we represent a hole using extents in
>>> a extent based file.
>>> Just like we had a convention of having the block number 0 in case of holes.
>>>
>>> Similarly, what do we look at to figure out if its a hole or not. BMAP
>>> is one way. But since, in a extent based file, we have only extents,
>>> there should be some flag to indicate the same.
>>
>> Sandeep,
>>
>> If you look at e4defrag, it first gets a list of all the extents.  I'm
>> pretty sure extents only exist for allocated extents.  Holes do not
>> have any associated extents.

I did a extent dump of a holey file.

Inode: 12   Type: regularMode:  0644   Flags: 0x8
Generation: 4284390079Version: 0x0001
User:  5572   Group:  5573   Size: 20877312000
File ACL: 0Directory ACL: 0
Links: 1   Blockcount: 16000
Fragment:  Address: 0Number: 0Size: 0
ctime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
atime: 0x4aad34e9 -- Sun Sep 13 23:37:37 2009
mtime: 0x4aae0975 -- Mon Sep 14 14:44:29 2009
EXTENTS:
(0-3999): 10241-14240, (20384000-20387999): 14337-18336

Level Entries LogicalPhysical Length Flags
 0/ 0   1/  20 - 3999  10241 -  14240   4000
 0/ 0   2/  2 20384000 - 20387999  14337 -  18336   4000

I am looking at the source, but as you can see it is not printing the
extents for the hole part.


>>
>
> This is what my actual question is, think of this situation...
>
> |-|-|-|--|
> 0              500          700            1200               3000
> [Logical block numbers for an inode]
>
>
> In this situation you will have four extents for sure.
> ext_1 -> 0 -- 500
> ext_2 -> 501 --700 [ This will be an initialized extent]
> ext_3 -> 701 -- 1200
> ext_4 -> 1200 -- 3000
>
> After looking at the sources and some comments in the ext4 source
> code, I could figure out that holes would be having an initialized
> extent.
> Reference: http://lxr.linux.no/#linux+v2.6.31/fs/ext4/extents.c#L2843
>
> I think we cannot have a mixture of both a BMAP and an EMAP, it will be 
> either.
>
>> Then it calls merge_extents to create extent groups.  In e4defrag
>> terminology, an extent group is a collection of all the logically
>> contiguous extents.  I don't know if the kernel uses that terminology
>> or not.
>>
>
> Hope they are not merging together any initialized and uninitialized
> extents together, since they can be logically contiguous. Or rather
> they will be.
>
>
>> In other words in e4defrag terminology a sparse file is a series of:
>>
>> extent group - hole - extent group - hole - extent group - etc.
>>
>> Then e4defrag creates a donor file with exactly the same allocated
>> block areas by calling fallocate on the donor file for each extent
>> group with the same starting offset and length as the extent group.
>>
>
> This is true and should be applicable to initialized extents as well.
> I fear if they are
>
>
>> Thus the donor file ends up have exactly the same holes as the
>> original file.  Then the donor blocks are used to defrag the original
>> file by calling move_extent.  In the kernel, the move_extent logic
>> looks for holes and only replaces blocks that are allocated in the
>> original file.
>>
>
> This is true. I am sure of the kernel

Re: Copying kernel module error messages to userspace

2009-09-14 Thread Pei Lin
why u must use a law to limit your solution?
And u can hack kernel and dig the hole and do what u want..

Lin

2009/9/14 Leonidas . :
>
>
> On Mon, Sep 14, 2009 at 2:19 PM, Leonidas .  wrote:
>>
>>
>> On Mon, Sep 14, 2009 at 1:57 PM, Pei Lin  wrote:
>>>
>>> SO u can use the first method,write files from the kernel space.
>>> See the hyperlink i give.
>>>
>>> Lin
>>>
>>> 2009/9/14 Leonidas . :
>>> >
>>> >
>>> > On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
>>> > wrote:
>>> >>
>>> >>
>>> >> Hi List
>>> >>
>>> >> I have written a kernel module which implements a char device. An
>>> >> userspace app
>>> >> is supposed to get data from my module and then dump it into a file
>>> >> for
>>> >> further processing.
>>> >>
>>> >> The kind of data which kernel module is going to pass to userspace is
>>> >> going to be a 4K buffer,
>>> >> and the data traffic is not going to be really heavy, meaning may be a
>>> >> 4K
>>> >> buffer every 1 min or so.
>>> >> I am not very sure though, but certainly not heavy traffic the way
>>> >> they
>>> >> describe for network traffic etc.
>>> >>
>>> >> And this data needs to be logged to a file either from kernel or
>>> >> userspace
>>> >> and an userspace all will work
>>> >> on that data. This data needs to be logged as soon as it arrives
>>> >> meaning,
>>> >> I might not be able to write it to
>>> >> /proc since from module I can update /proc only when user actually
>>> >> accesses it. This data needs to be
>>> >> static in nature, meaning I get one error and I write it to a file
>>> >> somehow
>>> >> and user can see it anytime.
>>> >>
>>> >> I hope I have described the situation clearly. I have explored some
>>> >> mechanism like ioctls, mmaping the
>>> >> kernel buffer etc but all these would require the user module to poll
>>> >> or
>>> >> notified somehow by kernel that
>>> >> the data is available. I dont want the user module to poll.
>>> >>
>>> >>
>>> >> -Leo.
>>> >>
>>> >
>>> > When we do a printk it writes to kernel log buffer, correct? This is
>>> > real in
>>> > time operation i.e. as soon as we do a
>>> > printk the messages get logged. Now this log file can be accesses from
>>> > /var/log/messages right? How is this done?
>>> >
>>> > I want to so something similar, so I can log my messages to a seprate
>>> > file
>>> > which is going to stay around so user can
>>> > see at across reboots as well.
>>> >
>>> >
>>> >
>>> > -Leo.
>>> >
>>> >
>>
>>
>> No, Greg KH mentions that is should not be done!
>> And I have been reading that 'It is a bad..bad thing to access files from
>> kernel space'
>> since I started doing Linux stuff.
>>
>> _Leo.
>
>
> I am aware of other legitimate mechanisms as I have described on my origianl
> post.
> It is just that I have certain constraints under which I cant use many of
> the methods
> since I dont want to user space entity to do polling or get signal from
> kernel.
>
> -Leo.
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread Pei Lin
SO u can use the first method,write files from the kernel space.
See the hyperlink i give.

Lin

2009/9/14 Leonidas . :
>
>
> On Mon, Sep 14, 2009 at 1:22 PM, Leonidas .  wrote:
>>
>>
>> Hi List
>>
>> I have written a kernel module which implements a char device. An
>> userspace app
>> is supposed to get data from my module and then dump it into a file for
>> further processing.
>>
>> The kind of data which kernel module is going to pass to userspace is
>> going to be a 4K buffer,
>> and the data traffic is not going to be really heavy, meaning may be a 4K
>> buffer every 1 min or so.
>> I am not very sure though, but certainly not heavy traffic the way they
>> describe for network traffic etc.
>>
>> And this data needs to be logged to a file either from kernel or userspace
>> and an userspace all will work
>> on that data. This data needs to be logged as soon as it arrives meaning,
>> I might not be able to write it to
>> /proc since from module I can update /proc only when user actually
>> accesses it. This data needs to be
>> static in nature, meaning I get one error and I write it to a file somehow
>> and user can see it anytime.
>>
>> I hope I have described the situation clearly. I have explored some
>> mechanism like ioctls, mmaping the
>> kernel buffer etc but all these would require the user module to poll or
>> notified somehow by kernel that
>> the data is available. I dont want the user module to poll.
>>
>>
>> -Leo.
>>
>
> When we do a printk it writes to kernel log buffer, correct? This is real in
> time operation i.e. as soon as we do a
> printk the messages get logged. Now this log file can be accesses from
> /var/log/messages right? How is this done?
>
> I want to so something similar, so I can log my messages to a seprate file
> which is going to stay around so user can
> see at across reboots as well.
>
>
>
> -Leo.
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 2:19 PM, Leonidas .  wrote:

>
>
> On Mon, Sep 14, 2009 at 1:57 PM, Pei Lin  wrote:
>
>> SO u can use the first method,write files from the kernel space.
>> See the hyperlink i give.
>>
>> Lin
>>
>> 2009/9/14 Leonidas . :
>> >
>> >
>> > On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
>> wrote:
>> >>
>> >>
>> >> Hi List
>> >>
>> >> I have written a kernel module which implements a char device. An
>> >> userspace app
>> >> is supposed to get data from my module and then dump it into a file for
>> >> further processing.
>> >>
>> >> The kind of data which kernel module is going to pass to userspace is
>> >> going to be a 4K buffer,
>> >> and the data traffic is not going to be really heavy, meaning may be a
>> 4K
>> >> buffer every 1 min or so.
>> >> I am not very sure though, but certainly not heavy traffic the way they
>> >> describe for network traffic etc.
>> >>
>> >> And this data needs to be logged to a file either from kernel or
>> userspace
>> >> and an userspace all will work
>> >> on that data. This data needs to be logged as soon as it arrives
>> meaning,
>> >> I might not be able to write it to
>> >> /proc since from module I can update /proc only when user actually
>> >> accesses it. This data needs to be
>> >> static in nature, meaning I get one error and I write it to a file
>> somehow
>> >> and user can see it anytime.
>> >>
>> >> I hope I have described the situation clearly. I have explored some
>> >> mechanism like ioctls, mmaping the
>> >> kernel buffer etc but all these would require the user module to poll
>> or
>> >> notified somehow by kernel that
>> >> the data is available. I dont want the user module to poll.
>> >>
>> >>
>> >> -Leo.
>> >>
>> >
>> > When we do a printk it writes to kernel log buffer, correct? This is
>> real in
>> > time operation i.e. as soon as we do a
>> > printk the messages get logged. Now this log file can be accesses from
>> > /var/log/messages right? How is this done?
>> >
>> > I want to so something similar, so I can log my messages to a seprate
>> file
>> > which is going to stay around so user can
>> > see at across reboots as well.
>> >
>> >
>> >
>> > -Leo.
>> >
>> >
>>
>
>
> No, Greg KH mentions that is should not be done!
> And I have been reading that 'It is a bad..bad thing to access files from
> kernel space'
> since I started doing Linux stuff.
>
> _Leo.
>


I am aware of other legitimate mechanisms as I have described on my origianl
post.
It is just that I have certain constraints under which I cant use many of
the methods
since I dont want to user space entity to do polling or get signal from
kernel.

-Leo.


Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 1:57 PM, Pei Lin  wrote:

> SO u can use the first method,write files from the kernel space.
> See the hyperlink i give.
>
> Lin
>
> 2009/9/14 Leonidas . :
> >
> >
> > On Mon, Sep 14, 2009 at 1:22 PM, Leonidas . 
> wrote:
> >>
> >>
> >> Hi List
> >>
> >> I have written a kernel module which implements a char device. An
> >> userspace app
> >> is supposed to get data from my module and then dump it into a file for
> >> further processing.
> >>
> >> The kind of data which kernel module is going to pass to userspace is
> >> going to be a 4K buffer,
> >> and the data traffic is not going to be really heavy, meaning may be a
> 4K
> >> buffer every 1 min or so.
> >> I am not very sure though, but certainly not heavy traffic the way they
> >> describe for network traffic etc.
> >>
> >> And this data needs to be logged to a file either from kernel or
> userspace
> >> and an userspace all will work
> >> on that data. This data needs to be logged as soon as it arrives
> meaning,
> >> I might not be able to write it to
> >> /proc since from module I can update /proc only when user actually
> >> accesses it. This data needs to be
> >> static in nature, meaning I get one error and I write it to a file
> somehow
> >> and user can see it anytime.
> >>
> >> I hope I have described the situation clearly. I have explored some
> >> mechanism like ioctls, mmaping the
> >> kernel buffer etc but all these would require the user module to poll or
> >> notified somehow by kernel that
> >> the data is available. I dont want the user module to poll.
> >>
> >>
> >> -Leo.
> >>
> >
> > When we do a printk it writes to kernel log buffer, correct? This is real
> in
> > time operation i.e. as soon as we do a
> > printk the messages get logged. Now this log file can be accesses from
> > /var/log/messages right? How is this done?
> >
> > I want to so something similar, so I can log my messages to a seprate
> file
> > which is going to stay around so user can
> > see at across reboots as well.
> >
> >
> >
> > -Leo.
> >
> >
>


No, Greg KH mentions that is should not be done!
And I have been reading that 'It is a bad..bad thing to access files from
kernel space'
since I started doing Linux stuff.

_Leo.


Re: Copying kernel module error messages to userspace

2009-09-14 Thread Pei Lin
u can do this within your module.
Give u a link for reference.
http://www.linuxjournal.com/article/8110

And u also can refer to the mechanism like dmesg

BRs
Lin

2009/9/14 Leonidas . :
>
>
> Hi List
>
> I have written a kernel module which implements a char device. An userspace
> app
> is supposed to get data from my module and then dump it into a file for
> further processing.
>
> The kind of data which kernel module is going to pass to userspace is going
> to be a 4K buffer,
> and the data traffic is not going to be really heavy, meaning may be a 4K
> buffer every 1 min or so.
> I am not very sure though, but certainly not heavy traffic the way they
> describe for network traffic etc.
>
> And this data needs to be logged to a file either from kernel or userspace
> and an userspace all will work
> on that data. This data needs to be logged as soon as it arrives meaning, I
> might not be able to write it to
> /proc since from module I can update /proc only when user actually accesses
> it. This data needs to be
> static in nature, meaning I get one error and I write it to a file somehow
> and user can see it anytime.
>
> I hope I have described the situation clearly. I have explored some
> mechanism like ioctls, mmaping the
> kernel buffer etc but all these would require the user module to poll or
> notified somehow by kernel that
> the data is available. I dont want the user module to poll.
>
>
> -Leo.
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ



Re: Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
On Mon, Sep 14, 2009 at 1:22 PM, Leonidas .  wrote:

>
>
> Hi List
>
> I have written a kernel module which implements a char device. An userspace
> app
> is supposed to get data from my module and then dump it into a file for
> further processing.
>
> The kind of data which kernel module is going to pass to userspace is going
> to be a 4K buffer,
> and the data traffic is not going to be really heavy, meaning may be a 4K
> buffer every 1 min or so.
> I am not very sure though, but certainly not heavy traffic the way they
> describe for network traffic etc.
>
> And this data needs to be logged to a file either from kernel or userspace
> and an userspace all will work
> on that data. This data needs to be logged as soon as it arrives meaning, I
> might not be able to write it to
> /proc since from module I can update /proc only when user actually accesses
> it. This data needs to be
> static in nature, meaning I get one error and I write it to a file somehow
> and user can see it anytime.
>
> I hope I have described the situation clearly. I have explored some
> mechanism like ioctls, mmaping the
> kernel buffer etc but all these would require the user module to poll or
> notified somehow by kernel that
> the data is available. I dont want the user module to poll.
>
>
> -Leo.
>
>
When we do a printk it writes to kernel log buffer, correct? This is real in
time operation i.e. as soon as we do a
printk the messages get logged. Now this log file can be accesses from
/var/log/messages right? How is this done?

I want to so something similar, so I can log my messages to a seprate file
which is going to stay around so user can
see at across reboots as well.



-Leo.


Copying kernel module error messages to userspace

2009-09-14 Thread Leonidas .
Hi List

I have written a kernel module which implements a char device. An userspace
app
is supposed to get data from my module and then dump it into a file for
further processing.

The kind of data which kernel module is going to pass to userspace is going
to be a 4K buffer,
and the data traffic is not going to be really heavy, meaning may be a 4K
buffer every 1 min or so.
I am not very sure though, but certainly not heavy traffic the way they
describe for network traffic etc.

And this data needs to be logged to a file either from kernel or userspace
and an userspace all will work
on that data. This data needs to be logged as soon as it arrives meaning, I
might not be able to write it to
/proc since from module I can update /proc only when user actually accesses
it. This data needs to be
static in nature, meaning I get one error and I write it to a file somehow
and user can see it anytime.

I hope I have described the situation clearly. I have explored some
mechanism like ioctls, mmaping the
kernel buffer etc but all these would require the user module to poll or
notified somehow by kernel that
the data is available. I dont want the user module to poll.


-Leo.


Re: Modules required for booting without initrd

2009-09-14 Thread Pei Lin
Not only the ext3 driver u need compile into the kernel, there are
always need some other disk driver support like sata,ide to compile
into the kernel.
Give u an article for reference.
http://www.gentoo.org/doc/en/kernel-config.xml


BRs

Lin


2009/9/14 sky knight 
>
> Hi,
>
> I want to boot my laptop without initrd, I tried to compile 2.6.30 kernel 
> from debian back port repository, by building ext3 driver into kernel but 
> during booting i am getting "vfs: could not mount root fs unkown-block(8,1)".
>
> My menu.lst:
>
> title   Debian GNU/Linux, kernel 2.6.30-130909f-we-test
> root(hd0,0)
> kernel  /boot/vmlinuz-2.6.30-130909f-we-test root=/dev/sda1 ro
>
> fdisk -l:
> http://paste.debian.net/46476/
>
> lsmod:
> http://paste.debian.net/46474/
>
> lspci:
> http://paste.debian.net/46475/
>
>
>
> What are the modules should be loaded into the kernel to boot without initrd? 
> and how to find them?
>
>
>
> Thanks,
> Alagunambi Welkin
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ