In SMP system, is there any api to disable IRQ for all CPUs?

2015-10-01 Thread loody
hi all:
is there any kernel API can let IRQ disable for all CPU in SMP system
for a while?
I just need it for a experiment on my module.

such as:
  --> disable SMP all cpu IRQ
  OOO   ---> no interrupt happen
  OOO   ---> no interrupt happen
  ---> enable SMP all cou IRQ

Appreciate your kind help in advance,

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


can direct ftrace to file

2014-03-19 Thread loody
hi all:
usually I use
cat /sys/kernel/debug/tracing/trace
to look the ftrace result.

Is it possible
1. direct trace to some file
2. enable ftrace
3. starting tracing what I interested
4. stop ftrace
5. open the file of #1 I directed

that mean I can see whole trace log from #2 to #4
-- 
Regards,

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


Re: how to determine kernel interrupt latency

2014-03-16 Thread loody
hi peter:


2014-01-17 13:41 GMT+08:00 Peter Teoh htmldevelo...@gmail.com:
 http://stackoverflow.com/questions/15383259/are-there-any-kernel-tools-available-to-measure-interrupt-latency-with-reasonabl

 checkout cyclictest.
I have checked cyclictest.
from manual page, it seems used to calculate thread latency instead of
interrupt latency
Would you please let me know if there any kind of command for using it
to check interrupt latency ?
thanks for your help,

cyclictest V 0.42
Usage:
cyclictest options

-a [NUM] --affinityrun thread #N on processor #N, if possible
   with NUM pin all threads to the processor NUM
-b USEC  --breaktrace=USEC send break trace command when latency  USEC
-B   --preemptirqs both preempt and irqsoff tracing (used with -b)
-c CLOCK --clock=CLOCK select clock
   0 = CLOCK_MONOTONIC (default)
   1 = CLOCK_REALTIME
-C   --context context switch tracing (used with -b)
-d DIST  --distance=DIST   distance of thread intervals in us default=500
-E   --event   event tracing (used with -b)
-f   --ftrace  function trace (when -b is active)
-i INTV  --interval=INTV   base interval of thread in us default=1000
-I   --irqsoff Irqsoff tracing (used with -b)
-l LOOPS --loops=LOOPS number of loops: default=0(endless)
-m   --mlockalllock current and future memory allocations
-n   --nanosleep   use clock_nanosleep
-N   --nsecs   print results in ns instead of ms (default ms)
-o RED   --oscope=RED  oscilloscope mode, reduce verbose output by RED
-O TOPT  --traceopt=TOPTtrace option
-p PRIO  --prio=PRIO   priority of highest prio thread
-P   --preemptoff  Preempt off tracing (used with -b)
-q   --quiet   print only a summary on exit
-r   --relativeuse relative timer instead of absolute
-s   --system  use sys_nanosleep and sys_setitimer
-T TRACE --tracer=TRACER   set tracing function
configured tracers: unavailable (debugfs not mounted)
-t   --threads one thread per available processor
-t [NUM] --threads=NUM number of threads:
   without NUM, threads = max_cpus
   without -t default = 1
-v   --verbose output values on stdout for statistics
   format: n:c:v n=tasknum c=count v=value in us
-D   --duration=t  specify a length for the test run
   default is in seconds, but 'm', 'h', or 'd' maybe add
ed
   to modify value to minutes, hours or days
-h   --histogram=USdump a latency histogram to stdout after the run
   US is the max time to be be tracked in microseconds
-w   --wakeup  task wakeup tracing (used with -b)
-W   --wakeuprtrt task wakeup tracing (used with -b)

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


how to determine kernel interrupt latency

2014-01-10 Thread loody
hi all:
is it possible to determine interrupt latency in kernel with any ftrace or proc?

-- 
Regards,

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


suspend/resume call back functions

2013-10-05 Thread loody
hi all:
At the end of mail are the platform_driver and device_driver structures:
My question are:
1. what is the relation between 
platform_driver- suspend/resumt,
device_driver-suspend/resume
device_driver-pm-suspend/resume

2. and what are their relationship?

Appreciate your kind help,


struct platform_driver {
 int (*probe)(struct platform_device *);
 int (*remove)(struct platform_device *);
 void (*shutdown)(struct platform_device *);
 int (*suspend)(struct platform_device *, pm_message_t state);
 int (*resume)(struct platform_device *);
 struct device_driver driver;
 const struct platform_device_id *id_table;
 };

 struct device_driver {
 const char  *name;
 struct bus_type *bus;
 struct module   *owner;
 const char  *mod_name;  /* used for built-in modules */
 bool suppress_bind_attrs;   /* disables bind/unbind via sysfs */
 const struct of_device_id   *of_match_table;
 const struct acpi_device_id *acpi_match_table;
 int (*probe) (struct device *dev);
 int (*remove) (struct device *dev);
 void (*shutdown) (struct device *dev);
 int (*suspend) (struct device *dev, pm_message_t state);
 int (*resume) (struct device *dev);
 const struct attribute_group **groups;
 const struct dev_pm_ops *pm;
 struct driver_private *p;
 };

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


Re: some questions about log level

2012-06-28 Thread loody
hi all:

 Jonathan refer to consoles you usually get when pressing Ctrl-Alt-F1
 throught Ctrl-Alt-F6.
is it possible to direct kernel log to xterm-alikes console?
Thanks for your help in advance,

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


Re: [Q] USB urb completion handler

2012-05-23 Thread loody
hi:

2012/5/23 Ezequiel Garcia elezegar...@gmail.com:
 Hi,

 Bingo! Because the driver will only submit *one* urb at a time,
 how could it possible have more than one completion handlers
 called at a time?

 how about multi-thread try to send urbs on the same pipe with the same
 complete function?

 Actually, I was wrong because my driver (being a video capture driver)
 submits several
 isoc urbs at the same time.

 I'm still not sure how this works regarding concurrency, but I guess
 (or hope) the usb core calls
 the completion handler one at a time OR the device sends interrupts
 one at a time for each urb.
take multi-core system for example, it is possible your completion
handler execute at the same time, except you add a spin lock for
activating your completion function.



 I know it's a terrible thing for me to guess (or hope), but these days
 I've been testing
 the driver under several conditions and it seems to work fine.
 So I'm not worrying too much.

 If someone more knowledgeable reads this and can put a light upon this issue,
 I would appreciate it.

 loody: Thanks for your answer regarding context ;)
 Ezequiel.



-- 
Regards,

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


Re: [Q] USB urb completion handler

2012-05-22 Thread loody
hi:

2012/5/8 Ezequiel Garcia elezegar...@gmail.com:
 On Mon, May 7, 2012 at 2:48 PM, Peter Senna Tschudin
 peter.se...@gmail.com wrote:
 http://www.makelinux.net/ldd3/chp-13-sect-3#chp-13-sect-3.4

  If the function succeeds, the completion handler of the urb (as
 specified by the complete function pointer) is called exactly once
 when the urb is completed. When this function is called, the USB core
 is finished with the URB, and control of it is now returned to the
 device driver.


 Bingo! Because the driver will only submit *one* urb at a time,
 how could it possible have more than one completion handlers
 called at a time?
how about multi-thread try to send urbs on the same pipe with the same
complete function?

 I wasn't thinking with the right half of my brain.
 Thanks,
 Ezequiel.

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



-- 
Regards,

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


Re: [Q] USB urb completion handler

2012-05-22 Thread loody
hi

2012/5/8 Ezequiel Garcia elezegar...@gmail.com:
 Hi,

 I have a very simple question:
 Is it possible for an urb completion handler (the function that you
 put in the urb-complete field)
 to execute concurrently with itself?

 And in what context does it get called? Is it in interrupt context or
 in the context of a kernel thread?

Both conditions will try to call complete functions.


 Hope my question is clear enough,
 Regards,
 Ezequiel.

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

-- 
Regards,

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


Some questions about boot memory

2012-05-04 Thread loody
hi all:

 I have some question about the relationship between page table
 creation and bootmemery allocation.
 bootmemory allocation use 1-bit to declare this page is used or not.
 Does that mean when a new page table is creating, it will reference
 the bits of bootmap and add dirty flag on the page of the page table created?

 --
 Thanks a lot

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


about kmemtrace-user program

2012-05-03 Thread loody
hi all:
from below thread,
http://www.kerneltrap.org/mailarchive/linux-kernel/2009/12/24/4522989
it seems kmemtrace-user, http://repo.or.cz/w/kmemtrace-user.git,
cannot work on current kernel.
if it is the truth, is there any other user program I can use for
replacing kmemtrace-user.

-- 
Regards,

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


Re: Some questions about high memory

2012-04-06 Thread loody
hi mulyadi

2012/4/6 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi...

 On Fri, Apr 6, 2012 at 09:19, loody milo...@gmail.com wrote:
 hi all:
 I am trying to write a driver for my block device which dma support
 high memory copying.
 I have register my device as blk_bounce_any.
 But my driver cannot see block layer pass high memory to me so far.

 perhaps because you need to kmap them first?
If I remember correctly, Kmap is used for mapping high memory into
kernel virtual memory.
Isn't that the job for block layer?

I thought once I declare my block device as blk_bounce_any, the
block layer will pass the physical address of high memory to device.



 BTW, is it 32 bit or 64 bit Linux kernel?
32-bits linux kernel.


 Is there any user/kernel test program which will purposely send high
 memory for driver to use?
 or is there any flag when opening a file in user mode that will use high 
 memory?

 I recheck mmap and mmap manual page and I found none of such flag

does that mean mmap can specify which memory to map?
if that is true, which range I should use?


 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com

Appreciate your help

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


Some questions about high memory

2012-04-05 Thread loody
hi all:
I am trying to write a driver for my block device which dma support
high memory copying.
I have register my device as blk_bounce_any.
But my driver cannot see block layer pass high memory to me so far.

Is there any user/kernel test program which will purposely send high
memory for driver to use?
or is there any flag when opening a file in user mode that will use high memory?

-- 
Thanks for your help in advance,

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


some question about time

2012-03-06 Thread loody
hi all:
There are 2 time structs in kernel, timespec and ktime_t.
Under what circumstances we will use timespec or ktime_t?

under 32-bits system, they seem same because both them store second
and nanosecond information, right?
-- 
Regards,

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


some questions about container_of and user_struct

2012-02-12 Thread loody
hi all:
I add below function in free_uid to get which task try to free user_struct

struct task_struct *p;
struct cred *c;
c = container_of(up,struct cred, user);
p = container_of(c,struct task_struct,real_cred);
printk(%s user %p, cred-user = %p p-pid = %d\n,__func__,up, c-user,p-pid);

but p-pid is always 0.
I think it is wrong for me to get cred and task by using container_of.

1. from kernel definition below, is it ok that member is pointer?
#define container_of(ptr, type, member)

2. is there already exist macros or functions I can use for #1 above?

3. what is user_struct used for? When and under what circumstances
kernel will try to release it.

4. since user_struct is allocated by kmem_cache_zalloc, is there api
or tool I can monitor it?

Thanks for your help,

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


Re: Some question about security context of a task

2012-02-01 Thread loody
hi Mulyadi:

2012/2/1 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi

 On Wed, Feb 1, 2012 at 14:12, loody milo...@gmail.com wrote:
 below is the place it happen

 if (atomic_read(p-real_cred-user-processes) =
             p-signal-rlim[RLIMIT_NPROC].rlim_cur) {

 Seems like a normal user limit checking...the one we usually set via
 ulimit command. Checking number of processes to be precise...

 after checking the parameter, I found p-real_cred-user is NULL.

 hm, IMHO if it exceeds ulimit, the process creation should just stop.
Yes, I think you are right.

 Not sure why read_cred-user becomes NULL. Maybe that's for clean up,
 since later process will be terminated?

The later process you mean is the caller?
please let me describe my environment more detail.
1. when outside event happen
2. calling driver's probe.
3. I use kernel_thread to create a thread in probe function.
Then the sequence seems like:
kernel_thread
  - do_fork
  - copy_process
  ..
  p = dup_task_struct(current);
  /*The user_struct user is inherited from current.*/
  ...
if (atomic_read(p-real_cred-user-processes) =
             p-signal-rlim[RLIMIT_NPROC].rlim_cur) {
...

Then it panic.
1. why kernel thread need user_struct
2. is it use for kernel thread to record how may user mode program it created?

Thanks for your help,

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


Re: what is trace_sched_kthread_stop_ret used for?

2011-12-29 Thread loody
hi Richard :

2011/12/29 Townsend, Richard richard.towns...@warwick.ac.uk:
 It appears to be a macro defined in include/trace/events/shed.h.

  35 TRACE_EVENT(sched_kthread_stop_ret,
  36
  37         TP_PROTO(int ret),
  38
  39         TP_ARGS(ret),
  40
  41         TP_STRUCT__entry(
  42                 __field(        int,    ret     )
  43         ),
  44
  45         TP_fast_assign(
  46                 __entry-ret    = ret;
  47         ),
  48
  49         TP_printk(ret=%d, __entry-ret)
  50 );

 --
 Richard Townsend

Thanks for your help,

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


what is trace_sched_kthread_stop_ret used for?

2011-12-28 Thread loody
Dear all:
i saw there is a function called trace_sched_kthread_stop_ret in
some place of kernel.
but I found it is empty function.
http://lxr.linux.no/linux+v3.1.5/+code=trace_sched_kthread_stop_ret

if it is empty, why we still keep it in kernel?

-- 
Regards,

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


Re: how to determine whether in irq context

2011-12-28 Thread loody
hi bojan:

2011/12/28 bojan prtvar prtva...@gmail.com:
 On Wed, Dec 28, 2011 at 10:20 AM, loody milo...@gmail.com wrote:
 Dear all:
 i remember there is a marco for us to determine whether we are located
 in irq context.
 I forget what it is.
 Would anyone know what it is?


 --
Thanks for your help,

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


where to check Kthread info

2011-12-20 Thread loody
Dear all:
is there any in formations I can get such as
1. when the last time the kthread running.
2. is the kthread alive?

from the proc?


-- 
Thanks for your help,

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


Re: some questions about log level

2011-12-14 Thread loody
hi all:
I can see the message, right now.
2011/12/13 Mulyadi Santosa mulyadi.sant...@gmail.com:
 On Tue, Dec 13, 2011 at 08:57, loody milo...@gmail.com wrote:
 hi:

 2011/12/13 Jonathan Neuschäfer j.neuschae...@gmx.net:
 On Mon, Dec 12, 2011 at 10:18:20PM +0800, loody wrote:
 Then I purposely connect/disconnect USB, but my console keep quiet.

 Which console are you looking at? It only works with the consoles
 provided by the kernel (ttyN) on usual desktop distros, and not with
 xterm-alikes.
 I use ubuntu 11.04 and I use gnome terminal.
 so you mean what I saw in gonme terminal may not be the ttyN that
 enabled by kernel?
 if that is the root cause, is it possible for me to switch my gonme
 terminal to ttyN you mentioned?

 Appreciate your help,

 Jonathan refer to consoles you usually get when pressing Ctrl-Alt-F1
 throught Ctrl-Alt-F6.

BTW, is there any api I can flush all the messages in kernel buffer
ring before when I jump to BUG(), kernel checking MACRO?
my problem is:
1. I put more detail messages in the level 8, usually it will shows up
if I change console_loglevel or type dmesg.
2. I don't want it to show in normal operation.
3. but I want to see them before my driver jump to BUG() check point.
Thanks for your help,

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


how can we wake up some process which is scheduled?

2011-12-13 Thread loody
hi all:
There is a kernel API, schedule_timeout_interruptible.
since it has the name interruptible, who and how can we interrupt this task?
suppose A use schedule_timeout_interruptible for 20s period and B
found something and he want to wake up A within this 20s period.

-- 
Regards,

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


some questions about log level

2011-12-12 Thread loody
hi all:
my questions are below:
1. Can I temporarily let kernel message show in stdout?
I google some key word as console_loglevel and I found following methods:
 a. echo 8  /proc/sys/kernel/printk
 b. write a simple program which calling klogctl(8, NULL, level)
Then I purposely connect/disconnect USB, but my console keep quiet.
But dmesg shows connect/disconnect messages.

2. what is differences between above a and b methods?
Are they not to used to change console_loglevel?

3. is it possible the max level of console_loglevel doesn't mean it
will show on stdout?




-- 
Thanks for your help

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


Re: some questions about log level

2011-12-12 Thread loody
hi:

2011/12/13 Jonathan Neuschäfer j.neuschae...@gmx.net:
 On Mon, Dec 12, 2011 at 10:18:20PM +0800, loody wrote:
 Then I purposely connect/disconnect USB, but my console keep quiet.

 Which console are you looking at? It only works with the consoles
 provided by the kernel (ttyN) on usual desktop distros, and not with
 xterm-alikes.
I use ubuntu 11.04 and I use gnome terminal.
so you mean what I saw in gonme terminal may not be the ttyN that
enabled by kernel?
if that is the root cause, is it possible for me to switch my gonme
terminal to ttyN you mentioned?

Appreciate your help,

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


What is Backing device used for?

2011-12-04 Thread loody
Dear all:
Is there any document which explain what backing device used for?

-- 
Thanks a lot,

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


Can I get the information of bounce limit from sys?

2011-11-18 Thread loody
hi all:
I saw sys can show some information such as max_sectors_kb ,
physical_block_size, hw_sector_size  and max_segments.
Where i can get bounce limit information, except digging through source code.


-- 
Regards,

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


Re: Re SD/MMC subsystem resources

2011-11-10 Thread loody
hi:
2011/11/10, Asutosh Das das.asut...@gmail.com:
 Hi All
 Please can you let me know if there are any good articles and/or books
 that explain the linux sd/mmc stack that you may know of.

 TIA

how about posting this message on the linux-mmc mailing list?

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


Re: some questions about block and scatterlist

2011-11-07 Thread loody
Dear Jonathan:
2011/11/1 Jonathan Corbet cor...@lwn.net:
 On Tue, 1 Nov 2011 19:32:38 +0900
 loody milo...@gmail.com wrote:

 My questions are below:

 As are some answers :)
That will be great appreciated :)

 1. Are all struct page 32-bit aligned?

 Certainly, I would expect any structures found in the system memory map to
 be so aligned, yes.  If you've created an arbitrary one elsewhere I'm only
 99% sure it would be.

 If so, where is this part of code for handleing struct page be 32-bits 
 aligned?

 Note that the size of struct page is carefully considered, and that they
 are packed as densely as possible, both externally and internally.  No
 lesser alignment would make sense.
I found kernel stealing LSB of page_link to put additional
information, such as sg_is_chain and sg_is_last.

That means the address of all pages have to be at least 4byte alignment.
But I didn't see any additional attribute added at the end of struct
or any precaution to take care this.


 2. if the page of scatterlist is located at high mem, how does
 dma_map_sg mapping the virtual address?

 That depends on a vast array of things.  What are the addressing
 capabilities of the target device?  Is there an IOMMU involved?
No, my device has no iommu. and I found where kernel handle this part.

 3. in blk_rq_map_sg, it seems we only copy bvec-bv_page to sg-page_link
    why don't we add dma_address in bvec and send the bio directly to
 the lower level driver?

 That would be a bit of a mixing of the layers, if nothing else.

 4. if I plug a USB HD with 3 partitions, will there be 3 request_queues?

 No, there is one request queue for the underlying device.
I study some block devices and it seems we use blk_init_queue for
getting a request_queue, if we want block layer handle requests and
coalesces adjacent requests.
what happen and lower driver need to do if we don't use blk_init_queue
to register a request_queue?


 That's an interesting mix of questions.  If you have more in the future,
 you'll likely get more (and more clueful) responses if they're accompanied
 by the code you're working on.

 Thanks,

 jon

-- 
Regards,

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


some questions about block and scatterlist

2011-11-03 Thread loody
Dear all:
My questions are below:
1. Are all struct page 32-bit aligned?
If so, where is this part of code for handleing struct page be 32-bits aligned?
2. if the page of scatterlist is located at high mem, how does
dma_map_sg mapping the virtual address?
3. in blk_rq_map_sg, it seems we only copy bvec-bv_page to sg-page_link
   why don't we add dma_address in bvec and send the bio directly to
the lower level driver?
4. if I plug a USB HD with 3 partitions, will there be 3 request_queues?


-- 
Regards,

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


how to compile additional module?

2011-08-23 Thread loody
Dear all:
I make a module under kernel tree and adding Kconfig for that.
But I have no idea where I should add that when I type make modules,
the modules I add will be compiled.
Would anyone tell me where the modules list located?


-- 
Regards,

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


Re: how to compile additional module?

2011-08-23 Thread loody
hi all:
I found if kernel want to build usb modules it will show below:there is
make -f scripts/Makefile.build obj=drivers/usb

if I have a folder in drivers/miloodytest
how could I generate
make -f scripts/Makefile.build obj=drivers/miloodytest

BR,

2011/8/23 loody milo...@gmail.com:
 Dear all:
 I make a module under kernel tree and adding Kconfig for that.
 But I have no idea where I should add that when I type make modules,
 the modules I add will be compiled.
 Would anyone tell me where the modules list located?


 --
 Regards,




-- 
Regards,

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


Re: how to compile additional module?

2011-08-23 Thread loody
hi:
Thanks for your help.


2011/8/23 Mirco Tischler mt...@gmx.de:
 2011/8/23 loody milo...@gmail.com:
 hi all:
 I found if kernel want to build usb modules it will show below:there is
 make -f scripts/Makefile.build obj=drivers/usb

 if I have a folder in drivers/miloodytest
 how could I generate
 make -f scripts/Makefile.build obj=drivers/miloodytest

 BR,

 2011/8/23 loody milo...@gmail.com:
 Dear all:
 I make a module under kernel tree and adding Kconfig for that.
 But I have no idea where I should add that when I type make modules,
 the modules I add will be compiled.
 Would anyone tell me where the modules list located?


 --
 Regards,

 Hi
 It seems you forgot to edit the Makefiles. Take a look at
 Documentation/kbuild/makefiles.txt for a detailed explanation. Section
 3 is probably the most interesting.

I put Makefile in drivers/miloodytest
I have no idea how to let kbuild jump to there and make modules.
I guess the secret should be in scripts folder, since it seems some
tool or shell will generate command as below:
make -f scripts/Makefile.build obj=drivers/usb
make -f scripts/Makefile.build obj=drivers/block
make -f scripts/Makefile.build obj=drivers/cdrom
make -f scripts/Makefile.build obj=drivers/char
make -f scripts/Makefile.build obj=drivers/clocksource
make -f scripts/Makefile.build obj=drivers/firmware

but there is no Makefile in drivers, right?
Yours,



-- 
Regards,

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


Re: how to compile additional module?

2011-08-23 Thread loody
hi:
I found it and successfully make the module.

2011/8/23 Mirco Tischler mt...@gmx.de:
 2011/8/23 loody milo...@gmail.com:
 hi:
 Thanks for your help.


 2011/8/23 Mirco Tischler mt...@gmx.de:
 2011/8/23 loody milo...@gmail.com:
 hi all:
 I found if kernel want to build usb modules it will show below:there is
 make -f scripts/Makefile.build obj=drivers/usb

 if I have a folder in drivers/miloodytest
 how could I generate
 make -f scripts/Makefile.build obj=drivers/miloodytest

 BR,

 2011/8/23 loody milo...@gmail.com:
 Dear all:
 I make a module under kernel tree and adding Kconfig for that.
 But I have no idea where I should add that when I type make modules,
 the modules I add will be compiled.
 Would anyone tell me where the modules list located?


 --
 Regards,

 Hi
 It seems you forgot to edit the Makefiles. Take a look at
 Documentation/kbuild/makefiles.txt for a detailed explanation. Section
 3 is probably the most interesting.

 I put Makefile in drivers/miloodytest
 I have no idea how to let kbuild jump to there and make modules.
 I guess the secret should be in scripts folder, since it seems some
 tool or shell will generate command as below:
 make -f scripts/Makefile.build obj=drivers/usb
 make -f scripts/Makefile.build obj=drivers/block
 make -f scripts/Makefile.build obj=drivers/cdrom
 make -f scripts/Makefile.build obj=drivers/char
 make -f scripts/Makefile.build obj=drivers/clocksource
 make -f scripts/Makefile.build obj=drivers/firmware

 but there is no Makefile in drivers, right?
 Yours,



 --
 Regards,

 Actually, there is a Makefile in drivers. Just add something like
 obj-$(YOUR_CONFIG_OPTION) += miloodytest/ to drivers/Makefile and
 make will descend into miloodytest if YOUR_CONFIG_OPTION evaluates to
 m or y

Appreciate your help,

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


Re: change kthread priority

2011-07-11 Thread loody
hi:


2011/7/11 Dave Hylands dhyla...@gmail.com:
 Hi Milody,

 On Sun, Jul 10, 2011 at 8:55 PM, loody milo...@gmail.com wrote:
 hi:

 2011/7/11 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi...


 ...snip...

 AFAIK they are user mode libc functions...
 I found there are the same export_symbols in kernel.
 I use them to dynamically change the priority.
 It works but I found something interesting:
 1. if thread use schedule algorithm of SCHED_NORMAL, it cannot change
 the priority.
 2. can we set the priority  to any number less than (MAX_USER_RT_PRIO-1)?
 ( I tried to set the priority as 99, but it fail)

 You need to change the scheduling algorithim to be SCHED_FIFO or
 SCHED_RR in order to use the real-time priorities.
I saw kernel restrict the algorithm as SCHED_FIFO and SCHED_RR to
change the priority.
What are the differences between rt_priority, prio, static_prio and normal_prio?
sched_setscheduler seems only change rt_priority.

normal_prio is MAX_RT_PRIO-1 - t_priority
prio will be min(normal_prio, task_top_pi_waiter)

what is the real priority that kthread runs after calling sched_setscheduler ?



 3. can we get the name of thread from task_struct or pid?
 (I use cat /proc/338/status, I can see the name of thread. But I
 look around the task_struct, I cannot find any name information in
 it.)

 You can use the comm field from the task struct. This can be set using
 the prctl API and passing in PR_SET_NAME. You can see the task name by
 doing something like

 ps -T -o pid,ppid,user,time,comm

 Normally, ps shows the args column.

 --
 Dave Hylands
 Shuswap, BC, Canada
 http://www.davehylands.com




-- 
Regards,

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


faster way to find task

2011-07-11 Thread loody
Dear all:
Is there faster way to find a give name of task?
for example, I have a thread, named test, is there faster way to get the
task struct  by passing test to some kernel api?


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


Re: faster way to find task

2011-07-11 Thread loody
Hi all:

2011/7/12 loody milo...@gmail.com

 Dear all:
 Is there faster way to find a give name of task?
 for example, I have a thread, named test, is there faster way to get the
 task struct  by passing test to some kernel api?


 --
 Regards,

I found a way as below:
for_each_process(task) {
printk(“%s[%d]\n”, task-comm, task-pid);
}

But it is time-consuming to do so if I periodically want to know whether
test exist or not.
is there better way to do so?


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


Re: faster way to find task

2011-07-11 Thread loody
hi:


2011/7/12 Nuno Martins nuno.m.g.mart...@gmail.com:


 On Mon, Jul 11, 2011 at 5:34 PM, loody milo...@gmail.com wrote:

 Hi all:

 2011/7/12 loody milo...@gmail.com

 Dear all:
 Is there faster way to find a give name of task?
 for example, I have a thread, named test, is there faster way to get
 the task struct  by passing test to some kernel api?

 --
 Regards,

 I found a way as below:
 for_each_process(task) {
 printk(“%s[%d]\n”, task-comm, task-pid);
 }

 But it is time-consuming to do so if I periodically want to know whether
 test exist or not.
 is there better way to do so?

Thanks for your help :)
 If you have the thread pid you could find it really fast. By name i don't
 know any function that could help you with that.

actually, I only have the name for searching, since the thread start
and finish periodically, pid of it will change dynamically. The only
thing that fixed is the name of the thread.

 You could search [1,2] for functions that could help you with that.
 If you are invoking from the thread you want, inside the kernel you can get
 the current variable that points to ther current process.

  [1]  http://lxr.linux.no/linux+v2.6.39/kernel/pid.c#L426
  [2] struct task_struct *find_task_by_vpid(pid_t vnr);
 Have a good work.
I will check what you mentioned above.
Thanks a lot,

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


change kthread priority

2011-07-10 Thread loody
Dear all:
I have some questions about kthread:
1. can we change kthread priority through user mode program?
2. I found some functions that may be helpful.
sched_getscheduler
sched_setscheduler

When I use them in user mode, the return value of sched_setscheduler  is fail.

there is a thread talking about this,
http://www.spinics.net/lists/linux-rt-users/msg06588.html
What makes me confuse is these 2 functions is used in user mode or
kernel mode?

--
Regards,

--
Regards,



-- 
Regards,

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


Re: change kthread priority

2011-07-10 Thread loody
hi:

2011/7/11 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi...

 On Sun, Jul 10, 2011 at  is 17:27, loody milo...@gmail.com wrote:
 Dear all:
 I have some questions about kthread:
 1. can we change kthread priority through user mode program?

 Theoritically you can, but only if the priority not fixed and/or you
 have required capability to do so

 2. I found some functions that may be helpful.
 sched_getscheduler
 sched_setscheduler

 When I use them in user mode, the return value of sched_setscheduler  is 
 fail.

 did you do that as root? anything blocking you doing that withing
 SELinux or AppArmor policy?
I execute it as root.
what is SELinux or AppArmor policy?


 there is a thread talking about this,
 http://www.spinics.net/lists/linux-rt-users/msg06588.html
 What makes me confuse is these 2 functions is used in user mode or
 kernel mode?

 AFAIK they are user mode libc functions...
I found there are the same export_symbols in kernel.
I use them to dynamically change the priority.
It works but I found something interesting:
1. if thread use schedule algorithm of SCHED_NORMAL, it cannot change
the priority.
2. can we set the priority  to any number less than (MAX_USER_RT_PRIO-1)?
( I tried to set the priority as 99, but it fail)
3. can we get the name of thread from task_struct or pid?
(I use cat /proc/338/status, I can see the name of thread. But I
look around the task_struct, I cannot find any name information in
it.)

Thanks for your kind help,

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


Re: make error in building sample code!

2011-06-23 Thread loody
hi :
sorry for pick up this old thread.

2009/8/4 Robert P. J. Day rpj...@crashcourse.ca:
 On Tue, 4 Aug 2009, Greg Peter wrote:

 Hello,

 I am trying to build LDD3 sample code, just to get expirement around.
 (Obtained from the link -
 http://oreilly.com.cn/codeexample/ldd3/examples.tar.gz).

 But I get the following errors when I run make: (PS note, I have the kernel
 source and headers installed)


 #examples make
 for n in misc-progs misc-modules skull scull scullc sculld scullp scullv
 sbull snull short shortprint pci simple usb tty lddbus; do make -C $n ||
 exit 1; done
 make[1]: Entering directory `/home/gregp/examples/misc-progs'
 cc -O2 -fomit-frame-pointer -Wall
 -I/lib/modules/2.6.27.23-0.1-pae/build/include    setlevel.c   -o setlevel
 setlevel.c:30: error: expected declaration specifiers or ?...? before 
 ?syslog?
 setlevel.c:30: error: expected declaration specifiers or ?...? before ?type?
 setlevel.c:30: error: expected declaration specifiers or ?...? before ?bufp?
 setlevel.c:30: error: expected declaration specifiers or ?...? before ?len?
 setlevel.c:30: warning: data definition has no type or storage class
 setlevel.c:30: warning: type defaults to ?int? in declaration of ?_syscall3?
 setlevel.c: In function ?main?:
 setlevel.c:41: warning: implicit declaration of function ?syslog?
 make[1]: *** [setlevel] Error 1
 make[1]: Leaving directory `/home/gregp/examples/misc-progs'
 make: *** [subdirs] Error 1

  those userspace programs still use the now-deprecated and
 unsupported _syscall macros.  they should be rewritten to use
 syscall() instead.  see:

 http://www.kernel.org/doc/man-pages/online/pages/man2/_syscall.2.html

I can compile the attach lddbus.c successfully but fail to insert the module.
it is because device_register return a non-zero value.
I have also checked other driver to compare the procedure of initial
struct device, but I cannot see the difference.

take scsi_debug.c for example:
static struct device pseudo_primary = {
.init_name  = pseudo_0,
.release= pseudo_0_release,
};

static int __init scsi_debug_init(void)
{
..
ret = device_register(pseudo_primary);
if (ret  0) {
printk(KERN_WARNING scsi_debug: device_register error: %d\n,
ret);
goto free_vm;
}
.
}

is there any CONFIG in kernel i should open for fixing this problem?

-- 
Regards,
/*
 * A virtual bus for LDD sample code devices to plug into.  This
 * code is heavily borrowed from drivers/base/sys.c
 *
 * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet
 * Copyright (C) 2001 O'Reilly  Associates
 *
 * The source code in this file can be freely used, adapted,
 * and redistributed in source or binary form, so long as an
 * acknowledgment appears in derived source files.  The citation
 * should list that the code comes from the book Linux Device
 * Drivers by Alessandro Rubini and Jonathan Corbet, published
 * by O'Reilly  Associates.   No warranty is attached;
 * we cannot take responsibility for errors or fitness for use.
 *
 */
/* $Id: lddbus.c,v 1.9 2004/09/26 08:12:27 gregkh Exp $ */

#include linux/device.h
#include linux/module.h
#include linux/kernel.h
#include linux/init.h
#include linux/string.h
#include linux/kdev_t.h

#include lddbus.h

MODULE_AUTHOR(Jonathan Corbet);
MODULE_LICENSE(Dual BSD/GPL);
static char *Version = $Revision: 1.9 $;

/*
 * Respond to udev events.
 */
static int ldd_uevent(struct device *dev, struct kobj_uevent_env *env)
{
	if (add_uevent_var(env,
			   LDDBUS_VERSION=%s, Version))
		return -ENOMEM;

	return 0;
}

/*
 * Match LDD devices to drivers.  Just do a simple name test.
 */
static int ldd_match(struct device *dev, struct device_driver *driver)
{
	return !strncmp(dev_name(dev), driver-name, strlen(driver-name));
}


/*
 * The LDD bus device.
 */
static void ldd_bus_release(struct device *dev)
{
	printk(KERN_DEBUG lddbus release\n);
}


struct device ldd_bus = {
	.release  = ldd_bus_release
};


/*
 * And the bus type.
 */
struct bus_type ldd_bus_type = {
	.name = ldd,
	.match = ldd_match,
	.uevent  = ldd_uevent,
};

/*
 * Export a simple attribute.
 */
static ssize_t show_bus_version(struct bus_type *bus, char *buf)
{
	return snprintf(buf, PAGE_SIZE, %s\n, Version);
}

static BUS_ATTR(version, S_IRUGO, show_bus_version, NULL);



/*
 * LDD devices.
 */

/*
 * For now, no references to LDDbus devices go out which are not
 * tracked via the module reference count, so we use a no-op
 * release function.
 */
static void ldd_dev_release(struct device *dev)
{ }

int register_ldd_device(struct ldd_device *ldddev)
{
	ldddev-dev.bus = ldd_bus_type;
	ldddev-dev.parent = ldd_bus;
	ldddev-dev.release = ldd_dev_release;
	dev_set_name(ldddev-dev, ldd0);
	return device_register(ldddev-dev);
}
EXPORT_SYMBOL(register_ldd_device);

void unregister_ldd_device(struct ldd_device *ldddev)
{
	device_unregister(ldddev-dev);
}
EXPORT_SYMBOL(unregister_ldd_device);

/*
 * Crude 

Re: about 64-bits division in kernel

2011-05-21 Thread loody
hi dave:

2011/5/20 Dave Hylands dhyla...@gmail.com:
 Hi loody,

 On Thu, May 19, 2011 at 10:51 PM, loody milo...@gmail.com wrote:
 hi Dave:
 Thanks for your kind reply.
 2011/5/20 Dave Hylands dhyla...@gmail.com:
 Hi lody,

 On Thu, May 19, 2011 at 8:34 PM, loody milo...@gmail.com wrote:
 hi all:
 My platform is 32-bits cpu and I need following calculation in my driver.
 #define longdiv(sr1, sr2, div)      (unsigned long )unsigned long
 long)(sr1)  32) ^ (sr2)) / (div))

 my question are:
 1. why __udivdi3 has any relationship with above calculation?

 Because you're doing 64 bit arithmetic (unsigned long long) and 64 bit
 division is not supported in all kernels.

 why the name __udivdi3 has relation to 64-bits arighmetic?
 Why linker ask for __udivdi3, it seems there is a common sense for
 linker that when doing 64-bits calculation it will try to find
 __udivdi3, am i right?

 Well, since the CPU doesn't directly have support for 64-bit division,
 the compiler uses helper functions. The helper function __udivdi3 is
 the one for the particular operation you're providing.

 The functions in question are part of a library called libgcc and this
 library is not linked into the kernel.

 2. I know the above calculation is implemented in clibc, but why
 kernel still implement itself?
     why kernel try to make another wheel instead of including what
 clib provided ?

 The kernel doesn't use anything from the C runtime  library at all.

 64-bit division and floating point are 2 things not supported in the
 kernel, although they do happen to word on some platforms, they aren't
 portable operations.

 the 64-bit division seem supported in gcc toolchain, and gcc will take
 care the platform issue when we cross-compile the gcc, right?
 It should be safe to static link the 64bits division in gcc.

 You need to use the do_div macro available in linux/div64.h to perform
 64-bit division in the kernel.

I found div64.h is located at includ/asm-generic/div64.h instead of
include/linux/
BTW, I still cannot figure out why kernel doesn't adopt the gcc's solution.
libgcc.a will be compiled by different platform, arm, mips, etc.
And that should be safe for kernel to adopt it.

-- 
Thanks a lot,
miloody

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


Re: about 64-bits division in kernel

2011-05-19 Thread loody
hi Dave:
Thanks for your kind reply.
2011/5/20 Dave Hylands dhyla...@gmail.com:
 Hi lody,

 On Thu, May 19, 2011 at 8:34 PM, loody milo...@gmail.com wrote:
 hi all:
 My platform is 32-bits cpu and I need following calculation in my driver.
 #define longdiv(sr1, sr2, div)      (unsigned long )unsigned long
 long)(sr1)  32) ^ (sr2)) / (div))

 my question are:
 1. why __udivdi3 has any relationship with above calculation?

 Because you're doing 64 bit arithmetic (unsigned long long) and 64 bit
 division is not supported in all kernels.

why the name __udivdi3 has relation to 64-bits arighmetic?
Why linker ask for __udivdi3, it seems there is a common sense for
linker that when doing 64-bits calculation it will try to find
__udivdi3, am i right?


 2. I know the above calculation is implemented in clibc, but why
 kernel still implement itself?
     why kernel try to make another wheel instead of including what
 clib provided ?

 The kernel doesn't use anything from the C runtime  library at all.

 64-bit division and floating point are 2 things not supported in the
 kernel, although they do happen to word on some platforms, they aren't
 portable operations.

the 64-bit division seem supported in gcc toolchain, and gcc will take
care the platform issue when we cross-compile the gcc, right?
It should be safe to static link the 64bits division in gcc.

-- 
Regards,

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


quiet compile kernel

2011-04-27 Thread loody
Hi all:
I found the compile message of kernel is quite succinct, when we set
V=0, and I try to make my project output as clean as kernel did.

Then I traced the Makefile and it just define quiet and Q then export it.
Where is the exact place that quiet build begin?

Is that complicated to copy this quiet-build process?

-- 
Thanks for your help,
miloody

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


Re: where is __memory_barrier in kernel ?

2011-03-10 Thread loody
hi

2011/3/8 piyush moghe pmker...@gmail.com:
 Yes what you are saying is also right, since in order to prevent the
 ordering all the pending memory operations should have completed
 hence as you mentioned processor stops and make sure all the memory
 operations are completed.
I am not sure whether all the memory operations are completed after
cpu stops running for a while.
I think there should be a more aggressive and precise instruction  to
handle this behavior, right?
appreciate your kind help,
miloody

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


Re: Any tool under linux to parsing BPB/Bs/FAT table?

2011-03-04 Thread loody
hi:
2011/3/4 Beraldo Leal bera...@beraldoleal.com:
 On Fri, Mar 04, 2011 at 10:28:58AM +0800, loody wrote:
 hi :

 But the disk did have dirs and files
 # mount
 /dev/sdc1 on /media/disk type vfat (rw)
 # ls /media/disk
 ifrename  iwconfig  iwevent  iwgetid  iwlist  iwpriv  iwspy  strace
 strace.output  strace.output.tar.bz2
 #
 Please, print the ./fat-util info /dev/sdc1 output
here it is :

# ./fat-util info /dev/sdc1
JMP opcodes: EB 58 90
OEM Name:  mkdosfs
Bytes per sector: 512
Sectors per cluster: 8
# reserved sectors: 32
# FATs on volume: 2
# root directory entries: 0
Sectors in volume: 0
Media descriptor type: 248
Sectors per FAT: 0
Sectors per Track: 62
# heads: 63
# hidden sectors: 0
Huge sectors in volume: 3941092
FAT Type: 32
Drive number: 0
Signature: 29
Volume ID: -1598503492
Volume Label:
FAT Type: FAT32
Root Cluster: 2
#

appreciate your help,
miloody

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


Re: Any tool under linux to parsing BPB/Bs/FAT table?

2011-03-04 Thread loody
hi Beraldo:
 On Fri, Mar 04, 2011 at 08:09:17PM +0800, loody wrote:
 hi:
 # ./fat-util info /dev/sdc1
 JMP opcodes: EB 58 90
 OEM Name:  mkdosfs
 Bytes per sector: 512
 Sectors per cluster: 8
 # reserved sectors: 32
 # FATs on volume: 2
 # root directory entries: 0
 Sectors in volume: 0
 Media descriptor type: 248
 Sectors per FAT: 0
 Sectors per Track: 62
 # heads: 63
 # hidden sectors: 0
 Huge sectors in volume: 3941092
 FAT Type: 32
 Drive number: 0
 Signature: 29
 Volume ID: -1598503492
 Volume Label:
 FAT Type: FAT32
 Root Cluster: 2
 #

 Hi loody, I think this is a bug.

 I never try this tool with a real partition, just with img files:

  $ dd if=/dev/zero of=/tmp/img2 bs=521 count=10
  $ mkdosfs /tmp/img2
  $ mount -o loop /tmp/img2 /media/fat
  $ mkdir /media/fat/teste2
  $  /media/fat/teste
  $ cp /etc/passwd /media/fat/
  $ umount /media/fat
  $ ./fat-util list / /tmp/img2
    2 file(s), 1 dir(s)
    -a        0 2011 Mar 04 TESTE
    d-        0 2011 Mar 04 TESTE2
    -a     2869 2011 Mar 04 PASSWD

 Maybe the tool is not ready for real partitions! Sorry...
Actually I think you did a great job, at least you provide a tool for
newbies like me to have a chance to learn file system.


What is the difference between real partition and image?
for kernel, they are nothing but a place to write file systems, right?
Appreciate your help,
miloody
it is fine.

what is the diff

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


Re: Any tool under linux to parsing BPB/Bs/FAT table?

2011-03-03 Thread loody
hi beraldo:

2010/12/20 Beraldo Leal bera...@beraldoleal.com:
 On Mon, Dec 20, 2010 at 09:45:47PM +0800, loody wrote:
 Dear all:
 I recently trace FS/fat and I want to know is there any utility under
 linux that can help us to easily parse BPB/BS or FAT tables?

 http://gitorious.org/unix-stuff/fat-util ?

I download the tool you mentioned but I have some questions about the usage.
I try to list out the dir content on my usb flash disk, which is fat
file system.
But I got the below messages:

# mount
/dev/sdc1 on /media/disk type vfat (rw)
# ls /media/disk
ifrename  iwconfig  iwevent  iwgetid  iwlist  iwpriv  iwspy  strace
strace.output  strace.output.tar.bz2
# ./fat-util list strace.output /dev/sdc1
strace.output not found.
#

did I use the wrong cmds or the file system type the utility not support?
appreciate your help,
miloody

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


Re: Page Table query

2011-02-19 Thread loody
hi:

2011/2/19 Rajat Sharma fs.ra...@gmail.com:
 Even I keep on seeing these errors, everytime I post anything on
 kernelnewbies. Initially I kept ignoring, but looks I am not alone to
 face this.

 As a resolution to this, we need to remove id a...@fibcom.com from
 kernelnewbies subscribers.

I saw this mail too.
It seems this guy quit his company and the mail server of the company
told people who sent mail to him.
Regards,
miloody

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


Re: some questions about kernel source

2011-02-18 Thread loody
hi :


2011/2/18 John Mahoney jmaho...@waav.com:
 On Thu, Feb 17, 2011 at 9:17 AM, loody milo...@gmail.com wrote:
 hi :-)

 2011/2/16 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi :)

 On Wed, Feb 16, 2011 at 12:59, Rajat Jain rajatj...@juniper.net wrote:
 Hello loody,

 1. in kernel/trace, I always see __read_mostly at the end of
 parameter is that a compiler optimization parameter?

 Yes, it is a hint to the compiler that the parameter is mostly read, thus 
 if the compiler has to make a decision between optimizing one of the read 
 / write paths, it will optimize the read path even at the expense of write 
 path.


 To be precise, they will be grouped into same cache line as much as
 possible. By doing so, those cache line won't be invalidated so often
 (keeping them hot :) hehehhe )

 I cannot find it on the gcc manual.
 is it a option in kernel for kernel usage?
 if so, where I can found them.
 If not, can I use it on normal user level program?


 It is a macro defined for x86 as:

 #define __read_mostly __attribute__((__section__(.data..read_mostly)))

 http://lxr.linux.no/linux+v2.6.37/arch/x86/include/asm/cache.h
I found where you pointed out but I try to find out where is it in the
mips arch.
thank you,
miloody

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


struct assignment?

2011-02-18 Thread loody
hi all:
I found there seems no declaring about struct ftrace_entry.
below the greping result of my kernel source code:

# grep -rwn 'struct ftrace_entry' *
kernel/trace/trace.h:214:   IF_ASSIGN(var, ent, struct 
ftrace_entry, TRACE_FN); \
kernel/trace/trace_events.c:1483:   struct ftrace_entry *entry;
kernel/trace/trace_output.c:818:struct ftrace_entry *field;
kernel/trace/trace_output.c:845:struct ftrace_entry *field;
kernel/trace/trace_output.c:859:struct ftrace_entry *field;
kernel/trace/trace_output.c:872:struct ftrace_entry *field;
kernel/trace/trace.c:1098:  struct ftrace_entry *entry;
#


usually we use a struct we will declare its elements such as:

struct usb_host_endpoint {
struct usb_endpoint_descriptor  desc;
struct list_headurb_list;
void*hcpriv;
..
};

I guess the secret should be if_assign, but how does compiler interpret it?

-- 
Regards,
miloody

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


Re: some questions about kernel source

2011-02-17 Thread loody
hi :-)

2011/2/16 Mulyadi Santosa mulyadi.sant...@gmail.com:
 Hi :)

 On Wed, Feb 16, 2011 at 12:59, Rajat Jain rajatj...@juniper.net wrote:
 Hello loody,

 1. in kernel/trace, I always see __read_mostly at the end of
 parameter is that a compiler optimization parameter?

 Yes, it is a hint to the compiler that the parameter is mostly read, thus if 
 the compiler has to make a decision between optimizing one of the read / 
 write paths, it will optimize the read path even at the expense of write 
 path.


 To be precise, they will be grouped into same cache line as much as
 possible. By doing so, those cache line won't be invalidated so often
 (keeping them hot :) hehehhe )

I cannot find it on the gcc manual.
is it a option in kernel for kernel usage?
if so, where I can found them.
If not, can I use it on normal user level program?

BTW, i have some more questions (since it is also related to kernel, I
append in the same mail)
1. the parameters we pass to ftrace_trace_function are (unsigned long
ip, unsigned long parent_ip), which are previous and pre-previous
return address.
what can we do on these 2 addresses?

2. per kernel document, HAVE_FUNCTION_TRACE_MCOUNT_TEST is used for 
an optional optimization for the normal case and there is a pseudo
sample code such as
+   if (function_trace_stop)
+   return;
so the optimization the config did is judge whether
function_trace_stop before operation, right?
Meanwhile, I found this judgement seems enable in
ftrace_test_stop_func and it is located at #ifndef
CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST.
The source code seems quite conflict with the document.


-- 
Appreciate your kind help,
miloody

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


Re: some question about snprintf

2011-02-17 Thread loody
hi :

2011/2/7 Greg KH g...@kroah.com:
 On Sun, Feb 06, 2011 at 05:23:01PM +0800, loody wrote:
 hi:

 2011/2/6 loody milo...@gmail.com:
  hi all:
  I want to use snprintf for collecting debug message and print it later.
  But I found :
  1. when I add \n as below, the buffer will be cleared, that means
  the irq status will put at the head of Buffer instead of at the end
  of ehci work.
     Size -= snprintf (Buffer , Size,ehci_work\n);
     Size -= snprintf (Buffer , Size,irq status 0x%x\n,status);
  is it possible to add \n in the buffer, but will will not reset the 
  buffer?
 
  2. instead of snprintf, is there any better idea for saving debug
  message and show it out later?
 3. is there any function in kernel, like snprintf, which will also
 collect strings but tread the buffer as ring buffer, such that I will
 not need to take care the overflow.

 Look at include/linux/ring_buffer.h
I found some code such as ftrace seems use ring_buffer to record the data.
but the source is hard to understand for me right now. :-)
Is there simple sample code or document for me to reference?

-- 
Thank U,
miloody

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


some question about snprintf

2011-02-06 Thread loody
hi all:
I want to use snprintf for collecting debug message and print it later.
But I found :
1. when I add \n as below, the buffer will be cleared, that means
the irq status will put at the head of Buffer instead of at the end
of ehci work.
Size -= snprintf (Buffer , Size,ehci_work\n);
Size -= snprintf (Buffer , Size,irq status 0x%x\n,status);
is it possible to add \n in the buffer, but will will not reset the buffer?

2. instead of snprintf, is there any better idea for saving debug
message and show it out later?



-- 
Regards,
miloody

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


Re: how to measure IRQ service latency

2011-01-31 Thread loody
hi :
thanks for your help :)

2011/1/13 loody milo...@gmail.com:
 Hi

 2011/1/13 neependra.kh...@gmail.com neependra.kh...@gmail.com:


 On Thu, Jan 13, 2011 at 10:23 AM, loody milo...@gmail.com wrote:

 hi:

 2010/12/22 neependra.kh...@gmail.com neependra.kh...@gmail.com:
 
 
  On Wed, Dec 22, 2010 at 5:30 PM, Pradeep Kumar pradeepker...@gmail.com
  wrote:
 
  hi,
      can any one suggest a way to measure IRQ service latency? .
 
  I believe you can measure it with Ftrace. You might need to use irqsoff
  tracer.
  For reference:-
  http://people.redhat.com/srostedt/
 I go into the website and see a lot of files with suffix odp.


 These are presentations which you can open with Open Office.
 Those contain the examples as well.


 is there any document which can tell us how to use it?

 http://lwn.net/Articles/365835/
 http://lwn.net/Articles/366796/
 http://lwn.net/Articles/370423/

 You can look at my presentation which I gave at FOSS.in and see it is
 useful.
 http://neependra.net/?p=148
I have some questions about the document you mention:
1. I tried lttv recently and it seems different than the ftrace.
Is there any document or setting can help me to tell them apart?

2. there is a column called TRACE in kernel menuconfig, is it used
for ftrace or lttv?
appreciate your help,
miloody

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


can we measure the traffic between user and kernel mode

2011-01-26 Thread loody
Dear all:
Is there any directory under proc/sys or tools that can help us to
measure the traffic between user and kernel mode?
(such as ioctl, open, close, etc.)


-- 
Regards,
miloody

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


Re: can we measure the traffic between user and kernel mode

2011-01-26 Thread loody
hi all:
thanks for your kind reply :-)

2011/1/27 Mulyadi Santosa mulyadi.sant...@gmail.com:
 On Thu, Jan 27, 2011 at 10:42, loody milo...@gmail.com wrote:
 Dear all:
 Is there any directory under proc/sys or tools that can help us to
 measure the traffic between user and kernel mode?
 (such as ioctl, open, close, etc.)

 By traffic, you mean context switch latency? Perhaps you mean a tool
 like lmbench?
I got a user-mode application without symbol and source, and it keeps
console no response about 2 mins.
I just want to know whether it is busy on processing itself or do the
context switch frequently for calling kernel drivers at that time.
thanks a lot,
miloody



 --
 regards,

 Mulyadi Santosa
 Freelance Linux trainer and consultant

 blog: the-hydra.blogspot.com
 training: mulyaditraining.blogspot.com




-- 
Regards,

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


Re: how to measure IRQ service latency

2011-01-12 Thread loody
hi:

2010/12/22 neependra.kh...@gmail.com neependra.kh...@gmail.com:


 On Wed, Dec 22, 2010 at 5:30 PM, Pradeep Kumar pradeepker...@gmail.com
 wrote:

 hi,
     can any one suggest a way to measure IRQ service latency? .

 I believe you can measure it with Ftrace. You might need to use irqsoff
 tracer.
 For reference:-
 http://people.redhat.com/srostedt/
I go into the website and see a lot of files with suffix odp.
is there any document which can tell us how to use it?
sincerely,
miloody

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


Re: how to compile the 0.01 version of kernel

2011-01-09 Thread loody
hi:

2011/1/9 KK nitric.a...@gmx.us:
 Hello All,
 I was going through the linux kernel newbie articles in
 kernelnewbies.com and found it very interesting. I downloaded the
 tarballs for the 0.01 version of kernel from :
 http://www.kernel.org/pub/linux/kernel/Historic/

 Then the next thing I was trying to do was to compile the source code
 and try to understand the various methods/function calls, system calls
 etc, but I'm not able to compile the code, I'm getting the following
 errors:

     $ make -f Makefile
     gas -c -o boot/head.o boot/head.s
     make: gas: Command not found
     make: *** [boot/head.o] Error 127

 Then I searched in the web for GAS and found that it GNU AS.  I've as
 installed in my box, so I tried creating a symlink with the name gas
 but then bumped into another error:

     $ make
     gas -c -o boot/head.o boot/head.s
     gas: unrecognized option `-c'
     make: *** [boot/head.o] Error 1

 Is GNU AS same as as ? when running version check I got this:
     $ as --version
     GNU assembler (GNU Binutils) 2.20.51.20100410
     Copyright 2010 Free Software Foundation, Inc.
     This program is free software; you may redistribute it under the
 terms of
     the GNU General Public License version 3 or later.
     This program has absolutely no warranty.
     This assembler was configured for a target of `i686-cygwin'.

 I tried searching on the web to find ways to install GNU AS but could
 not get any useful info. I'm facing similar problem with GNU LD. Is it
 different from the ld:
     $ ld --version
     GNU ld (GNU Binutils) 2.20.51.20100410
     Copyright 2010 Free Software Foundation, Inc.
     This program is free software; you may redistribute it under the
 terms of
     the GNU General Public License version 3 or (at your option) a
 later version.
     This program has absolutely no warranty.

 Can someone help me installing these two or let me know what is the fix
 for the same.

 I'm running cygwin on Win7-64 bit
I have never try this before, but I can give you some suggestions that
I may try:
1. check Makefile and modify AS as the name on your machine.
2. try alias the gas with as on your cygiwn machine.
3. use a managed mount; this will help you avoid some file name
case-sensitivity issues
that crop up in the kernel source code (ex, the netfiler code uses file
names that differ only in case).
http://cygwin.com/faq/faq.using.html
PS: about item3 is excerpted from
http://www.cygwin.com/ml/cygwin/2007-07/msg00737.html

BTW, I sincerely suggest you may find any useful information on cygwin
mailing list.
Since most of people on cygwin can compile kernel successfully.

HTH,
miloody

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


Re: Questions about complete

2011-01-07 Thread loody
hi all:

2011/1/6 Rajat Sharma fs.ra...@gmail.com:
 Hi loody,

 calling complete will make the waiter process runnable but won't
 necessarily switch to waiter thread and make it run. Its upto
 scheduler to pick this process from run queue and execute based on its
 priority value. I think there is not deterministic time in which the
 waiter process will start executing.

 Probably what you want to do is calibrate timeout value in
 wait_for_completion_timeout. I would suggest to do a binary search
 between minimum timeout value (latency by which function A calls
 complete, though this process can also schedule in between) to max
 value (max your application can afford).

 Rajat

 On Thu, Jan 6, 2011 at 1:35 PM, loody milo...@gmail.com wrote:
 hi:

 2011/1/6 Pavan Savoy pavan_sa...@sify.com:
 On Thu, Jan 6, 2011 at 12:23 PM, loody milo...@gmail.com wrote:
 hi:

 2011/1/6 Pavan Savoy pavan_sa...@sify.com:
 On Thu, Jan 6, 2011 at 11:48 AM, loody milo...@gmail.com wrote:

 Dear all:
 I know complete will wake up the process who call wait_complete.
 Is there any methods I can use to measure how long from calling
 complete to the process that detect done=1?
 Regards,
 miloody

 returned value of wait_for_completion_timeout ?
 No.
 I want to measure the duration of complete to the time of wake up
 process who is pending on wait.

 Ah, Ok, Got it...
 I would do a copy of jiffies before the complete and do a diff for
 jiffies after the
 wait_for_ ...

 I suppose there would be much more better/optimized way 
 thank U :)
 why I ask so is I am porting kernel to other platform right now.
 and I found the time of getting complete is too long.
 What I mean is
 function A call wait_complete_timeout
 function B complete
 theoretically A will get complete and leave successfully
 but my platform A will told me that before timeout the complete is not got.

I doubt my problem comes from cpu timer interrupt is so often such
that when function B get the change to complete, the left time is
almost exhausted.
for not to be confused, I take following jiffies for example:
1   2345
68
start wait  B try complete
   time out

B try to complete but cpu timer keep firing and at 8 it is time out.
My platform is mips and is there any possibility to only let cpu timer
be preemptible?

BTW, in x86 or other ARCH, will they try to let timer ISR be preemptible?


-- 
Regards,
miloody

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


Questions about complete

2011-01-05 Thread loody
Dear all:
I know complete will wake up the process who call wait_complete.
Is there any methods I can use to measure how long from calling
complete to the process that detect done=1?
Regards,
miloody

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


Re: Questions about complete

2011-01-05 Thread loody
hi:

2011/1/6 Pavan Savoy pavan_sa...@sify.com:
 On Thu, Jan 6, 2011 at 11:48 AM, loody milo...@gmail.com wrote:

 Dear all:
 I know complete will wake up the process who call wait_complete.
 Is there any methods I can use to measure how long from calling
 complete to the process that detect done=1?
 Regards,
 miloody

 returned value of wait_for_completion_timeout ?
No.
I want to measure the duration of complete to the time of wake up
process who is pending on wait.
thank you.

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