richardweiyang / kernel_exploring Goto Github PK
View Code? Open in Web Editor NEWMy exploring in linux kernel
My exploring in linux kernel
__raw_spin_lock_irqsave()
local_irq_save()
preempt_disable()
do_raw_spin_lock()
We disable irq, this means on one would interrupt us to do schedule.
And then grab a spinlock, which imply we can't sleep or it is a bad thing to sleep/scheduler by ourself.
Based on this, why we need to disable preempt?
as title
commit ba81f83842549871cbd7226fc11530dc464500bb
Author: Huang Ying [email protected]
Date: Wed Feb 22 15:45:46 2017 -0800
mm/swap: skip readahead only when swap slot cache is enabled
Because during swap off, a swap entry may have swap_map[] ==
SWAP_HAS_CACHE (for example, just allocated). If we return NULL in
__read_swap_cache_async(), the swap off will abort. So when swap slot
cache is disabled, (for swap off), we will wait for page to be put into
swap cache in such race condition. This should not be a problem for swap
slot cache, because swap slot cache should be drained after clearing
swap_slot_cache_enabled.
Not get the point yet.
sounds it is time to dig into more about page allocator
swapcache_prepare() is used to set SWAP_HAS_CACHE if there is no cache and entry is used.
While I am confused why this could happen? From SWAP_HAS_CACHE point of view, there is only two possibilities: 1. get_swap_page() with SWAP_HAS_CACHE set; 2. get_swap_page_of_type() leave SWAP_HAS_CACHE cleared.
When we get this point, __read_swap_cache_async(), it means we already get an swap entry and looking for it. The comment mentioned "Swap entry may have been freed since our caller observed it."
Why would be have an entry with SWAP_HAS_CACHE cleared at this point?
I thought it means this page has backup in swap, like it does in swapin_readahead().
But it seems not, since page_add_new_anon_rmap() would set it too. And even shmem has this set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.