Some Kernel Questions/Confusions [Pls help]

Pranay Srivastava pranjas at gmail.com
Mon Oct 27 12:47:45 EDT 2014


Hi Krishna

On Mon, Oct 27, 2014 at 6:15 PM, Er Krishna <erkrishna at gmail.com> wrote:
> Hi All,
>
> Pls help me here by answering following two queries. If my understanding is
> incorrect in asking the question pls correct me:
>
>
> 1. In case of Paging and discontiguous memory allocation for a particular
> process, is it possible that all the segments say DS, SS, CS, Heap and all
> can be in different page frames. I am asking this for a particular segment
> (I know all the segments can be in different non contiguous pages
> seperately, but what about one segment in different non contiguous page
> frames). For example lets say stack segment (or data segment) which is in
> RAM requires 45 pages and in RAM 45 pages are not contiguous avilable, so
> can it be reside from page frame no 100-125 and then again in 140-160  ?
>

Yes it can and probably is.

>
> 2. In case of execution of  fast interrupt handler when other interrupts are
> disable, if device controller generate interrupt then it will not reaches to
> CPU ? Is it loss of interrupts and not a good condition on system/driver ?
> Can we ignore it safely for our driver or we must not fall into this
> scenario ?
>
>From what I know you can configure the interrupts to be Level or Edge
trigerred by programming
the interrupt controller. It is mostly configured Level Trigerred from
what I know probably because
of the condition you are describing above. True that interrupt won't
be delivered but it won't be lost.

What would be lost however if the device generates data and signals
interrupt then device must have some
sort of buffer in hardware where it can buffer this data until the
software reads it. So when your current fast
handler is running and other interrupt occurs then that is not
buffered it's just in asserted state ready to be available
when the processor is enables its interrupts.

>
> 3. Inside kernel page fault should not happen, I was trying to understand it
> w.r.t copy from/to usr api. Say on usr address the particular page is not
> there and kernel wants to copy it in kernel address space? What will happen
> if we use memcpy rather than copy from usr, will the kernel crash due to
> page fault? how copy from usr prevents this? Is the page fault handler code
> always remains in RAM in case of  Linux Kernel ?
>
First is permissions. It's checking if the address you wish to write
to belongs to your process
address space and if you've the access to it for what you intend to do (R/W/X).

Secondly if the page isn't there and you have all permissions to
perform the operation then it can be brought
in.
>
> 4. In case of read/write system call, a normal user program wants to acess
> some file or more specifically (direct or indirect block of particular
> inode). This user space process page table which is in RAM doesn't contain
> valid bit for particular pages which correspond to these blocks. If these
> blocks are not in page-cache, it will be bring ito RAM by vector i/o with
> the help of bio-vec data structures. Will this scenario triggers the page
> fault inside kernel ?
>
Probably not.

Page fault for user process in this case would trigger swap not the
file system. Page cache pages are not
put to swap they are just thrown away.

If however you've done an mmap of the file assuming that you didn't
Pre-faulted the pages using MAP_POPULATE,
when you access your memory area then there would be a page fault
which would trigger the file system to read in pages which would
be exactly same as page cache unless you write on this area.

>
> Best Regards,
> Krishna
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
        ---P.K.S



More information about the Kernelnewbies mailing list