This is mostly for my kernel blog, but I feel occasionally some non-kernel work are good to be here too :-). After long-waiting, finally My first Asterisk patch got accepted:
https://issues.asterisk.org/file_download.php?file_id=24698&type=bug
lmadsen (administrator)
2009-04-09 10:44
License accepted! This looks like it could be useful :)
lmadsen (administrator)
2009-04-09 10:46
Don't forget to update the documentation either. If it is not already in XML format, that would also be an ideal change, but for now, you will need to update the docs in the code so that people at least know you can either pass it a file, or a playlist filename.
Thanks!
(0103048)
macli (reporter)
2009-04-09 15:58
I added some documentation in XML format, second patch app_mp3.diff uploaded
I will add note here describing how to play m3u playlist file :-)
#############
dialplan will look like this:
exten => 1234,1,Answer()
exten => 1234,n,MP3Player(/var/lib/asterisk/mp3/playlist.m3u)
and the playlist.m3u will be like this:
/var/lib/asterisk/mp3/1.mp3
/var/lib/asterisk/mp3/2.mp3
/var/lib/asterisk/mp3/3.mp3
..........
/var/lib/asterisk/mp3/n.mp3
It is easy to generate mp3 playlist file with .m3u, do the following:
find /path/to/your-mp3-file -type file *.mp3 > playlist.m3u
#############
(0103049)
macli (reporter)
2009-04-09 16:11
the second patch seems have one single long line, I uploaded third patch app_mp3.diff1 to comform to code guide line :-)
(0106495)
lmadsen (administrator)
2009-06-16 14:01
This is a new feature, so it can only go into trunk, but I'm marking this as targeted for 1.6.3.0 in the hopes we can get it merged in sooner rather than later. I will also set the status to Ready for Testing in the hopes we can get some other testers. Thanks!
(0114777)
dvossel (administrator)
2009-12-04 12:20
macli, I don't understand some of your changes. I uploaded a patch that strips out some some of the stuff that didn't seem necessary to me. Let me know what you think. The main thing I didn't understand was why you used the argument parser for a single argument and modified the http mpg321 code. It's still your work of coarse and will be documented as such when it is committed.
(0114784)
macli (reporter)
2009-12-04 13:40
Hi dvossel, I added the argument parser only for learning purpose, I do not remember exactly why I modifed mpg321 code, maybe it is related to some problem while playing some live online music list. Please go ahead using your simple solution, thanks!
(0114787)
svnbot (reporter)
2009-12-04 14:27
Repository: asterisk
Revision: 233234
U trunk/apps/app_mp3.c
------------------------------------------------------------------------
r233234 | dvossel | 2009-12-04 14:27:38 -0600 (Fri, 04 Dec 2009) | 9 lines
.m3u support for Mp3Player app
(closes issue 0014823)
Reported by: macli
Patches:
app_mp3.diff1 uploaded by macli (license )
Tested by: macli, dvossel
Saturday, December 5, 2009
Friday, August 14, 2009
My patch to pagemap clear_refs
I posted one trivial patch to fix the user input and got accepted in Andrew Morton's mm test tree, Oh yeah, This is my first kernel patch and it got accepted, that is encouraging and making me feel contributing more :-)
http://marc.info/?t=125011994400002&r=1&w=2
http://marc.info/?t=125011994400002&r=1&w=2
fs/proc/task_mmu.c v1: fix clear_refs_write() input sanity check
v1 fix the compiling errors and keep the type variable name.
Andrew Morton pointed out similar string hacking and obfuscated check for zero-length input
at the end of the function, David Rientjes suggested to use strict_strtol to replace
simple_strtol, this patch cover above suggestions, add removing of leading and trailing
whitespace from user input. It does not change function behavious.
This patch is rebased on mmotm-2009-08-04-14-22.
Signed-off-by: Vincent Li
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index f884ad4..2a1bef9 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -492,21 +492,20 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct task_struct *task;
- char buffer[PROC_NUMBUF], *end;
+ char buffer[PROC_NUMBUF];
struct mm_struct *mm;
struct vm_area_struct *vma;
- int type;
+ long type;
memset(buffer, 0, sizeof(buffer));
if (count > sizeof(buffer) - 1)
count = sizeof(buffer) - 1;
if (copy_from_user(buffer, buf, count))
return -EFAULT;
- type = simple_strtol(buffer, &end, 0);
+ if (strict_strtol(strstrip(buffer), 10, &type))
+ return -EINVAL;
if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
return -EINVAL;
- if (*end == '\n')
- end++;
task = get_proc_task(file->f_path.dentry->d_inode);
if (!task)
return -ESRCH;
@@ -542,9 +541,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
mmput(mm);
}
put_task_struct(task);
- if (end - buffer == 0)
- return -EIO;
- return end - buffer;
+
+ return count;
}
const struct file_operations proc_clear_refs_operations = {
pagemap clear_refs: specify anon or mapped pages to be cleared
Moussa A. Ba posted patch to specify anon or mapped page reference to be cleared
http://marc.info/?l=linux-kernel&m=124882208428609&w=2
and the script to test out this patch:
http://marc.info/?l=linux-kernel&m=124898170201564&w=2
http://marc.info/?l=linux-kernel&m=124882208428609&w=2
and the script to test out this patch:
http://marc.info/?l=linux-kernel&m=124898170201564&w=2
Monday, August 10, 2009
Add some trace events for the page allocator
Mel Gorman has posted series of patches to add trace events for page allocator:
http://marc.info/?l=linux-kernel&m=124991900725530&w=2
Here is How I tested out those patches:
1, make menuconfig as below:
kernel hacking -> Tracers
.config - Linux Kernel v2.6.31-rc5 Configuration
─────────────────────────────────────────────────────────────────────────────────────────────────────
┌─────────────────────────────────────────── Tracers ────────────────────────────────────────────┐
│ Arrow keys navigate the menu. selects submenus --->. Highlighted letters are │
│ hotkeys. Pressing includes, excludes, modularizes features. Press to │
│ exit, for Help, > for Search. Legend: [*] built-in [ ] excluded module < > │
│ module capable │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ --- Tracers │ │
│ │ [*] Kernel Function Tracer │ │
│ │ [*] Kernel Function Graph Tracer │ │
│ │ [ ] Interrupts-off Latency Tracer │ │
│ │ [ ] Sysprof Tracer │ │
│ │ [ ] Scheduling Latency Tracer │ │
│ │ [*] Trace syscalls │ │
│ │ [ ] Trace boot initcalls │ │
│ │ Branch Profiling (No branch profiling) ---> │ │
│ │ [ ] Trace power consumption behavior │ │
│ │ [ ] Trace max stack │ │
│ │ [*] Trace SLAB allocations │ │
│ │ [ ] Trace workqueues │ │
│ │ [*] Support for tracing block io actions │ │
│ │ [*] enable/disable ftrace tracepoints dynamically │ │
│ │ [*] Kernel function profiler │ │
│ │ [ ] Perform a startup test on ftrace │ │
│ │ [*] Memory mapped IO tracing │ │
│ │ < > Test module for mmiotrace │ │
│ │ < > Ring buffer benchmark stress tester │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────┘ │
2, read Documentation/trace/ftrace.txt and add line below in /etc/fstab:
debugfs /sys/kernel/debug debugfs defaults 0 0
3, apply the series of patches in order as git am series of patches
4, enable page allocator tracing events with:
#for i in `find /sys/kernel/debug/tracing/events -name "enable" | grep mm_`; do echo 1 > $i; done
5, run post-process script to get the page allocator events tracing data:
trace-pagealloc-postprocess.pl < /sys/kernel/debug/tracing/trace_pipe
We could use perf user tools under tools/perf/ to enable the page allocator trace events and track events data. read more in Documentation/trace/tracepoint-analysis.txt
http://marc.info/?l=linux-kernel&m=124991900725530&w=2
Here is How I tested out those patches:
1, make menuconfig as below:
kernel hacking -> Tracers
.config - Linux Kernel v2.6.31-rc5 Configuration
─────────────────────────────────────────────────────────────────────────────────────────────────────
┌─────────────────────────────────────────── Tracers ────────────────────────────────────────────┐
│ Arrow keys navigate the menu.
│ hotkeys. Pressing
│ exit, for Help, > for Search. Legend: [*] built-in [ ] excluded
│ module capable │
│ ┌────────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ --- Tracers │ │
│ │ [*] Kernel Function Tracer │ │
│ │ [*] Kernel Function Graph Tracer │ │
│ │ [ ] Interrupts-off Latency Tracer │ │
│ │ [ ] Sysprof Tracer │ │
│ │ [ ] Scheduling Latency Tracer │ │
│ │ [*] Trace syscalls │ │
│ │ [ ] Trace boot initcalls │ │
│ │ Branch Profiling (No branch profiling) ---> │ │
│ │ [ ] Trace power consumption behavior │ │
│ │ [ ] Trace max stack │ │
│ │ [*] Trace SLAB allocations │ │
│ │ [ ] Trace workqueues │ │
│ │ [*] Support for tracing block io actions │ │
│ │ [*] enable/disable ftrace tracepoints dynamically │ │
│ │ [*] Kernel function profiler │ │
│ │ [ ] Perform a startup test on ftrace │ │
│ │ [*] Memory mapped IO tracing │ │
│ │ < > Test module for mmiotrace │ │
│ │ < > Ring buffer benchmark stress tester │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────────────────────────────┘ │
2, read Documentation/trace/ftrace.txt and add line below in /etc/fstab:
debugfs /sys/kernel/debug debugfs defaults 0 0
3, apply the series of patches in order as git am series of patches
4, enable page allocator tracing events with:
#for i in `find /sys/kernel/debug/tracing/events -name "enable" | grep mm_`; do echo 1 > $i; done
5, run post-process script to get the page allocator events tracing data:
trace-pagealloc-postprocess.pl < /sys/kernel/debug/tracing/trace_pipe
We could use perf user tools under tools/perf/ to enable the page allocator trace events and track events data. read more in Documentation/trace/tracepoint-analysis.txt
Wednesday, August 5, 2009
Move oom_adj to signal_struct discussion
I copy and paste the content here for future reference:
Full discussion thread is here:
http://marc.info/?l=linux-mm&m=124938152105260&w=2
http://marc.info/?l=linux-mm&m=124938156605311&w=2
Full discussion thread is here:
http://marc.info/?l=linux-mm&m=124938152105260&w=2
http://marc.info/?l=linux-mm&m=124938156605311&w=2
Minchan Kimwrote:
> Hmm. I can't understand why it is troublesome.
> I think it's related to moving oom_adj to singal_struct.
> Unfortunately, I can't understand why we have to put oom_adj
> in singal_struct?
>
> That's why I have a question to Kosaki a while ago.
> I can't understand it still. :-(
>
> Could you elaborate it ?
>
Current code is as following
==
do_each_thread(g,p) {
......
p = badness();
record p of highest badness.
}
p = higest badness thread.
Scan all threads which shares mm_struct of p. and check oom_adj
==
Assume a process which has 20000 threads. And 1 of thread has OOM_DISABLE.
Then, at worst, this scan will needs
(1+2+3+....+20000) * (20000-1) scan. (when ignoring other processes)
even with your patch.
This means the kernel wastes enough long time that Cluster-Management-Software can
detetct this as livelock, and do reboot/cluster-fail-over.
Fixing livelock is not the last goal. I (we) would like to reduct stall time
to reasonable level. If we move oom_adj to signal_struct or mm_struct, scan-cost
will be only 20000. No retry at all.
And, if we can use for_each_process() rather than do_each_thread(),
scan-cost will be 1.
(BTW, "signal" struct is bad name I think, it should be "process" struct ;)
Thanks,
-Kame
> > > > > > > > Hi, Kosaki.
> > > > > > > >
> > > > > > > > I am so late to invole this thread.
> > > > > > > > But let me have a question.
> > > > > > > >
> > > > > > > > What's advantage of placing oom_adj in singal rather than task ?
> > > > > > > > I mean task->oom_adj and task->signal->oom_adj ?
> > > > > > > >
> > > > > > > > I am sorry if you already discussed it at last threads.
> > > > > > >
> > > > > > > Not sorry. that's very good question.
> > > > > > >
> > > > > > > I'm trying to explain the detailed intention of commit 2ff05b2b4eac
> > > > > > > (move oom_adj to mm_struct).
> > > > > > >
> > > > > > > In 2.6.30, OOM logic callflow is here.
> > > > > > >
> > > > > > > __out_of_memory
> > > > > > > select_bad_process for each task
> > > > > > > badness calculate badness of one task
> > > > > > > oom_kill_process search child
> > > > > > > oom_kill_task kill target task and mm shared tasks with it
> > > > > > >
> > > > > > > example, process-A have two thread, thread-A and thread-B and it
> > > > > > > have very fat memory.
> > > > > > > And, each thread have following likes oom property.
> > > > > > >
> > > > > > > thread-A: oom_adj = OOM_DISABLE, oom_score = 0
> > > > > > > thread-B: oom_adj = 0, oom_score = very-high
> > > > > > >
> > > > > > > Then, select_bad_process() select thread-B, but oom_kill_task refuse
> > > > > > > kill the task because thread-A have OOM_DISABLE.
> > > > > > > __out_of_memory() call select_bad_process() again. but select_bad_process()
> > > > > > > select the same task. It mean kernel fall in the livelock.
> > > > > > >
> > > > > > > The fact is, select_bad_process() must select killable task. otherwise
> > > > > > > OOM logic go into livelock.
> > > > > > >
> > > > > > > Is this enough explanation? thanks.
> > > > > > >
> > > >
> > > > The problem resulted from David patch.
> > > > It can solve live lock problem but make a new problem like vfork problem.
> > > > I think both can be solved by different approach.
> > > >
> > > > It's just RFC.
> > > >
> > > > If some process is selected by OOM killer but it have a child of OOM immune,
> > > > We just decrease point of process. It can affect selection of bad process.
> > > > After some trial, at last bad score is drastically low and another process is
> > > > selected by OOM killer. So I think Live lock don't happen.
> > > >
> > > > New variable adding in task struct is rather high cost.
> > > > But i think we can union it with oomkilladj
> > > > since oomkilladj is used to present just -17 ~ 15.
> > > >
> > > > What do you think about this approach ?
> > > >
> > > keeping this in "task" struct is troublesome.
> > > It may not livelock but near-to-livelock state, in bad case.
> >
> > Hmm. I can't understand why it is troublesome.
> > I think it's related to moving oom_adj to singal_struct.
> > Unfortunately, I can't understand why we have to put oom_adj
> > in singal_struct?
> >
> > That's why I have a question to Kosaki a while ago.
> > I can't understand it still. :-(
> >
> > Could you elaborate it ?
>
> Maybe, It's because my explanation is still poor. sorry.
> Please give me one more chance.
>
> In my previous mail, I explained select_bad_process() must not
> unkillable task, is this ok?
> IOW, if all thread have the same oom_adj, the issue gone.
>
> signal_struct is shared all thread in the process. then, the issue gone.
>
>
Your and Kame's good explanation opens my eyes. :)
I realized your approach's benefit.
Yes. Let's wait to listen others's opinios.
Friday, July 24, 2009
gfp_zone analysis
I have three zones on my system, DMA, NORMAL, HIGHMEM, Let's figure out how gfp_zone works:
assume that the allocation flags is 0x421 which can be tranlate to:
__GFP_DMA | GFP_HIGH | GFP_REPEAT
which means allocate memory from ZONE_DMA, Will gfp_zone be able to get ZONE_DMA from gfp flags?
Let's continue:
#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
The GFP_ZONEMASK on my system would be:
GFP_ZONEMASK = 0x03
We have total three zones, so
ZONES_SHIFT = 0x02
GFP_ZONE_TABLE would be:
2 << 0x02 =33=100001
bit = (__GFP_DMA | __GFP_HIGH | __GFP_REPEAT ) & 0x03 = 0x01
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & ((1 << ZONES_SHIFT) - 1)
= (100001 >> (0x01 * 0x02)) & (( 1 << 0x02 -1 )
= 1000 & 0011
= 0
= ZONE_DMA
assume that the allocation flags is 0x421 which can be tranlate to:
__GFP_DMA | GFP_HIGH | GFP_REPEAT
which means allocate memory from ZONE_DMA, Will gfp_zone be able to get ZONE_DMA from gfp flags?
Let's continue:
#define GFP_ZONEMASK (__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)
The GFP_ZONEMASK on my system would be:
GFP_ZONEMASK = 0x03
We have total three zones, so
ZONES_SHIFT = 0x02
GFP_ZONE_TABLE would be:
2 << 0x02 =33=100001
bit = (__GFP_DMA | __GFP_HIGH | __GFP_REPEAT ) & 0x03 = 0x01
static inline enum zone_type gfp_zone(gfp_t flags)
{
enum zone_type z;
int bit = flags & GFP_ZONEMASK;
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) &
((1 <<>> bit) & 1);
else {
#ifdef CONFIG_DEBUG_VM
BUG_ON((GFP_ZONE_BAD >> bit) & 1);
#endif
}
return z;
}
z = (GFP_ZONE_TABLE >> (bit * ZONES_SHIFT)) & ((1 << ZONES_SHIFT) - 1)
= (100001 >> (0x01 * 0x02)) & (( 1 << 0x02 -1 )
= 1000 & 0011
= 0
= ZONE_DMA
Thursday, July 23, 2009
Chat about git on how to apply local custom patch on top of mainline master branch
(09:35:49) vincentinsz: hm, question about git, now my kernel git repo is 2.6.31-rc3, and i git branched a test branch and committed custom patch, so the test branch is 2.6.31-rc3 + custom patch
(09:36:47) vincentinsz: now the mainline kernel is 2.6.31-rc4, i git checkout master and git pull to sync to the mainline kernel
(09:37:26) vincentinsz: but how I sync my test branch so it would be 2.6.31-rc4 + custom branch?
(09:38:05) qunying: is your branch a direct checkout from the branch point or from the mainline
(09:43:23) vincentinsz: say linus is the public git repo, here is my working step: 1, git clone linus, 2, git pull (from time to time), 3, git branch test, 4, git commit custom patch, 5 git checkout master, 6 git pull ( new kernel tag released say -rc4), now how I let branch test sync to -rc4 + custom patch?
(09:44:44) qunying: normally you don't you git pull, as it will automatically merge
(09:45:12) qunying: use git fetch then git rebase origin
(09:45:48) qunying: will move your local commits to the top
(09:45:50) vincentinsz: but the merge only touch master branch, not test branch, I care about the custom patch in test branch, not master branch
(09:46:42) qunying: then in test branch, you rebase against master
(09:46:52) qunying: git rebase master
(09:47:45) vincentinsz: then the custom patch would be on top of master?
(09:47:57) qunying: ya
(09:48:45) qunying: it will bring you branch to the latest master + your own commit on top
(09:49:21) vincentinsz: ah, that is it
(09:52:17) vincentinsz: My thought is that I would never touch my local master branch except git pull to sync to linus public git repo, I only test custom patch on a local test branch and also would like to have the test branch sync to master with custom patch on top of it
(09:52:53) vincentinsz: so I would never ruin my local master branch
(09:53:46) vincentinsz: based on the idea that i would never run git clone again :-)
(09:53:54) vincentinsz: reasonable?
(09:55:13) qunying: ya
(09:57:49) vincentinsz: there is git stash, but it seems only save non-committed custom patch and reapply the patch on top
(09:58:04) qunying: ya
(10:06:24) vincentinsz: hm, interesting, it seems I can not save the gaim chat log any more to other text file
(10:06:34) vincentinsz: like copy and paste
(10:06:53) qunying: that is strange
(10:07:39) vincentinsz: I could highlight all the text, right click, there is copy option, but it wont be saved in memory
(10:08:14) vincentinsz: there is save as option in conversation menu, but it only save as html format, annoying
(10:08:40) qunying: ya
(10:09:04) vincentinsz: same to you?
(10:09:32) qunying: never try it, i always let gaim save its own
(10:09:58) qunying: mime is working fine
(10:10:18) vincentinsz: I would like to have the technical discussion posted on my personal blog, so I can always looked it up when I need it :)
(10:11:17) qunying: it works for me, probably i am using a newer version
(10:11:52) qunying: try just highlight the text, and use middle-key to paste on other program
(10:13:24) vincentinsz: I have no middle key on mouse, it is scroll key
(10:14:56) qunying: it is the same, press it like the other will do
(09:36:47) vincentinsz: now the mainline kernel is 2.6.31-rc4, i git checkout master and git pull to sync to the mainline kernel
(09:37:26) vincentinsz: but how I sync my test branch so it would be 2.6.31-rc4 + custom branch?
(09:38:05) qunying: is your branch a direct checkout from the branch point or from the mainline
(09:43:23) vincentinsz: say linus is the public git repo, here is my working step: 1, git clone linus, 2, git pull (from time to time), 3, git branch test, 4, git commit custom patch, 5 git checkout master, 6 git pull ( new kernel tag released say -rc4), now how I let branch test sync to -rc4 + custom patch?
(09:44:44) qunying: normally you don't you git pull, as it will automatically merge
(09:45:12) qunying: use git fetch then git rebase origin
(09:45:48) qunying: will move your local commits to the top
(09:45:50) vincentinsz: but the merge only touch master branch, not test branch, I care about the custom patch in test branch, not master branch
(09:46:42) qunying: then in test branch, you rebase against master
(09:46:52) qunying: git rebase master
(09:47:45) vincentinsz: then the custom patch would be on top of master?
(09:47:57) qunying: ya
(09:48:45) qunying: it will bring you branch to the latest master + your own commit on top
(09:49:21) vincentinsz: ah, that is it
(09:52:17) vincentinsz: My thought is that I would never touch my local master branch except git pull to sync to linus public git repo, I only test custom patch on a local test branch and also would like to have the test branch sync to master with custom patch on top of it
(09:52:53) vincentinsz: so I would never ruin my local master branch
(09:53:46) vincentinsz: based on the idea that i would never run git clone again :-)
(09:53:54) vincentinsz: reasonable?
(09:55:13) qunying: ya
(09:57:49) vincentinsz: there is git stash, but it seems only save non-committed custom patch and reapply the patch on top
(09:58:04) qunying: ya
(10:06:24) vincentinsz: hm, interesting, it seems I can not save the gaim chat log any more to other text file
(10:06:34) vincentinsz: like copy and paste
(10:06:53) qunying: that is strange
(10:07:39) vincentinsz: I could highlight all the text, right click, there is copy option, but it wont be saved in memory
(10:08:14) vincentinsz: there is save as option in conversation menu, but it only save as html format, annoying
(10:08:40) qunying: ya
(10:09:04) vincentinsz: same to you?
(10:09:32) qunying: never try it, i always let gaim save its own
(10:09:58) qunying: mime is working fine
(10:10:18) vincentinsz: I would like to have the technical discussion posted on my personal blog, so I can always looked it up when I need it :)
(10:11:17) qunying: it works for me, probably i am using a newer version
(10:11:52) qunying: try just highlight the text, and use middle-key to paste on other program
(10:13:24) vincentinsz: I have no middle key on mouse, it is scroll key
(10:14:56) qunying: it is the same, press it like the other will do
Subscribe to:
Posts (Atom)