LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-08-2008, 04:11 AM   #1
duanius
LQ Newbie
 
Registered: May 2008
Posts: 6

Rep: Reputation: 0
what does the bit PG_locked mean?


maybe its not only makes a page unswappable but i dont know further
Can anybody here help me and give me a detailed explanation?
 
Old 05-08-2008, 04:33 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Try reading page-flags.h ...
Code:
 20  * During disk I/O, PG_locked is used. This bit is set before I/O and
 21  * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
 22  * waiting for the I/O on this page to complete.
... what would happen to disk IO process if this wasn't used? What would happen to those tasks that are waiting for the IO to complete?

Note: PG_reserved stops a page from being swapped out.
 
Old 05-08-2008, 05:00 AM   #3
duanius
LQ Newbie
 
Registered: May 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Simon Bridge View Post
Try reading page-flags.h ...
Code:
 20  * During disk I/O, PG_locked is used. This bit is set before I/O and
 21  * reset when I/O completes. page_waitqueue(page) is a wait queue of all tasks
 22  * waiting for the I/O on this page to complete.
... what would happen to disk IO process if this wasn't used? What would happen to those tasks that are waiting for the IO to complete?

Note: PG_reserved stops a page from being swapped out.
thx but according to this article http://lwn.net/Articles/161204/ the reserved bit had been removed since 2.6.15

and suppose a page has been locked(PG_locked) while a device (like NIC card)get the physical address of this page .can this device dma data to the address?
its not 2 processes and both of them wanna access the page but a device who use bus address or physical address so maybe it works?
 
Old 05-08-2008, 11:31 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,706
Blog Entries: 4

Rep: Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030
"Let's get physical..." You're a device-controller and you're ready to start a disk I/O. You've got to tell the hardware what to do and where to send the data. The hardware's going to use Direct Memory Access (DMA) to move the data to-or-from the absolute memory-address that you specify.

So, you're going to translate the virtual-address of the target buffer into a real-address and that's going to be what you put into the device hardware-request. Now therefore, while that DMA-transfer is going on, you need to be absolutely certain that this page will not be touched by anyone else. It must not be released or paged-out or otherwise considered to be "available" in any way.

Hence, you set a status-bit for all the (software) world to see, so that it will know not to touch this page. When the hardware informs you that the DMA-transfer is complete, you turn the bit off.

Now... "let's get logical." The DMA transfer is complete. So, now the corresponding I/O-request is also done. Any process that was waiting for that request is now "good to go," so we tell the dispatcher that it can start dispatching those processes again. This is altogether a different concept, entirely unrelated to the first.

The page-status flags are strictly referred-to by the virtual memory subsystem.
 
Old 05-09-2008, 03:28 AM   #5
duanius
LQ Newbie
 
Registered: May 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs View Post
"Let's get physical..." You're a device-controller and you're ready to start a disk I/O. You've got to tell the hardware what to do and where to send the data. The hardware's going to use Direct Memory Access (DMA) to move the data to-or-from the absolute memory-address that you specify.

So, you're going to translate the virtual-address of the target buffer into a real-address and that's going to be what you put into the device hardware-request. Now therefore, while that DMA-transfer is going on, you need to be absolutely certain that this page will not be touched by anyone else. It must not be released or paged-out or otherwise considered to be "available" in any way.

Hence, you set a status-bit for all the (software) world to see, so that it will know not to touch this page. When the hardware informs you that the DMA-transfer is complete, you turn the bit off.

Now... "let's get logical." The DMA transfer is complete. So, now the corresponding I/O-request is also done. Any process that was waiting for that request is now "good to go," so we tell the dispatcher that it can start dispatching those processes again. This is altogether a different concept, entirely unrelated to the first.

The page-status flags are strictly referred-to by the virtual memory subsystem.
i feel what u mentioned is just like Streaming DMA mapping .Mapped for one DMA transfer,and unmapped right after it.Thanks for ur reply but are u sure when one page is PG_locked,it can not be read by ANY process in user mode?and i have to set and unset it when every DMA transfer begin and end? its horrible...

I am doing a ZERO-COPY system .The NIC card send packet directly to the user buffer and the application(like snort or tcpdump or sth else)pick one packet from buffer and then analyze it,and the whole procedure bypass the process of sth like IP stack or else.At the init time the NIC get the address passed by a process in user mode(this process alloced the buffer) .The NIC translate the virt-addr to phys-addr and PG_locked it and the pages PG_locked during the whole time when system is running.I suppose that aftet PG_locked be set, there is just ONE process in user mode can access the pages,thats the process who passed the virt-addr to kernel(CURRENT->mm in ioctl ,it provide virt-addr and page table) while other processes are fobidden to access the locked page,so we dont have to set and unset it again and again .

i dont know whether my suppose is right or not ,so can u explain more?
 
Old 10-11-2017, 11:58 PM   #6
changbin
LQ Newbie
 
Registered: Oct 2017
Location: China
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by duanius View Post
maybe its not only makes a page unswappable but i dont know further
Can anybody here help me and give me a detailed explanation?
The semantics of lock_page() is similar to generic lock syncronization mechanism. If PG_locked is set for a page, it means only the owner process occupy the page, others please don't touch it. lock_page() need wait if someoneelse only take the lock. When lock_page() returns, current process occupy the page exclusively and safe to touch it. At the end, call unlock_page() to release the lock.
 
Old 10-12-2017, 12:35 AM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,001

Rep: Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219Reputation: 2219
That's a very old thread - hopefully the OP has progressed somewhat by now ...

Nice post though, and welcome.
 
Old 11-03-2017, 04:31 PM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,706
Blog Entries: 4

Rep: Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030Reputation: 3030
It is also worth noting that there are two possible ways to regard the generic term, "locking a page in memory."

One of these is physical, and it refers to a (physical) "page frame." As I described, uhh, almost 10 years ago, this concern has to do with making sure that the content of physical memory does not change while an I/O-card is moving data to-and-fro.

The other one is logical, and it refers to some number of pages within some process's virtual memory space. The concern here is to make sure that the contents of this area will not be swapped-out. This might be needed by real-time applications, which cannot tolerate the so-called "latency" of being obliged to wait for a page-in, or by high-security applications which want to make sure that sensitive information cannot be scribbled onto a hard-drive someplace.

Although the terminology is similar, the concepts are not the same. There is no concept of "waiting for" a locked physical resource: it is simply a "don't touch this!" flag-bit that is considered by the virtual memory manager as it looks for "not-recently-used" data which might be a candidate for swapping or stealing.

Last edited by sundialsvcs; 11-03-2017 at 04:34 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
64 bit cpu-64 bit Ubuntu-are there 32 bit app issues? sofasurfer Ubuntu 7 04-09-2014 03:02 PM
64-bit or 32-bit Application on 64-bit Linux jjana123 Linux - General 4 05-06-2008 06:27 PM
Triple Boot Suse 10.3 32 bit, suse alpha 11.0 64 bit and Windows XP (32 Bit) 1kyle SUSE / openSUSE 1 02-28-2008 11:25 AM
Integrated 16-bit Sound Blaster Pro compatible audio 24-bit DAC jelgavchik Linux - Hardware 1 11-16-2006 06:31 PM
32 bit or 64 bit install - is 32 bit easier for a newbie? dms05 Linux - Newbie 3 05-19-2006 04:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration