Re: Attach my own pid

2016-03-20 Thread Nitin Varyani
I am reframing my question:
Sub-task 1: Until now, parent process cannot control the pid of the forked
child. A pid gets assigned as a sequential number by the kernel at the time
the process is forked . I want to modify kernel in such a way that parent
process can control the pid of the forked child.

Sub-task 2: On Linux, you can find the maximum PID value for your system
with the following command:

$ cat /proc/sys/kernel/pid_max

Suppose pid_max=2000 for a system. I want that the parent process should be
able to assign a pid which is greater that 2000 to the forked child.

On Mon, Mar 21, 2016 at 12:03 AM,  wrote:

> On Sun, 20 Mar 2016 02:07:29 -0700, Nitin Varyani said:
>
> >  The linux kernel attaches a pid to newly forked process. I want to
> > create a facility by which a process has the option of attaching a new
> pid
> > to its child which is not in the pid space.
>
> Not at all sure what you mean by "not in the pid space", or what you're
> trying to achieve by doing it.
>
> But "pid namespaces" may be what you're looking for.
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: "kdumpbase" dracut module

2016-03-20 Thread Freeman Zhang
 Original Message 
> I want to know what is the job of "kdumpbase" dracut module.
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 

dracut uses modules to include instructions and functions in initramfs. When 
the dump kernel(2nd kernel) is started, it needs to know what action it should 
take to dump the core. It also needs some infrastructure to support those 
actions. Dracut follows the kdumpbase script to build initramfs for the 2nd 
kernel.

Above is my own understanding, hope this will help.

Freeman



signature.asc
Description: OpenPGP digital signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: 回复:Re: add_disk() make my driver's initialisation, thus kernel stall.

2016-03-20 Thread Valdis . Kletnieks
On Mon, 21 Mar 2016 09:53:47 +0800, 张云 said:
> The code is just for learning block driver

THe kernel doesn't know that.  You call a routine with the wrong
parameters, it will not work properly.


pgp60L5FwYLA3.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


回复:Re: add_disk() make my driver's initialisation, thus kernel stall.

2016-03-20 Thread 张云
The code is just for learning block driver


发自 网易邮箱大师
在2016年03月21日 06:18,valdis.kletni...@vt.edu 写道:
On Sun, 20 Mar 2016 16:38:12 +0800, å¼ äº‘ said:

> My memory disk block driver was compiled successfully.
> But when I insmod my module, initialisation stall at add_disk  in =
> setup_dev function.

> int major = 0;

Are you positive that this is both safe and usable?
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: add_disk() make my driver's initialisation, thus kernel stall.

2016-03-20 Thread Valdis . Kletnieks
On Sun, 20 Mar 2016 16:38:12 +0800, 张云 said:

> My memory disk block driver was compiled successfully.
> But when I insmod my module, initialisation stall at add_disk  in =
> setup_dev function.

> int major = 0;

Are you positive that this is both safe and usable?


pgpOvdXw4jw1a.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


add_disk() make my driver's initialisation, thus kernel stall.

2016-03-20 Thread 张云
Hi,
My memory disk block driver was compiled successfully.
But when I insmod my module, initialisation stall at add_disk  in setup_dev 
function.

What’s wrong with my gendisk setup code?
Thanks.

static void setup_dev(struct blkplay_dev *dev, int which)
{
// setup disk size
memset(dev, 0, sizeof(struct blkplay_dev));
dev->size = nsectors * hardsect_size;
dev->data = vmalloc(dev->size);
if (dev->data == NULL) {
printk(KERN_NOTICE "vmalloc failure.\n");
return;
}

// init request queue
spin_lock_init(>lock);

dev->queue = blk_init_queue(blkplay_request, >lock);
if (dev->queue == NULL) {
printk(KERN_NOTICE "init queue failure.\n");
goto out_vfree;
}

//blk_queue_logical_block_size(dev->queue, hardsect_size);
dev->queue->queuedata = dev;

dev->gd = alloc_disk(BLKPLAY_MINORS);
if (!dev->gd) {
printk(KERN_NOTICE "alloc_disk failure!\n");
goto out_vfree;
}

dev->gd->major = major;
dev->gd->first_minor = which * BLKPLAY_MINORS;
dev->gd->fops = _ops;
dev->gd->queue = dev->queue;
dev->gd->private_data = dev;
snprintf(dev->gd->disk_name, 32, "blkplay%c", which + 'a');
set_capacity(dev->gd, nsectors * (hardsect_size/KERNEL_SECTOR_SIZE));

printk(KERN_ALERT "5\n”);

// *
// initialisation stall at the statement below.
// *
add_disk(dev->gd);

printk(KERN_ALERT "6\n");

return;

out_vfree:
if (dev->data)
vfree(dev->data); 
}



The whole module code:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "debug.h"

#define BLKPLAY_MINORS 16
#define KERNEL_SECTOR_SIZE 512
#define DEVICE_NUMBER   1

int major = 0;
int nsectors = 1024;
int hardsect_size = 512;

static const char *module_name = "blkplay";

struct blkplay_dev {
int size;
uint8_t *data;
spinlock_t lock;
struct request_queue *queue;
struct gendisk *gd;
};

struct blkplay_dev * devices;


int blkplay_open(struct block_device *dev, fmode_t mode)
{
return 0;
}

void blkplay_release(struct gendisk *disk, fmode_t mode)
{
}

/*
 * Handle an I/O request.
 */
static void blkplay_transfer(struct blkplay_dev *dev, unsigned long sector, 
unsigned long nsect, char *buffer, int write)
{
unsigned long offset = sector*KERNEL_SECTOR_SIZE;
unsigned long nbytes = nsect*KERNEL_SECTOR_SIZE;

if ((offset + nbytes) > dev->size) {
printk (KERN_NOTICE "Beyond-end write (%ld %ld)\n", offset, 
nbytes);
return;
}
if (write)
memcpy(dev->data + offset, buffer, nbytes);
else
memcpy(buffer, dev->data + offset, nbytes);
}

/*
 * Transfer a single BIO.
 */
static int vmem_disk_xfer_bio(struct blkplay_dev *dev, struct bio *bio)
{
struct bio_vec bvec;
struct bvec_iter iter;
sector_t sector = bio->bi_iter.bi_sector;

bio_for_each_segment(bvec, bio, iter) {
char *buffer = __bio_kmap_atomic(bio, iter);
blkplay_transfer(dev, sector, bio_cur_bytes(bio) >> 9,
buffer, bio_data_dir(bio) == WRITE);
sector += bio_cur_bytes(bio) >> 9;
__bio_kunmap_atomic(buffer);
}
return 0;
}
void blkplay_request(struct request_queue *q)
{
struct request *req;
struct bio *bio;

while (!blk_queue_stopped(q) && 
(req = blk_peek_request(q)) != NULL) {
struct blkplay_dev *dev = req->rq_disk->private_data;
blk_start_request(req);
if (req->cmd_type != REQ_TYPE_FS) {
printk (KERN_NOTICE "Skip non-fs request\n");
blk_end_request_all(req, -EIO);
continue;
}

__rq_for_each_bio(bio, req)
vmem_disk_xfer_bio(dev, bio);
blk_end_request_all(req, 0);
}
}

const struct block_device_operations blkplay_ops = {
//.owner = THIS_MODULE,
//.open = blkplay_open,
//.release = blkplay_release,
};

static void release_dev(struct blkplay_dev *dev)
{
del_gendisk(dev->gd);
put_disk(dev->gd);
blk_cleanup_queue(dev->queue);
vfree(dev->data);
}
static void setup_dev(struct blkplay_dev *dev, int which)
{
// setup disk size
memset(dev, 0, sizeof(struct blkplay_dev));
dev->size = nsectors * hardsect_size;
dev->data = vmalloc(dev->size);
if (dev->data == NULL) {
printk(KERN_NOTICE "vmalloc failure.\n");
return;
}

// init request queue
spin_lock_init(>lock);

dev->queue = blk_init_queue(blkplay_request, >lock);
if (dev->queue == NULL) {
printk(KERN_NOTICE "init queue failure.\n");
goto out_vfree;
}

//blk_queue_logical_block_size(dev->queue, hardsect_size);
dev->queue->queuedata = dev;

dev->gd = alloc_disk(BLKPLAY_MINORS);
if (!dev->gd) {
printk(KERN_NOTICE "alloc_disk failure!\n");
goto out_vfree;
}


Re: Attach my own pid

2016-03-20 Thread Valdis . Kletnieks
On Sun, 20 Mar 2016 02:07:29 -0700, Nitin Varyani said:

>  The linux kernel attaches a pid to newly forked process. I want to
> create a facility by which a process has the option of attaching a new pid
> to its child which is not in the pid space.

Not at all sure what you mean by "not in the pid space", or what you're
trying to achieve by doing it.

But "pid namespaces" may be what you're looking for.


pgpGFla9nlmfa.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Attach my own pid

2016-03-20 Thread Nitin Varyani
Hi,
 The linux kernel attaches a pid to newly forked process. I want to
create a facility by which a process has the option of attaching a new pid
to its child which is not in the pid space.
  Any suggestions of how this can be achieved?
Nitin
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Kdump from source

2016-03-20 Thread Li Wang
Hi,

I hope this could be helpful to you.
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Kernel_Crash_Dump_Guide/chap-installing-configuring-kdump.html

On 4 March 2016 at 18:06, Ronit Halder  wrote:
> I am trying to build kdump from source.
> I have enabled my vmcore option in kernel config.
> But it isn't showing any /proc/vmcore .
>
> I have installed kexec-tools from source. But the kdump is not working.
> Is there any guide? I am unable to find one.
> Please help.
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
Regards,
Li Wang
Email: wangli.a...@gmail.com

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


Is it possible to turn off the gcc optimization when compiling kernel?

2016-03-20 Thread Hao Lee
Hi,
When I am debugging the linux kernel, I find that the execution
sequence of some code is very strange. I think I need to turn off gcc
optimization by  changing "-O2" to "-O0". But I encounter many errors.
So, I want to know is it possible to turn off the gcc optimization or
how can I compile some functions without optimization.
Thanks.

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



Re: How to rewrite sbull_request in ldd3 for current kernel?

2016-03-20 Thread 张云

> On Mar 20, 2016, at 2:25 PM, Ruben Safir  wrote:
> 
> On Sun, Mar 20, 2016 at 01:58:47PM +0800, 张云 wrote:
>> Thanks!
>> I have another question if it is possible to rewrite the data transfer 
>> function avoiding the bio complexity? 
> 
> what is the bio complexity that you are refering to?
> 

I don’t think request’s bio is much complex.
I want to rewrite the data transfer function as simple as possible 
for getting my driver working even without the knowledges of bio, like the 
sbull_request.

>> 
>> Yun Zhang(张云)
>> 
>>> On Mar 20, 2016, at 8:13 AM, Dongli Zhang  
>>> wrote:
>>> 
>>> Please refer to 
>>> https://github.com/21cnbao/training/tree/50506cf04bc5616e0c3f3285dbb006c54deb1c53/kernel/drivers/vmem_disk
>>> 
>>> Dongli Zhang (张东立)
>>> http://finallyjustice.github.io
>>> 
>>> 
>>> 
 From: zyun...@163.com 
 Subject: How to rewrite sbull_request in ldd3 for current kernel? 
 Date: Sat, 19 Mar 2016 21:22:19 +0800 
 To: kernelnewbies@kernelnewbies.org 
 
 Hi, 
 I am reading the book, Linux Driver Development 3. 
 In the chapter on block driver of this book, I need some help to 
 rewriting the sbull_request since the kernel’s block API was changed. 
 
 The sbull_request code: 
 /* 
 * The simple form of the request function. 
 */ 
 static void sbull_request(request_queue_t *q) 
 { 
 struct request *req; 
 
 while ((req = elv_next_request(q)) != NULL) { 
 struct sbull_dev *dev = req->rq_disk->private_data; 
 if (! blk_fs_request(req)) { 
 printk (KERN_NOTICE "Skip non-fs request\n"); 
 end_request(req, 0); 
 continue; 
 } 
 sbull_transfer(dev, req->sector, req->current_nr_sectors, 
 req->buffer, rq_data_dir(req)); 
 end_request(req, 1); 
 } 
 } 
 
 I have rewritten the code above into: 
 
 /* 
 * The simple form of the request function. 
 */ 
 void blkplay_request(struct request_queue *q) 
 { 
 struct request *req; 
 
 while (!blk_queue_stopped(q) && 
 (req = blk_peek_request(q)) != NULL) { 
 struct blkplay_dev *dev = req->rq_disk->private_data; 
 blk_start_request(req); 
 if (req->cmd_type != REQ_TYPE_FS) { 
 printk (KERN_NOTICE "Skip non-fs request\n"); 
 blk_end_request(req, -EIO, 0); 
 continue; 
 } 
 
 /* I don’t know how to write the statement below */ 
 blkplay_transfer(dev, req->sector, req->current_nr_sectors, 
 req->buffer, rq_data_dir(req)); 
 
 blk_end_request_cur(req, 0); 
 } 
 } 
 
 
 Is the rewrite proper? 
 
 
 
 The compiler can’t compile it because the request struct no longer has 
 
 the field of ‘sector’ and ‘current_nr_sectors’. I have read the kernel 
 code 
 
 about the request struct, the kernel code said the __data_len and 
 __sector field of 
 request struct is internal so that we shouldn’t access them directly. 
 
 How could I rewrite it ? Thanks. 
 
 ___ Kernelnewbies mailing 
 list Kernelnewbies@kernelnewbies.org 
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies 
>>>   
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> 
>> 
>> 
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org 
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies 
>> 
> 
> -- 
> So many immigrant groups have swept through our town
> that Brooklyn, like Atlantis, reaches mythological
> proportions in the mind of the world - RI Safir 1998
> http://www.mrbrklyn.com  
> 
> DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
> http://www.nylxs.com  - Leadership Development in Free 
> Software
> http://www2.mrbrklyn.com/resources  - 
> Unpublished Archive 
> http://www.coinhangout.com  - coins!
> http://www.brooklyn-living.com  
> 
> Being so tracked is for FARM ANIMALS and and extermination camps, 
> but incompatible with living as a free human being. -RI Safir 2013

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


Re: How to rewrite sbull_request in ldd3 for current kernel?

2016-03-20 Thread Ruben Safir
On Sun, Mar 20, 2016 at 01:58:47PM +0800, 张云 wrote:
> Thanks!
> I have another question if it is possible to rewrite the data transfer 
> function avoiding the bio complexity? 


what is the bio complexity that you are refering to?

> 
> Yun Zhang(张云)
> 
> > On Mar 20, 2016, at 8:13 AM, Dongli Zhang  
> > wrote:
> > 
> > Please refer to 
> > https://github.com/21cnbao/training/tree/50506cf04bc5616e0c3f3285dbb006c54deb1c53/kernel/drivers/vmem_disk
> > 
> > Dongli Zhang (张东立)
> > http://finallyjustice.github.io
> > 
> > 
> > 
> >> From: zyun...@163.com 
> >> Subject: How to rewrite sbull_request in ldd3 for current kernel? 
> >> Date: Sat, 19 Mar 2016 21:22:19 +0800 
> >> To: kernelnewbies@kernelnewbies.org 
> >> 
> >> Hi, 
> >> I am reading the book, Linux Driver Development 3. 
> >> In the chapter on block driver of this book, I need some help to 
> >> rewriting the sbull_request since the kernel’s block API was changed. 
> >> 
> >> The sbull_request code: 
> >> /* 
> >> * The simple form of the request function. 
> >> */ 
> >> static void sbull_request(request_queue_t *q) 
> >> { 
> >> struct request *req; 
> >> 
> >> while ((req = elv_next_request(q)) != NULL) { 
> >> struct sbull_dev *dev = req->rq_disk->private_data; 
> >> if (! blk_fs_request(req)) { 
> >> printk (KERN_NOTICE "Skip non-fs request\n"); 
> >> end_request(req, 0); 
> >> continue; 
> >> } 
> >> sbull_transfer(dev, req->sector, req->current_nr_sectors, 
> >> req->buffer, rq_data_dir(req)); 
> >> end_request(req, 1); 
> >> } 
> >> } 
> >> 
> >> I have rewritten the code above into: 
> >> 
> >> /* 
> >> * The simple form of the request function. 
> >> */ 
> >> void blkplay_request(struct request_queue *q) 
> >> { 
> >> struct request *req; 
> >> 
> >> while (!blk_queue_stopped(q) && 
> >> (req = blk_peek_request(q)) != NULL) { 
> >> struct blkplay_dev *dev = req->rq_disk->private_data; 
> >> blk_start_request(req); 
> >> if (req->cmd_type != REQ_TYPE_FS) { 
> >> printk (KERN_NOTICE "Skip non-fs request\n"); 
> >> blk_end_request(req, -EIO, 0); 
> >> continue; 
> >> } 
> >> 
> >> /* I don’t know how to write the statement below */ 
> >> blkplay_transfer(dev, req->sector, req->current_nr_sectors, 
> >> req->buffer, rq_data_dir(req)); 
> >> 
> >> blk_end_request_cur(req, 0); 
> >> } 
> >> } 
> >> 
> >> 
> >> Is the rewrite proper? 
> >> 
> >> 
> >> 
> >> The compiler can’t compile it because the request struct no longer has 
> >> 
> >> the field of ‘sector’ and ‘current_nr_sectors’. I have read the kernel 
> >> code 
> >> 
> >> about the request struct, the kernel code said the __data_len and 
> >> __sector field of 
> >> request struct is internal so that we shouldn’t access them directly. 
> >> 
> >> How could I rewrite it ? Thanks. 
> >> 
> >> ___ Kernelnewbies mailing 
> >> list Kernelnewbies@kernelnewbies.org 
> >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies 
> >   
> > ___
> > Kernelnewbies mailing list
> > Kernelnewbies@kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> 
> 
> 
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-- 
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com 

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive 
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com 

Being so tracked is for FARM ANIMALS and and extermination camps, 
but incompatible with living as a free human being. -RI Safir 2013


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