LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-05-2012, 11:54 PM   #1
DKSL
LQ Newbie
 
Registered: Apr 2012
Posts: 29

Rep: Reputation: Disabled
memory page swapping


Hi all,

For a project I am doing I want to swap in/out some applications I choose. Can any one point me where is this swap in/out function in the kernel source? Is it called by the scheduling function while doing a context switching(sched.c -> schedule())?

Btw I am using Linux version 2.6.29

Last edited by DKSL; 05-05-2012 at 11:59 PM. Reason: adding linux version
 
Old 05-06-2012, 12:29 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
I don't believe Linux has used such a function since about 2.2
The "swap" partition/file is now a misnomer, and is used on a per-page, not per-process, basis.

kswapd is responsible for page migration, not the scheduler.
 
1 members found this post helpful.
Old 05-07-2012, 05:45 AM   #3
DKSL
LQ Newbie
 
Registered: Apr 2012
Posts: 29

Original Poster
Rep: Reputation: Disabled
Okey lets say I want to switch a process from memory. How can I do it manually by myself(not the kernel)? I mean what are the functions that needs to be called and the order of them?

I gave a printk inside the kswapd function(in mm/vmscan.c) and changed some applications but printk was printed only once upon running dmesg cmd. (I assume it was printed at the boot time, may be initialization. when I increased the application load it was not called! )

Last edited by DKSL; 05-07-2012 at 06:06 AM.
 
Old 05-07-2012, 06:59 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I'd hardly call this a newbie qn
Why don't you use the Report button to get the Mods to move it to the Programming forum; I think you'll get the help you need better over there.
 
1 members found this post helpful.
Old 05-07-2012, 09:07 PM   #5
DKSL
LQ Newbie
 
Registered: Apr 2012
Posts: 29

Original Poster
Rep: Reputation: Disabled
Thanks for the suggestion
 
Old 05-07-2012, 10:05 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 05-08-2012, 07:32 AM   #7
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by DKSL View Post
Okey lets say I want to switch a process from memory. How can I do it manually by myself(not the kernel)?
You can't. As far as I know, there is no kernel module providing that facility.

In a large majority of cases, the user decision on what to swap, would most likely be wrong anyway. Only the kernel has the requisite information on what memory has been accessed recently, to make efficient swapping decisions.

That said, you can always increase swappiness so that the kernel is more aggressive in swapping out unneeded pages.

If you wanted to create such a facility, you would have to write a kernel module. Note that for the above reasons, you would need very good reasons why this would be useful, in order to get your module accepted upstream. That kernel module would then provide some kind of an interface, perhaps a PID list written to a /sys file. The module would scan the processes for all pages owned by them, and attempt to swap them all out. (You might wish to skip shared mappings, so other processes using e.g. the same libraries won't be affected.)

Because I for one fail to see the usefulness of such a kernel module, I haven't checked the kernel sources to see which interfaces would be useful for this.
 
1 members found this post helpful.
Old 05-08-2012, 08:31 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by Nominal Animal View Post
Because I for one fail to see the usefulness of such a kernel module, I haven't checked the kernel sources to see which interfaces would be useful for this.
My sentiments as well. The whole concept of process swap went out of fashion years ago. In all (normal) environments I'm aware of.

However, were I of such a mind, maybe I'd start by looking at the hibernation code for some ideas. Having sat in on some sessions from the folks during the development of what is now known as TuxOnIce, it was apparently a minefield.
 
1 members found this post helpful.
  


Reply



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
>> page swapping << devil_ Programming 1 04-10-2010 05:59 AM
LXer: Compcache: in-memory compressed swapping LXer Syndicated Linux News 0 06-11-2009 03:40 AM
Swapping vs Paging vs Virtual Memory SBN Linux - General 4 04-05-2008 09:06 AM
how to limit swapping - prevent processes allocating huge amounts of memory david@linuxquestions Linux - General 10 12-21-2006 07:26 AM
RH 7.3 not swapping memory...? severedhead Linux - Distributions 4 05-28-2002 05:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:23 PM.

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
Open Source Consulting | Domain Registration