2010/07/22

linux v0.01's switch_to macro.

I read a source code that is switch_to macro in linux kernel v0.01. This version of switch_to macro is different from current one. It used hardware context switching instead of software context switching. Although, it's quite easy to understand how it works.

You can see the source code at LEX and the switch_to macro is in include/linux/sched.h.

168#define switch_to(n) {\
 169struct {long a,b;} __tmp; \
 170__asm__("cmpl %%ecx,_current\n\t" \
 171        "je 1f\n\t" \
 172        "xchgl %%ecx,_current\n\t" \
 173        "movw %%dx,%1\n\t" \
 174        "ljmp %0\n\t" \
 175        "cmpl %%ecx,%2\n\t" \
 176        "jne 1f\n\t" \
 177        "clts\n" \
 178        "1:" \
 179        ::"m" (*&__tmp.a),"m" (*&__tmp.b), \
 180        "m" (last_task_used_math),"d" _TSS(n),"c" ((long) task[n])); \
This is the switch_to macro at all. It's simple isn't it?
It is called from schedule() like switch_to(next);. next is an index number to next process in the array of task it data type is struct task_struct.

At line 169, temporary structure is defined which need to segment jump. Line 170 is comparing ecx register to current process. btw, in assembly code, "_" prefix is needed. Anyway, why it uses ecx register means at line 180 you can see "c" ((long) task[n]) statement. It means the address of task[n] is copied to ecx register. so, it can use ecx register to comparing.
Then if current process and next process is same, jump to line 178 and finish this macro. If current process != next process, current process is copied to ecx register.
At line 173, edx register's value is copied to __tmp.b. Then do segment jump at line 174. Then process was switched to new process because linux v0.01 uses hardware context switch so that segment jump via TSS segment cause task switching.
Next, at line 175 checks if current is same as last_task_used_math. The last_task_used_math has FPU registers state. If current == last_task_used_math, it call clts instruction to clear TS flag in CR0 register. From intel's ducument, it says The processor sets the TS flag every time a task switch occurs. The flag is used to synchronize the saving of FPU context in
multitasking applications
. Then everything is done:-)

2010/07/20

memo: do_fork()

Flow of switching a process address space.
do_fork() @kernel/fork.c
|-> copy_process() @kernel/fork.c
   |-> copy_mm() @kernel/fork.c
       |-> dup_mm() @kernel/fork.c
           |-> mm_init() @kernel/fork.c
               |-> mm_alloc_pgd() @kernel/fork.c
                   |-> pgd_alloc() @arch/x86/mm/pgtable.c

2010/07/14

What is the .treeinfo

When I was reading some test cases, I thought where the .treeinfo is. I check install disk but there were no .treeinfo. so I googled it then I got where the .treeinfo is.
It in "/somedirectory/x86_64/os/.treeinfo" you mayn't see it from web browser or ftp client because ftp server won't show dot file. however, if you enter the url directory, you'll be able to see it.

2010/07/08

proven tester

I was approved to Fedora proven tester group:-) I'll do my best.
I hope I can help to making Fedora release better. anyway, I need to learn a lot about whole fedora's features, critical path pakcages feathers and so forth.

2010/07/05

memo: boot option

This is my memo to pass boot option to anaconda.
There is two ways to enter boot option.
1. add repo=<host>/Linux/fedora/releases/13/Fedora/x86_64/os/images/
This option get install.img from the URL.

2. add askmethod
This option ask you to where to get install.img from(e.g. http, nfs and so on).

2010/07/03

Testing rawhide.

I submitted three bug reports against rawhide today.

The reports are following URLs.
#611037
#611073
#611083

AFAIK, run a program from terminal emulator is good way to test. cuz, if run a program from an icon or likewise, it may works fine but sometimes error message is shown at stderr or stdout.
If you run a program via an icon, you won't miss to see an error messages. so I think run a program both way is useful.

2010/07/01

Bug report 2010/07/01

I reported it today.
https://bugzilla.redhat.com/show_bug.cgi?id=610087

It summary is qemu-kvm chrash. I have some fedora images e.g. FC13, rawhide. but I only had this happen while I was running FC13 image.
I could reproduce sometimes but I don't know what is the cause of the crash:-(

2010/06/30

Bug reports.

I've submitted two bug reports today. Both are against elfutils package.

One is crash /usr/bin/eu-strings if you run without any arguments.
https://bugzilla.redhat.com/show_bug.cgi?id=609476

The other is minor l10n bug.
https://bugzilla.redhat.com/show_bug.cgi?id=609468

2010/06/29

to be...

Today, I've submitted a ticket to fedora-qa's trac that request for a mentor to be a proventester.
I'd be happy to working with proventesters:-)

2010/06/28

memo: writing new autotest test case.

This is my memo about writing autotest test case.
At least, it requires control file, python file and test code.

This is a test code directories.
[masami@moon]~/autotest-0.12.0/client/tests/pwrite_test% ls . src
.:
.  ..  control  pwrite_test.py  pwrite_test.py.bk  pwrite_test.pyc  src

src:
.  ..  Makefile  pwrite_test.c

This is a control file. It defines some information e.g. test type, author and so forth.
AUTHOR = "your name "
EXPERIMENTAL = 'True'  # Not really, but this is only for testing autotest...
                       # not testing _with_ autotest.
NAME = "pwrite_test"
TEST_TYPE = "client"
TEST_CLASS = "General"
TEST_CATEGORY = "Functional"
TIME = "SHORT"
DOC = """\
Test program for pwrite(2) and pread(2).
"""

job.run_test('pwrite_test')
job.run_test() calls your python script which implements test.test class.

This is a python code. this file name is pwrite_test.py.
In the setup(), it changes current directory from somewhere to "src" directory. src directory contains your my test code then call make command to create test program.

import os
from autotest_lib.client.bin import test, utils


class pwrite_test(test.test):
    """
    @author: your name (your email address)
    """
    version = 1
    preserve_srcdir = True

    def setup(self):
        os.chdir(self.srcdir)
        utils.system('make')
        utils.system('make create_test_file')

    def initialize(self):
        self.job.require_gcc()
        self.results = None


    def run_once(self, num_groups=90):
        pwrite_test_bin = os.path.join(self.srcdir, 'pwrite_test')
        cmd = '%s' % (pwrite_test_bin)
        self.results = utils.system(cmd)
    
    def cleanup(self):
        os.chdir(self.srcdir)
        utils.system('make clean')
        os.remove(os.path.join(self.srcdir, '.version'))

This is a test code.
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static const char filename[] = "/home/masami/autotest-0.12.0/client/tests/pwrite_test/src/test.txt";
static const int offset = 6;
static const int read_byte = 5;

int main(int argc, char **argv)
{
 char buf[16];
 int fd, ret;
 off_t off;

 fd = open(filename, O_RDWR);
 if (fd < 0) {
  printf("file open error\n");
  return -1;
 }
 
 errno = 0;

 // Read data from file.
 pread(fd, &buf, read_byte, offset);
 if (errno) {
  printf("pread faild\n");
  return -1;
 }

 // Read data shuold be "world".
 if (strcmp(buf, "world")) {
  printf("read buf isn't \"world\"\n");
  return -1;
 }

 off = lseek(fd, 0, SEEK_CUR);
 // cursor should be zero.
 if (off) {
  printf("cursor isn't 0\n");
  return -1;
 }

 strcpy(buf, "WORLD");
 errno = 0;
 ret = pwrite(fd, buf, strlen(buf), 6);
 if (errno) {
  printf("pwrite faild\n");
  return -1;
 }
 
 pread(fd, &buf, read_byte, offset);
 // Read data shuold be "world".
 if (strcmp(buf, "WORLD")) {
  printf("read buf isn't \"world\"\n");
  return -1;
 }

 off = lseek(fd, 0, SEEK_CUR);
 // cursor should be zero.
 if (off) {
  printf("cursor isn't 0\n");
  return -1;
 }
 
 close(fd);

 printf("Done.\n");

 return 0;
}
Then, you can run your test code.
[masami@moon]~/autotest-0.12.0/client% sudo ./bin/autotest tests/pwrite_test/control
23:35:06 INFO | Writing results to /home/masami/autotest-0.12.0/client/results/default
23:35:06 INFO | Initializing the state engine
23:35:06 INFO | Symlinking init scripts
23:35:08 INFO | START ---- ---- timestamp=1277735708 localtime=Jun 28 23:35:08 
23:35:08 INFO |  START pwrite_test pwrite_test timestamp=1277735708 localtime=Jun 28 23:35:08 
23:35:10 INFO | Test started. Number of iterations: 1
23:35:10 INFO | Executing iteration 1 of 1
23:35:10 INFO | Dropping caches between iterations
23:35:10 INFO | Test finished after 1 iterations.
23:35:12 INFO |   GOOD pwrite_test pwrite_test timestamp=1277735712 localtime=Jun 28 23:35:12 completed successfully
23:35:12 INFO |  END GOOD pwrite_test pwrite_test timestamp=1277735712 localtime=Jun 28 23:35:12 
23:35:12 INFO | END GOOD ---- ---- timestamp=1277735712 localtime=Jun 28 23:35:12

2010/06/17

Submitted a bug report.

I've submitted a bug report to Fedora's bugzilla today.

This is the evidence of the bug.
[masami@moon]~% ls ダウンロード
ls *** glibc detected *** /bin/zsh: double free or corruption (!prev): 0x00000000025e2c10 ***
*** glibc detected *** /bin/zsh: malloc(): memory corruption: 0x00000000025e2cc0 ***

2010/06/14

Started Updates Testing

I thought that better update testing environment is my main desktop environment because I use many softwares every day on it. so I enabled update-testing repo on it instead of test environemt.
AFKIK, it good test case because it's real use case, right? although, it may be job to fill update comment but it's ok. you know, helping QA activiteis is my purpose anyway.
Ahh, of course, I've installed fedora-easy-karma:P

2010/06/13

Sharing USB-HDD via nfs.

My main laptop has only two USB ports. It isn't enough, isn't it? Therefore, I use USB hub to plug USB-mouse and speaker.
However, my USB-HDDs need electricity. If I plug it into USB port directory, it works but USB hub doesn't. Luckly, I have an eeepc so that I decided to share USB-HDD via nfs.

At first, I tested to share local disk. Then I got following messages.
[masami@moon]~% LANG=C sudo mount -t nfs 192.168.1.26:/home/masami /mnt/home
mount: wrong fs type, bad option, bad superblock on 192.168.1.26:/home/masami,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so

I tested to mount that directory at eeepc was no problems. Eeepc could mount directory by itself also /etc/hosts.allow and /etc/hosts.deny's setting is correct.
It seemed like fedora has some problem I thought.
Then, I googled and got answer that I should have installed nfs-utils package.
Finally, I could share USB-HDD via nfs:-)

Starting fedora life.


I used Debian for many years but I started to use Fedora recently for some reasons.
Anyway, I want to help to develop it. so, I'm reading Fedora's QA pages and created bugzilla account, subsrcibed some mailing lists, prepare testing environments on kvm.

I tried to create own live cd but I had one problem which is already reported to the Bugzilla. I added "LANG=C" before the sudo command and it worked fine:-) I did like this.
LANG=C sudo livecd-creator

I used FC13 repo instead of Rawhide. anyway, my PC may be ready to test FC14 but I need learn about QA activities.