On Fri, Jul 17, 2009 at 6:54 PM, er krishna<[email protected]> wrote:
> Dear All,
>
> I am facing some problem, I have to flush the buffer cacheĀ from my driver &
> I am trying to find any api for linux kernel or any way to do it from a
> kernel module on x86 platform. Does anybody know how to do it ? Please help.
>
> I have tried following things :
>
> 1. echo 3 > /proc/sys/vm/drop_caches :
>
> It works fine, but is there any way to do this from a kernel module, I mean
> is there anyway to write into in a existing proc entry via a kernel module
> using create_proc_entry function ? Or, Can someone tell me internally how
> this configuration parameter goes to kernel & what api it calls from any
> memory driver (or like that ) ?
>
>
> 2. void flush_cache_all(void) :
>
> This api doesn't work for linux kernel on x86 architecture , because it is
> defined blak ( only { } ) .
this "cache" which u are talking about is referring to the x86 CPU
cache, or L1 cache. ****I think*****!!!! but buffer cache is
indepdent of architecture so it could not be this API. many user of
this API flush_cache_all() is found in the different architecture
specific branch:
./arch/sparc/kernel/smp_32.c:
void smp_flush_cache_all(void)
xc0((smpfunc_t) BTFIXUP_CALL(local_flush_cache_all));
local_flush_cache_all();
./arch/sparc/kernel/sun4m_smp.c:
local_flush_cache_all();
./arch/sparc/kernel/sun4d_smp.c:
local_flush_cache_all();
./arch/m32r/mm/cache.c:
void _flush_cache_all(void
Again indicating its CPU-specific characteristic.
Userspace it is called "sync" - read about this here:
http://linux.die.net/sag/buffer-cache.html
But in kernel, there are many types of syncing API available,
depending whether your memory is anonymously mapped or not etc....eg:
buffer.c:EXPORT_SYMBOL(sync_mapping_buffers);
buffer.c:EXPORT_SYMBOL(block_sync_page);
buffer.c:EXPORT_SYMBOL(file_fsync);
buffer.c:EXPORT_SYMBOL(sync_dirty_buffer);
fs-writeback.c:EXPORT_SYMBOL_GPL(generic_sync_sb_inodes);
fs-writeback.c:EXPORT_SYMBOL(sync_inode);
fs-writeback.c:EXPORT_SYMBOL(generic_osync_inode);
sync.c:EXPORT_SYMBOL_GPL(sync_filesystem);
sync.c:EXPORT_SYMBOL(vfs_fsync);
sync.c:EXPORT_SYMBOL_GPL(do_sync_mapping_range);
If u call sys_sync(), which is kernel's implementation of the
userspace sync() call, it will be quite heavy, as it will traverse all
possible mounted filesystem to sync it. But since for a specific
driver, u know either the specific range of memory, or specific inode,
u can pick the more specific and less performance-overhead API from
the above list.
What are the specific input parameter for syncing?
>
> 3. If anybody is aware of any such other api then please help me, its very
> urgent at my end.
>
>
> Thanks & Best Regards,
> Krishna
>
--
Regards,
Peter Teoh
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ